The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::RootStatCnv Class Reference

Description: Base class converter for N-tuples and related classes. More...

#include <Root/RootStatCnv.h>

Inheritance diagram for Gaudi::RootStatCnv:
Collaboration diagram for Gaudi::RootStatCnv:

Public Member Functions

 RootStatCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor.
 
- Public Member Functions inherited from Gaudi::RootConverter
 RootConverter (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor.
 
long repSvcType () const override
 Retrieve the class type of the data store the converter uses.
 
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) override
 Converter overrides: Create transient object from persistent data.
 
StatusCode fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object.
 
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override
 Converter overrides: Convert the transient object to the requested representation.
 
StatusCode fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object.
 
- Public Member Functions inherited from Converter
StatusCode initialize () override
 Initialize the converter.
 
StatusCode finalize () override
 Initialize the converter.
 
StatusCode setDataProvider (IDataProviderSvc *svc) override
 Set Data provider service.
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Get Data provider service.
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Set conversion service the converter is connected to.
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Get conversion service the converter is connected to.
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility.
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility.
 
const CLIDobjType () const override
 Retrieve the class type of objects the converter produces.
 
virtual long i_repSvcType () const
 Retrieve the class type of the data store the converter uses.
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Create the transient representation of an object.
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the created transient object.
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Update the transient object from the other representation.
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the references of an updated transient object.
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Convert the transient object to the requested representation.
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the converted object.
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the converted representation of a transient object.
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the references of an already converted object.
 
 Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0)
 Standard Constructor.
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true) const
 Return a pointer to the service identified by name (or "type/name")
 
- Public Member Functions inherited from implements< IConverter >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
 implements ()=default
 Default constructor.
 
 implements (const implements &)
 Copy constructor (zero the reference count)
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count).
 
unsigned long addRef () const override
 Reference Interface instance.
 
unsigned long release () const override
 Release Interface instance.
 
unsigned long refCount () const override
 Current reference count.
 

Protected Member Functions

MsgStreamlog () const
 Helper to use mesage logger.
 
StatusCode initialize () override
 Initialize converter object.
 
StatusCode finalize () override
 Finalize converter object.
 
virtual const std::string containerName (IRegistry *pDir) const
 Retrieve the name of the container a given object is placed into.
 
virtual const std::string fileName (IRegistry *pReg) const
 Retrieve the name of the file a given object is placed into.
 
virtual const std::string topLevel (IRegistry *pReg) const
 Retrieve the full path of the file a given object is placed into.
 
StatusCode makeError (const std::string &msg, bool throw_exception=false) const
 Helper method to issue error messages.
 
StatusCode saveDescription (const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
 Save statistics object description.
 
- Protected Member Functions inherited from Converter
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service.
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service.
 
- Protected Member Functions inherited from implements< IConverter >
unsigned long decRef () const override
 

Protected Attributes

SmartIF< IDataManagerSvcm_dataMgr
 Reference to data manager service to manipulate the TES.
 
std::unique_ptr< MsgStreamm_log
 Reference to logger object.
 
- Protected Attributes inherited from Gaudi::RootConverter
RootCnvSvcm_dbMgr
 Conversion service needed for proper operation to forward requests.
 
- Protected Attributes inherited from implements< IConverter >
std::atomic_ulong m_refCount
 Reference counter.
 

Additional Inherited Members

- Public Types inherited from Converter
using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>
 
- Public Types inherited from implements< IConverter >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
using iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

Detailed Description

Description: Base class converter for N-tuples and related classes.

Author
M.Frank
Version
1.0

Definition at line 39 of file RootStatCnv.h.

Constructor & Destructor Documentation

◆ RootStatCnv()

RootStatCnv::RootStatCnv ( long typ,
const CLID & clid,
ISvcLocator * svc,
RootCnvSvc * mgr )

Initializing Constructor.

Parameters
typ[IN] Concrete storage type of the converter
clid[IN] Class identifier of the object
svc[IN] Pointer to service locator object
Returns
Reference to RootBaseCnv object

Definition at line 34 of file RootStatCnv.cpp.

35 : RootConverter( typ, clid, svc, mgr ) {}
RootConverter(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.

Member Function Documentation

◆ containerName()

const string RootStatCnv::containerName ( IRegistry * pDir) const
protectedvirtual

Retrieve the name of the container a given object is placed into.

Parameters
pReg[IN] Pointer to registry entry.
Returns
Name of the container the object should be put to.

Reimplemented in Gaudi::RootDatabaseCnv.

Definition at line 56 of file RootStatCnv.cpp.

56 {
57 const string& path = pReg->identifier();
58 long loc = path.find( '/', 1 );
59 string local = "<local>";
60 // local = "";
61 if ( loc > 0 ) {
62 loc = path.find( '/', ++loc );
63 if ( loc > 0 ) { local += path.substr( loc ); }
64 }
65 // for(size_t i=0; i<local.length();++i)
66 // if ( !isalnum(local[i])) local[i] = '_';
67 return local;
68}
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram

◆ fileName()

const string RootStatCnv::fileName ( IRegistry * pReg) const
protectedvirtual

Retrieve the name of the file a given object is placed into.

Parameters
pReg[IN] Pointer to registry entry.
Returns
Name of the file the object should be put to.

Definition at line 71 of file RootStatCnv.cpp.

71 {
72 string path = topLevel( pReg );
73 DataObject* pObj = nullptr;
74 dataProvider()->retrieveObject( path, pObj ).ignore();
75 if ( pObj ) {
76 NTuple::File* fptr = dynamic_cast<NTuple::File*>( pObj );
77 if ( fptr ) { return fptr->name(); }
78 }
79 return "";
80}
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition Converter.cpp:77
virtual const std::string topLevel(IRegistry *pReg) const
Retrieve the full path of the file a given object is placed into.
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
const std::string & name() const
Retrun physical file name.
Definition NTuple.h:941
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139

◆ finalize()

StatusCode RootStatCnv::finalize ( )
overrideprotected

Finalize converter object.

Definition at line 49 of file RootStatCnv.cpp.

49 {
50 m_log.reset();
51 m_dataMgr.reset();
53}
StatusCode finalize() override
Initialize the converter.
Definition Converter.cpp:59
SmartIF< IDataManagerSvc > m_dataMgr
Reference to data manager service to manipulate the TES.
Definition RootStatCnv.h:42
std::unique_ptr< MsgStream > m_log
Reference to logger object.
Definition RootStatCnv.h:44

◆ initialize()

StatusCode RootStatCnv::initialize ( )
overrideprotected

Initialize converter object.

Definition at line 38 of file RootStatCnv.cpp.

38 {
39 StatusCode sc = RootConverter::initialize();
40 if ( sc.isSuccess() ) {
42 if ( !m_dataMgr ) { return makeError( "Failed to access IDataManagerSvc interface." ); }
43 }
44 m_log.reset( new MsgStream( msgSvc(), System::typeinfoName( typeid( *this ) ) ) );
45 return sc;
46}
StatusCode initialize() override
Initialize the converter.
Definition Converter.cpp:52
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
bool isSuccess() const
Definition StatusCode.h:314
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ log()

MsgStream & Gaudi::RootStatCnv::log ( ) const
inlineprotected

Helper to use mesage logger.

Definition at line 47 of file RootStatCnv.h.

47{ return *m_log; }

◆ makeError()

StatusCode RootStatCnv::makeError ( const std::string & msg,
bool throw_exception = false ) const
protected

Helper method to issue error messages.

Parameters
msg[IN] Text of the error message
throw_exc[IN]If true throw an exception of type std::runtime_error
Returns
Status code indicating success or failure.

Definition at line 97 of file RootStatCnv.cpp.

97 {
98 if ( m_log ) {
99 log() << MSG::ERROR << msg << endmsg;
100 } else {
101 MsgStream l( msgSvc(), "RootConverter" );
102 l << MSG::ERROR << msg << endmsg;
103 }
104 if ( throw_exc ) {}
105 return StatusCode::FAILURE;
106}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & log() const
Helper to use mesage logger.
Definition RootStatCnv.h:47
constexpr static const auto FAILURE
Definition StatusCode.h:100
@ ERROR
Definition IMessageSvc.h:22
dict l
Definition gaudirun.py:583

◆ saveDescription()

StatusCode RootStatCnv::saveDescription ( const std::string & path,
const std::string & ident,
const std::string & desc,
const std::string & opt,
const CLID & clid )
protected

Save statistics object description.

Parameters
path[IN] Path of file to save the description on.
ident[IN] Identifier of description to be saved.
desc[IN] Description
opt[IN] Optional description
guid[IN] Object giud of described object
openMode[IN] Mode of opening the file to save description
Returns
Status code indicating success or failure.

Definition at line 109 of file RootStatCnv.cpp.

110 {
111 RootDataConnection* con = nullptr;
112 StatusCode status = m_dbMgr->connectDatabase( path, IDataConnection::UPDATE, &con );
113 if ( status.isSuccess() ) {
114 TClass* cl = gROOT->GetClass( "Gaudi::RootNTupleDescriptor", kTRUE );
115 if ( cl ) {
116 RootNTupleDescriptor* ptr;
117 std::unique_ptr<RootNTupleDescriptor> dsc( ptr = new RootNTupleDescriptor() );
118 TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription", cl, ptr, 512, 0 );
119 if ( b ) {
120 dsc->description = desc;
121 dsc->optional = opt;
122 dsc->container = ident;
123 dsc->clid = clid;
124 b->SetAddress( &ptr );
125 int nb = b->Fill();
126 if ( nb > 1 ) {
127 log() << MSG::DEBUG << "Save description for " << ident << endmsg;
128 return StatusCode::SUCCESS;
129 }
130 }
131 return makeError( "Failed to access ROOT branch GaudiStatisticsDescription" );
132 }
133 return makeError( "Failed to access TClass RootNTupleDescriptor" );
134 }
135 return makeError( "Failed to access Tuple file:" + path );
136}
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
constexpr static const auto SUCCESS
Definition StatusCode.h:99
@ DEBUG
Definition IMessageSvc.h:22

◆ topLevel()

const string RootStatCnv::topLevel ( IRegistry * pReg) const
protectedvirtual

Retrieve the full path of the file a given object is placed into.

Parameters
pReg[IN] Pointer to registry entry.
Returns
Name of the file the object should be put to.

Definition at line 83 of file RootStatCnv.cpp.

83 {
84 if ( pReg ) {
85 string path = pReg->identifier();
86 size_t idx = path.find( '/', 1 );
87 if ( idx != string::npos ) {
88 idx = path.find( '/', idx + 1 );
89 if ( idx != string::npos ) { path.resize( idx ); }
90 return path;
91 }
92 }
93 return "";
94}
virtual const id_type & identifier() const =0
Full identifier (or key)

Member Data Documentation

◆ m_dataMgr

SmartIF<IDataManagerSvc> Gaudi::RootStatCnv::m_dataMgr
protected

Reference to data manager service to manipulate the TES.

Definition at line 42 of file RootStatCnv.h.

◆ m_log

std::unique_ptr<MsgStream> Gaudi::RootStatCnv::m_log
protected

Reference to logger object.

Definition at line 44 of file RootStatCnv.h.


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