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 >
typedef extends base_class
 Typedef to this class. More...
 
typedef extend_interfaces< Interfaces...> extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extends base_class
 Typedef to this class. More...
 
typedef extend_interfaces< Interfaces...> extend_interfaces_base
 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
 Return default service type. More...
 
const CLIDobjType () const
 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 236 of file HistogramPersistencySvc.cpp.

238  : PersistencySvc(name, svc)
239 {
240  std::vector<std::string> defServices;
241  defServices.push_back("RootHistSvc");
242  m_svcNames.set(defServices);
243  declareProperty ("HistogramPersistency", m_histPersName = "");
244  declareProperty ("OutputFile", m_outputFile = "");
245  //
246  declareProperty
247  ("ConvertHistos" , m_convert ,
248  "The list of patterns to be accepted for conversion" ) ;
249  //
250  declareProperty
251  ("ExcludeHistos" , m_exclude ,
252  "The list of patterns to be excluded for conversion" ) ;
253  declareProperty("Warnings",m_warnings=true,
254  "Set this property to false to suppress warning messages");
255 }
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 201 of file HistogramPersistencySvc.cpp.

203 {
204  // enable the conversion
205  enable ( true ) ;
206  // conversion is possible ?
207  if ( "NONE" == m_histPersName )
208  {
209  enable ( false ) ;
210  return PersistencySvc::createRep ( pObj , refpAddr ) ; // RETURN
211  }
212  // histogram ?
213  if ( dynamic_cast<AIDA::IBaseHistogram*> ( pObj ) )
214  {
215 
216  auto match_pObj = [&](const std::string& s) { return match( pObj , s ); };
217  // Empty ConvertHistos property means convert all
218  bool select = ( m_convert.empty()
219  || std::any_of( m_convert.begin(), m_convert.end(), match_pObj )
220  ) && std::none_of( m_exclude.begin(), m_exclude.end(), match_pObj );
221  //
222  enable ( select ) ;
223  //
224  const auto& path = oname ( pObj ) ;
225  //
226  if ( !select ) { m_excluded.insert ( path ) ; }
227  else { m_converted.insert ( path ) ; }
228  }
229  //
230  return PersistencySvc::createRep ( pObj , refpAddr ) ; // RETURN
231 }
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:246
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 51 of file HistogramPersistencySvc.cpp.

52 {
53  //
54  MsgStream log ( msgSvc() , name() );
55  if ( !(m_convert.empty() && m_exclude.empty()) )
56  { // print message if any of the two properties is used
57  log << MSG::INFO << "Histograms Converted/Excluded: "
58  << m_converted.size() << "/" << m_excluded.size() << endmsg ;
59  }
60  if (msgLevel(MSG::DEBUG)) {
61  if ( !m_excluded.empty() )
62  {
63  log << MSG::DEBUG << "Excluded Histos : #" << m_excluded.size() ;
64  for ( const auto& item : m_excluded )
65  { log << std::endl << " '" << item << "'" ; }
66  log << endmsg ;
67  }
68  //
69  if ( !m_converted.empty() )
70  {
71  log << MSG::DEBUG << "Converted Histos : #" << m_converted.size() ;
72  for ( const auto& item : m_converted )
73  { log << std::endl << " '" << item << "'" ; }
74  log << endmsg ;
75  }
76  }
77  return PersistencySvc::finalize();
78 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Set m_excluded
for the final report: the list of excluded histograms
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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 82 of file HistogramPersistencySvc.cpp.

82  {
84  if ( status.isSuccess() ) {
85  status = reinitialize();
86  }
87  return status;
88 }
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 92 of file HistogramPersistencySvc.cpp.

93 {
94  MsgStream log(msgSvc(), name());
95  // Obtain the IProperty of the ApplicationMgr
96  auto prpMgr = serviceLocator()->as<IProperty>();
97  if ( !prpMgr ) {
98  log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endmsg;
99  return StatusCode::FAILURE;
100  }
101  else {
102  setProperty(prpMgr->getProperty("HistogramPersistency")).ignore();
103  }
104 
105  // To keep backward compatibility, we set the property of conversion service
106  // into JobOptions catalogue
107  if( !m_outputFile.empty() ) {
108  auto joptsvc = serviceLocator()->service<IJobOptionsSvc> ("JobOptionsSvc");
109  if( joptsvc ) {
110  StringProperty p("OutputFile", m_outputFile);
111  if ( m_histPersName == "ROOT" ) {
112  joptsvc->addPropertyToCatalogue("RootHistSvc", p).ignore();
113  } else if (m_histPersName == "HBOOK" ) {
114  joptsvc->addPropertyToCatalogue("HbookHistSvc", p).ignore();
115  }
116  }
117  }
118 
119  // Load the Histogram persistency service that's required as default
120  setConversionSvc(nullptr).ignore();
121  if ( m_histPersName == "ROOT" ) {
122  setConversionSvc(service("RootHistSvc")).ignore();
123  if ( !conversionSvc() ) {
124  return StatusCode::FAILURE;
125  }
126  enable(true);
127  }
128  else if ( m_histPersName == "HBOOK" ) {
129  setConversionSvc(service("HbookHistSvc")).ignore();
130  if ( !conversionSvc() ) {
131  return StatusCode::FAILURE;
132  }
133  enable(true);
134  }
135  else if ( m_histPersName == "NONE" ) {
136  enable(false);
137  if ( m_warnings ) {
138  log << MSG::WARNING << "Histograms saving not required." << endmsg;
139  }
140  }
141  else {
143  if ( !conversionSvc() ) {
144  return StatusCode::FAILURE;
145  }
146  enable(true);
147  if ( m_warnings ) {
148  log << MSG::WARNING << "Unknown Histogram Persistency Mechanism " << m_histPersName << endmsg;
149  }
150  }
151  return StatusCode::SUCCESS;
152 }
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:255
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: