RootCnvSvc.cpp
Go to the documentation of this file.
1 //====================================================================
2 // RootCnvSvc implementation
3 //--------------------------------------------------------------------
4 //
5 // Description: Implementation of the ROOT data storage
6 //
7 // Author : M.Frank
8 //
9 //====================================================================
10 
11 // Framework include files
12 #include "GaudiKernel/MsgStream.h"
13 #include "GaudiKernel/IRegistry.h"
14 #include "GaudiKernel/IUpdateable.h"
15 #include "GaudiKernel/IIncidentSvc.h"
16 #include "GaudiKernel/IDataManagerSvc.h"
17 #include "GaudiKernel/IDataProviderSvc.h"
18 #include "GaudiKernel/KeyedContainer.h"
19 #include "GaudiKernel/DataIncident.h"
20 #include "GaudiKernel/LinkManager.h"
21 #include "GaudiKernel/Incident.h"
22 #include "GaudiKernel/System.h"
23 #include "GaudiUtils/IIODataManager.h"
24 #include "RootCnv/RootRefs.h"
25 #include "RootCnv/RootCnvSvc.h"
26 #include "RootCnv/RootAddress.h"
27 #include "RootCnv/RootConverter.h"
28 #include "RootCnv/RootDatabaseCnv.h"
29 #include "RootCnv/RootDirectoryCnv.h"
30 #include "RootCnv/RootNTupleCnv.h"
31 #include "RootCnv/RootDataConnection.h"
32 #include "RootUtils.h"
33 
34 using namespace std;
35 using namespace Gaudi;
36 typedef const string& CSTR;
37 
38 #define S_OK StatusCode::SUCCESS
39 #define S_FAIL StatusCode::FAILURE
40 namespace GaudiRoot { bool patchStreamers(MsgStream& log); }
41 
42 namespace {
43  static map<string, TClass*> s_classesNames;
44  static map<CLID, TClass*> s_classesClids;
45 }
46 #define MBYTE 1024*1024
47 #define kBYTE 1024
48 // Standard constructor
49 RootCnvSvc::RootCnvSvc(CSTR nam, ISvcLocator* svc)
50 : ConversionSvc( nam, svc, ROOT_StorageType)
51 {
52  m_classRefs = m_classDO = 0;
53  m_setup = new RootConnectionSetup();
54  m_setup->cacheBranches.push_back("*");
55  declareProperty("IOPerfStats", m_ioPerfStats);
56  declareProperty("ShareFiles", m_shareFiles = "NO");
57  declareProperty("EnableIncident", m_incidentEnabled = true);
58  declareProperty("RecordsName", m_recordName = "/FileRecords");
59  declareProperty("LoadSection", m_setup->loadSection = "Event");
60 
61  // ROOT Write parameters
62  declareProperty("AutoFlush", m_autoFlush = 100);
63  declareProperty("BasketSize", m_basketSize = 2*MBYTE);
64  declareProperty("BufferSize", m_bufferSize = 2*kBYTE);
65  declareProperty("SplitLevel", m_splitLevel = 0);
66  declareProperty("GlobalCompression",m_compression); // empty: do nothing
67 
68  // ROOT Read parameters: must be shared for the entire file!
69  declareProperty("CacheSize", m_setup->cacheSize = 10*MBYTE);
70  declareProperty("LearnEntries", m_setup->learnEntries = 10);
71  declareProperty("CacheBranches", m_setup->cacheBranches);
72  declareProperty("VetoBranches", m_setup->vetoBranches);
73 }
74 
75 // Standard destructor
76 RootCnvSvc::~RootCnvSvc() {
77  if (m_setup) m_setup->release();
78 }
79 
80 // Small routine to issue exceptions
82  if ( m_log ) {
83  log() << MSG::ERROR << "Error: " << msg << endmsg;
84  return S_FAIL;
85  }
86  MsgStream m(msgSvc(),name());
87  m << MSG::ERROR << "Error: " << msg << endmsg;
88  return S_FAIL;
89 }
90 
91 // Initialize the Db data persistency service
93  string cname;
95  if ( !status.isSuccess() ) {
96  return error("Failed to initialize ConversionSvc base class.");
97  }
98  m_log.reset( new MsgStream(msgSvc(),name()) );
99  if ( !m_compression.empty() ) {
100  log() << MSG::INFO << "Setting global ROOT compression to:" << m_compression << endmsg;
101  if ( !(status=RootConnectionSetup::setCompression(m_compression)).isSuccess() ) {
102  return error("Unable to interprete ROOT compression encoding:"+m_compression);
103  }
104  }
105  m_ioMgr = service("IODataManager");
106  if( !m_ioMgr)
107  return error("Unable to localize interface from service:IODataManager");
108  m_incidentSvc = service("IncidentSvc");
109  if( !m_incidentSvc )
110  return error("Unable to localize interface from service:IncidentSvc");
111  m_setup->setMessageSvc(new MsgStream(msgSvc(),name()));
114  cname = System::typeinfoName(typeid(DataObject));
115  m_classDO = TClass::GetClass(cname.c_str());
116  if ( !m_classDO )
117  return error("Unable to load class description for DataObject");
118  cname = System::typeinfoName(typeid(RootObjectRefs));
119  m_classRefs = TClass::GetClass(cname.c_str());
120  if ( !m_classRefs )
121  return error("Unable to load class description for ObjectRefs");
122  return S_OK;
123 }
124 
125 // Finalize the Db data persistency service
127  log() << MSG::INFO;
128  if ( m_ioMgr ) {
129  IIODataManager::Connections cons = m_ioMgr->connections(0);
130  for(auto &i : cons ) {
131  auto pc = dynamic_cast<RootDataConnection*>(i);
132  if ( pc ) {
133  if ( pc->owner() == this && !m_ioPerfStats.empty() ) {
134  pc->saveStatistics(m_ioPerfStats);
135  }
136  if ( pc->lookupClient(this) ) {
137  size_t num_clients = pc->removeClient(this);
138  if ( num_clients == 0 ) {
139  if ( m_ioMgr->disconnect(pc).isSuccess() ) {
140  log() << "Disconnected data IO:" << pc->fid()
141  << " [" << pc->pfn() << "]" << endmsg;
142  delete pc;
143  }
144  }
145  }
146  }
147  }
148  m_ioMgr.reset();
149  }
150  m_log.reset();
152  m_setup->setIncidentSvc(nullptr);
153  return ConversionSvc::finalize();
154 }
155 
156 // ConversionSvc overload: Create new Converter using factory
157 IConverter* RootCnvSvc::createConverter(long typ,const CLID& wanted,const ICnvFactory*) {
158  if ( wanted == CLID_StatisticsFile )
159  return new RootDatabaseCnv(typ,wanted,serviceLocator().get(),this);
160  else if ( wanted == CLID_StatisticsDirectory )
161  return new RootDirectoryCnv(typ,wanted,serviceLocator().get(),this);
162  else if ( wanted == CLID_RowWiseTuple )
163  return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
164  else if ( wanted == CLID_ColumnWiseTuple )
165  return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
166  else
167  return new RootConverter(typ,wanted,serviceLocator().get(),this);
168 }
169 
170 // ConversionSvc overload: Load the class (dictionary) for the converter
172  if (pObject) {
173  string cname = System::typeinfoName(typeid(*pObject));
174  if( log().level() <= MSG::DEBUG )
175  log() << MSG::DEBUG << "Trying to 'Autoload' dictionary for class " << cname << endmsg;
176  TClass* cl = s_classesNames[cname];
177  if ( 0 == cl ) {
178  cl = TClass::GetClass(cname.c_str());
179  if ( cl ) {
180  s_classesNames[cname] = cl;
181  s_classesClids[pObject->clID()] = cl;
182  }
183  }
184  }
185 }
186 
187 // Helper: Get TClass for a given DataObject pointer
188 TClass* RootCnvSvc::getClass(DataObject* pObject) {
189  auto i=s_classesClids.find(pObject->clID());
190  if ( i != s_classesClids.end() ) return i->second;
191  loadConverter(pObject);
192  i=s_classesClids.find(pObject->clID());
193  if ( i != s_classesClids.end() ) return i->second;
194 
195  string cname = System::typeinfoName(typeid(*pObject));
196  throw runtime_error("Unknown ROOT class for object:"+cname);
197  return nullptr;
198 }
199 
200 // Connect the output file to the service with open mode.
202  StatusCode sc = S_FAIL;
203  m_current = nullptr;
204  m_currSection.clear();
205  if ( ::strncasecmp(openMode.c_str(),"RECREATE",3)==0 )
207  else if ( ::strncasecmp(openMode.c_str(),"NEW",1)==0 )
209  else if ( ::strncasecmp(openMode.c_str(),"CREATE",1)==0 )
211  else if ( ::strncasecmp(openMode.c_str(),"UPDATE",1)==0 )
213  if ( sc.isSuccess() && m_current && m_current->isConnected() ) {
214  return S_OK;
215  }
217  log() << MSG::ERROR << "The dataset " << dsn << " cannot be opened in mode "
218  << openMode << ". [Invalid mode]" << endmsg;
219  return sc;
220 }
221 
222 // Connect the output file to the service with open mode.
224 RootCnvSvc::connectDatabase(CSTR dataset, int mode, RootDataConnection** con) {
225  try {
226  IDataConnection* c = m_ioMgr->connection(dataset);
227  bool fire_incident = false;
228  *con = 0;
229  if ( !c ) {
230  std::unique_ptr<RootDataConnection> connection(new RootDataConnection(this,dataset,m_setup));
231  StatusCode sc = (mode != IDataConnection::READ)
232  ? m_ioMgr->connectWrite(connection.get(),IDataConnection::IoType(mode),"ROOT")
233  : m_ioMgr->connectRead(false,connection.get());
234  c = sc.isSuccess() ? m_ioMgr->connection(dataset) : 0;
235  if ( c ) {
236  bool writable = 0 != (mode&(IDataConnection::UPDATE|IDataConnection::RECREATE));
237  fire_incident = m_incidentEnabled && (0 != (mode&(IDataConnection::UPDATE|IDataConnection::READ)));
238  if ( writable ) {
239  m_incidentSvc->fireIncident(ContextIncident<TFile*>(connection->pfn(),"CONNECTED_OUTPUT",connection->file()));
240  }
241  if ( 0 != (mode&IDataConnection::READ) ) {
242  if ( !m_ioPerfStats.empty() ) {
243  connection->enableStatistics(m_setup->loadSection);
244  }
245  }
246  connection.release();
247  }
248  else {
249  m_incidentSvc->fireIncident(Incident(dataset,mode == IDataConnection::READ
252  // An error message was already printed by the IODataManager. no need to do it here!
253  return StatusCode::FAILURE;
254  }
255  }
256  RootDataConnection* pc = dynamic_cast<RootDataConnection*>(c);
257  if ( pc ) {
258  if ( !pc->isConnected() ) pc->connectRead();
259  *con = pc;
260  pc->resetAge();
261  pc->addClient(this);
262  }
263  if ( *con ) {
264  if ( fire_incident ) {
265  IOpaqueAddress* pAddr = nullptr;
266  string fid = pc->fid();
267  string section = m_recordName[0] == '/' ? m_recordName.substr(1) : m_recordName;
268  TBranch* b = pc->getBranch(section,m_recordName);
269  if ( b ) {
270  const string par[2] = { fid, m_recordName };
271  unsigned long ipar[2] = { (unsigned long)(*con), (unsigned long)b->GetEntries()-1 };
272  for(int i=0; i<b->GetEntries(); ++i) {
273  ipar[1] = i;
274  if ( !pc->mergeFIDs().empty() )
275  fid = pc->mergeFIDs()[i];
276  if ( !createAddress(repSvcType(),CLID_DataObject,par,ipar,pAddr).isSuccess() ) {
277  if( log().level() <= MSG::VERBOSE )
278  log() << MSG::VERBOSE << "Failed to create address for " << m_recordName << " in:" << fid
279  << " [" << pc->fid() << "][" << i << "]" << endmsg;
280  continue;
281  }
282  if( log().level() <= MSG::VERBOSE )
283  log() << MSG::VERBOSE << "Prepare " << m_recordName << " " << fid << " [" << par[0] << "][" << i << "]" << endmsg;
284  m_incidentSvc->fireIncident(ContextIncident<IOpaqueAddress*>(fid,"FILE_OPEN_READ",pAddr));
285  }
286  }
287  else {
288  if( log().level() <= MSG::VERBOSE )
289  log() << MSG::VERBOSE << "No valid Records " << m_recordName << " present in:" << pc->fid() << endmsg;
290  }
291  }
292 
293  // We can remove retired connections, which are no longer used....
294  for( auto &i : m_ioMgr->connections(this) ) {
295  if ( i != *con && !i->isConnected() ) {
296  RootDataConnection* pc = dynamic_cast<RootDataConnection*>(i);
297  if ( pc && pc->lookupClient(this) ) {
298  size_t num_client = pc->removeClient(this);
299  if ( num_client == 0 ) {
300  if ( m_ioMgr->disconnect(pc).isSuccess() ) {
301  log() << MSG::INFO << "Removed disconnected IO stream:" << pc->fid()
302  << " [" << pc->pfn() << "]" << endmsg;
303  delete pc;
304  }
305  }
306  }
307  }
308  }
309  return S_OK;
310  }
312  return S_FAIL;
313  }
314  catch (exception& e) {
316  return error(string("connectDatabase> Caught exception:")+e.what());
317  }
318  catch (...) {
320  return error("connectDatabase> Unknown Fatal Exception for "+dataset);
321  }
322 }
323 
324 // Conect output stream (valid until overwritten)
326  return connectOutput(db_name, "NEW");
327 }
328 
329 // Commit pending output on open container
330 StatusCode RootCnvSvc::commitOutput(CSTR dsn, bool /* doCommit */) {
331  if ( m_current ) {
332  size_t len = m_currSection.find('/',1);
333  string section = m_currSection.substr(1,len==string::npos ? string::npos : len-1);
334  TBranch* b = m_current->getBranch(section, m_currSection);
335  if ( b ) {
336  Long64_t evt = b->GetEntries();
337  TTree* t = b->GetTree();
338  TObjArray* a = t->GetListOfBranches();
339  Int_t nb = a->GetEntriesFast();
341  for(Int_t i=0; i<nb; ++i) {
342  TBranch* br_ptr = (TBranch*)a->UncheckedAt(i);
343  Long64_t br_evt = br_ptr->GetEntries();
344  if ( br_evt < evt ) {
345  Long64_t num = evt-br_evt;
346  br_ptr->SetAddress(nullptr);
347  while(num>0) {
348  br_ptr->Fill();
349  --num;
350  }
351  if( log().level() <= MSG::DEBUG ) log() << MSG::DEBUG
352  << "commit: Added " << long(evt-br_evt)
353  << " Section: " << evt << " Branch: " << br_ptr->GetEntries()
354  << " RefNo: " << br_ptr->GetEntries()-1
355  << " NULL entries to:" << br_ptr->GetName() << endmsg;
356  }
357  }
358 
359  b->GetTree()->SetEntries(evt);
360  if ( evt == 1 ) {
361  b->GetTree()->OptimizeBaskets(m_basketSize,1.1,"");
362  }
363  if ( evt > 0 && (evt%m_autoFlush)==0 ) {
364  if ( evt == m_autoFlush ) {
365  b->GetTree()->SetAutoFlush(m_autoFlush);
366  b->GetTree()->OptimizeBaskets(m_basketSize,1.,"");
367  }
368  else {
369  b->GetTree()->FlushBaskets();
370  }
371  }
372  if( log().level() <= MSG::DEBUG )
373  log() << MSG::DEBUG << "Set section entries of " << m_currSection
374  << " to " << long(evt) << " entries." << endmsg;
375  }
376  else {
377  return error("commitOutput> Failed to update entry numbers on "+dsn);
378  }
379  }
380  return S_OK;
381 }
382 
383 // Disconnect from an existing data stream.
385  IDataConnection* c = m_ioMgr->connection(dataset);
386  return c ? m_ioMgr->disconnect(c) : S_FAIL;
387 }
388 
389 // IAddressCreator implementation: Address creation
391  const CLID& clid,
392  const string* par,
393  const unsigned long* ip,
394  IOpaqueAddress*& refpAddress)
395 {
396  refpAddress = new RootAddress(typ,clid,par[0],par[1],ip[0],ip[1]);
397  return S_OK;
398 }
399 
400 // Insert null marker for not existent transient object
402  size_t len = path.find('/',1);
403  string section = path.substr(1,len==string::npos ? string::npos : len-1);
404  m_current->saveObj(section,path,0,0,m_bufferSize,m_splitLevel);
405  return S_OK;
406 }
407 
408 // Insert null marker for not existent transient object
410  RootObjectRefs* refs = 0;
411  size_t len = path.find('/',1);
412  string section = path.substr(1,len==string::npos ? string::npos : len-1);
413  pair<int,unsigned long> ret =
414  m_current->save(section,path+"#R",0,refs,m_bufferSize,m_splitLevel);
415  if( log().level() <= MSG::VERBOSE )
416  log() << MSG::VERBOSE << "Writing object:" << path << " "
417  << ret.first << " " << hex << ret.second << dec << " [NULL]" << endmsg;
418  return S_OK;
419 }
420 
421 // Mark an object for write given an object reference
423  refpAddr = 0;
424  if ( pObj ) {
425  CLID clid = pObj->clID();
426  IRegistry* pR = pObj->registry();
427  string p[2] = {m_current->fid(), pR->identifier()};
428  TClass* cl = (clid == CLID_DataObject) ? m_classDO : getClass(pObj);
429  size_t len = p[1].find('/',1);
430  string sect = p[1].substr(1,len==string::npos ? string::npos : len-1);
431  pair<int,unsigned long> ret =
432  m_current->saveObj(sect,p[1],cl,pObj,m_bufferSize,m_splitLevel,true);
433  if ( ret.first > 1 || (clid == CLID_DataObject && ret.first==1) ) {
434  unsigned long ip[2] = {0,ret.second};
435  if ( m_currSection.empty() ) m_currSection = p[1];
436  return createAddress(repSvcType(),clid,p,ip,refpAddr);
437  }
438  return error("Failed to write object data for:"+p[1]);
439  }
440  return error("createRep> Current Database is invalid!");
441 }
442 
443 // Save object references to data file
445  if ( pObj ) {
446  typedef vector<IRegistry*> Leaves;
447  Leaves leaves;
448  RootObjectRefs refs;
449  IRegistry* pR = pObj->registry();
450  auto dataMgr = SmartIF<IDataManagerSvc>{ pR->dataSvc() };
451  if ( dataMgr ) {
452  StatusCode status = dataMgr->objectLeaves(pObj, leaves);
453  if ( status.isSuccess() ) {
454  RootRef ref;
455  const string& id = pR->identifier();
456  size_t len = id.find('/',1);
457  string sect = id.substr(1,len==string::npos ? string::npos : len-1);
458  LinkManager* pLinks = pObj->linkMgr();
459  for(auto &i : leaves ) {
460  if ( i->address() ) {
461  m_current->makeRef(i,ref);
462  ref.entry = i->address()->ipar()[1];
463  refs.refs.push_back(ref);
464  }
465  }
466  for(int i = 0, n=pLinks->size(); i < n; ++i) {
467  LinkManager::Link* lnk = pLinks->link(i);
468  int link_id = m_current->makeLink(lnk->path());
469  refs.links.push_back(link_id);
470  }
471  pair<int,unsigned long> ret =
472  m_current->save(sect,id+"#R",m_classRefs,&refs,m_bufferSize,m_splitLevel,true);
473  if ( ret.first > 1 ) {
474  if( log().level() <= MSG::DEBUG )
475  log() << MSG::DEBUG << "Writing object:" << id << " "
476  << ret.first << " " << hex << ret.second << dec << endmsg;
477  return S_OK;
478  }
479  }
480  }
481  }
482  return S_FAIL;
483 }
484 
485 // Read existing object. Open transaction in read mode if not active
487  refpObj = nullptr;
488  if ( pA ) {
489  RootDataConnection* con = nullptr;
490  const string* par = pA->par();
491  unsigned long* ipar = const_cast<unsigned long*>(pA->ipar());
492  StatusCode sc = connectDatabase(par[0],IDataConnection::READ,&con);
493  if ( sc.isSuccess() ) {
494  ipar[0] = (unsigned long)con;
495  DataObject* pObj = 0;
496  size_t len = par[1].find('/',1);
497  string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
498 
499  int nb = con->loadObj(section,par[1],ipar[1],pObj);
500  if ( nb > 1 || (nb == 1 && pObj->clID() == CLID_DataObject) ) {
501  refpObj = pObj;
502  return S_OK;
503  }
504  delete pObj;
505  }
506  string tag = par[0]+":"+par[1];
507  if ( m_badFiles.find(tag) == m_badFiles.end() ) {
508  m_badFiles.insert(tag);
509  return error("createObj> Cannot access the object:"+tag);
510  }
511  return S_FAIL;
512  }
513  return S_FAIL;
514 }
515 
516 // Resolve the references of the created transient object.
518  if ( pA && pObj ) {
519  const unsigned long* ipar = pA->ipar();
520  RootDataConnection* con = (RootDataConnection*)ipar[0];
521  if ( con ) {
522  RootObjectRefs refs;
523  const string* par = pA->par();
524  size_t len = par[1].find('/',1);
525  string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
526  int nb = con->loadRefs(section,par[1],ipar[1],refs);
527  if ( nb >= 1 ) {
528  string npar[3];
529  unsigned long nipar[2];
530  IOpaqueAddress* nPA;
531  IRegistry* pR = pObj->registry();
532  auto dataMgr = SmartIF<IDataManagerSvc>{ pR->dataSvc() };
533  LinkManager* mgr = pObj->linkMgr();
534  for(const auto& i : refs.links ) mgr->addLink(con->getLink(i),nullptr);
535  for(size_t j=0, n=refs.refs.size(); j<n; ++j) {
536  const RootRef& r = refs.refs[j];
537  npar[0] = con->getDb(r.dbase);
538  npar[1] = con->getCont(r.container);
539  npar[2] = con->getLink(r.link);
540  nipar[0] = 0;
541  nipar[1] = r.entry;
542  StatusCode sc = addressCreator()->createAddress(r.svc,r.clid,npar,nipar,nPA);
543  if ( sc.isSuccess() ) {
544  if( log().level() <= MSG::VERBOSE )
545  log() << MSG::VERBOSE << dataMgr.as<IService>()->name()
546  << " -> Register:" << pA->registry()->identifier()
547  << "#" << npar[2] << "[" << r.entry << "]" << endmsg;
548  sc = dataMgr->registerAddress(pA->registry(),npar[2],nPA);
549  if ( sc.isSuccess() ) {
550  continue;
551  }
552  }
553  log() << MSG::ERROR << con->fid() << ": Failed to create address!!!!" << endmsg;
554  return S_FAIL;
555  }
556  return pObj->update();
557  }
558  else if ( nb < 0 ) {
559  string tag = par[0]+":"+par[1];
560  if ( m_badFiles.find(tag) == m_badFiles.end() ) {
561  m_badFiles.insert(tag);
562  return error("createObj> Cannot access the object:"+tag+" [Corrupted file]");
563  }
564  }
565  }
566  return S_FAIL;
567  }
568  return error("read> Cannot read object -- no valid object address present ");
569 }
void addClient(const IInterface *client)
Add new client to this data source.
bool lookupClient(const IInterface *client) const
Lookup client for this data source.
virtual const std::string * par() const =0
Retrieve String parameters.
tuple c
Definition: gaudirun.py:392
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:83
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:99
Description:
Definition: RootAddress.h:36
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
std::pair< int, unsigned long > save(const std::string &section, const std::string &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.
const std::string & fid() const
Access file id.
std::string m_currSection
Property: ROOT section name.
Definition: RootCnvSvc.h:68
virtual IConverter * createConverter(long typ, const CLID &wanted, const ICnvFactory *fac)
ConversionSvc overload: Create new Converter using factory.
Definition: RootCnvSvc.cpp:157
virtual void loadConverter(DataObject *pObj)
ConversionSvc overload: Load the class (dictionary) for the converter.
Definition: RootCnvSvc.cpp:171
virtual StatusCode createNullRef(const std::string &path)
Insert null marker for not existent transient object.
Definition: RootCnvSvc.cpp:409
IoType
I/O Connection types.
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
IAddressCreator implementation: Address creation.
Definition: RootCnvSvc.cpp:390
const std::string & getDb(int which) const
Access database/file name from saved index.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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 m_basketSize
Property: Basket optimization parameter for ROOT TTree (total basket size)
Definition: RootCnvSvc.h:84
Gaudi::RootDataConnection * m_current
On writing: reference to active output stream.
Definition: RootCnvSvc.h:60
std::unique_ptr< MsgStream > m_log
Message streamer.
Definition: RootCnvSvc.h:94
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
int loadObj(const std::string &section, const std::string &cnt, unsigned long entry, DataObject *&pObj)
Load object.
std::set< std::string > m_badFiles
Set with bad files/tables.
Definition: RootCnvSvc.h:91
list path
Definition: __init__.py:15
std::vector< Connection * > Connections
void release()
Decrease reference count.
size_t removeClient(const IInterface *client)
Remove client from this data source.
constexpr double pc
STL namespace.
const long ROOT_StorageType
Definition: ClassID.h:52
bool patchStreamers(MsgStream &log)
const std::string & getLink(int which) const
Access link name from saved index.
void setMessageSvc(MsgStream *m)
Set message service reference.
const std::string FailInputFile
could not open or read from this file
Definition: Incident.h:78
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:56
virtual StatusCode disconnect(const std::string &dbName)
Disconnect from an existing data stream.
const std::string & pfn() const
Access physical file name.
std::vector< int > links
The links of the link manager.
Definition: RootRefs.h:73
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
int loadRefs(const std::string &section, const std::string &cnt, unsigned long entry, RootObjectRefs &refs)
Load references object.
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject...
Definition: RootRefs.h:71
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:78
virtual StatusCode commitOutput(const std::string &outputFile, bool do_commit)
Commit pending output.
std::string loadSection
RootCnvSvc Property: Root data cache size.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
int dbase
Data members to define object location in the persistent world.
Definition: RootRefs.h:32
Persistent reference object.
Definition: RootRefs.h:30
int m_splitLevel
Property: Split level optimization parameter for ROOT TTree.
Definition: RootCnvSvc.h:88
virtual bool isConnected() const
Check if connected to data source.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
virtual long repSvcType() const
Retrieve the class type of the data store the converter uses.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
virtual StatusCode finalize()
stop the service.
StatusCode error(const std::string &msg)
Standard way to print errors.
virtual IRegistry * registry() const =0
Update branch name.
General service interface definition.
Definition: IService.h:18
TClass * m_classDO
TClass pointer to DataObject class.
Definition: RootCnvSvc.h:64
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
constexpr double m
Definition: SystemOfUnits.h:93
#define S_OK
Definition: RootCnvSvc.cpp:38
TBranch * getBranch(const std::string &section, const std::string &branch_name)
Access data branch by name: Get existing branch in read only mode.
void makeRef(IRegistry *pA, RootRef &ref)
Create reference object from registry entry.
Statistics file converter class definition.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
const std::string CSTR
virtual StatusCode i__createObj(IOpaqueAddress *pAddr, DataObject *&refpObj)
Create transient object from persistent data.
Definition: RootCnvSvc.cpp:486
const std::string & getCont(int which) const
Access container name from saved index.
virtual StatusCode finalize()
ConversionSvc overload: Finalize Db service.
Definition: RootCnvSvc.cpp:126
NTuple converter class definition for NTuples writted/read using ROOT.
Definition: RootNTupleCnv.h:34
std::pair< int, unsigned long > saveObj(const std::string &section, const std::string &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.
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
bool m_incidentEnabled
Property: Flag to enable incidents on FILE_OPEN.
Definition: RootCnvSvc.h:71
const StringVec & mergeFIDs() const
Access merged FIDs.
#define MBYTE
Definition: RootCnvSvc.cpp:46
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
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:401
virtual StatusCode connectOutput(const std::string &outputFile, const std::string &openMode)
Connect the output file to the service with open mode.
TClass * m_classRefs
TClass pointer to reference class.
Definition: RootCnvSvc.h:62
ABC describing basic data connection.
virtual StatusCode connectRead()
Open data stream in read mode.
void resetAge()
Reset age.
RootConnectionSetup * m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:66
Base class for all Incidents (computing events).
Definition: Incident.h:16
std::string m_compression
Property: Compression-algorithm:compression-level.
Definition: RootCnvSvc.h:79
virtual StatusCode i__fillRepRefs(IOpaqueAddress *pAddr, DataObject *pObj)
Resolve the references of the converted object.
Definition: RootCnvSvc.cpp:444
static long setCompression(const std::string &compression)
Set the global compression level.
std::string m_recordName
Property: Records name to fire incident for file records.
Definition: RootCnvSvc.h:75
virtual StatusCode i__fillObjRefs(IOpaqueAddress *pAddr, DataObject *pObj)
Resolve the references of the created transient object.
Definition: RootCnvSvc.cpp:517
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
virtual SmartIF< IAddressCreator > & addressCreator() const
Retrieve address creator facility.
virtual StatusCode initialize()
Initialize the service.
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:88
virtual StatusCode initialize()
ConversionSvc overload: initialize Db service.
Definition: RootCnvSvc.cpp:92
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
Definition: RootCnvSvc.h:58
int makeLink(const std::string &p)
Convert path string to path index.
const std::string FailOutputFile
could not create or write to this file
Definition: Incident.h:73
Opaque address interface definition.
Base class for all conversion services.
Definition: ConversionSvc.h:46
std::string m_ioPerfStats
Property: Enable TTree IOperfStats if not empty; otherwise perf stat file name.
Definition: RootCnvSvc.h:77
#define S_FAIL
Definition: RootCnvSvc.cpp:39
void setIncidentSvc(IIncidentSvc *m)
Set incident service reference.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
list i
Definition: ana.py:128
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: RootRefs.h:75
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
Helper functions to set/get the application return code.
Definition: __init__.py:1
virtual StatusCode i__createRep(DataObject *pObj, IOpaqueAddress *&refpAddr)
Convert the transient object to the requested persistent representation.
Definition: RootCnvSvc.cpp:422
#define kBYTE
Definition: RootCnvSvc.cpp:47
Description: Definition of the ROOT data converter.
Definition: RootConverter.h:32
int m_bufferSize
Property: Buffer size optimization parameter for ROOT TTree.
Definition: RootCnvSvc.h:86
const string & CSTR
Definition: RootCnvSvc.cpp:36
int m_autoFlush
Property: AutoFlush parameter for ROOT TTree (Number of events between auto flushes) ...
Definition: RootCnvSvc.h:82
TClass * getClass(DataObject *pObject)
Helper: Get TClass for a given DataObject pointer.
Definition: RootCnvSvc.cpp:188