HistogramPersistencySvc Class Reference

HistogramPersistencySvc class implementation definition. More...

#include <src/PersistencySvc/HistogramPersistencySvc.h>

Inheritance diagram for HistogramPersistencySvc:
Collaboration diagram for HistogramPersistencySvc:

Public Types

typedef std::vector< std::string > Strings
 the actual type for the vector of strings More...
 
typedef std::set< std::string > Set
 for report: unconverted histograms More...
 
- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

PersistencySvc overrides
StatusCode initialize () override
 Initialize the service. More...
 
StatusCode reinitialize () override
 Reinitialize the service. More...
 
StatusCode finalize () override
 Finalize the service. More...
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Implementation of IConverter: Convert the transient object to the requested representation. More...
 
: Object implementation
 HistogramPersistencySvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
 ~HistogramPersistencySvc () override=default
 Standard Destructor. More...
 
- Public Member Functions inherited from PersistencySvc
long repSvcType () const override
 Return default service type. More...
 
const CLIDobjType () const override
 Retrieve the class type of objects the converter produces. (DUMMY) More...
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Implementation of IConverter: Create the transient representation of an object. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the created transient object. More...
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Implementation of IConverter: Update the transient object from the other representation. More...
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an updated transient object. More...
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Implementation of IConverter: Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the converted object. More...
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the converted representation of a transient object. More...
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an already converted object. More...
 
StatusCode setDataProvider (IDataProviderSvc *pStore) override
 Define transient datastore. More...
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Access reference to transient datastore. More...
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Set conversion service the converter is connected to. More...
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Get conversion service the converter is connected to. More...
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility. More...
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility. More...
 
StatusCode addConverter (IConverter *pConverter) override
 Add converter object to conversion service. More...
 
StatusCode addConverter (const CLID &clid) override
 Add converter object to conversion service. More...
 
IConverterconverter (const CLID &clid) override
 Retrieve converter from list. More...
 
StatusCode removeConverter (const CLID &clid) override
 Remove converter object from conversion service (if present). More...
 
StatusCode connectOutput (const std::string &outputFile, const std::string &openMode) override
 Connect the output file to the service with open mode. More...
 
StatusCode connectOutput (const std::string &outputFile) override
 Connect the output file to the service. More...
 
StatusCode commitOutput (const std::string &output, bool do_commit) override
 Commit pending output. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string *pars, const unsigned long *ipars, IOpaqueAddress *&refpAddress) override
 Create a Generic address using explicit arguments to identify a single object. More...
 
StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress) override
 Convert an address to string form. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
 Convert an address in string form to object form. More...
 
StatusCode addCnvService (IConversionSvc *service) override
 Add a new Service. More...
 
StatusCode removeCnvService (long type) override
 Remove a Service. More...
 
StatusCode setDefaultCnvService (long type) override
 Set default service type. More...
 
StatusCode getService (long service_type, IConversionSvc *&refpSvc) override
 Retrieve conversion service identified by technology. More...
 
StatusCode getService (const std::string &service_type, IConversionSvc *&refpSvc) override
 Retrieve conversion service identified by technology. More...
 
StatusCode initialize () override
 Initialize the service. More...
 
StatusCode finalize () override
 stop the service. More...
 
 PersistencySvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
 ~PersistencySvc () override=default
 Standard Destructor. More...
 
- Public Member Functions inherited from extends< BASE, Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Attributes

std::string m_histPersName
 Name of the Hist Pers type. More...
 
std::string m_outputFile
 Name of the outputFile. More...
 
Strings m_convert
 the list of patterns to be converted More...
 
Strings m_exclude
 the list of patterns to be excludes More...
 
Set m_converted
 for the final report: the list of converted histograms More...
 
Set m_excluded
 for the final report: the list of excluded histograms More...
 
bool m_warnings
 Flag to disable warning messages when using external input. More...
 
- Protected Attributes inherited from PersistencySvc
long m_cnvDefType = TEST_StorageType
 Default service type. More...
 
SmartIF< IDataProviderSvcm_dataSvc
 Pointer to datma provider service. More...
 
Services m_cnvServices
 List of convermsion workers. More...
 
SmartIF< IConversionSvcm_cnvDefault
 Default output service. More...
 
StringArrayProperty m_svcNames
 Names of services to be requested from the service locator and added by default. More...
 
bool m_enable = true
 Flag to indicate that the service is enabled. More...
 
SmartIF< IAddressCreatorm_addrCreator
 Pointer to the IAddressCreator interface of this, for addressCreator(). More...
 

Additional Inherited Members

- Protected Types inherited from PersistencySvc
typedef std::map< long, ServiceEntryServices
 
- Protected Member Functions inherited from PersistencySvc
void svcNamesHandler (Property &theProp)
 Handlers for Service Names Property. More...
 
SmartIF< IConversionSvc > & service (const std::string &nam)
 Retrieve conversion service by name. More...
 
SmartIF< IConversionSvc > & service (long service_type)
 Retrieve conversion service from list. More...
 
SmartIF< IAddressCreator > & addressCreator (long service_type)
 Retrieve address creator from list. More...
 
void encodeAddrHdr (long service_type, const CLID &clid, std::string &address) const
 Retrieve string from storage type and clid. More...
 
void decodeAddrHdr (const std::string &address, long &service_type, CLID &clid, std::string &address_trailer) const
 Retrieve storage type and clid from address header of string. More...
 
StatusCode makeCall (int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
 Implementation helper. More...
 
bool enable (bool value)
 Set enabled flag. More...
 

Detailed Description

HistogramPersistencySvc class implementation definition.

System: The LHCb Offline System

Package: HistogramPersistencySvc

Dependencies:

History:

+---------+----------------------------------------------+---------+
|    Date |                 Comment                      | Who     |
+---------+----------------------------------------------+---------+
| 3/11/98 | Initial version                              | M.Frank |
+---------+----------------------------------------------+---------+
Author
Markus Frank
Version
1.0

Definition at line 47 of file HistogramPersistencySvc.h.

Member Typedef Documentation

typedef std::set<std::string> HistogramPersistencySvc::Set

for report: unconverted histograms

Definition at line 75 of file HistogramPersistencySvc.h.

typedef std::vector<std::string> HistogramPersistencySvc::Strings

the actual type for the vector of strings

Definition at line 73 of file HistogramPersistencySvc.h.

Constructor & Destructor Documentation

HistogramPersistencySvc::HistogramPersistencySvc ( const std::string &  name,
ISvcLocator svc 
)

Standard Constructor.

Definition at line 243 of file HistogramPersistencySvc.cpp.

245  : PersistencySvc(name, svc)
246 {
247  std::vector<std::string> defServices;
248  defServices.push_back("RootHistSvc");
249  m_svcNames.set(defServices);
250  declareProperty ("HistogramPersistency", m_histPersName = "");
251  declareProperty ("OutputFile", m_outputFile = "");
252  //
253  declareProperty
254  ("ConvertHistos" , m_convert ,
255  "The list of patterns to be accepted for conversion" ) ;
256  //
257  declareProperty
258  ("ExcludeHistos" , m_exclude ,
259  "The list of patterns to be excluded for conversion" ) ;
260  declareProperty("Warnings",m_warnings=true,
261  "Set this property to false to suppress warning messages");
262 }
bool set(const TYPE &value)
update the value of the property/check the verifier
Definition: Property.h:434
StringArrayProperty m_svcNames
Names of services to be requested from the service locator and added by default.
Strings m_convert
the list of patterns to be converted
PersistencySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
bool m_warnings
Flag to disable warning messages when using external input.
Strings m_exclude
the list of patterns to be excludes
std::string m_outputFile
Name of the outputFile.
std::string m_histPersName
Name of the Hist Pers type.
HistogramPersistencySvc::~HistogramPersistencySvc ( )
overridedefault

Standard Destructor.

Member Function Documentation

StatusCode HistogramPersistencySvc::createRep ( DataObject pObject,
IOpaqueAddress *&  refpAddress 
)
override

Implementation of IConverter: Convert the transient object to the requested representation.

Definition at line 208 of file HistogramPersistencySvc.cpp.

210 {
211  // enable the conversion
212  enable ( true ) ;
213  // conversion is possible ?
214  if ( "NONE" == m_histPersName )
215  {
216  enable ( false ) ;
217  return PersistencySvc::createRep ( pObj , refpAddr ) ; // RETURN
218  }
219  // histogram ?
220  if ( dynamic_cast<AIDA::IBaseHistogram*> ( pObj ) )
221  {
222 
223  auto match_pObj = [&](const std::string& s) { return match( pObj , s ); };
224  // Empty ConvertHistos property means convert all
225  bool select = ( m_convert.empty()
226  || std::any_of( m_convert.begin(), m_convert.end(), match_pObj )
227  ) && std::none_of( m_exclude.begin(), m_exclude.end(), match_pObj );
228  //
229  enable ( select ) ;
230  //
231  const auto& path = oname ( pObj ) ;
232  //
233  if ( !select ) { m_excluded.insert ( path ) ; }
234  else { m_converted.insert ( path ) ; }
235  }
236  //
237  return PersistencySvc::createRep ( pObj , refpAddr ) ; // RETURN
238 }
Set m_excluded
for the final report: the list of excluded histograms
list path
Definition: __init__.py:15
Strings m_convert
the list of patterns to be converted
Set m_converted
for the final report: the list of converted histograms
bool enable(bool value)
Set enabled flag.
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
string s
Definition: gaudirun.py:245
Strings m_exclude
the list of patterns to be excludes
def select(list, sel)
Definition: AnalysisInit.py:29
std::string m_histPersName
Name of the Hist Pers type.
StatusCode HistogramPersistencySvc::finalize ( )
override

Finalize the service.

Definition at line 58 of file HistogramPersistencySvc.cpp.

59 {
60  //
61  MsgStream log ( msgSvc() , name() );
62  if ( !(m_convert.empty() && m_exclude.empty()) )
63  { // print message if any of the two properties is used
64  log << MSG::INFO << "Histograms Converted/Excluded: "
65  << m_converted.size() << "/" << m_excluded.size() << endmsg ;
66  }
67  if (msgLevel(MSG::DEBUG)) {
68  if ( !m_excluded.empty() )
69  {
70  log << MSG::DEBUG << "Excluded Histos : #" << m_excluded.size() ;
71  for ( const auto& item : m_excluded )
72  { log << std::endl << " '" << item << "'" ; }
73  log << endmsg ;
74  }
75  //
76  if ( !m_converted.empty() )
77  {
78  log << MSG::DEBUG << "Converted Histos : #" << m_converted.size() ;
79  for ( const auto& item : m_converted )
80  { log << std::endl << " '" << item << "'" ; }
81  log << endmsg ;
82  }
83  }
84  return PersistencySvc::finalize();
85 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Set m_excluded
for the final report: the list of excluded histograms
Strings m_convert
the list of patterns to be converted
Set m_converted
for the final report: the list of converted histograms
StatusCode finalize() override
stop the service.
Strings m_exclude
the list of patterns to be excludes
tuple item
print s1,s2
Definition: ana.py:146
StatusCode HistogramPersistencySvc::initialize ( )
override

Initialize the service.

Definition at line 89 of file HistogramPersistencySvc.cpp.

89  {
91  if ( status.isSuccess() ) {
92  status = reinitialize();
93  }
94  return status;
95 }
StatusCode initialize() override
Initialize the service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
StatusCode reinitialize() override
Reinitialize the service.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode HistogramPersistencySvc::reinitialize ( )
override

Reinitialize the service.

Definition at line 99 of file HistogramPersistencySvc.cpp.

100 {
101  MsgStream log(msgSvc(), name());
102  // Obtain the IProperty of the ApplicationMgr
103  auto prpMgr = serviceLocator()->as<IProperty>();
104  if ( !prpMgr ) {
105  log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endmsg;
106  return StatusCode::FAILURE;
107  }
108  else {
109  setProperty(prpMgr->getProperty("HistogramPersistency")).ignore();
110  }
111 
112  // To keep backward compatibility, we set the property of conversion service
113  // into JobOptions catalogue
114  if( !m_outputFile.empty() ) {
115  auto joptsvc = serviceLocator()->service<IJobOptionsSvc> ("JobOptionsSvc");
116  if( joptsvc ) {
117  StringProperty p("OutputFile", m_outputFile);
118  if ( m_histPersName == "ROOT" ) {
119  joptsvc->addPropertyToCatalogue("RootHistSvc", p).ignore();
120  } else if (m_histPersName == "HBOOK" ) {
121  joptsvc->addPropertyToCatalogue("HbookHistSvc", p).ignore();
122  }
123  }
124  }
125 
126  // Load the Histogram persistency service that's required as default
127  setConversionSvc(nullptr).ignore();
128  if ( m_histPersName == "ROOT" ) {
129  setConversionSvc(service("RootHistSvc")).ignore();
130  if ( !conversionSvc() ) {
131  return StatusCode::FAILURE;
132  }
133  enable(true);
134  }
135  else if ( m_histPersName == "HBOOK" ) {
136  setConversionSvc(service("HbookHistSvc")).ignore();
137  if ( !conversionSvc() ) {
138  return StatusCode::FAILURE;
139  }
140  enable(true);
141  }
142  else if ( m_histPersName == "NONE" ) {
143  enable(false);
144  if ( m_warnings ) {
145  log << MSG::WARNING << "Histograms saving not required." << endmsg;
146  }
147  }
148  else {
150  if ( !conversionSvc() ) {
151  return StatusCode::FAILURE;
152  }
153  enable(true);
154  if ( m_warnings ) {
155  log << MSG::WARNING << "Unknown Histogram Persistency Mechanism " << m_histPersName << endmsg;
156  }
157  }
158  return StatusCode::SUCCESS;
159 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
bool m_warnings
Flag to disable warning messages when using external input.
bool enable(bool value)
Set enabled flag.
Main interface for the JobOptions service.
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:254
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
void ignore() const
Definition: StatusCode.h:108
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
std::string m_outputFile
Name of the outputFile.
std::string m_histPersName
Name of the Hist Pers type.

Member Data Documentation

Strings HistogramPersistencySvc::m_convert
protected

the list of patterns to be converted

Definition at line 83 of file HistogramPersistencySvc.h.

Set HistogramPersistencySvc::m_converted
protected

for the final report: the list of converted histograms

Definition at line 87 of file HistogramPersistencySvc.h.

Strings HistogramPersistencySvc::m_exclude
protected

the list of patterns to be excludes

Definition at line 85 of file HistogramPersistencySvc.h.

Set HistogramPersistencySvc::m_excluded
protected

for the final report: the list of excluded histograms

Definition at line 89 of file HistogramPersistencySvc.h.

std::string HistogramPersistencySvc::m_histPersName
protected

Name of the Hist Pers type.

Definition at line 79 of file HistogramPersistencySvc.h.

std::string HistogramPersistencySvc::m_outputFile
protected

Name of the outputFile.

Definition at line 81 of file HistogramPersistencySvc.h.

bool HistogramPersistencySvc::m_warnings
protected

Flag to disable warning messages when using external input.

Definition at line 91 of file HistogramPersistencySvc.h.


The documentation for this class was generated from the following files: