The Gaudi Framework  v33r1 (b1225454)
RootCnvSvc.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 //====================================================================
12 // RootCnvSvc implementation
13 //--------------------------------------------------------------------
14 //
15 // Description: Implementation of the ROOT data storage
16 //
17 // Author : M.Frank
18 //
19 //====================================================================
20 
21 // Framework include files
22 #include "RootCnv/RootCnvSvc.h"
27 #include "GaudiKernel/IRegistry.h"
29 #include "GaudiKernel/Incident.h"
32 #include "GaudiKernel/MsgStream.h"
33 #include "GaudiKernel/System.h"
34 #include "RootCnv/RootAddress.h"
35 #include "RootCnv/RootConverter.h"
39 #include "RootCnv/RootNTupleCnv.h"
40 #include "RootCnv/RootRefs.h"
41 #include "RootUtils.h"
42 
43 using namespace std;
44 using namespace Gaudi;
45 typedef const string& CSTR;
46 
47 #define S_OK StatusCode::SUCCESS
48 #define S_FAIL StatusCode::FAILURE
49 namespace GaudiRoot {
50  bool patchStreamers( MsgStream& log );
51 }
52 
53 namespace {
54  static map<string, TClass*> s_classesNames;
55  static map<CLID, TClass*> s_classesClids;
56 } // namespace
57 #define MBYTE ( 1024 * 1024 )
58 #define kBYTE 1024
59 // Standard constructor
60 RootCnvSvc::RootCnvSvc( CSTR nam, ISvcLocator* svc )
61  : ConversionSvc( nam, svc, ROOT_StorageType ), m_setup{new RootConnectionSetup()} {
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 }
71 
72 // Small routine to issue exceptions
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 }
82 
83 // Initialize the Db data persistency service
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 }
110 
111 // Finalize the Db data persistency service
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 }
138 
139 // ConversionSvc overload: Create new Converter using factory
140 IConverter* RootCnvSvc::createConverter( long typ, const CLID& wanted, const ICnvFactory* ) {
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 }
152 
153 // ConversionSvc overload: Load the class (dictionary) for the converter
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 }
169 
170 // Helper: Get TClass for a given DataObject pointer
171 TClass* RootCnvSvc::getClass( DataObject* pObject ) {
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 }
182 
183 // Connect the output file to the service with open mode.
185  StatusCode sc = S_FAIL;
186  m_current = nullptr;
188  if ( ::strncasecmp( openMode.c_str(), "RECREATE", 3 ) == 0 )
190  else if ( ::strncasecmp( openMode.c_str(), "NEW", 1 ) == 0 )
192  else if ( ::strncasecmp( openMode.c_str(), "CREATE", 1 ) == 0 )
194  else if ( ::strncasecmp( openMode.c_str(), "UPDATE", 1 ) == 0 )
196  if ( sc.isSuccess() && m_current && m_current->isConnected() ) { return S_OK; }
197  m_incidentSvc->fireIncident( Incident( dsn, IncidentType::FailOutputFile ) );
198  log() << MSG::ERROR << "The dataset " << dsn << " cannot be opened in mode " << openMode << ". [Invalid mode]"
199  << endmsg;
200  return sc;
201 }
202 
203 // Connect the output file to the service with open mode.
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() )
236  if ( auto sc = pc->connectRead(); !sc ) return sc;
237  *con = pc;
238  pc->resetAge();
239  pc->addClient( this );
240  }
241  if ( *con ) {
242  if ( fire_incident ) {
243  IOpaqueAddress* pAddr = nullptr;
244  string fid = pc->fid();
245  string section = m_recordName[0] == '/' ? m_recordName.value().substr( 1 ) : m_recordName.value();
246  TBranch* b = pc->getBranch( section, m_recordName.value() );
247  if ( b ) {
248  const string par[2] = {fid, m_recordName};
249  unsigned long ipar[2] = {(unsigned long)( *con ), (unsigned long)b->GetEntries() - 1};
250  for ( int i = 0; i < b->GetEntries(); ++i ) {
251  ipar[1] = i;
252  if ( !pc->mergeFIDs().empty() ) fid = pc->mergeFIDs()[i];
253  if ( !createAddress( repSvcType(), CLID_DataObject, par, ipar, pAddr ).isSuccess() ) {
254  if ( log().level() <= MSG::VERBOSE )
255  log() << MSG::VERBOSE << "Failed to create address for " << m_recordName << " in:" << fid << " ["
256  << pc->fid() << "][" << i << "]" << endmsg;
257  continue;
258  }
259  if ( log().level() <= MSG::VERBOSE )
260  log() << MSG::VERBOSE << "Prepare " << m_recordName << " " << fid << " [" << par[0] << "][" << i << "]"
261  << endmsg;
262  m_incidentSvc->fireIncident( ContextIncident<IOpaqueAddress*>( fid, "FILE_OPEN_READ", pAddr ) );
263  }
264  } else {
265  if ( log().level() <= MSG::VERBOSE )
266  log() << MSG::VERBOSE << "No valid Records " << m_recordName << " present in:" << pc->fid() << endmsg;
267  }
268  }
269 
270  // We can remove retired connections, which are no longer used....
271  for ( auto& i : m_ioMgr->connections( this ) ) {
272  if ( i != *con && !i->isConnected() ) {
273  RootDataConnection* pc = dynamic_cast<RootDataConnection*>( i );
274  if ( pc && pc->lookupClient( this ) ) {
275  size_t num_client = pc->removeClient( this );
276  if ( num_client == 0 ) {
277  if ( m_ioMgr->disconnect( pc ).isSuccess() ) {
278  log() << MSG::INFO << "Removed disconnected IO stream:" << pc->fid() << " [" << pc->pfn() << "]"
279  << endmsg;
280  delete pc;
281  }
282  }
283  }
284  }
285  }
286  return S_OK;
287  }
288  m_incidentSvc->fireIncident( Incident( dataset, IncidentType::FailOutputFile ) );
289  return S_FAIL;
290  } catch ( exception& e ) {
291  m_incidentSvc->fireIncident( Incident( dataset, IncidentType::FailOutputFile ) );
292  return error( string( "connectDatabase> Caught exception:" ) + e.what() );
293  } catch ( ... ) {
294  m_incidentSvc->fireIncident( Incident( dataset, IncidentType::FailOutputFile ) );
295  return error( "connectDatabase> Unknown Fatal Exception for " + dataset );
296  }
297 }
298 
299 // Conect output stream (valid until overwritten)
300 StatusCode RootCnvSvc::connectOutput( CSTR db_name ) { return connectOutput( db_name, "NEW" ); }
301 
302 // Commit pending output on open container
303 StatusCode RootCnvSvc::commitOutput( CSTR dsn, bool /* doCommit */ ) {
304  if ( m_current ) {
305  size_t len = m_currSection.find( '/', 1 );
306  string section = m_currSection.substr( 1, len == string::npos ? string::npos : len - 1 );
307  TBranch* b = m_current->getBranch( section, m_currSection );
308  if ( b ) {
309  Long64_t evt = b->GetEntries();
310  TTree* t = b->GetTree();
311  TObjArray* a = t->GetListOfBranches();
312  Int_t nb = a->GetEntriesFast();
314  for ( Int_t i = 0; i < nb; ++i ) {
315  TBranch* br_ptr = (TBranch*)a->UncheckedAt( i );
316  Long64_t br_evt = br_ptr->GetEntries();
317  if ( br_evt < evt ) {
318  Long64_t num = evt - br_evt;
319  br_ptr->SetAddress( nullptr );
320  while ( num > 0 ) {
321  br_ptr->Fill();
322  --num;
323  }
324  if ( log().level() <= MSG::DEBUG )
325  log() << MSG::DEBUG << "commit: Added " << long( evt - br_evt ) << " Section: " << evt
326  << " Branch: " << br_ptr->GetEntries() << " RefNo: " << br_ptr->GetEntries() - 1
327  << " NULL entries to:" << br_ptr->GetName() << endmsg;
328  }
329  }
330 
331  b->GetTree()->SetEntries( evt );
332  if ( evt == 1 ) { b->GetTree()->OptimizeBaskets( m_basketSize, 1.1, "" ); }
333  if ( evt > 0 && ( evt % m_autoFlush ) == 0 ) {
334  if ( evt == m_autoFlush ) {
335  b->GetTree()->SetAutoFlush( m_autoFlush );
336  b->GetTree()->OptimizeBaskets( m_basketSize, 1., "" );
337  } else {
338  b->GetTree()->FlushBaskets();
339  }
340  }
341  if ( log().level() <= MSG::DEBUG )
342  log() << MSG::DEBUG << "Set section entries of " << m_currSection << " to " << long( evt ) << " entries."
343  << endmsg;
344  } else {
345  return error( "commitOutput> Failed to update entry numbers on " + dsn );
346  }
347  }
348  return S_OK;
349 }
350 
351 // Disconnect from an existing data stream.
353  IDataConnection* c = m_ioMgr->connection( dataset );
354  return c ? m_ioMgr->disconnect( c ) : S_FAIL;
355 }
356 
357 // IAddressCreator implementation: Address creation
358 StatusCode RootCnvSvc::createAddress( long typ, const CLID& clid, const string* par, const unsigned long* ip,
359  IOpaqueAddress*& refpAddress ) {
360  refpAddress = new RootAddress( typ, clid, par[0], par[1], ip[0], ip[1] );
361  return S_OK;
362 }
363 
364 // Insert null marker for not existent transient object
366  size_t len = path.find( '/', 1 );
367  string section = path.substr( 1, len == string::npos ? string::npos : len - 1 );
368  m_current->saveObj( section, path, nullptr, nullptr, m_bufferSize, m_splitLevel );
369  return S_OK;
370 }
371 
372 // Insert null marker for not existent transient object
374  RootObjectRefs* refs = nullptr;
375  size_t len = path.find( '/', 1 );
376  string section = path.substr( 1, len == string::npos ? string::npos : len - 1 );
377  pair<int, unsigned long> ret = m_current->save( section, path + "#R", nullptr, refs, m_bufferSize, m_splitLevel );
378  if ( log().level() <= MSG::VERBOSE )
379  log() << MSG::VERBOSE << "Writing object:" << path << " " << ret.first << " " << hex << ret.second << dec
380  << " [NULL]" << endmsg;
381  return S_OK;
382 }
383 
384 // Mark an object for write given an object reference
386  refpAddr = nullptr;
387  if ( !pObj ) return error( "createRep> Current Database is invalid!" );
388  CLID clid = pObj->clID();
389  IRegistry* pR = pObj->registry();
390  string p[2] = {m_current->fid(), pR->identifier()};
391  TClass* cl = ( clid == CLID_DataObject ) ? m_classDO : getClass( pObj );
392  size_t len = p[1].find( '/', 1 );
393  string sect = p[1].substr( 1, len == string::npos ? string::npos : len - 1 );
394  pair<int, unsigned long> ret = m_current->saveObj( sect, p[1], cl, pObj, m_bufferSize, m_splitLevel, true );
395  if ( ret.first > 1 || ( clid == CLID_DataObject && ret.first == 1 ) ) {
396  unsigned long ip[2] = {0, ret.second};
397  if ( m_currSection.empty() ) m_currSection = p[1];
398  return createAddress( repSvcType(), clid, p, ip, refpAddr );
399  }
400  return error( "Failed to write object data for:" + p[1] );
401 }
402 
403 // Save object references to data file
405  if ( pObj ) {
406  typedef vector<IRegistry*> Leaves;
407  Leaves leaves;
408  RootObjectRefs refs;
409  IRegistry* pR = pObj->registry();
410  auto dataMgr = SmartIF<IDataManagerSvc>{pR->dataSvc()};
411  if ( dataMgr ) {
412  StatusCode status = dataMgr->objectLeaves( pObj, leaves );
413  if ( status.isSuccess() ) {
414  RootRef ref;
415  const string& id = pR->identifier();
416  size_t len = id.find( '/', 1 );
417  string sect = id.substr( 1, len == string::npos ? string::npos : len - 1 );
418  LinkManager* pLinks = pObj->linkMgr();
419  for ( auto& i : leaves ) {
420  if ( i->address() ) {
421  m_current->makeRef( *i, ref );
422  ref.entry = i->address()->ipar()[1];
423  refs.refs.push_back( ref );
424  }
425  }
426  for ( int i = 0, n = pLinks->size(); i < n; ++i ) {
427  LinkManager::Link* lnk = pLinks->link( i );
428  int link_id = m_current->makeLink( lnk->path() );
429  refs.links.push_back( link_id );
430  }
432  m_current->save( sect, id + "#R", m_classRefs, &refs, m_bufferSize, m_splitLevel, true );
433  if ( ret.first > 1 ) {
434  if ( log().level() <= MSG::DEBUG )
435  log() << MSG::DEBUG << "Writing object:" << id << " " << ret.first << " " << hex << ret.second << dec
436  << endmsg;
437  return S_OK;
438  }
439  }
440  }
441  }
442  return S_FAIL;
443 }
444 
445 // Read existing object. Open transaction in read mode if not active
447  refpObj = nullptr;
448  if ( !pA ) return S_FAIL;
449  RootDataConnection* con = nullptr;
450  const string* par = pA->par();
451  unsigned long* ipar = const_cast<unsigned long*>( pA->ipar() );
453  if ( sc.isSuccess() ) {
454  ipar[0] = (unsigned long)con;
455  DataObject* pObj = nullptr;
456  size_t len = par[1].find( '/', 1 );
457  string section = par[1].substr( 1, len == string::npos ? string::npos : len - 1 );
458 
459  int nb = con->loadObj( section, par[1], ipar[1], pObj );
460  if ( nb > 1 || ( nb == 1 && pObj->clID() == CLID_DataObject ) ) {
461  refpObj = pObj;
462  return S_OK;
463  }
464  delete pObj;
465  }
466  string tag = par[0] + ":" + par[1];
467  if ( m_badFiles.find( tag ) == m_badFiles.end() ) {
468  m_badFiles.insert( tag );
469  return error( "createObj> Cannot access the object:" + tag );
470  }
471  return S_FAIL;
472 }
473 
474 // Resolve the references of the created transient object.
476  if ( !pA || !pObj ) return error( "read> Cannot read object -- no valid object address present " );
477 
478  const unsigned long* ipar = pA->ipar();
479  RootDataConnection* con = (RootDataConnection*)ipar[0];
480  if ( con ) {
481  RootObjectRefs refs;
482  const string* par = pA->par();
483  size_t len = par[1].find( '/', 1 );
484  string section = par[1].substr( 1, len == string::npos ? string::npos : len - 1 );
485  int nb = con->loadRefs( section, par[1], ipar[1], refs );
486  if ( nb >= 1 ) {
487  string npar[3];
488  unsigned long nipar[2];
489  IRegistry* pR = pObj->registry();
490  auto dataMgr = SmartIF<IDataManagerSvc>{pR->dataSvc()};
491  LinkManager* mgr = pObj->linkMgr();
492  for ( const auto& i : refs.links ) mgr->addLink( con->getLink( i ), nullptr );
493  for ( auto& r : refs.refs ) {
494  npar[0] = con->getDb( r.dbase );
495  npar[1] = con->getCont( r.container );
496  npar[2] = con->getLink( r.link );
497  nipar[0] = 0;
498  nipar[1] = r.entry;
499  IOpaqueAddress* nPA = nullptr;
500  StatusCode sc = addressCreator()->createAddress( r.svc, r.clid, npar, nipar, nPA );
501  if ( sc.isSuccess() ) {
502  if ( log().level() <= MSG::VERBOSE )
503  log() << MSG::VERBOSE << dataMgr.as<IService>()->name() << " -> Register:" << pA->registry()->identifier()
504  << "#" << npar[2] << "[" << r.entry << "]" << endmsg;
505  sc = dataMgr->registerAddress( pA->registry(), npar[2], nPA );
506  if ( sc.isSuccess() ) continue;
507  }
508  log() << MSG::ERROR << con->fid() << ": Failed to create address!!!!" << endmsg;
509  return S_FAIL;
510  }
511  return pObj->update();
512  } else if ( nb < 0 ) {
513  string tag = par[0] + ":" + par[1];
514  if ( m_badFiles.find( tag ) == m_badFiles.end() ) {
515  m_badFiles.insert( tag );
516  return error( "createObj> Cannot access the object:" + tag + " [Corrupted file]" );
517  }
518  }
519  }
520  return S_FAIL;
521 }
virtual const std::string * par() const =0
Retrieve String parameters.
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:75
Gaudi::Property< int > m_autoFlush
Definition: RootCnvSvc.h:73
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
T empty(T... args)
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
Description:
Definition: RootAddress.h:46
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
The data converters are responsible to translate data from one representation into another.
Definition: IConverter.h:68
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
std::string m_currSection
Property: ROOT section name.
Definition: RootCnvSvc.h:96
Gaudi::Property< std::string > m_recordName
Definition: RootCnvSvc.h:69
virtual StatusCode createNullRef(const std::string &path)
Insert null marker for not existent transient object.
Definition: RootCnvSvc.cpp:373
IoType
I/O Connection types.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
Definition: RootCnvSvc.h:86
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.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:308
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.
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.
int makeLink(std::string_view p)
Convert path string to path index.
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:84
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:358
T log(T... args)
int loadRefs(std::string_view section, std::string_view cnt, unsigned long entry, RootObjectRefs &refs)
Load references object.
std::shared_ptr< RootConnectionSetup > m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:94
void loadConverter(DataObject *pObj) override
ConversionSvc overload: Load the class (dictionary) for the converter.
Definition: RootCnvSvc.cpp:154
MsgStream & dec(MsgStream &log)
Definition: MsgStream.h:277
Gaudi::Property< std::string > m_compression
Definition: RootCnvSvc.h:80
virtual Connection * connection(const std::string &dsn) const =0
Retrieve known connection.
constexpr double pc
STL namespace.
bool patchStreamers(MsgStream &log)
const std::string & fid() const
Access file id.
StatusCode initialize() override
ConversionSvc overload: initialize Db service.
Definition: RootCnvSvc.cpp:84
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
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
const std::string & getDb(int which) const
Access database/file name from saved index.
StatusCode finalize() override
ConversionSvc overload: Finalize Db service.
Definition: RootCnvSvc.cpp:112
MsgStream & hex(MsgStream &log)
Definition: MsgStream.h:281
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Gaudi::Property< int > m_splitLevel
Definition: RootCnvSvc.h:79
Gaudi::Property< int > m_bufferSize
Definition: RootCnvSvc.h:77
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
STL class.
StatusCode commitOutput(const std::string &outputFile, bool do_commit) override
Commit pending output.
Definition: RootCnvSvc.cpp:303
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
virtual StatusCode disconnect(IDataConnection *con)=0
Release data stream.
bool isConnected() const override
Check if connected to data source.
STL class.
Persistent reference object.
Definition: extractEvt.C:44
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
T push_back(T... args)
static StatusCode setCompression(std::string_view compression)
Set the global compression level.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
const std::string & getCont(int which) const
Access container name from saved index.
virtual IRegistry * registry() const =0
Update branch name.
T what(T... args)
Gaudi::Property< std::string > m_ioPerfStats
Definition: RootCnvSvc.h:64
General service interface definition.
Definition: IService.h:28
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
constexpr double m
virtual Connections connections(const IInterface *owner) const =0
Get connection by owner instance (0=ALL)
#define S_OK
Definition: RootCnvSvc.cpp:47
const std::string & getLink(int which) const
Access link name from saved index.
Statistics file converter class definition.
virtual StatusCode connectRead(bool keep_open, IDataConnection *con)=0
Open data stream in read mode.
TClass * m_classDO
TClass pointer to DataObject class.
Definition: RootCnvSvc.h:92
StringVec cacheBranches
Vector of strings with branches to be cached for input files.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
const long ROOT_StorageType
Definition: ClassID.h:62
virtual StatusCode i__createObj(IOpaqueAddress *pAddr, DataObject *&refpObj)
Create transient object from persistent data.
Definition: RootCnvSvc.cpp:446
T reset(T... args)
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
T clear(T... args)
bool isSuccess() const
Definition: StatusCode.h:365
NTuple converter class definition for NTuples writted/read using ROOT.
Definition: RootNTupleCnv.h:45
STL class.
int loadObj(std::string_view section, std::string_view cnt, unsigned long entry, DataObject *&pObj)
Load object.
virtual StatusCode disconnect(const std::string &dbName)
Disconnect from an existing data stream.
Definition: RootCnvSvc.cpp:352
IConverter * createConverter(long typ, const CLID &wanted, const ICnvFactory *fac) override
ConversionSvc overload: Create new Converter using factory.
Definition: RootCnvSvc.cpp:140
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
#define MBYTE
Definition: RootCnvSvc.cpp:57
Description: NTuple directory converter class definition Definition of the converter to manage the di...
virtual StatusCode createNullRep(const std::string &path)
Insert null marker for not existent transient object.
Definition: RootCnvSvc.cpp:365
T find(T... args)
STL class.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:66
ABC describing basic data connection.
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:84
T c_str(T... args)
Base class for all Incidents (computing events).
Definition: Incident.h:27
virtual StatusCode i__fillRepRefs(IOpaqueAddress *pAddr, DataObject *pObj)
Resolve the references of the converted object.
Definition: RootCnvSvc.cpp:404
constexpr static const auto FAILURE
Definition: StatusCode.h:101
virtual StatusCode i__fillObjRefs(IOpaqueAddress *pAddr, DataObject *pObj)
Resolve the references of the created transient object.
Definition: RootCnvSvc.cpp:475
MSG::Level level() const
Retrieve output level.
Definition: MsgStream.h:113
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
T substr(T... args)
Gaudi::Property< int > m_basketSize
Definition: RootCnvSvc.h:75
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
void makeRef(const IRegistry &pA, RootRef &ref)
Create reference object from registry entry.
virtual const id_type & identifier() const =0
Full identifier (or key)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
Opaque address interface definition.
Base class for all conversion services.
Definition: ConversionSvc.h:55
#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.
StatusCode finalize() override
stop the service.
std::vector< RootRef > refs
The references corresponding to the next layer of items in the data store.
Definition: extractEvt.C:85
virtual StatusCode connectWrite(IDataConnection *con, IoType mode=Connection::CREATE, const std::string &doctype="UNKNOWN")=0
Open data stream in write mode.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
virtual StatusCode i__createRep(DataObject *pObj, IOpaqueAddress *&refpAddr)
Convert the transient object to the requested persistent representation.
Definition: RootCnvSvc.cpp:385
StatusCode initialize() override
Initialize the service.
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
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
Description: Definition of the ROOT data converter.
Definition: RootConverter.h:42
Gaudi::RootDataConnection * m_current
On writing: reference to active output stream.
Definition: RootCnvSvc.h:88
const string & CSTR
Definition: RootCnvSvc.cpp:45
TClass * getClass(DataObject *pObject)
Helper: Get TClass for a given DataObject pointer.
Definition: RootCnvSvc.cpp:171
TClass * m_classRefs
TClass pointer to reference class.
Definition: RootCnvSvc.h:90