| The Gaudi Framework v32r1 (f65d50dc)

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