The Gaudi Framework  v30r3 (a5ef0a68)
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. More...
 
- Public Member Functions inherited from Gaudi::RootConverter
 RootConverter (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor. More...
 
long repSvcType () const override
 Retrieve the class type of the data store the converter uses. More...
 
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) override
 Converter overrides: Create transient object from persistent data. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object. More...
 
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override
 Converter overrides: Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object. More...
 
- Public Member Functions inherited from Converter
StatusCode initialize () override
 Initialize the converter. More...
 
StatusCode finalize () override
 Initialize the converter. More...
 
StatusCode setDataProvider (IDataProviderSvc *svc) override
 Set Data provider service. More...
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Get Data provider service. 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...
 
const CLIDobjType () const override
 Retrieve the class type of objects the converter produces. More...
 
virtual long i_repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Create the transient representation of an object. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the created transient object. More...
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Update the transient object from the other representation. More...
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the references of an updated transient object. More...
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the converted object. More...
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the converted representation of a transient object. More...
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the references of an already converted object. More...
 
 Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0)
 Standard Constructor. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &type, const std::string &name, T *&psvc) const
 Access a service by name, type creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true) const
 Return a pointer to the service identified by name (or "type/name") More...
 
- Public Member Functions inherited from implements< IConverter >
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...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 

Protected Member Functions

MsgStreamlog () const
 Helper to use mesage logger. More...
 
StatusCode initialize () override
 Initialize converter object. More...
 
StatusCode finalize () override
 Finalize converter object. More...
 
virtual const std::string containerName (IRegistry *pDir) const
 Retrieve the name of the container a given object is placed into. More...
 
virtual const std::string fileName (IRegistry *pReg) const
 Retrieve the name of the file a given object is placed into. More...
 
virtual const std::string topLevel (IRegistry *pReg) const
 Retrieve the full path of the file a given object is placed into. More...
 
StatusCode makeError (const std::string &msg, bool throw_exception=false) const
 Helper method to issue error messages. More...
 
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. More...
 
- Protected Member Functions inherited from Converter
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service. More...
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service. More...
 

Protected Attributes

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

Additional Inherited Members

- Public Types inherited from Converter
using Factory = Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)>
 
- Public Types inherited from implements< IConverter >
using base_class = implements< Interfaces... >
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- 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...
 

Detailed Description

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

Author
M.Frank
Version
1.0

Definition at line 31 of file RootStatCnv.h.

Constructor & Destructor Documentation

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 24 of file RootStatCnv.cpp.

25  : RootConverter( typ, clid, svc, mgr )
26 {
27 }
RootConverter(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Definition: RootConverter.h:47

Member Function Documentation

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 52 of file RootStatCnv.cpp.

53 {
54  const string& path = pReg->identifier();
55  long loc = path.find( '/', 1 );
56  string local = "<local>";
57  // local = "";
58  if ( loc > 0 ) {
59  loc = path.find( '/', ++loc );
60  if ( loc > 0 ) {
61  local += path.substr( loc );
62  }
63  }
64  // for(size_t i=0; i<local.length();++i)
65  // if ( !isalnum(local[i])) local[i] = '_';
66  return local;
67 }
T find(T...args)
T substr(T...args)
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 70 of file RootStatCnv.cpp.

71 {
72  string path = topLevel( pReg );
73  DataObject* pObj = nullptr;
74  dataProvider()->retrieveObject( path, pObj );
75  if ( pObj ) {
76  NTuple::File* fptr = dynamic_cast<NTuple::File*>( pObj );
77  if ( fptr ) {
78  return fptr->name();
79  }
80  }
81  return "";
82 }
const std::string & name() const
Retrun physical file name.
Definition: NTuple.h:1016
virtual const std::string topLevel(IRegistry *pReg) const
Retrieve the full path of the file a given object is placed into.
Definition: RootStatCnv.cpp:85
virtual StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:73
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:987
StatusCode RootStatCnv::finalize ( )
overrideprotected

Finalize converter object.

Definition at line 44 of file RootStatCnv.cpp.

45 {
46  m_log.reset();
47  m_dataMgr.reset();
48  return RootConverter::finalize();
49 }
SmartIF< IDataManagerSvc > m_dataMgr
Reference to data manager service to manipulate the TES.
Definition: RootStatCnv.h:35
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:53
T reset(T...args)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
std::unique_ptr< MsgStream > m_log
Reference to logger object.
Definition: RootStatCnv.h:37
StatusCode RootStatCnv::initialize ( )
overrideprotected

Initialize converter object.

Definition at line 30 of file RootStatCnv.cpp.

31 {
33  if ( sc.isSuccess() ) {
35  if ( !m_dataMgr ) {
36  return makeError( "Failed to access IDataManagerSvc interface." );
37  }
38  }
39  m_log.reset( new MsgStream( msgSvc(), System::typeinfoName( typeid( *this ) ) ) );
40  return sc;
41 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:332
bool isSuccess() const
Definition: StatusCode.h:287
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:43
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:102
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
SmartIF< IDataManagerSvc > m_dataMgr
Reference to data manager service to manipulate the TES.
Definition: RootStatCnv.h:35
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
T reset(T...args)
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:73
std::unique_ptr< MsgStream > m_log
Reference to logger object.
Definition: RootStatCnv.h:37
MsgStream& Gaudi::RootStatCnv::log ( ) const
inlineprotected

Helper to use mesage logger.

Definition at line 40 of file RootStatCnv.h.

40 { return *m_log; }
std::unique_ptr< MsgStream > m_log
Reference to logger object.
Definition: RootStatCnv.h:37
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 102 of file RootStatCnv.cpp.

103 {
104  if ( m_log ) {
105  log() << MSG::ERROR << msg << endmsg;
106  } else {
107  MsgStream l( msgSvc(), "RootConverter" );
108  l << MSG::ERROR << msg << endmsg;
109  }
110  if ( throw_exc ) {
111  }
112  return StatusCode::FAILURE;
113 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:102
dictionary l
Definition: gaudirun.py:440
std::unique_ptr< MsgStream > m_log
Reference to logger object.
Definition: RootStatCnv.h:37
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
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 116 of file RootStatCnv.cpp.

118 {
119  RootDataConnection* con = nullptr;
121  if ( status.isSuccess() ) {
122  TClass* cl = gROOT->GetClass( "Gaudi::RootNTupleDescriptor", kTRUE );
123  if ( cl ) {
126  TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription", cl, ptr, 512, 0 );
127  if ( b ) {
128  dsc->description = desc;
129  dsc->optional = opt;
130  dsc->container = ident;
131  dsc->clid = clid;
132  b->SetAddress( &ptr );
133  int nb = b->Fill();
134  if ( nb > 1 ) {
135  log() << MSG::DEBUG << "Save description for " << ident << endmsg;
136  return StatusCode::SUCCESS;
137  }
138  }
139  return makeError( "Failed to access ROOT branch GaudiStatisticsDescription" );
140  }
141  return makeError( "Failed to access TClass RootNTupleDescriptor" );
142  }
143  return makeError( "Failed to access Tuple file:" + path );
144 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
bool isSuccess() const
Definition: StatusCode.h:287
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:210
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
TBranch * getBranch(boost::string_ref section, boost::string_ref branch_name)
Access data branch by name: Get existing branch in read only mode.
STL class.
Concrete implementation of the IDataConnection interface to access ROOT files.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
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 85 of file RootStatCnv.cpp.

86 {
87  if ( pReg ) {
88  string path = pReg->identifier();
89  size_t idx = path.find( '/', 1 );
90  if ( idx != string::npos ) {
91  idx = path.find( '/', idx + 1 );
92  if ( idx != string::npos ) {
93  path = path.substr( 0, idx );
94  }
95  return path;
96  }
97  }
98  return "";
99 }
virtual const id_type & identifier() const =0
Full identifier (or key)
T find(T...args)
T substr(T...args)

Member Data Documentation

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

Reference to data manager service to manipulate the TES.

Definition at line 35 of file RootStatCnv.h.

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

Reference to logger object.

Definition at line 37 of file RootStatCnv.h.


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