| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

RootDataConnection.cpp
Go to the documentation of this file.
1 //====================================================================
2 // RootDataConnection.cpp
3 //--------------------------------------------------------------------
4 //
5 // Author : M.Frank
6 //====================================================================
7
8 // Framework include files
9 #include "RootCnv/RootDataConnection.h"
10 #include "RootUtils.h"
11 #include "GaudiKernel/IOpaqueAddress.h"
12 #include "GaudiKernel/IIncidentSvc.h"
13 #include "GaudiKernel/LinkManager.h"
14 #include "GaudiKernel/strcasecmp.h"
15 #include "GaudiKernel/DataObject.h"
16 #include "GaudiKernel/IRegistry.h"
17 #include "GaudiKernel/Incident.h"
18 #include "GaudiKernel/MsgStream.h"
19 // ROOT include files
20 #include "TROOT.h"
21 #include "TFile.h"
22 #include "TTree.h"
23 #include "TLeaf.h"
24 #include "TClass.h"
25 #include "TBranch.h"
26 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
27 #include "Compression.h"
28 static int s_compressionLevel = ROOT::CompressionSettings(ROOT::kLZMA,6);
29 #else
30 static int s_compressionLevel = 1;
31 #endif
32
33 // C/C++ include files
34 #include <stdexcept>
35
36 using namespace Gaudi;
37 using namespace std;
38 typedef const string& CSTR;
39
40 static const string s_empty;
41 static const string s_local = "<localDB>";
42
43 #ifdef __POOL_COMPATIBILITY
44 #include "PoolTool.h"
45 #endif
46 #include "RootTool.h"
47
48 namespace {
49 std::array<char,256> init_table() {
50 std::array<char,256> table;
51 std::iota(std::begin(table),std::end(table),0);
52 return table;
53 }
54 }
55
56
57 static bool match_wild(const char *str, const char *pat) {
58 //
59 // Credits: Code from Alessandro Felice Cantatore.
60 //
61 static const std::array<char,256> table = init_table();
62 const char *s, *p;
63 bool star = false;
64 loopStart:
65 for (s = str, p = pat; *s; ++s, ++p) {
66 switch (*p) {
67 case '?':
68 if (*s == '.') goto starCheck;
69 break;
70 case '*':
71 star = true;
72 str = s, pat = p;
73 do { ++pat; } while (*pat == '*');
74 if (!*pat) return true;
75 goto loopStart;
76 default:
77 if ( table[*s] != table[*p] )
78 goto starCheck;
79 break;
80 } /* endswitch */
81 } /* endfor */
82 while (*p == '*') ++p;
83 return (!*p);
84
85 starCheck:
86 if (!star) return false;
87 str++;
88 goto loopStart;
89 }
90
92 long RootConnectionSetup::setCompression(const std::string& compression) {
93 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
94 int res = 0, level = ROOT::CompressionSettings(ROOT::kLZMA,6);
95 auto idx = compression.find(':');
96 if ( idx != string::npos ) {
97 string alg = compression.substr(0,idx);
98 ROOT::ECompressionAlgorithm alg_code = ROOT::kUseGlobalSetting;
99 if ( strcasecmp(alg.c_str(),"ZLIB") == 0 )
100 alg_code = ROOT::kZLIB;
101 else if ( strcasecmp(alg.c_str(),"LZMA") == 0 )
102 alg_code = ROOT::kLZMA;
103 else
104 throw runtime_error("ERROR: request to set unknown ROOT compression algorithm:"+alg);
105 res = ::sscanf(compression.c_str()+idx+1,"%d",&level);
106 if ( res == 1 ) {
107 s_compressionLevel = ROOT::CompressionSettings(alg_code,level);
108 return StatusCode::SUCCESS;
109 }
110 throw runtime_error("ERROR: request to set unknown ROOT compression level:"+compression.substr(idx+1));
111 }
112 else if ( 1==::sscanf(compression.c_str(),"%d",&level) ) {
113 s_compressionLevel = level;
114 return StatusCode::SUCCESS;
115 }
116 throw runtime_error("ERROR: request to set unknown ROOT compression mechanism:"+compression);
117 #else
118 if ( !compression.empty() ) {}
119 return StatusCode::SUCCESS;
120 #endif
121 }
122
124 int RootConnectionSetup::compression() {
125 return s_compressionLevel;
126 }
127
128
130 void RootConnectionSetup::setMessageSvc(MsgStream* m) {
131 m_msgSvc.reset(m);
132 }
133
135 void RootConnectionSetup::setIncidentSvc(IIncidentSvc* s) {
136 m_incidentSvc.reset(s);
137 }
138
140 RootDataConnection::RootDataConnection(const IInterface* owner, CSTR fname, std::shared_ptr<RootConnectionSetup> setup)
141 : IDataConnection(owner,fname), m_setup(std::move(setup))
142 { // 01234567890123456789012345678901234567890
143 // Check if FID: A82A3BD8-7ECB-DC11-8DC0-000423D950B0
144 if ( fname.length() == 36 && fname[8]=='-'&&fname[13]=='-'&&fname[18]=='-'&&fname[23]=='-' ) {
145 m_name = "FID:"+fname;
146 }
147 m_age = 0;
148 m_file.reset();
149 addClient(owner);
150 }
151
153 void RootDataConnection::addClient(const IInterface* client) {
154 m_clients.insert(client);
155 }
156
158 size_t RootDataConnection::removeClient(const IInterface* client) {
159 auto i=m_clients.find(client);
160 if ( i != m_clients.end() ) m_clients.erase(i);
161 return m_clients.size();
162 }
163
165 bool RootDataConnection::lookupClient(const IInterface* client) const {
166 auto i=m_clients.find(client);
167 return i != m_clients.end();
168 }
169
171 void RootDataConnection::badWriteError(const string& msg) const {
172 msgSvc() << MSG::ERROR << "File:" << fid() << "Failed action:" << msg << endmsg;
173 }
174
176 void RootDataConnection::saveStatistics(CSTR statisticsFile) {
177 if ( m_statistics ) {
178 m_statistics->Print();
179 if ( !statisticsFile.empty() )
180 m_statistics->SaveAs(statisticsFile.c_str());
181 m_statistics.reset();
182 }
183 }
184
186 void RootDataConnection::enableStatistics(CSTR section) {
187 if ( m_statistics ) {
188 TTree* t=getSection(section,false);
189 if ( t ) {
190 m_statistics.reset( new TTreePerfStats((section+"_ioperf").c_str(),t) );
191 return;
192 }
193 msgSvc() << MSG::WARNING << "Failed to enable perfstats for tree:" << section << endmsg;
194 return;
195 }
196 msgSvc() << MSG::INFO << "Perfstats are ALREADY ENABLED." << endmsg;
197 }
198
200 RootDataConnection::Tool* RootDataConnection::makeTool() {
201 if ( !m_refs ) m_refs = (TTree*)m_file->Get("Refs");
202 if ( m_refs )
203 m_tool.reset( new RootTool(this) );
204 #ifdef __POOL_COMPATIBILITY
205 else if ( m_file->Get("##Links") != nullptr )
206 m_tool.reset(new PoolTool(this));
207 #endif
208 else
209 m_tool.reset();
210 return m_tool.get();
211 }
212
214 StatusCode RootDataConnection::connectRead() {
215 m_file.reset( TFile::Open(m_pfn.c_str()) );
216 if ( !m_file || m_file->IsZombie() ) {
217 m_file.reset();
218 return StatusCode::FAILURE;
219 }
220 StatusCode sc = StatusCode::FAILURE;
221 msgSvc() << MSG::DEBUG << "Opened file " << m_pfn << " in mode READ. [" << m_fid << "]" << endmsg << MSG::DEBUG;
222 if ( msgSvc().isActive() ) m_file->ls();
223 msgSvc() << MSG::VERBOSE;
224 if ( msgSvc().isActive() ) m_file->Print();
225 if ( makeTool() ) {
226 sc = m_tool->readRefs();
227 sc.ignore();
228 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
229 if ( sc.getCode() == ROOT_READ_ERROR ) {
230 IIncidentSvc* inc = m_setup->incidentSvc();
231 if ( inc ) {
232 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
233 }
234 }
235 #endif
236 }
237 if ( !sc.isSuccess() ) return sc;
238 bool need_fid = m_fid == m_pfn;
239 string fid = m_fid;
240 m_mergeFIDs.clear();
241 for(auto & elem : m_params) {
242 if ( elem.first == "FID" ) {
243 m_mergeFIDs.push_back(elem.second);
244 if ( elem.second != m_fid ) {
245 msgSvc() << MSG::DEBUG << "Check FID param:" << elem.second << endmsg;
246 //if ( m_fid == m_pfn ) {
247 m_fid = elem.second;
248 //}
249 }
250 }
251 }
252 if ( !need_fid && fid != m_fid ) {
253 msgSvc() << MSG::ERROR << "FID mismatch:" << fid << "(Catalog) != " << m_fid << "(file)" << endmsg
254 << "for PFN:" << m_pfn << endmsg;
255 return StatusCode::FAILURE;
256 }
257 msgSvc() << MSG::DEBUG << "Using FID " << m_fid << " from params table...." << endmsg
258 << "for PFN:" << m_pfn << endmsg;
259 return sc;
260 }
261
263 StatusCode RootDataConnection::connectWrite(IoType typ) {
264 int compress = RootConnectionSetup::compression();
265 msgSvc() << MSG::DEBUG;
266 switch(typ) {
267 case CREATE:
268 resetAge();
269 m_file.reset(TFile::Open(m_pfn.c_str(),"CREATE","Root event data",compress));
270 m_refs = new TTree("Refs","Root reference data");
271 msgSvc() << "Opened file " << m_pfn << " in mode CREATE. [" << m_fid << "]" << endmsg;
272 m_params.emplace_back("PFN",m_pfn);
273 if ( m_fid != m_pfn ) {
274 m_params.emplace_back("FID",m_fid);
275 }
276 makeTool();
277 break;
278 case RECREATE:
279 resetAge();
280 m_file.reset(TFile::Open(m_pfn.c_str(),"RECREATE","Root event data",compress));
281 msgSvc() << "Opened file " << m_pfn << " in mode RECREATE. [" << m_fid << "]" << endmsg;
282 m_refs = new TTree("Refs","Root reference data");
283 m_params.emplace_back("PFN",m_pfn);
284 if ( m_fid != m_pfn ) {
285 m_params.emplace_back("FID",m_fid);
286 }
287 makeTool();
288 break;
289 case UPDATE:
290 resetAge();
291 m_file.reset(TFile::Open(m_pfn.c_str(),"UPDATE","Root event data",compress));
292 msgSvc() << "Opened file " << m_pfn << " in mode UPDATE. [" << m_fid << "]" << endmsg;
293 if ( m_file && !m_file->IsZombie() ) {
294 if ( makeTool() ) {
295 StatusCode sc = m_tool->readRefs();
296 sc.ignore();
297 if ( sc.getCode() == ROOT_READ_ERROR ) {
298 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
299 IIncidentSvc* inc = m_setup->incidentSvc();
300 if ( inc ) {
301 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
302 }
303 #endif
304 }
305 return sc;
306 }
307 TDirectory::TContext ctxt(m_file.get());
308 m_refs = new TTree("Refs","Root reference data");
309 makeTool();
310 return StatusCode::SUCCESS;
311 }
312 break;
313 default:
314 m_refs = nullptr;
315 m_file.reset();
316 return StatusCode::FAILURE;
317 }
318 return m_file ? StatusCode::SUCCESS : StatusCode::FAILURE ;
319 }
320
322 StatusCode RootDataConnection::disconnect() {
323 if ( m_file ) {
324 if ( !m_file->IsZombie() ) {
325 if ( m_file->IsWritable() ) {
326 msgSvc() << MSG::DEBUG;
327 TDirectory::TContext ctxt(m_file.get());
328 if ( m_refs ) {
329 if ( !m_tool->saveRefs().isSuccess() ) badWriteError("Saving References");
330 if ( m_refs->Write() < 0 ) badWriteError("Write Reference branch");
331 }
332 for( auto& i : m_sections ) {
333 if ( i.second ) {
334 if ( i.second->Write() < 0 ) badWriteError("Write section:"+i.first);
335 msgSvc() << "Disconnect section " << i.first << " " << i.second->GetName() << endmsg;
336 }
337 }
338 m_sections.clear();
339 }
340 msgSvc() << MSG::DEBUG;
341 if ( msgSvc().isActive() ) m_file->ls();
342 msgSvc() << MSG::VERBOSE;
343 if ( msgSvc().isActive() ) m_file->Print();
344 m_file->Close();
345 }
346 msgSvc() << MSG::DEBUG << "Disconnected file " << m_pfn << " " << m_file->GetName() << endmsg;
347 m_file.reset();
348 m_tool.reset();
349 }
350 return StatusCode::SUCCESS;
351 }
352
354 TTree* RootDataConnection::getSection(CSTR section, bool create) {
355 TTree* t = m_sections[section];
356 if ( !t ) {
357 t = (TTree*)m_file->Get(section.c_str());
358 if ( !t && create ) {
359 TDirectory::TContext ctxt(m_file.get());
360 t = new TTree(section.c_str(),"Root data for Gaudi");
361 }
362 if ( t ) {
363 int cacheSize = m_setup->cacheSize;
364 if ( create ) {
365 //t->SetAutoFlush(100);
366 }
367 if ( section == m_setup->loadSection && cacheSize>-2 ) {
368 MsgStream& msg = msgSvc();
369 int learnEntries = m_setup->learnEntries;
370 t->SetCacheSize(cacheSize);
371 t->SetCacheLearnEntries(learnEntries);
372 msg << MSG::DEBUG;
373 if ( create ) {
374 msg << "Tree:" << section << "Setting up tree cache:" << cacheSize << endmsg;
375 }
376 else {
377 const StringVec& vB = m_setup->vetoBranches;
378 const StringVec& cB = m_setup->cacheBranches;
379 msg << "Tree:" << section << " Setting up tree cache:" << cacheSize << " Add all branches." << endmsg;
380 msg << "Tree:" << section << " Learn for " << learnEntries << " entries." << endmsg;
381
382 if ( cB.empty() && vB.empty()) {
383 msg << "Adding (default) all branches to tree cache." << endmsg;
384 t->AddBranchToCache("*",kTRUE);
385 }
386 if ( cB.size()==1 && cB[0]=="*" ) {
387 msg << "Adding all branches to tree cache according to option \"CacheBranches\"." << endmsg;
388 t->AddBranchToCache("*",kTRUE);
389 }
390 else {
391 for(TIter it(t->GetListOfBranches()); it.Next(); ) {
392 const char* n = ((TNamed*)(*it))->GetName();
393 bool add = false, veto = false;
394 for(const auto& i : cB ) {
395 if ( !match_wild(n,(i).c_str()) ) continue;
396 add = true;
397 break;
398 }
399 for(auto i=vB.cbegin(); !add && i!=vB.cend();++i) {
400 if ( !match_wild(n,(*i).c_str()) ) continue;
401 veto = true;
402 break;
403 }
404 if ( add && !veto ) {
405 msg << "Add " << n << " to branch cache." << endmsg;
406 t->AddBranchToCache(n,kTRUE);
407 }
408 else {
409 msg << "Do not cache branch " << n << endmsg;
410 }
411 }
412 }
413 }
414 }
415 m_sections[section] = t;
416 }
417 }
418 return t;
419 }
420
422 TBranch* RootDataConnection::getBranch(CSTR section, CSTR branch_name, TClass* cl, void* ptr, int buff_siz, int split_lvl) {
423 string n = branch_name;
424 std::replace_if(std::begin(n),std::end(n),
425 [](const char c) { return !isalnum(c); },
426 '_');
427 n += ".";
428 TTree* t = getSection(section,true);
429 TBranch* b = t->GetBranch(n.c_str());
430 if ( !b && cl && m_file->IsWritable() ) {
431 b = t->Branch(n.c_str(),cl->GetName(),(void*)(ptr ? &ptr : nullptr),buff_siz,split_lvl);
432 }
433 if ( !b ) b = t->GetBranch(branch_name.c_str());
434 if ( b ) b->SetAutoDelete(kFALSE);
435 return b;
436 }
437
439 int RootDataConnection::makeLink(CSTR p) {
440 auto ip = std::find(std::begin(m_links),std::end(m_links),p);
441 if (ip!=std::end(m_links)) return std::distance(std::begin(m_links),ip);
442 m_links.push_back(p);
443 return m_links.size()-1;
444 }
445
447 CSTR RootDataConnection::getDb(int which) const {
448 if ( (which>=0) && (size_t(which)<m_dbs.size()) ) {
449 if ( *(m_dbs.begin()+which) == s_local ) return m_fid;
450 return *(m_dbs.begin()+which);
451 }
452 return s_empty;
453 }
454
456 CSTR RootDataConnection::empty() const {
457 return s_empty;
458 }
459
461 pair<int,unsigned long>
462 RootDataConnection::saveObj(CSTR section, CSTR cnt, TClass* cl, DataObject* pObj, int buff_siz, int split_lvl,bool fill) {
463 DataObjectPush push(pObj);
464 return save(section,cnt,cl,pObj,buff_siz,split_lvl,fill);
465 }
466
468 pair<int,unsigned long>
469 RootDataConnection::save(CSTR section, CSTR cnt, TClass* cl, void* pObj, int buff_siz, int split_lvl, bool fill_missing) {
470 split_lvl = 0;
471 TBranch* b = getBranch(section, cnt, cl, pObj ? &pObj : nullptr, buff_siz, split_lvl);
472 if ( b ) {
473 Long64_t evt = b->GetEntries();
474 //msgSvc() << MSG::DEBUG << cnt.c_str() << " Obj:" << (void*)pObj
475 // << " Split:" << split_lvl << " Buffer size:" << buff_siz << endl;
476 if ( fill_missing ) {
477 Long64_t num, nevt = b->GetTree()->GetEntries();
478 if ( nevt > evt ) {
479 b->SetAddress(nullptr);
480 num = nevt - evt;
481 while( num > 0 ) { b->Fill(); --num; }
482 msgSvc() << MSG::DEBUG << "Added " << long(nevt-evt)
483 << " / Tree: " << nevt << " / Branch: " << b->GetEntries()+1
484 << " NULL entries to:" << cnt << endmsg;
485 evt = b->GetEntries();
486 }
487 }
488 b->SetAddress(&pObj);
489 return {b->Fill(),evt};
490 }
491 if ( pObj ) {
492 msgSvc() << MSG::ERROR << "Failed to access branch " << m_name << "/" << cnt << endmsg;
493 }
494 return {-1,~0};
495 }
496
498 int RootDataConnection::loadObj(CSTR section, CSTR cnt, unsigned long entry, DataObject*& pObj) {
499 TBranch* b = getBranch(section,cnt);
500 if ( b ) {
501 TClass* cl = gROOT->GetClass(b->GetClassName(),kTRUE);
502 if ( cl ) {
503 int nb = -1;
504 pObj = (DataObject*)cl->New();
505 {
506 DataObjectPush push(pObj);
507 b->SetAddress(&pObj);
508 if ( section == m_setup->loadSection ) {
509 TTree* t = b->GetTree();
510 if ( Long64_t(entry) != t->GetReadEntry() ) {
511 t->LoadTree(Long64_t(entry));
512 }
513 }
514 nb = b->GetEntry(entry);
515 msgSvc() << MSG::VERBOSE;
516 if ( msgSvc().isActive() ) {
517 msgSvc() << "Load [" << entry << "] --> " << section
518 << ":" << cnt << " " << nb << " bytes."
519 << endmsg;
520 }
521 if ( nb < 0 ) { // This is definitely an error...ROOT says if reads fail, -1 is issued.
522 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
523 IIncidentSvc* inc = m_setup->incidentSvc();
524 if ( inc ) {
525 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
526 }
527 #endif
528 }
529 else if ( nb == 0 && pObj->clID() == CLID_DataObject) {
530 TFile* f = b->GetFile();
531 int vsn = f->GetVersion();
532 if ( vsn < 52400 ) {
533 // For Gaudi v21r5 (ROOT 5.24.00b) DataObject::m_version was not written!
534 // Still this call be well be successful.
535 nb = 1;
536 }
537 else if ( vsn>1000000 && (vsn%1000000)<52400 ) {
538 // dto. Some POOL files have for unknown reasons a version
539 // not according to ROOT standards. Hack this explicitly.
540 nb = 1;
541 }
542 }
543 if ( nb < 0 ) {
544 delete pObj;
545 pObj = nullptr;
546 }
547 }
548 return nb;
549 }
550 }
551 return -1;
552 }
553
555 int RootDataConnection::loadRefs(const std::string& section, const std::string& cnt,
556 unsigned long entry, RootObjectRefs& refs)
557 {
558 int nbytes = m_tool->loadRefs(section,cnt,entry,refs);
559 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
560 if ( nbytes < 0 ) {
561 // This is definitely an error:
562 // -- Either branch not preesent at all or
563 // -- ROOT I/O error, which issues -1
564 IIncidentSvc* inc = m_setup->incidentSvc();
565 if ( inc ) {
566 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
567 }
568 }
569 #endif
570 return nbytes;
571 }
572
574 pair<const RootRef*,const RootDataConnection::ContainerSection*>
575 RootDataConnection::getMergeSection(const string& container, int entry) const {
576 //size_t idx = cont.find('/',1);
577 //string container = cont[0]=='/' ? cont.substr(1,idx==string::npos?idx:idx-1) : cont;
578 auto i=m_mergeSects.find(container);
579 if ( i != m_mergeSects.end() ) {
580 size_t cnt = 0;
581 const ContainerSections& s = (*i).second;
582 for(auto j=s.cbegin(); j != s.cend(); ++j,++cnt) {
583 const ContainerSection& c = *j;
584 if ( entry >= c.start && entry < (c.start+c.length) ) {
585 if ( m_linkSects.size() > cnt ) {
586 if ( msgSvc().isActive() ) {
587 msgSvc() << MSG::VERBOSE << "MergeSection for:" << container
588 << " [" << entry << "]" << endmsg
589 << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
590 }
591 return { &(m_linkSects[cnt]), &c };
592 }
593 }
594 }
595 }
596 msgSvc() << MSG::DEBUG << "Return INVALID MergeSection for:" << container
597 << " [" << entry << "]" << endmsg
598 << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
599 return { nullptr, nullptr };
600 }
601
603 void RootDataConnection::makeRef(IRegistry* pR, RootRef& ref) {
604 IOpaqueAddress* pA = pR->address();
605 makeRef(pR->name(),pA->clID(),pA->svcType(),pA->par()[0],pA->par()[1],-1,ref);
606 }
607
609 void RootDataConnection::makeRef(CSTR name, long clid, int tech, CSTR dbase, CSTR cnt, int entry, RootRef& ref) {
610 string db(dbase);
611 if ( db == m_fid ) db = s_local;
612 ref.entry = entry;
613
614 int cdb = -1;
615 if ( !db.empty() ) {
616 auto idb = std::find_if( m_dbs.begin(),m_dbs.end(),
617 [&](const std::string& i) { return i == db; } );
618 cdb = std::distance(m_dbs.begin(),idb);
619 if ( idb == m_dbs.end() ) m_dbs.push_back(db);
620 }
621
622 int ccnt = -1;
623 if ( !cnt.empty() ) {
624 auto icnt = std::find_if( m_conts.begin(),m_conts.end(),
625 [&](const std::string& i) { return i == cnt; } );
626 ccnt = std::distance(m_conts.begin(),icnt);
627 if ( icnt == m_conts.end() ) m_conts.push_back(cnt);
628 }
629
630 int clnk=-1;
631 if ( !name.empty() ) {
632 auto ilnk = std::find_if( m_links.begin(),m_links.end(),
633 [&](const std::string& i) { return i == name; } );
634 clnk = std::distance( m_links.begin(), ilnk);
635 if ( ilnk == m_links.end() ) m_links.push_back(name);
636 }
637
638 ref.dbase = cdb;
639 ref.container = ccnt;
640 ref.link = clnk;
641 ref.clid = clid;
642 ref.svc = tech;
643 if ( ref.svc == POOL_ROOT_StorageType ||
644 ref.svc == POOL_ROOTKEY_StorageType ||
645 ref.svc == POOL_ROOTTREE_StorageType ) {
646 ref.svc = ROOT_StorageType;
647 }
648 }
Gaudi::RootDataConnection::addClient
void addClient(const IInterface *client)
Add new client to this data source.
Definition: RootDataConnection.cpp:153
Gaudi::RootDataConnection::lookupClient
bool lookupClient(const IInterface *client) const
Lookup client for this data source.
Definition: RootDataConnection.cpp:165
IOpaqueAddress::par
virtual const std::string * par() const =0
Retrieve String parameters.
Gaudi::RootDataConnection::m_mergeSects
MergeSections m_mergeSects
Database section map for merged files.
Definition: RootDataConnection.h:171
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::shared_ptr
std::string::empty
T empty(T...args)
std::distance
T distance(T...args)
Gaudi::IDataConnection::m_age
int m_age
Age counter.
Definition: IIODataManager.h:33
Gaudi::IDataConnection::fid
const std::string & fid() const
Access file id.
Definition: IIODataManager.h:52
LinkManager.h
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233
Gaudi::IDataConnection::m_name
std::string m_name
Connection name/identifier.
Definition: IIODataManager.h:27
Gaudi::IDataConnection::IoType
IoType
I/O Connection types.
Definition: IIODataManager.h:38
Gaudi::RootDataConnection::saveObj
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.
Definition: RootDataConnection.cpp:462
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93
GaudiMP.FdsRegistry.msg
tuple msg
Definition: FdsRegistry.py:8
MsgStream.h
Gaudi::RootDataConnection::saveStatistics
void saveStatistics(const std::string &statisticsFile)
Save TTree access statistics if required.
Definition: RootDataConnection.cpp:176
std::sscanf
T sscanf(T...args)
Gaudi::RootDataConnection::getDb
const std::string & getDb(int which) const
Access database/file name from saved index.
Definition: RootDataConnection.cpp:447
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
Gaudi::RootDataConnection::m_statistics
std::unique_ptr< TTreePerfStats > m_statistics
I/O read statistics from TTree.
Definition: RootDataConnection.h:153
Gaudi::RootDataConnection::loadObj
int loadObj(const std::string &section, const std::string &cnt, unsigned long entry, DataObject *&pObj)
Load object.
Definition: RootDataConnection.cpp:498
gaudirun.c
tuple c
Definition: gaudirun.py:391
std::isalnum
T isalnum(T...args)
Gaudi::RootDataConnection::ROOT_READ_ERROR
Definition: RootDataConnection.h:95
Gaudi::RootConnectionSetup::compression
static int compression()
Access to global compression level.
Definition: RootDataConnection.cpp:124
Gaudi::RootDataConnection::m_clients
Clients m_clients
Client list.
Definition: RootDataConnection.h:175
Gaudi::RootDataConnection::ContainerSection::length
int length
The length of the section.
Definition: RootDataConnection.h:127
Gaudi::RootDataConnection::getSection
TTree * getSection(const std::string &sect, bool create=false)
Access TTree section from section name. The section is created if required.
Definition: RootDataConnection.cpp:354
MSG::DEBUG
Definition: IMessageSvc.h:18
Gaudi::RootDataConnection::ContainerSection::start
int start
The start entry of the section.
Definition: RootDataConnection.h:125
Gaudi::RootDataConnection::removeClient
size_t removeClient(const IInterface *client)
Remove client from this data source.
Definition: RootDataConnection.cpp:158
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
Gaudi::Utils::Histos::fill
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:36
std
STL namespace.
Gaudi::RootDataConnection::RootDataConnection
RootDataConnection(const IInterface *own, const std::string &nam, std::shared_ptr< RootConnectionSetup > setup)
Standard constructor.
Definition: RootDataConnection.cpp:140
Gaudi::RootRef::container
int container
Definition: RootRefs.h:32
IRegistry::name
virtual const name_type & name() const =0
Name of the directory (or key)
std::end
T end(T...args)
std::iota
T iota(T...args)
Gaudi::IDataConnection::RECREATE
Definition: IIODataManager.h:38
Gaudi::RootConnectionSetup::setMessageSvc
void setMessageSvc(MsgStream *m)
Set message service reference.
Definition: RootDataConnection.cpp:130
Gaudi::RootRef::entry
int entry
Definition: RootRefs.h:32
Gaudi::RootDataConnection::connectWrite
StatusCode connectWrite(IoType typ) override
Open data stream in write mode.
Definition: RootDataConnection.cpp:263
MSG::VERBOSE
Definition: IMessageSvc.h:17
merge_files.sc
int sc
Definition: merge_files.py:167
IOpaqueAddress::svcType
virtual long svcType() const =0
Retrieve service type.
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:54
PoolTool.h
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
Gaudi::RootDataConnection::loadRefs
int loadRefs(const std::string &section, const std::string &cnt, unsigned long entry, RootObjectRefs &refs)
Load references object.
Definition: RootDataConnection.cpp:555
Gaudi::RootObjectRefs
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject...
Definition: RootRefs.h:58
Gaudi::RootDataConnection::m_links
StringVec m_links
Map containing internal links names.
Definition: RootDataConnection.h:165
Gaudi::RootDataConnection::m_params
ParamMap m_params
Parameter map for file parameters.
Definition: RootDataConnection.h:169
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
POOL_ROOTKEY_StorageType
const long POOL_ROOTKEY_StorageType
Definition: ClassID.h:69
Incident.h
CSTR
const string & CSTR
Definition: RootDataConnection.cpp:38
Gaudi::RootDataConnection::m_mergeFIDs
StringVec m_mergeFIDs
Map containing merge FIDs.
Definition: RootDataConnection.h:167
Gaudi::IDataConnection::m_pfn
std::string m_pfn
Physical file name of the connection.
Definition: IIODataManager.h:31
Gaudi::RootRef::dbase
int dbase
Data members to define object location in the persistent world.
Definition: RootRefs.h:32
GaudiPython.Persistency.add
def add(instance)
Definition: Persistency.py:32
Gaudi::RootRef
Persistent reference object.
Definition: RootRefs.h:30
std::vector::push_back
T push_back(T...args)
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
RootTool.h
Gaudi::RootTool
Description:
Definition: RootTool.h:16
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
IOpaqueAddress::clID
virtual const CLID & clID() const =0
Retrieve class information from link.
Gaudi::IDataConnection::name
const std::string & name() const
Connection name.
Definition: IIODataManager.h:48
StatusCode::FAILURE
Definition: StatusCode.h:29
std::replace_if
T replace_if(T...args)
IIncidentSvc.h
Gaudi::RootDataConnection::Tool
Helper class to facilitate an abstraction layer for reading POOL style files with this package...
Definition: RootDataConnection.h:195
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
MsgStream::clear
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
read_lhcb_event_file.evt
tuple evt
Definition: read_lhcb_event_file.py:14
Gaudi::RootDataConnection::getBranch
TBranch * getBranch(const std::string &section, const std::string &branch_name)
Access data branch by name: Get existing branch in read only mode.
Definition: RootDataConnection.h:307
std::runtime_error
STL class.
Gaudi::RootDataConnection::makeRef
void makeRef(IRegistry *pA, RootRef &ref)
Create reference object from registry entry.
Definition: RootDataConnection.cpp:603
std::set::erase
T erase(T...args)
RootUtils.h
Gaudi::RootDataConnection::m_conts
StringVec m_conts
Map containing external container names.
Definition: RootDataConnection.h:163
Gaudi::RootDataConnection::empty
const std::string & empty() const
Empty string reference.
Definition: RootDataConnection.cpp:456
ana.nevt
list nevt
Definition: ana.py:134
Gaudi::RootDataConnection::m_sections
Sections m_sections
Tree sections in TFile.
Definition: RootDataConnection.h:159
Gaudi::RootDataConnection::getMergeSection
std::pair< const RootRef *, const ContainerSection * > getMergeSection(const std::string &container, int entry) const
Access link section for single container and entry.
Definition: RootDataConnection.cpp:575
IRegistry.h
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
ROOT_StorageType
const long ROOT_StorageType
Definition: ClassID.h:52
RootDataConnection.h
std::unique_ptr::reset
T reset(T...args)
std::vector::clear
T clear(T...args)
POOL_ROOT_StorageType
const long POOL_ROOT_StorageType
Definition: ClassID.h:68
Gaudi::RootDataConnection::makeTool
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
Definition: RootDataConnection.cpp:200
IRegistry::address
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
std::move
T move(T...args)
Gaudi::IDataConnection::UPDATE
Definition: IIODataManager.h:38
IOpaqueAddress.h
Gaudi::RootRef::clid
int clid
Definition: RootRefs.h:32
std::pair
Gaudi::RootDataConnection::save
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.
Definition: RootDataConnection.cpp:469
std::unique_ptr::get
T get(T...args)
std::set::insert
T insert(T...args)
std::string::find
T find(T...args)
std::string::length
T length(T...args)
Gaudi::RootDataConnection::connectRead
StatusCode connectRead() override
Open data stream in read mode.
Definition: RootDataConnection.cpp:214
std::vector< std::string >
Gaudi::IDataConnection
ABC describing basic data connection.
Definition: IIODataManager.h:24
Gaudi::RootDataConnection::makeLink
int makeLink(const std::string &p)
Convert path string to path index.
Definition: RootDataConnection.cpp:439
Gaudi::IDataConnection::CREATE
Definition: IIODataManager.h:38
POOL_ROOTTREE_StorageType
const long POOL_ROOTTREE_StorageType
Definition: ClassID.h:70
Gaudi::RootRef::link
int link
Definition: RootRefs.h:32
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151
std::begin
T begin(T...args)
Gaudi::RootDataConnection::m_linkSects
LinkSections m_linkSects
Database link sections.
Definition: RootDataConnection.h:173
GaudiTesting.BaseTest.which
def which(executable)
Definition: BaseTest.py:547
Gaudi::IDataConnection::resetAge
void resetAge()
Reset age.
Definition: IIODataManager.h:60
std::string::c_str
T c_str(T...args)
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
gaudirun.s
string s
Definition: gaudirun.py:245
std::array
STL class.
Gaudi::RootConnectionSetup::setCompression
static long setCompression(const std::string &compression)
Set the global compression level.
Definition: RootDataConnection.cpp:92
MSG::ERROR
Definition: IMessageSvc.h:21
std::string::substr
T substr(T...args)
gaudirun.level
level
Definition: gaudirun.py:261
Gaudi::RootRef::svc
int svc
Definition: RootRefs.h:32
MSG::WARNING
Definition: IMessageSvc.h:20
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
Gaudi::RootDataConnection::m_dbs
StringVec m_dbs
Map containing external database file names (fids)
Definition: RootDataConnection.h:161
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
MSG::INFO
Definition: IMessageSvc.h:19
Gaudi::RootDataConnection::disconnect
StatusCode disconnect() override
Release data stream and release implementation dependent resources.
Definition: RootDataConnection.cpp:322
Gaudi::RootConnectionSetup::setIncidentSvc
void setIncidentSvc(IIncidentSvc *m)
Set incident service reference.
Definition: RootDataConnection.cpp:135
Gaudi::RootDataConnection::enableStatistics
void enableStatistics(const std::string &section)
Enable TTreePerStats.
Definition: RootDataConnection.cpp:186
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
ana.i
list i
Definition: ana.py:128
Gaudi::RootDataConnection::m_refs
TTree * m_refs
Pointer to the reference tree.
Definition: RootDataConnection.h:157
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
strcasecmp.h
Gaudi::RootDataConnection::ContainerSection
Internal helper class, which described a TBranch section in a ROOT file.
Definition: RootDataConnection.h:109
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
Gaudi::RootDataConnection::badWriteError
void badWriteError(const std::string &msg) const
Error handler when bad write statements occur.
Definition: RootDataConnection.cpp:171
DataObject.h
Gaudi::PoolTool
Definition: PoolTool.h:18
std::vector::emplace_back
T emplace_back(T...args)