The Gaudi Framework  v33r0 (d5ea422b)
Gaudi::RootCnvSvc Class Reference

Description: More...

#include <src/RootCnvSvc.h>

Inheritance diagram for Gaudi::RootCnvSvc:
Collaboration diagram for Gaudi::RootCnvSvc:

Public Member Functions

 RootCnvSvc (const std::string &name, ISvcLocator *svc)
 Standard constructor. More...
 
StatusCode updateServiceState (IOpaqueAddress *) override
 Update state of the service. More...
 
StatusCode error (const std::string &msg)
 Standard way to print errors. More...
 
StatusCode connectDatabase (const std::string &dataset, int mode, RootDataConnection **con)
 Connect the output file to the service with open mode. More...
 
StatusCode initialize () override
 ConversionSvc overload: initialize Db service. More...
 
StatusCode finalize () override
 ConversionSvc overload: Finalize Db service. More...
 
IConvertercreateConverter (long typ, const CLID &wanted, const ICnvFactory *fac) override
 ConversionSvc overload: Create new Converter using factory. More...
 
void loadConverter (DataObject *pObj) override
 ConversionSvc overload: Load the class (dictionary) for the converter. 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 &outputFile, bool do_commit) override
 Commit pending output. More...
 
virtual StatusCode disconnect (const std::string &dbName)
 Disconnect from an existing data stream. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
 IAddressCreator implementation: Address creation. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
 IAddressCreator implementation: Creates an address in string form to object form. More...
 
virtual StatusCode createNullRep (const std::string &path)
 Insert null marker for not existent transient object. More...
 
virtual StatusCode createNullRef (const std::string &path)
 Insert null marker for not existent transient object. More...
 
virtual StatusCode i__createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
 Convert the transient object to the requested persistent representation. More...
 
virtual StatusCode i__fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj)
 Resolve the references of the converted object. More...
 
virtual StatusCode i__createObj (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Create transient object from persistent data. More...
 
virtual StatusCode i__fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj)
 Resolve the references of the created transient object. 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...
 
- 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...
 
- 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
 
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, 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
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const 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...
 

Protected Member Functions

TClass * getClass (DataObject *pObject)
 Helper: Get TClass for a given DataObject pointer. More...
 
MsgStreamlog () const
 Helper: Use message streamer. More...
 
- Protected Member Functions inherited from ConversionSvc
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 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 > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

Gaudi::Property< std::stringm_ioPerfStats
 
Gaudi::Property< std::stringm_shareFiles
 
Gaudi::Property< bool > m_incidentEnabled {this, "EnableIncident", true, "Flag to enable incidents on FILE_OPEN"}
 
Gaudi::Property< std::stringm_recordName
 
Gaudi::Property< int > m_autoFlush
 
Gaudi::Property< int > m_basketSize
 
Gaudi::Property< int > m_bufferSize
 
Gaudi::Property< int > m_splitLevel {this, "SplitLevel", 0, "Split level optimization parameter for ROOT TTree"}
 
Gaudi::Property< std::stringm_compression
 
SmartIF< Gaudi::IIODataManagerm_ioMgr
 Reference to the I/O data manager. More...
 
SmartIF< IIncidentSvcm_incidentSvc
 Reference to incident service. More...
 
Gaudi::RootDataConnectionm_current = nullptr
 On writing: reference to active output stream. More...
 
TClass * m_classRefs = nullptr
 TClass pointer to reference class. More...
 
TClass * m_classDO = nullptr
 TClass pointer to DataObject class. More...
 
std::shared_ptr< RootConnectionSetupm_setup
 Setup structure (ref-counted) and passed to data connections. More...
 
std::string m_currSection
 Property: ROOT section name. More...
 
std::set< std::stringm_badFiles
 Set with bad files/tables. More...
 
std::unique_ptr< MsgStreamm_log
 Message streamer. 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, " 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...
 

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
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- 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...
 

Detailed Description

Description:

RootCnvSvc class implementation definition.

Author
Markus Frank
Version
1.0
Date
20/12/2009

Definition at line 62 of file RootCnvSvc.h.

Constructor & Destructor Documentation

◆ RootCnvSvc()

RootCnvSvc::RootCnvSvc ( const std::string name,
ISvcLocator svc 
)

Standard constructor.

Definition at line 60 of file RootCnvSvc.cpp.

62  m_setup->cacheBranches.push_back( "*" );
63  declareProperty( "LoadSection", m_setup->loadSection = "Event" );
64 
65  // ROOT Read parameters: must be shared for the entire file!
66  declareProperty( "CacheSize", m_setup->cacheSize = 10 * MBYTE );
67  declareProperty( "LearnEntries", m_setup->learnEntries = 10 );
68  declareProperty( "CacheBranches", m_setup->cacheBranches );
69  declareProperty( "VetoBranches", m_setup->vetoBranches );
70 }
ConversionSvc(const std::string &name, ISvcLocator *svc, long type)
Standard Constructor.
std::shared_ptr< RootConnectionSetup > m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:94
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
const long ROOT_StorageType
Definition: ClassID.h:62
#define MBYTE
Definition: RootCnvSvc.cpp:57

Member Function Documentation

◆ commitOutput()

StatusCode RootCnvSvc::commitOutput ( const std::string outputFile,
bool  do_commit 
)
override

Commit pending output.

Parameters
outputFileString containig output file
do_commitif true commit the output and flush eventually pending items to the database if false, discard pending buffers. Note: The possibility to commit or rollback depends on the database technology used!
Returns
Status code indicating success or failure.

fill NULL pointers to all branches, which have less entries than the section branch

Definition at line 302 of file RootCnvSvc.cpp.

302  {
303  if ( m_current ) {
304  size_t len = m_currSection.find( '/', 1 );
305  string section = m_currSection.substr( 1, len == string::npos ? string::npos : len - 1 );
306  TBranch* b = m_current->getBranch( section, m_currSection );
307  if ( b ) {
308  Long64_t evt = b->GetEntries();
309  TTree* t = b->GetTree();
310  TObjArray* a = t->GetListOfBranches();
311  Int_t nb = a->GetEntriesFast();
313  for ( Int_t i = 0; i < nb; ++i ) {
314  TBranch* br_ptr = (TBranch*)a->UncheckedAt( i );
315  Long64_t br_evt = br_ptr->GetEntries();
316  if ( br_evt < evt ) {
317  Long64_t num = evt - br_evt;
318  br_ptr->SetAddress( nullptr );
319  while ( num > 0 ) {
320  br_ptr->Fill();
321  --num;
322  }
323  if ( log().level() <= MSG::DEBUG )
324  log() << MSG::DEBUG << "commit: Added " << long( evt - br_evt ) << " Section: " << evt
325  << " Branch: " << br_ptr->GetEntries() << " RefNo: " << br_ptr->GetEntries() - 1
326  << " NULL entries to:" << br_ptr->GetName() << endmsg;
327  }
328  }
329 
330  b->GetTree()->SetEntries( evt );
331  if ( evt == 1 ) { b->GetTree()->OptimizeBaskets( m_basketSize, 1.1, "" ); }
332  if ( evt > 0 && ( evt % m_autoFlush ) == 0 ) {
333  if ( evt == m_autoFlush ) {
334  b->GetTree()->SetAutoFlush( m_autoFlush );
335  b->GetTree()->OptimizeBaskets( m_basketSize, 1., "" );
336  } else {
337  b->GetTree()->FlushBaskets();
338  }
339  }
340  if ( log().level() <= MSG::DEBUG )
341  log() << MSG::DEBUG << "Set section entries of " << m_currSection << " to " << long( evt ) << " entries."
342  << endmsg;
343  } else {
344  return error( "commitOutput> Failed to update entry numbers on " + dsn );
345  }
346  }
347  return S_OK;
348 }
Gaudi::Property< int > m_autoFlush
Definition: RootCnvSvc.h:73
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
std::string m_currSection
Property: ROOT section name.
Definition: RootCnvSvc.h:96
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
#define S_OK
Definition: RootCnvSvc.cpp:47
T find(T... args)
T substr(T... args)
Gaudi::Property< int > m_basketSize
Definition: RootCnvSvc.h:75
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::RootDataConnection * m_current
On writing: reference to active output stream.
Definition: RootCnvSvc.h:88

◆ connectDatabase()

StatusCode RootCnvSvc::connectDatabase ( const std::string dataset,
int  mode,
RootDataConnection **  con 
)

Connect the output file to the service with open mode.

Parameters
datasetString containig file name
modeString containig opening mode
Returns
Status code indicating success or failure.

Definition at line 204 of file RootCnvSvc.cpp.

204  {
205  try {
206  IDataConnection* c = m_ioMgr->connection( dataset );
207  bool fire_incident = false;
208  *con = nullptr;
209  if ( !c ) {
210  auto connection = std::make_unique<RootDataConnection>( this, dataset, m_setup );
211  StatusCode sc = ( mode != IDataConnection::READ )
212  ? m_ioMgr->connectWrite( connection.get(), IDataConnection::IoType( mode ), "ROOT" )
213  : m_ioMgr->connectRead( false, connection.get() );
214  c = sc.isSuccess() ? m_ioMgr->connection( dataset ) : nullptr;
215  if ( c ) {
216  bool writable = 0 != ( mode & ( IDataConnection::UPDATE | IDataConnection::RECREATE ) );
217  fire_incident = m_incidentEnabled && ( 0 != ( mode & ( IDataConnection::UPDATE | IDataConnection::READ ) ) );
218  if ( writable ) {
220  ContextIncident<TFile*>( connection->pfn(), "CONNECTED_OUTPUT", connection->file() ) );
221  }
222  if ( 0 != ( mode & IDataConnection::READ ) ) {
223  if ( !m_ioPerfStats.empty() ) { connection->enableStatistics( m_setup->loadSection ); }
224  }
225  connection.release();
226  } else {
228  dataset, mode == IDataConnection::READ ? IncidentType::FailInputFile : IncidentType::FailOutputFile ) );
229  // An error message was already printed by the IODataManager. no need to do it here!
230  return StatusCode::FAILURE;
231  }
232  }
233  RootDataConnection* pc = dynamic_cast<RootDataConnection*>( c );
234  if ( pc ) {
235  if ( !pc->isConnected() ) pc->connectRead();
236  *con = pc;
237  pc->resetAge();
238  pc->addClient( this );
239  }
240  if ( *con ) {
241  if ( fire_incident ) {
242  IOpaqueAddress* pAddr = nullptr;
243  string fid = pc->fid();
244  string section = m_recordName[0] == '/' ? m_recordName.value().substr( 1 ) : m_recordName.value();
245  TBranch* b = pc->getBranch( section, m_recordName.value() );
246  if ( b ) {
247  const string par[2] = {fid, m_recordName};
248  unsigned long ipar[2] = {(unsigned long)( *con ), (unsigned long)b->GetEntries() - 1};
249  for ( int i = 0; i < b->GetEntries(); ++i ) {
250  ipar[1] = i;
251  if ( !pc->mergeFIDs().empty() ) fid = pc->mergeFIDs()[i];
252  if ( !createAddress( repSvcType(), CLID_DataObject, par, ipar, pAddr ).isSuccess() ) {
253  if ( log().level() <= MSG::VERBOSE )
254  log() << MSG::VERBOSE << "Failed to create address for " << m_recordName << " in:" << fid << " ["
255  << pc->fid() << "][" << i << "]" << endmsg;
256  continue;
257  }
258  if ( log().level() <= MSG::VERBOSE )
259  log() << MSG::VERBOSE << "Prepare " << m_recordName << " " << fid << " [" << par[0] << "][" << i << "]"
260  << endmsg;
261  m_incidentSvc->fireIncident( ContextIncident<IOpaqueAddress*>( fid, "FILE_OPEN_READ", pAddr ) );
262  }
263  } else {
264  if ( log().level() <= MSG::VERBOSE )
265  log() << MSG::VERBOSE << "No valid Records " << m_recordName << " present in:" << pc->fid() << endmsg;
266  }
267  }
268 
269  // We can remove retired connections, which are no longer used....
270  for ( auto& i : m_ioMgr->connections( this ) ) {
271  if ( i != *con && !i->isConnected() ) {
272  RootDataConnection* pc = dynamic_cast<RootDataConnection*>( i );
273  if ( pc && pc->lookupClient( this ) ) {
274  size_t num_client = pc->removeClient( this );
275  if ( num_client == 0 ) {
276  if ( m_ioMgr->disconnect( pc ).isSuccess() ) {
277  log() << MSG::INFO << "Removed disconnected IO stream:" << pc->fid() << " [" << pc->pfn() << "]"
278  << endmsg;
279  delete pc;
280  }
281  }
282  }
283  }
284  }
285  return S_OK;
286  }
287  m_incidentSvc->fireIncident( Incident( dataset, IncidentType::FailOutputFile ) );
288  return S_FAIL;
289  } catch ( exception& e ) {
290  m_incidentSvc->fireIncident( Incident( dataset, IncidentType::FailOutputFile ) );
291  return error( string( "connectDatabase> Caught exception:" ) + e.what() );
292  } catch ( ... ) {
293  m_incidentSvc->fireIncident( Incident( dataset, IncidentType::FailOutputFile ) );
294  return error( "connectDatabase> Unknown Fatal Exception for " + dataset );
295  }
296 }
Gaudi::Property< std::string > m_recordName
Definition: RootCnvSvc.h:69
IoType
I/O Connection types.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
Definition: RootCnvSvc.h:86
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
IAddressCreator implementation: Address creation.
Definition: RootCnvSvc.cpp:357
std::shared_ptr< RootConnectionSetup > m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:94
virtual Connection * connection(const std::string &dsn) const =0
Retrieve known connection.
constexpr double pc
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
virtual StatusCode disconnect(IDataConnection *con)=0
Release data stream.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
T what(T... args)
Gaudi::Property< std::string > m_ioPerfStats
Definition: RootCnvSvc.h:64
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
#define S_OK
Definition: RootCnvSvc.cpp:47
virtual Connections connections(const IInterface *owner) const =0
Get connection by owner instance (0=ALL)
virtual StatusCode connectRead(bool keep_open, IDataConnection *con)=0
Open data stream in read mode.
bool isSuccess() const
Definition: StatusCode.h:361
STL class.
ABC describing basic data connection.
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:84
Base class for all Incidents (computing events).
Definition: Incident.h:27
constexpr static const auto FAILURE
Definition: StatusCode.h:97
Opaque address interface definition.
#define S_FAIL
Definition: RootCnvSvc.cpp:48
Concrete implementation of the IDataConnection interface to access ROOT files.
virtual StatusCode connectWrite(IDataConnection *con, IoType mode=Connection::CREATE, const std::string &doctype="UNKNOWN")=0
Open data stream in write mode.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::Property< bool > m_incidentEnabled
Definition: RootCnvSvc.h:68

◆ connectOutput() [1/2]

StatusCode Gaudi::RootCnvSvc::connectOutput ( const std::string outputFile,
const std::string openMode 
)
override

Connect the output file to the service with open mode.

Parameters
outputFileString containig output file
openModeString containig opening mode of the output file
Returns
Status code indicating success or failure.

◆ connectOutput() [2/2]

StatusCode Gaudi::RootCnvSvc::connectOutput ( const std::string outputFile)
override

Connect the output file to the service.

Parameters
outputFileString containig output file
Returns
Status code indicating success or failure.

◆ createAddress() [1/2]

StatusCode RootCnvSvc::createAddress ( long  svc_type,
const CLID clid,
const std::string par,
const unsigned long *  ip,
IOpaqueAddress *&  refpAddress 
)
override

IAddressCreator implementation: Address creation.

Create an address using the link infotmation together with the triple (database name/container name/object name).

Parameters
refLinkReference to abstract link information
dbNameDatabase name
containerNameObject container name
refpAddressOpaque address information to retrieve object
Returns
StatusCode indicating SUCCESS or failure

Definition at line 357 of file RootCnvSvc.cpp.

358  {
359  refpAddress = new RootAddress( typ, clid, par[0], par[1], ip[0], ip[1] );
360  return S_OK;
361 }
Description:
Definition: RootAddress.h:46
#define S_OK
Definition: RootCnvSvc.cpp:47

◆ createAddress() [2/2]

StatusCode Gaudi::RootCnvSvc::createAddress ( long  svc_type,
const CLID clid,
const std::string refAddress,
IOpaqueAddress *&  refpAddress 
)
inlineoverride

IAddressCreator implementation: Creates an address in string form to object form.

Parameters
svc_typeTechnology identifier encapsulated in this address.
clidClass identifier of the DataObject represented by the opaque address
addressInput address.
refpAddressOutput address in string form.
Returns
Status code indicating success or failure.

Definition at line 200 of file RootCnvSvc.h.

201  {
202  return this->ConversionSvc::createAddress( svc_type, clid, refAddress, refpAddress );
203  }
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.

◆ createConverter()

IConverter * RootCnvSvc::createConverter ( long  typ,
const CLID wanted,
const ICnvFactory *  fac 
)
overridevirtual

ConversionSvc overload: Create new Converter using factory.

Reimplemented from ConversionSvc.

Definition at line 140 of file RootCnvSvc.cpp.

140  {
141  if ( wanted == CLID_StatisticsFile )
142  return new RootDatabaseCnv( typ, wanted, serviceLocator().get(), this );
143  else if ( wanted == CLID_StatisticsDirectory )
144  return new RootDirectoryCnv( typ, wanted, serviceLocator().get(), this );
145  else if ( wanted == CLID_RowWiseTuple )
146  return new RootNTupleCnv( typ, wanted, serviceLocator().get(), this );
147  else if ( wanted == CLID_ColumnWiseTuple )
148  return new RootNTupleCnv( typ, wanted, serviceLocator().get(), this );
149  else
150  return new RootConverter( typ, wanted, serviceLocator().get(), this );
151 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Statistics file converter class definition.
NTuple converter class definition for NTuples writted/read using ROOT.
Definition: RootNTupleCnv.h:45
Description: NTuple directory converter class definition Definition of the converter to manage the di...
Description: Definition of the ROOT data converter.
Definition: RootConverter.h:42

◆ createNullRef()

StatusCode RootCnvSvc::createNullRef ( const std::string path)
virtual

Insert null marker for not existent transient object.

Parameters
path[IN] Path to the (null-)object
Returns
Status code indicating success or failure.

Definition at line 372 of file RootCnvSvc.cpp.

372  {
373  RootObjectRefs* refs = nullptr;
374  size_t len = path.find( '/', 1 );
375  string section = path.substr( 1, len == string::npos ? string::npos : len - 1 );
376  pair<int, unsigned long> ret = m_current->save( section, path + "#R", nullptr, refs, m_bufferSize, m_splitLevel );
377  if ( log().level() <= MSG::VERBOSE )
378  log() << MSG::VERBOSE << "Writing object:" << path << " " << ret.first << " " << hex << ret.second << dec
379  << " [NULL]" << endmsg;
380  return S_OK;
381 }
std::pair< int, unsigned long > save(std::string_view section, std::string_view cnt, TClass *cl, void *pObj, int buff_siz, int split_lvl, bool fill_missing=false)
Save object of a given class to section and container.
MsgStream & dec(MsgStream &log)
Definition: MsgStream.h:277
MsgStream & hex(MsgStream &log)
Definition: MsgStream.h:281
Gaudi::Property< int > m_splitLevel
Definition: RootCnvSvc.h:79
Gaudi::Property< int > m_bufferSize
Definition: RootCnvSvc.h:77
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject.
Definition: extractEvt.C:81
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
#define S_OK
Definition: RootCnvSvc.cpp:47
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::RootDataConnection * m_current
On writing: reference to active output stream.
Definition: RootCnvSvc.h:88

◆ createNullRep()

StatusCode RootCnvSvc::createNullRep ( const std::string path)
virtual

Insert null marker for not existent transient object.

Parameters
path[IN] Path to the (null-)object
Returns
Status code indicating success or failure.

Definition at line 364 of file RootCnvSvc.cpp.

364  {
365  size_t len = path.find( '/', 1 );
366  string section = path.substr( 1, len == string::npos ? string::npos : len - 1 );
367  m_current->saveObj( section, path, nullptr, nullptr, m_bufferSize, m_splitLevel );
368  return S_OK;
369 }
std::pair< int, unsigned long > saveObj(std::string_view section, std::string_view cnt, TClass *cl, DataObject *pObj, int buff_siz, int split_lvl, bool fill_missing=false)
Save object of a given class to section and container.
Gaudi::Property< int > m_splitLevel
Definition: RootCnvSvc.h:79
Gaudi::Property< int > m_bufferSize
Definition: RootCnvSvc.h:77
#define S_OK
Definition: RootCnvSvc.cpp:47
Gaudi::RootDataConnection * m_current
On writing: reference to active output stream.
Definition: RootCnvSvc.h:88

◆ disconnect()

StatusCode RootCnvSvc::disconnect ( const std::string dbName)
virtual

Disconnect from an existing data stream.

Parameters
dbNameString containing name of the database
Returns
Status code indicating success or failure.

Definition at line 351 of file RootCnvSvc.cpp.

351  {
352  IDataConnection* c = m_ioMgr->connection( dataset );
353  return c ? m_ioMgr->disconnect( c ) : S_FAIL;
354 }
virtual Connection * connection(const std::string &dsn) const =0
Retrieve known connection.
virtual StatusCode disconnect(IDataConnection *con)=0
Release data stream.
ABC describing basic data connection.
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:84
#define S_FAIL
Definition: RootCnvSvc.cpp:48

◆ error()

StatusCode RootCnvSvc::error ( const std::string msg)

Standard way to print errors.

after the printout an exception is thrown.

Parameters
msg[IN] Message string to be printed.
Returns
Status code returning failure.

Definition at line 73 of file RootCnvSvc.cpp.

73  {
74  if ( m_log ) {
75  log() << MSG::ERROR << "Error: " << msg << endmsg;
76  return S_FAIL;
77  }
78  MsgStream m( msgSvc(), name() );
79  m << MSG::ERROR << "Error: " << msg << endmsg;
80  return S_FAIL;
81 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
std::unique_ptr< MsgStream > m_log
Message streamer.
Definition: RootCnvSvc.h:102
constexpr double m
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
#define S_FAIL
Definition: RootCnvSvc.cpp:48
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ finalize()

StatusCode RootCnvSvc::finalize ( )
override

ConversionSvc overload: Finalize Db service.

Definition at line 112 of file RootCnvSvc.cpp.

112  {
113  log() << MSG::INFO;
114  if ( m_ioMgr ) {
116  for ( auto& i : cons ) {
117  auto pc = dynamic_cast<RootDataConnection*>( i );
118  if ( pc ) {
119  if ( pc->owner() == this && !m_ioPerfStats.empty() ) { pc->saveStatistics( m_ioPerfStats.value() ); }
120  if ( pc->lookupClient( this ) ) {
121  size_t num_clients = pc->removeClient( this );
122  if ( num_clients == 0 ) {
123  if ( m_ioMgr->disconnect( pc ).isSuccess() ) {
124  log() << "Disconnected data IO:" << pc->fid() << " [" << pc->pfn() << "]" << endmsg;
125  delete pc;
126  }
127  }
128  }
129  }
130  }
131  m_ioMgr.reset();
132  }
133  m_log.reset();
135  m_setup->setIncidentSvc( nullptr );
136  return ConversionSvc::finalize();
137 }
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
Definition: RootCnvSvc.h:86
std::shared_ptr< RootConnectionSetup > m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:94
constexpr double pc
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
virtual StatusCode disconnect(IDataConnection *con)=0
Release data stream.
Gaudi::Property< std::string > m_ioPerfStats
Definition: RootCnvSvc.h:64
std::unique_ptr< MsgStream > m_log
Message streamer.
Definition: RootCnvSvc.h:102
virtual Connections connections(const IInterface *owner) const =0
Get connection by owner instance (0=ALL)
T reset(T... args)
bool isSuccess() const
Definition: StatusCode.h:361
STL class.
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:84
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
StatusCode finalize() override
stop the service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ getClass()

TClass * RootCnvSvc::getClass ( DataObject pObject)
protected

Helper: Get TClass for a given DataObject pointer.

Definition at line 171 of file RootCnvSvc.cpp.

171  {
172  auto i = s_classesClids.find( pObject->clID() );
173  if ( i != s_classesClids.end() ) return i->second;
174  loadConverter( pObject );
175  i = s_classesClids.find( pObject->clID() );
176  if ( i != s_classesClids.end() ) return i->second;
177 
178  string cname = System::typeinfoName( typeid( *pObject ) );
179  throw runtime_error( "Unknown ROOT class for object:" + cname );
180  return nullptr;
181 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:308
void loadConverter(DataObject *pObj) override
ConversionSvc overload: Load the class (dictionary) for the converter.
Definition: RootCnvSvc.cpp:154
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:66

◆ i__createObj()

StatusCode RootCnvSvc::i__createObj ( IOpaqueAddress pAddr,
DataObject *&  refpObj 
)
virtual

Create transient object from persistent data.

Parameters
pAddr[IN] Pointer to object address.
refpObj[OUT] Location to pointer to store data object
Returns
Status code indicating success or failure.

Definition at line 445 of file RootCnvSvc.cpp.

445  {
446  refpObj = nullptr;
447  if ( !pA ) return S_FAIL;
448  RootDataConnection* con = nullptr;
449  const string* par = pA->par();
450  unsigned long* ipar = const_cast<unsigned long*>( pA->ipar() );
452  if ( sc.isSuccess() ) {
453  ipar[0] = (unsigned long)con;
454  DataObject* pObj = nullptr;
455  size_t len = par[1].find( '/', 1 );
456  string section = par[1].substr( 1, len == string::npos ? string::npos : len - 1 );
457 
458  int nb = con->loadObj( section, par[1], ipar[1], pObj );
459  if ( nb > 1 || ( nb == 1 && pObj->clID() == CLID_DataObject ) ) {
460  refpObj = pObj;
461  return S_OK;
462  }
463  delete pObj;
464  }
465  string tag = par[0] + ":" + par[1];
466  if ( m_badFiles.find( tag ) == m_badFiles.end() ) {
467  m_badFiles.insert( tag );
468  return error( "createObj> Cannot access the object:" + tag );
469  }
470  return S_FAIL;
471 }
T end(T... args)
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:204
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
#define S_OK
Definition: RootCnvSvc.cpp:47
int loadObj(std::string_view section, std::string_view cnt, unsigned long entry, DataObject *&pObj)
Load object.
T insert(T... args)
std::set< std::string > m_badFiles
Set with bad files/tables.
Definition: RootCnvSvc.h:99
T find(T... args)
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:66
#define S_FAIL
Definition: RootCnvSvc.cpp:48
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
Concrete implementation of the IDataConnection interface to access ROOT files.

◆ i__createRep()

StatusCode RootCnvSvc::i__createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
)
virtual

Convert the transient object to the requested persistent representation.

Parameters
pObj[IN] Pointer to data object
refpAddr[OUT] Location to store pointer to object address.
Returns
Status code indicating success or failure.

Definition at line 384 of file RootCnvSvc.cpp.

384  {
385  refpAddr = nullptr;
386  if ( !pObj ) return error( "createRep> Current Database is invalid!" );
387  CLID clid = pObj->clID();
388  IRegistry* pR = pObj->registry();
389  string p[2] = {m_current->fid(), pR->identifier()};
390  TClass* cl = ( clid == CLID_DataObject ) ? m_classDO : getClass( pObj );
391  size_t len = p[1].find( '/', 1 );
392  string sect = p[1].substr( 1, len == string::npos ? string::npos : len - 1 );
393  pair<int, unsigned long> ret = m_current->saveObj( sect, p[1], cl, pObj, m_bufferSize, m_splitLevel, true );
394  if ( ret.first > 1 || ( clid == CLID_DataObject && ret.first == 1 ) ) {
395  unsigned long ip[2] = {0, ret.second};
396  if ( m_currSection.empty() ) m_currSection = p[1];
397  return createAddress( repSvcType(), clid, p, ip, refpAddr );
398  }
399  return error( "Failed to write object data for:" + p[1] );
400 }
T empty(T... args)
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
std::string m_currSection
Property: ROOT section name.
Definition: RootCnvSvc.h:96
std::pair< int, unsigned long > saveObj(std::string_view section, std::string_view cnt, TClass *cl, DataObject *pObj, int buff_siz, int split_lvl, bool fill_missing=false)
Save object of a given class to section and container.
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
IAddressCreator implementation: Address creation.
Definition: RootCnvSvc.cpp:357
const std::string & fid() const
Access file id.
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
Gaudi::Property< int > m_splitLevel
Definition: RootCnvSvc.h:79
Gaudi::Property< int > m_bufferSize
Definition: RootCnvSvc.h:77
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
TClass * m_classDO
TClass pointer to DataObject class.
Definition: RootCnvSvc.h:92
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
T find(T... args)
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:66
T substr(T... args)
virtual const id_type & identifier() const =0
Full identifier (or key)
Gaudi::RootDataConnection * m_current
On writing: reference to active output stream.
Definition: RootCnvSvc.h:88
TClass * getClass(DataObject *pObject)
Helper: Get TClass for a given DataObject pointer.
Definition: RootCnvSvc.cpp:171

◆ i__fillObjRefs()

StatusCode RootCnvSvc::i__fillObjRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
virtual

Resolve the references of the created transient object.

Parameters
pAddr[IN] Pointer to object address.
pObj[IN] Pointer to data object
Returns
Status code indicating success or failure.

Definition at line 474 of file RootCnvSvc.cpp.

474  {
475  if ( !pA || !pObj ) return error( "read> Cannot read object -- no valid object address present " );
476 
477  const unsigned long* ipar = pA->ipar();
478  RootDataConnection* con = (RootDataConnection*)ipar[0];
479  if ( con ) {
480  RootObjectRefs refs;
481  const string* par = pA->par();
482  size_t len = par[1].find( '/', 1 );
483  string section = par[1].substr( 1, len == string::npos ? string::npos : len - 1 );
484  int nb = con->loadRefs( section, par[1], ipar[1], refs );
485  if ( nb >= 1 ) {
486  string npar[3];
487  unsigned long nipar[2];
488  IRegistry* pR = pObj->registry();
489  auto dataMgr = SmartIF<IDataManagerSvc>{pR->dataSvc()};
490  LinkManager* mgr = pObj->linkMgr();
491  for ( const auto& i : refs.links ) mgr->addLink( con->getLink( i ), nullptr );
492  for ( auto& r : refs.refs ) {
493  npar[0] = con->getDb( r.dbase );
494  npar[1] = con->getCont( r.container );
495  npar[2] = con->getLink( r.link );
496  nipar[0] = 0;
497  nipar[1] = r.entry;
498  IOpaqueAddress* nPA = nullptr;
499  StatusCode sc = addressCreator()->createAddress( r.svc, r.clid, npar, nipar, nPA );
500  if ( sc.isSuccess() ) {
501  if ( log().level() <= MSG::VERBOSE )
502  log() << MSG::VERBOSE << dataMgr.as<IService>()->name() << " -> Register:" << pA->registry()->identifier()
503  << "#" << npar[2] << "[" << r.entry << "]" << endmsg;
504  sc = dataMgr->registerAddress( pA->registry(), npar[2], nPA );
505  if ( sc.isSuccess() ) continue;
506  }
507  log() << MSG::ERROR << con->fid() << ": Failed to create address!!!!" << endmsg;
508  return S_FAIL;
509  }
510  return pObj->update();
511  } else if ( nb < 0 ) {
512  string tag = par[0] + ":" + par[1];
513  if ( m_badFiles.find( tag ) == m_badFiles.end() ) {
514  m_badFiles.insert( tag );
515  return error( "createObj> Cannot access the object:" + tag + " [Corrupted file]" );
516  }
517  }
518  }
519  return S_FAIL;
520 }
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:75
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ipar, IOpaqueAddress *&refpAddress)=0
Create a Generic address using explicit arguments to identify a single object.
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:84
int loadRefs(std::string_view section, std::string_view cnt, unsigned long entry, RootObjectRefs &refs)
Load references object.
const std::string & fid() const
Access file id.
T end(T... args)
const std::string & getDb(int which) const
Access database/file name from saved index.
std::vector< int > links
The links of the link manager.
Definition: extractEvt.C:83
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject.
Definition: extractEvt.C:81
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
const std::string & getCont(int which) const
Access container name from saved index.
General service interface definition.
Definition: IService.h:28
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
const std::string & getLink(int which) const
Access link name from saved index.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
bool isSuccess() const
Definition: StatusCode.h:361
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
T insert(T... args)
std::set< std::string > m_badFiles
Set with bad files/tables.
Definition: RootCnvSvc.h:99
T find(T... args)
MSG::Level level() const
Retrieve output level.
Definition: MsgStream.h:113
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
Opaque address interface definition.
#define S_FAIL
Definition: RootCnvSvc.cpp:48
Concrete implementation of the IDataConnection interface to access ROOT files.
std::vector< RootRef > refs
The references corresponding to the next layer of items in the data store.
Definition: extractEvt.C:85
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ i__fillRepRefs()

StatusCode RootCnvSvc::i__fillRepRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
virtual

Resolve the references of the converted object.

Parameters
pAddr[IN] Pointer to object address.
pObj[IN] Pointer to data object
Returns
Status code indicating success or failure.

Definition at line 403 of file RootCnvSvc.cpp.

403  {
404  if ( pObj ) {
405  typedef vector<IRegistry*> Leaves;
406  Leaves leaves;
407  RootObjectRefs refs;
408  IRegistry* pR = pObj->registry();
409  auto dataMgr = SmartIF<IDataManagerSvc>{pR->dataSvc()};
410  if ( dataMgr ) {
411  StatusCode status = dataMgr->objectLeaves( pObj, leaves );
412  if ( status.isSuccess() ) {
413  RootRef ref;
414  const string& id = pR->identifier();
415  size_t len = id.find( '/', 1 );
416  string sect = id.substr( 1, len == string::npos ? string::npos : len - 1 );
417  LinkManager* pLinks = pObj->linkMgr();
418  for ( auto& i : leaves ) {
419  if ( i->address() ) {
420  m_current->makeRef( *i, ref );
421  ref.entry = i->address()->ipar()[1];
422  refs.refs.push_back( ref );
423  }
424  }
425  for ( int i = 0, n = pLinks->size(); i < n; ++i ) {
426  LinkManager::Link* lnk = pLinks->link( i );
427  int link_id = m_current->makeLink( lnk->path() );
428  refs.links.push_back( link_id );
429  }
431  m_current->save( sect, id + "#R", m_classRefs, &refs, m_bufferSize, m_splitLevel, true );
432  if ( ret.first > 1 ) {
433  if ( log().level() <= MSG::DEBUG )
434  log() << MSG::DEBUG << "Writing object:" << id << " " << ret.first << " " << hex << ret.second << dec
435  << endmsg;
436  return S_OK;
437  }
438  }
439  }
440  }
441  return S_FAIL;
442 }
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
std::pair< int, unsigned long > save(std::string_view section, std::string_view cnt, TClass *cl, void *pObj, int buff_siz, int split_lvl, bool fill_missing=false)
Save object of a given class to section and container.
int makeLink(std::string_view p)
Convert path string to path index.
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:84
MsgStream & dec(MsgStream &log)
Definition: MsgStream.h:277
MsgStream & hex(MsgStream &log)
Definition: MsgStream.h:281
Gaudi::Property< int > m_splitLevel
Definition: RootCnvSvc.h:79
Gaudi::Property< int > m_bufferSize
Definition: RootCnvSvc.h:77
std::vector< int > links
The links of the link manager.
Definition: extractEvt.C:83
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject.
Definition: extractEvt.C:81
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
Persistent reference object.
Definition: extractEvt.C:44
T push_back(T... args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
#define S_OK
Definition: RootCnvSvc.cpp:47
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
bool isSuccess() const
Definition: StatusCode.h:361
T find(T... args)
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
void makeRef(const IRegistry &pA, RootRef &ref)
Create reference object from registry entry.
virtual const id_type & identifier() const =0
Full identifier (or key)
#define S_FAIL
Definition: RootCnvSvc.cpp:48
std::vector< RootRef > refs
The references corresponding to the next layer of items in the data store.
Definition: extractEvt.C:85
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::RootDataConnection * m_current
On writing: reference to active output stream.
Definition: RootCnvSvc.h:88
TClass * m_classRefs
TClass pointer to reference class.
Definition: RootCnvSvc.h:90

◆ initialize()

StatusCode RootCnvSvc::initialize ( )
override

ConversionSvc overload: initialize Db service.

Definition at line 84 of file RootCnvSvc.cpp.

84  {
85  string cname;
87  if ( !status.isSuccess() ) { return error( "Failed to initialize ConversionSvc base class." ); }
88  m_log.reset( new MsgStream( msgSvc(), name() ) );
89  if ( !m_compression.empty() ) {
90  log() << MSG::INFO << "Setting global ROOT compression to:" << m_compression.value() << endmsg;
91  if ( !( status = RootConnectionSetup::setCompression( m_compression.value() ) ).isSuccess() ) {
92  return error( "Unable to interprete ROOT compression encoding:" + m_compression );
93  }
94  }
95  m_ioMgr = service( "IODataManager" );
96  if ( !m_ioMgr ) return error( "Unable to localize interface from service:IODataManager" );
97  m_incidentSvc = service( "IncidentSvc" );
98  if ( !m_incidentSvc ) return error( "Unable to localize interface from service:IncidentSvc" );
99  m_setup->setMessageSvc( new MsgStream( msgSvc(), name() ) );
100  m_setup->setIncidentSvc( m_incidentSvc.get() );
102  cname = System::typeinfoName( typeid( DataObject ) );
103  m_classDO = TClass::GetClass( cname.c_str() );
104  if ( !m_classDO ) return error( "Unable to load class description for DataObject" );
105  cname = System::typeinfoName( typeid( RootObjectRefs ) );
106  m_classRefs = TClass::GetClass( cname.c_str() );
107  if ( !m_classRefs ) return error( "Unable to load class description for ObjectRefs" );
108  return S_OK;
109 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
Definition: RootCnvSvc.h:86
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:308
std::shared_ptr< RootConnectionSetup > m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:94
Gaudi::Property< std::string > m_compression
Definition: RootCnvSvc.h:80
bool patchStreamers(MsgStream &log)
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject.
Definition: extractEvt.C:81
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
static StatusCode setCompression(std::string_view compression)
Set the global compression level.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
std::unique_ptr< MsgStream > m_log
Message streamer.
Definition: RootCnvSvc.h:102
#define S_OK
Definition: RootCnvSvc.cpp:47
TClass * m_classDO
TClass pointer to DataObject class.
Definition: RootCnvSvc.h:92
T reset(T... args)
bool isSuccess() const
Definition: StatusCode.h:361
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:84
T c_str(T... args)
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.
Definition: Service.h:93
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
StatusCode initialize() override
Initialize the service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
TClass * m_classRefs
TClass pointer to reference class.
Definition: RootCnvSvc.h:90

◆ loadConverter()

void RootCnvSvc::loadConverter ( DataObject pObj)
overridevirtual

ConversionSvc overload: Load the class (dictionary) for the converter.

Reimplemented from ConversionSvc.

Definition at line 154 of file RootCnvSvc.cpp.

154  {
155  if ( pObject ) {
156  string cname = System::typeinfoName( typeid( *pObject ) );
157  if ( log().level() <= MSG::DEBUG )
158  log() << MSG::DEBUG << "Trying to 'Autoload' dictionary for class " << cname << endmsg;
159  TClass* cl = s_classesNames[cname];
160  if ( nullptr == cl ) {
161  cl = TClass::GetClass( cname.c_str() );
162  if ( cl ) {
163  s_classesNames[cname] = cl;
164  s_classesClids[pObject->clID()] = cl;
165  }
166  }
167  }
168 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:308
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
T c_str(T... args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ log()

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

Helper: Use message streamer.

Definition at line 107 of file RootCnvSvc.h.

107 { return *m_log; }
std::unique_ptr< MsgStream > m_log
Message streamer.
Definition: RootCnvSvc.h:102

◆ updateServiceState()

StatusCode Gaudi::RootCnvSvc::updateServiceState ( IOpaqueAddress )
inlineoverridevirtual

Update state of the service.

Reimplemented from ConversionSvc.

Definition at line 114 of file RootCnvSvc.h.

114 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

Member Data Documentation

◆ m_autoFlush

Gaudi::Property<int> Gaudi::RootCnvSvc::m_autoFlush
protected
Initial value:
{this, "AutoFlush", 100,
"AutoFlush parameter for ROOT TTree (Number of events between auto flushes)"}

Definition at line 73 of file RootCnvSvc.h.

◆ m_badFiles

std::set<std::string> Gaudi::RootCnvSvc::m_badFiles
protected

Set with bad files/tables.

Definition at line 99 of file RootCnvSvc.h.

◆ m_basketSize

Gaudi::Property<int> Gaudi::RootCnvSvc::m_basketSize
protected
Initial value:
{this, "BasketSize", 2 * 1024 * 1024 ,
"Basket optimization parameter for ROOT TTree (total basket size)"}

Definition at line 75 of file RootCnvSvc.h.

◆ m_bufferSize

Gaudi::Property<int> Gaudi::RootCnvSvc::m_bufferSize
protected
Initial value:
{this, "BufferSize", 2 * 1024 ,
"Buffer size optimization parameter for ROOT TTree"}

Definition at line 77 of file RootCnvSvc.h.

◆ m_classDO

TClass* Gaudi::RootCnvSvc::m_classDO = nullptr
protected

TClass pointer to DataObject class.

Definition at line 92 of file RootCnvSvc.h.

◆ m_classRefs

TClass* Gaudi::RootCnvSvc::m_classRefs = nullptr
protected

TClass pointer to reference class.

Definition at line 90 of file RootCnvSvc.h.

◆ m_compression

Gaudi::Property<std::string> Gaudi::RootCnvSvc::m_compression
protected
Initial value:
{this, "GlobalCompression", "",
"Compression-algorithm:compression-level, empty: do nothing"}

Definition at line 80 of file RootCnvSvc.h.

◆ m_current

Gaudi::RootDataConnection* Gaudi::RootCnvSvc::m_current = nullptr
protected

On writing: reference to active output stream.

Definition at line 88 of file RootCnvSvc.h.

◆ m_currSection

std::string Gaudi::RootCnvSvc::m_currSection
protected

Property: ROOT section name.

Definition at line 96 of file RootCnvSvc.h.

◆ m_incidentEnabled

Gaudi::Property<bool> Gaudi::RootCnvSvc::m_incidentEnabled {this, "EnableIncident", true, "Flag to enable incidents on FILE_OPEN"}
protected

Definition at line 68 of file RootCnvSvc.h.

◆ m_incidentSvc

SmartIF<IIncidentSvc> Gaudi::RootCnvSvc::m_incidentSvc
protected

Reference to incident service.

Definition at line 86 of file RootCnvSvc.h.

◆ m_ioMgr

SmartIF<Gaudi::IIODataManager> Gaudi::RootCnvSvc::m_ioMgr
protected

Reference to the I/O data manager.

Definition at line 84 of file RootCnvSvc.h.

◆ m_ioPerfStats

Gaudi::Property<std::string> Gaudi::RootCnvSvc::m_ioPerfStats
protected
Initial value:
{this, "IOPerfStats", "",
"Enable TTree IOperfStats if not empty; otherwise perf stat file name"}

Definition at line 64 of file RootCnvSvc.h.

◆ m_log

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

Message streamer.

Definition at line 102 of file RootCnvSvc.h.

◆ m_recordName

Gaudi::Property<std::string> Gaudi::RootCnvSvc::m_recordName
protected
Initial value:
{this, "RecordsName", "/FileRecords",
"Records name to fire incident for file records"}

Definition at line 69 of file RootCnvSvc.h.

◆ m_setup

std::shared_ptr<RootConnectionSetup> Gaudi::RootCnvSvc::m_setup
protected

Setup structure (ref-counted) and passed to data connections.

Definition at line 94 of file RootCnvSvc.h.

◆ m_shareFiles

Gaudi::Property<std::string> Gaudi::RootCnvSvc::m_shareFiles
protected
Initial value:
{this, "ShareFiles", "NO",
"Share files? If set to YES, files will not be closed on finalize"}

Definition at line 66 of file RootCnvSvc.h.

◆ m_splitLevel

Gaudi::Property<int> Gaudi::RootCnvSvc::m_splitLevel {this, "SplitLevel", 0, "Split level optimization parameter for ROOT TTree"}
protected

Definition at line 79 of file RootCnvSvc.h.


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