RootHistCnv::PersSvc Class Reference

Persistency service - to store histograms in ROOT format. More...

#include <src/PersSvc.h>

Inheritance diagram for RootHistCnv::PersSvc:
Collaboration diagram for RootHistCnv::PersSvc:

Public Member Functions

StatusCode initialize () override
 Initialise the service. More...
 
StatusCode finalize () override
 Finalise the service. More...
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Convert a collection of transient data objects into another representation. More...
 
 PersSvc (const std::string &name, ISvcLocator *svc)
 Standard constructor. More...
 
 ~PersSvc () override=default
 Standard destructor. More...
 
- Public Member Functions inherited from ConversionSvc
virtual long repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
const CLIDobjType () const
 Implementation of IConverter: dummy call. More...
 
virtual StatusCode setDataProvider (IDataProviderSvc *pService)
 Implementation of IConverter: Set Data provider service. More...
 
virtual SmartIF< IDataProviderSvc > & dataProvider () const
 Implementation of IConverter: Get Data provider service. More...
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Implementation of IConverter: Set conversion service the converter is connected to. More...
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Implementation of IConverter: Get conversion service the converter is connected to. More...
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility. More...
 
virtual SmartIF< IAddressCreator > & addressCreator () const
 Retrieve address creator facility. More...
 
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Implementation of IConverter: Create the transient representation of an object. More...
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the created transient object. More...
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
 Implementation of IConverter: Update the transient object from the other representation. More...
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an updated transient object. More...
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the converted object. More...
 
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the converted representation of a transient object. More...
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an already converted object. More...
 
virtual StatusCode addConverter (const CLID &clid)
 Add converter object to conversion service. More...
 
virtual StatusCode addConverter (IConverter *pConverter)
 Add converter object to conversion service. More...
 
virtual StatusCode removeConverter (const CLID &clid)
 Remove converter object from conversion service (if present). More...
 
virtual IConverterconverter (const CLID &wanted)
 Retrieve converter from list. More...
 
virtual StatusCode connectOutput (const std::string &outputFile, const std::string &openMode)
 Connect the output file to the service with open mode. More...
 
virtual StatusCode connectOutput (const std::string &output)
 Connect the output file to the service. More...
 
virtual StatusCode commitOutput (const std::string &output, bool do_commit)
 Commit pending output. More...
 
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
 Create a Generic address using explicit arguments to identify a single object. More...
 
virtual StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
 Convert an address to string form. More...
 
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
 Convert an address in string form to object form. More...
 
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service. More...
 
 ConversionSvc (const std::string &name, ISvcLocator *svc, long type)
 Standard Constructor. More...
 
- Public Member Functions inherited from extends< Service, IConversionSvc, IAddressCreator >
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::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Attributes

std::string m_defFileName
 Default file name. More...
 
std::unique_ptr< TFile > m_hfile
 Pointer to the ROOT file. More...
 
bool m_prtWar = false
 Already printed a Warning. More...
 
bool m_alphaIds
 Force alphabetic histograms/ntuple IDs. More...
 
bool m_outputEnabled
 Flag to enable/disable the output to file. More...
 

Additional Inherited Members

- Public Types inherited from extends< Service, IConversionSvc, IAddressCreator >
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 Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- 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...
 
- Protected Member Functions inherited from ConversionSvc
virtual ~ConversionSvc ()
 Standard Destructor. More...
 
virtual IConvertercreateConverter (long typ, const CLID &clid, const ICnvFactory *fac)
 Create new Converter using factory. More...
 
virtual StatusCode configureConverter (long typ, const CLID &clid, IConverter *cnv)
 Configure the new converter before initialize is called. More...
 
virtual StatusCode initializeConverter (long typ, const CLID &clid, IConverter *cnv)
 Initialize the new converter. More...
 
virtual StatusCode activateConverter (long typ, const CLID &clid, IConverter *cnv)
 Activate the new converter after initialization. More...
 
virtual void loadConverter (DataObject *pObject)
 Load converter or dictionary needed by the converter. More...
 
virtual SmartIF< IAddressCreator > & addressCreator ()
 Retrieve address creation interface. More...
 
StatusCode makeCall (int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from ConversionSvc
SmartIF< IDataProviderSvcm_dataSvc
 Pointer to data provider service. More...
 
SmartIF< IAddressCreatorm_addressCreator
 Pointer to the address creation service interface. More...
 
SmartIF< IConversionSvcm_cnvSvc
 Pointer to the IConversionSvc interface of this. More...
 
long m_type
 Conversion service type. More...
 
std::vector< WorkerEntrym_workers
 List of conversion workers. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 

Detailed Description

Persistency service - to store histograms in ROOT format.

Author
Charles Leggett

Definition at line 19 of file PersSvc.h.

Constructor & Destructor Documentation

RootHistCnv::PersSvc::PersSvc ( const std::string name,
ISvcLocator svc 
)

Standard constructor.

Definition at line 127 of file PersSvc.cpp.

129 : ConversionSvc(name, svc, ROOT_StorageType) {
130  declareProperty("OutputFile", m_defFileName = undefFileName);
131  declareProperty("ForceAlphaIds", m_alphaIds = false);
132  declareProperty("OutputEnabled", m_outputEnabled = true,
133  "Flag to enable/disable the output to file.");
134 }
bool m_outputEnabled
Flag to enable/disable the output to file.
Definition: PersSvc.h:41
ConversionSvc(const std::string &name, ISvcLocator *svc, long type)
Standard Constructor.
std::string m_defFileName
Default file name.
Definition: PersSvc.h:37
const long ROOT_StorageType
Definition: ClassID.h:52
bool m_alphaIds
Force alphabetic histograms/ntuple IDs.
Definition: PersSvc.h:40
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
RootHistCnv::PersSvc::~PersSvc ( )
overridedefault

Standard destructor.

Member Function Documentation

StatusCode RootHistCnv::PersSvc::createRep ( DataObject pObject,
IOpaqueAddress *&  refpAddress 
)
overridevirtual

Convert a collection of transient data objects into another representation.

Reimplemented from ConversionSvc.

Definition at line 76 of file PersSvc.cpp.

79 {
80  // There are objects in the HDS to be stored
81  if( m_outputEnabled && undefFileName != m_defFileName ) {
83  if ( 0 != top ) {
84  IRegistry* pReg = top->registry();
85  if ( pReg ) {
86  if ( top.ptr() == pObject ) {
87  TDirectory* pDir = m_hfile.get();
88  refpAddress = new RootObjAddress( repSvcType(),
89  CLID_DataObject,
90  stat_dir,
92  long(pDir),
93  long(0));
94  return StatusCode::SUCCESS;
95  }
96  else {
97  StatusCode sc = ConversionSvc::createRep(pObject, refpAddress);
98  if( sc.isFailure() ) {
99  MsgStream log( msgSvc(), name() );
100  log << MSG::ERROR
101  << "Error while creating persistent Histogram:"
102  << pReg->identifier()
103  << endmsg;
104  }
105  return sc;
106  }
107  }
108  }
109  MsgStream err( msgSvc(), name() );
110  err << MSG::ERROR
111  << "Internal error while creating Histogram persistent representations"
112  << endmsg;
113  return StatusCode::FAILURE;
114  } else {
115  if (m_outputEnabled && !m_prtWar) {
116  m_prtWar = true;
117  MsgStream log( msgSvc(), name() );
118  log << MSG::WARNING
119  << "no ROOT output file name, "
120  << "Histograms cannot be persistified" << endmsg;
121  }
122  }
123  return StatusCode::SUCCESS;
124 }
bool m_outputEnabled
Flag to enable/disable the output to file.
Definition: PersSvc.h:41
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Implementation of IConverter: Convert the transient object to the requested representation.
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
std::string m_defFileName
Default file name.
Definition: PersSvc.h:37
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
virtual long repSvcType() const
Retrieve the class type of the data store the converter uses.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
T get(T...args)
bool m_prtWar
Already printed a Warning.
Definition: PersSvc.h:39
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataPtr.h:46
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual const id_type & identifier() const =0
Full identifier (or key)
std::unique_ptr< TFile > m_hfile
Pointer to the ROOT file.
Definition: PersSvc.h:38
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual SmartIF< IDataProviderSvc > & dataProvider() const
Implementation of IConverter: Get Data provider service.
StatusCode RootHistCnv::PersSvc::finalize ( )
overridevirtual

Finalise the service.

Reimplemented from ConversionSvc.

Definition at line 62 of file PersSvc.cpp.

64 {
65  // Close ROOT only if the output file name is defined
66  MsgStream log( msgSvc(), name() );
67  log << MSG::DEBUG << "RootHistCnv::PersSvc::finalize()" << endmsg;
68  if( undefFileName != m_defFileName ) {
69  m_hfile->Write("",TObject::kOverwrite);
70  m_hfile->Close();
71  }
72  return ConversionSvc::finalize();
73 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::string m_defFileName
Default file name.
Definition: PersSvc.h:37
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
virtual StatusCode finalize()
stop the service.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
std::unique_ptr< TFile > m_hfile
Pointer to the ROOT file.
Definition: PersSvc.h:38
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode RootHistCnv::PersSvc::initialize ( )
overridevirtual

Initialise the service.

Reimplemented from ConversionSvc.

Definition at line 31 of file PersSvc.cpp.

33 {
34  MsgStream log( msgSvc(), name() );
35 
37  if( status.isFailure() ) return status;
38 
39  // Get my properties from the JobOptionsSvc
40  if (setProperties().isFailure()) {
41  log << MSG::ERROR << "Could not set my properties" << endmsg;
42  return StatusCode::FAILURE;
43  }
44  if (m_outputEnabled) {
45  // Initialize ROOT if output file name is defined
46  if( undefFileName != m_defFileName ) {
47  m_hfile.reset( TFile::Open(m_defFileName.c_str(),"RECREATE","GAUDI Histograms") );
48  } else {
49  m_hfile.reset();
50  }
51  log << MSG::INFO << "Writing ROOT histograms to: " << m_defFileName
52  << endmsg;
53  }
54  else {
55  log << MSG::INFO << "Writing ROOT histograms disabled." << endmsg;
56  }
57  return StatusCode(StatusCode::SUCCESS,true);
58 }
bool m_outputEnabled
Flag to enable/disable the output to file.
Definition: PersSvc.h:41
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::string m_defFileName
Default file name.
Definition: PersSvc.h:37
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T reset(T...args)
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:363
T c_str(T...args)
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual StatusCode initialize()
Initialize the service.
std::unique_ptr< TFile > m_hfile
Pointer to the ROOT file.
Definition: PersSvc.h:38
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

bool RootHistCnv::PersSvc::m_alphaIds
private

Force alphabetic histograms/ntuple IDs.

Definition at line 40 of file PersSvc.h.

std::string RootHistCnv::PersSvc::m_defFileName
private

Default file name.

Definition at line 37 of file PersSvc.h.

std::unique_ptr<TFile> RootHistCnv::PersSvc::m_hfile
private

Pointer to the ROOT file.

Definition at line 38 of file PersSvc.h.

bool RootHistCnv::PersSvc::m_outputEnabled
private

Flag to enable/disable the output to file.

Definition at line 41 of file PersSvc.h.

bool RootHistCnv::PersSvc::m_prtWar = false
private

Already printed a Warning.

Definition at line 39 of file PersSvc.h.


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