The Gaudi Framework  v29r0 (ff2e7097)
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
 ConversionSvc (const std::string &name, ISvcLocator *svc, long type)
 Standard Constructor. More...
 
 ConversionSvc (const ConversionSvc &)=delete
 disable copy and assignment More...
 
ConversionSvcoperator= (const ConversionSvc &)=delete
 
StatusCode initialize () override
 Initialize the service. More...
 
StatusCode finalize () override
 stop the service. More...
 
long repSvcType () const override
 Retrieve the class type of the data store the converter uses. More...
 
const CLIDobjType () const override
 Implementation of IConverter: dummy call. More...
 
StatusCode setDataProvider (IDataProviderSvc *pService) override
 Implementation of IConverter: Set Data provider service. More...
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Implementation of IConverter: Get Data provider service. More...
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Implementation of IConverter: Set conversion service the converter is connected to. More...
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Implementation of IConverter: 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 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 addConverter (const CLID &clid) override
 Add converter object to conversion service. More...
 
StatusCode addConverter (IConverter *pConverter) override
 Add converter object to conversion service. More...
 
StatusCode removeConverter (const CLID &clid) override
 Remove converter object from conversion service (if present). More...
 
IConverterconverter (const CLID &wanted) override
 Retrieve converter from list. 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 &output) 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 *par, const unsigned long *ip, 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...
 
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service. 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...
 
 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 >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used 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 PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- 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

Gaudi::Property< std::stringm_defFileName {this, "OutputFile", undefFileName, "default file name"}
 
Gaudi::Property< bool > m_alphaIds {this, "ForceAlphaIds", false, "force alphabetic histograms/ntuple IDs"}
 
Gaudi::Property< bool > m_outputEnabled {this, "OutputEnabled", true, "Flag to enable/disable the output to file."}
 
std::unique_ptr< TFile > m_hfile
 Pointer to the ROOT file. More...
 
bool m_prtWar = false
 Already printed a Warning. 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 PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- 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 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 PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- 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
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. 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 
)
inline

Standard constructor.

Definition at line 32 of file PersSvc.h.

32 : ConversionSvc( name, svc, ROOT_StorageType ) {}
ConversionSvc(const std::string &name, ISvcLocator *svc, long type)
Standard Constructor.
const long ROOT_StorageType
Definition: ClassID.h:52
RootHistCnv::PersSvc::~PersSvc ( )
overridedefault

Standard destructor.

Member Function Documentation

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

Convert a collection of transient data objects into another representation.

Definition at line 75 of file PersSvc.cpp.

77 {
78  // There are objects in the HDS to be stored
79  if ( m_outputEnabled && undefFileName != m_defFileName ) {
81  if ( 0 != top ) {
82  IRegistry* pReg = top->registry();
83  if ( pReg ) {
84  if ( top.ptr() == pObject ) {
85  TDirectory* pDir = m_hfile.get();
86  refpAddress =
87  new RootObjAddress( repSvcType(), CLID_DataObject, stat_dir, m_defFileName, long( pDir ), long( 0 ) );
88  return StatusCode::SUCCESS;
89  } else {
90  StatusCode sc = ConversionSvc::createRep( pObject, refpAddress );
91  if ( sc.isFailure() ) {
92  MsgStream log( msgSvc(), name() );
93  log << MSG::ERROR << "Error while creating persistent Histogram:" << pReg->identifier() << endmsg;
94  }
95  return sc;
96  }
97  }
98  }
99  MsgStream err( msgSvc(), name() );
100  err << MSG::ERROR << "Internal error while creating Histogram persistent representations" << endmsg;
101  return StatusCode::FAILURE;
102  } else {
103  if ( m_outputEnabled && !m_prtWar ) {
104  m_prtWar = true;
105  MsgStream log( msgSvc(), name() );
106  log << MSG::WARNING << "no ROOT output file name, "
107  << "Histograms cannot be persistified" << endmsg;
108  }
109  }
110  return StatusCode::SUCCESS;
111 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
virtual const id_type & identifier() const =0
Full identifier (or key)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Gaudi::Property< bool > m_outputEnabled
Definition: PersSvc.h:41
SmartIF< IDataProviderSvc > & dataProvider() const override
Implementation of IConverter: Get Data provider service.
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:44
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataPtr.h:47
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
std::unique_ptr< TFile > m_hfile
Pointer to the ROOT file.
Definition: PersSvc.h:43
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::Property< std::string > m_defFileName
Definition: PersSvc.h:39
StatusCode RootHistCnv::PersSvc::finalize ( )
override

Finalise the service.

Definition at line 61 of file PersSvc.cpp.

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

Initialise the service.

Definition at line 33 of file PersSvc.cpp.

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

Member Data Documentation

Gaudi::Property<bool> RootHistCnv::PersSvc::m_alphaIds {this, "ForceAlphaIds", false, "force alphabetic histograms/ntuple IDs"}
private

Definition at line 40 of file PersSvc.h.

Gaudi::Property<std::string> RootHistCnv::PersSvc::m_defFileName {this, "OutputFile", undefFileName, "default file name"}
private

Definition at line 39 of file PersSvc.h.

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

Pointer to the ROOT file.

Definition at line 43 of file PersSvc.h.

Gaudi::Property<bool> RootHistCnv::PersSvc::m_outputEnabled {this, "OutputEnabled", true, "Flag to enable/disable the output to file."}
private

Definition at line 41 of file PersSvc.h.

bool RootHistCnv::PersSvc::m_prtWar = false
private

Already printed a Warning.

Definition at line 44 of file PersSvc.h.


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