ATLAS Offline Software
xAODEventSelector.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // xAODEventSelector.cxx
8 // Implementation file for class xAODEventSelector
9 // Author: Johannes Elmsheuser, Will Buttinger
11 
12 // STL includes
13 #include <sstream>
14 #include <string>
15 #include <algorithm>
16 #include <vector>
17 #include <stdint.h>
18 
19 // ROOT includes
20 #include "TROOT.h"
22 #include "TClass.h"
23 #include "TFile.h"
24 #include "TKey.h"
25 #include "TLeaf.h"
26 
27 #include "Gaudi/Property.h"
28 
29 // Framework includes
30 #include "GaudiKernel/FileIncident.h"
31 #include "GaudiKernel/IIoComponentMgr.h"
32 #include "GaudiKernel/ISvcLocator.h"
33 #include "GaudiKernel/ITHistSvc.h"
34 #include "GaudiKernel/MsgStream.h"
35 #include "GaudiKernel/StatusCode.h"
36 #include "GaudiKernel/System.h"
37 #include "GaudiKernel/IClassIDSvc.h"
39 #include "AthenaKernel/CLASS_DEF.h"
42 
43 // StoreGate includes
44 
45 #include "SGTools/BuiltinsClids.h" // to make sure we have their clids
46 #include "SGTools/StlMapClids.h" // to make sure we have their clids
47 #include "SGTools/StlVectorClids.h" // to make sure we have their clids
49 #include "StoreGate/StoreGateSvc.h"
50 
51 // EventInfo includes
52 #include "EventInfo/EventInfo.h"
53 #include "EventInfo/EventType.h"
54 #include "EventInfo/EventID.h"
56 
57 // Package includes
58 #include "xAODEventSelector.h"
59 #include "xAODBranchAddress.h"
60 #include "RootGlobalsRestore.h"
61 
62 // xAOD include(s):
63 #include "xAODRootAccess/Init.h"
64 
65 #include "GaudiKernel/ServiceHandle.h"
67 #include <map>
68 
69 
72 #include "xAODCore/tools/IOStats.h"
73 
74 namespace Athena {
75 
79 class xAODEventContext : public ::IEvtSelector::Context
80 {
81 public:
85  virtual ~xAODEventContext() {}
87  virtual void* identifier() const override {
88  void* id ATLAS_THREAD_SAFE = const_cast<xAODEventSelector*>(m_evtsel);
89  return id;
90  }
92  const std::vector<std::string>& files() const { return m_evtsel->m_inputCollectionsName.value(); }
94  const TFile* file() const { return m_evtsel->m_tfile; }
96  StatusCode setFile ATLAS_NOT_THREAD_SAFE (const std::string& fname) {
97  return const_cast<xAODEventSelector*>(m_evtsel)->setFile(fname);
98  }
100  std::size_t fileIndex() const { return m_evtsel->m_collIdx; }
102  int64_t entry() const { return m_evtsel->m_curEvt; }
103 
104 private:
107 };
108 
110  ISvcLocator* svcLoc ) :
111  AthService ( name, svcLoc ),
112  m_dataStore( "StoreGateSvc/StoreGateSvc", name ),
113  m_imetaStore( "StoreGateSvc/InputMetaDataStore", name ),
114  m_ometaStore( "StoreGateSvc/MetaDataStore", name ),
115  m_clidsvc ( "ClassIDSvc", name ),
116  m_dictsvc ( "AthDictLoaderSvc", name ),
117  m_incsvc ( "IncidentSvc", name ),
118  m_poolSvc ( "PoolSvc" , name ),
119  m_ppSvc ( "ProxyProviderSvc" , name ),
120  m_nbrEvts ( 0 ),
121  m_curEvt ( 0 ),
122  m_collIdx ( 0 ),
123  m_collEvts ( ),
124  m_needReload (true),
125  m_rootAddresses (),
126  m_tevent(NULL),
127  m_tfile(NULL),
128  m_tevent_entries(0)
129 {
130 //Properties important to end user:
131  declareProperty( "InputCollections", m_inputCollectionsName,"List of input (ROOT) file names" );
132  declareProperty( "SkipEvents",m_skipEvts = 0,"Number of events to skip at the beginning" );
133  declareProperty( "AccessMode", m_accessMode = -1, "-1 = use TEvent Default; 0 = BranchAccess; 1 = ClassAccess; 2 = AthenaAccess" );
134 
135  declareProperty( "FillEventInfo", m_fillEventInfo=false,"If True, will fill old EDM EventInfo with xAOD::EventInfo content, necessary for database reading (IOVDbSvc)");
136 
137  declareProperty( "PrintPerfStats", m_printPerfStats=false,"If True, at end of job will print the xAOD perf stats");
138 
139 //Expert Properties:
140  declareProperty( "EvtStore", m_dataStore, "Store where to publish data");
141  declareProperty( "ProxyProviderSvc" , m_ppSvc , "The ProxyProviderSvc that we should register ourself in and connect the EvtStore to");
142  declareProperty( "InputMetaStore",m_imetaStore, "Store where to publish (input) metadata");
143  declareProperty( "MetaStore",m_ometaStore, "Store where to publish (output) metadata");
144  declareProperty( "TreeName",m_tupleName = "CollectionTree","Name of the TTree to load/read from input file(s)" );
145  declareProperty( "MetaDataTreeName", m_metadataName = "MetaData","Name of the TTree to load/read metadata from input file(s)" );
146 
147  declareProperty( "ReadMetaDataWithPool", m_readMetadataWithPool=false, "If true, using POOL to read metadata, will ensure input file is registered with catalog");
148  declareProperty( "printEventProxyWarnings", m_printEventProxyWarnings);
149 
150 #ifndef XAOD_ANALYSIS
151  declareProperty( "CollectionType", m_collectionType="", "Compability flag for RecExCommon");
152 #endif
153 
154 }
155 
156 // Destructor
159 {}
160 
162 {
163  ATH_MSG_VERBOSE ("Enter xAODEventSelector initialization...");
164 
165  CHECK( m_clidsvc.retrieve() );
166  CHECK( m_dictsvc.retrieve() );
167 
168  if ( m_tupleName.value().empty() ) {
169  ATH_MSG_ERROR("You have to give a TTree name to read from the ROOT files !");
170  return StatusCode::FAILURE;
171  }
172 
173  const std::size_t nbrInputFiles = m_inputCollectionsName.value().size();
174  if ( nbrInputFiles < 1 ) {
175  ATH_MSG_ERROR("You need to give at least 1 input file !!" << endmsg
176  << "(Got [" << nbrInputFiles << "] file instead !)");
177  return StatusCode::FAILURE;
178  } else {
179  ATH_MSG_INFO("Selector configured to read [" << nbrInputFiles << "] file(s)...");
180  }
181 
182  ATH_MSG_DEBUG("Calling xAOD::Init...");
183  int old_level = gErrorIgnoreLevel;
184  gErrorIgnoreLevel = kWarning;
185  xAOD::Init().ignore();
186  gErrorIgnoreLevel = old_level;
187  //if using the AthROOTErrorHandlerSvc, need to initialize it once again to give back error handling control to svc
188  if(serviceLocator()->existsService("AthROOTErrorHandlerSvc")) {
189  ServiceHandle<IService> ehSvc("AthROOTErrorHandlerSvc",name());
190  CHECK( ehSvc.retrieve() );
191  CHECK( ehSvc->initialize() ); //gives back control to svc
192  CHECK( ehSvc.release() );
193  }
194  switch(m_accessMode) {
195  case -1: ATH_MSG_INFO("Using DEFAULT xAOD access mode (usually same as CLASS mode)"); break;
196  case 0: ATH_MSG_INFO("Using BRANCH xAOD access mode"); break;
197  case 1: ATH_MSG_INFO("Using CLASS xAOD access mode"); break;
198  case 2: ATH_MSG_INFO("Using ATHENA xAOD access mode"); break;
199  }
200  if(m_accessMode != -1) {
201  m_tevent = new xAOD::xAODTEvent(xAOD::TEvent::EAuxMode(m_accessMode)); //our special class inheriting from xAOD::TEvent
202  } else {
203  m_tevent = new xAOD::xAODTEvent(); //our special class inheriting from xAOD::TEvent
204  }
206 
207  //use the first file to decide if reading metadata with POOL is ok
209  std::unique_ptr<TFile> f( TFile::Open( m_inputCollectionsName.value()[0].c_str() ) );
210  if(!f) {
211  ATH_MSG_ERROR("Failed to open first input file: " << m_inputCollectionsName.value()[0]);
212  return StatusCode::FAILURE;
213  }
214  if(!f->Get("##Shapes")) {
215  ATH_MSG_INFO("First file is not POOL file (e.g. is CxAOD), so reading metadata with xAOD::TEvent instead");
216  m_readMetadataWithPool = false;
217  }
218  f->Close();
219  }
220 
221 
222  {
223  // register this service for 'I/O' events
224  ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
225  if (!iomgr.retrieve().isSuccess()) {
226  ATH_MSG_FATAL("Could not retrieve IoComponentMgr !");
227  return StatusCode::FAILURE;
228  }
229  if (!iomgr->io_register(this).isSuccess()) {
230  ATH_MSG_FATAL("Could not register myself with the IoComponentMgr !");
231  return StatusCode::FAILURE;
232  }
233  // register input file's names with the I/O manager
234  const std::vector<std::string>& incol = m_inputCollectionsName.value();
235  bool allGood = true;
236  for (std::size_t icol = 0, imax = incol.size(); icol < imax; icol++) {
237  if (!iomgr->io_register(this,
239  incol[icol]).isSuccess()) {
240  ATH_MSG_FATAL("could not register [" << incol[icol] << "] for output !");
241  allGood = false;
242  } else {
243  ATH_MSG_VERBOSE("io_register[" << this->name() << "](" << incol[icol] << ") [ok]");
244  }
245  }
246  if (!allGood) {
247  return StatusCode::FAILURE;
248  }
249  }
250 
251  if (!do_init_io().isSuccess()) {
252  return StatusCode::FAILURE;
253  }
254 
255  // retrieve event stores
256  // this needs to happen *after* having initialized the i/o
257  // as our branches (which need a valid m_ntuple pointer)
258  // may be asked to be registered as we are a ProxyProvider.
259  // retrieving the event store will poke the ProxyProviderSvc...
260 /*
261  if ( !m_dataStore.retrieve().isSuccess() ) {
262  ATH_MSG_ERROR("Could not retrieve [" << m_dataStore.typeAndName() << "] !!");
263  return StatusCode::FAILURE;
264  }
265 
266  // ditto for (input) meta data store
267  if (!m_imetaStore.retrieve().isSuccess()) {
268  ATH_MSG_ERROR("Could not retrieve [" << m_imetaStore.typeAndName() << "] !!");
269  return StatusCode::FAILURE;
270  }
271 
272  // ditto for (output) meta data store
273  if (!m_ometaStore.retrieve().isSuccess()) {
274  ATH_MSG_ERROR
275  ("Could not retrieve [" << m_ometaStore.typeAndName() << "] !!");
276  return StatusCode::FAILURE;
277  }
278 */
279 
280  //ensure the xAODCnvSvc is listed in the EventPersistencySvc
281  ServiceHandle<IProperty> epSvc("EventPersistencySvc",name());
282 
283 
284  std::vector<std::string> propVal;
285  CHECK( Gaudi::Parsers::parse( propVal , epSvc->getProperty("CnvServices").toString() ) );
286  bool foundSvc(false); bool foundPoolSvc(false);
287  for(const std::string& s : propVal) {
288  if(s=="Athena::xAODCnvSvc") { foundSvc=true; }
289  if(s=="AthenaPoolCnvSvc") { foundPoolSvc=true; } //only need this if in hybrid mode
290  }
291  if(!foundSvc) propVal.push_back("Athena::xAODCnvSvc");
292  if(!foundPoolSvc && m_readMetadataWithPool) propVal.push_back("AthenaPoolCnvSvc");
293 
294  if(!foundSvc || (!foundPoolSvc && m_readMetadataWithPool)) {
295  CHECK( epSvc->setProperty("CnvServices", Gaudi::Utils::toString( propVal ) ));
296  }
297 
298 
299  //we should also add ourself as a proxy provider
300  CHECK( m_ppSvc.retrieve() );
301 
302  //ensure the MetaDataSvc is added as a provider first, if we are in hybrid mode
304  std::vector<std::string> propVal;
305  IProperty* prop = dynamic_cast<IProperty*>(&*m_ppSvc);
306  if (!prop) {
307  return StatusCode::FAILURE;
308  }
309  CHECK( Gaudi::Parsers::parse( propVal , prop->getProperty("ProviderNames").toString() ) );
310  bool foundSvc(false);
311  for(const std::string& s : propVal) {
312  if(s=="MetaDataSvc") { foundSvc=true; break; }
313  }
314  if(!foundSvc) {
315  propVal.push_back("MetaDataSvc");
316  IProperty* prop = dynamic_cast<IProperty*>(&*m_ppSvc);
317  if (!prop) {
318  return StatusCode::FAILURE;
319  }
320  CHECK( prop->setProperty("ProviderNames", Gaudi::Utils::toString( propVal ) ));
321  }
322  }
323 
324  //now we add ourself as a provider
325  m_ppSvc->addProvider( this );
326  //trigger a reload of proxies in the storegate, which will poke the proxyprovidersvc
327  //not actually needed
328  //CHECK( m_dataStore->loadEventProxies() );
329 
330 
331  //finally ensure the storegate has our proxy set in it
332  //FIXME: this doesnt seem to allow multi storegates on the fly ???
333  //m_dataStore->setProxyProviderSvc( &*m_ppSvc );
334 
335  CHECK( m_ppSvc.release() );
336 
337 
338  //load the first file .. this is so metadata can be read even if no events present
339  //checked above that there's at least one file
340  CHECK( setFile(m_inputCollectionsName.value()[0]) );
341 
342  //first FirstInputFile incident so that input metadata store is populated by MetaDataSvc
343  m_incsvc->fireIncident(FileIncident(name(), "FirstInputFile", m_inputCollectionsName.value()[0]));
344 
346 
347 
348  return StatusCode::SUCCESS;
349 }
350 
352 {
353  ATH_MSG_VERBOSE ("Finalize...");
354  // FIXME: this should be tweaked/updated if/when a selection function
355  // or filtering predicate is applied (one day?)
356  ATH_MSG_INFO ("Total events read: " << (m_nbrEvts - m_skipEvts));
357 
358  if(m_printPerfStats) {
361  }
362 
363 
364  return StatusCode::SUCCESS;
365 }
366 
367 // Query the interfaces.
368 // Input: riid, Requested interface ID
369 // ppvInterface, Pointer to requested interface
370 // Return: StatusCode indicating SUCCESS or FAILURE.
371 // N.B. Don't forget to release the interface after use!!!
372 StatusCode
373 xAODEventSelector::queryInterface( const InterfaceID& riid,
374  void** ppvInterface )
375 {
376  if ( IEvtSelector::interfaceID().versionMatch(riid) ) {
377  *ppvInterface = dynamic_cast<IEvtSelector*>(this);
378  } else if ( IEvtSelectorSeek::interfaceID().versionMatch(riid) ) {
379  *ppvInterface = dynamic_cast<IEvtSelectorSeek*>(this);
380  } else if ( IIoComponent::interfaceID().versionMatch(riid) ) {
381  *ppvInterface = dynamic_cast<IIoComponent*>(this);
382  } else {
383  // Interface is not directly available : try out a base class
384  return AthService::queryInterface(riid, ppvInterface);
385  }
386  addRef();
387  return StatusCode::SUCCESS;
388 }
389 
391 // Const methods:
393 
395 xAODEventSelector::next( IEvtSelector::Context& ctx ) const
396 {
397  // std::cout << "::next(fidx=" << m_collIdx << ", eidx=" << m_curEvt << ")"
398  // << std::endl;
399  ATH_MSG_DEBUG ("next() : iEvt " << m_curEvt);
400 
401  // get evt context
402  xAODEventContext* rctx = dynamic_cast<xAODEventContext*>(&ctx);
403  if ( 0 == rctx ) {
404  ATH_MSG_ERROR ("Could not dyn-cast to xAODEventContext !!");
405  throw GaudiException("xAODEventSelector::next() - Unable to get xAODEventContext","xAODEventSelector",StatusCode::FAILURE);
406  }
407 
408 
409  const TFile *file = rctx->file();
410  if(file && m_nbrEvts==0) {
411  //fire the BeginInputFile incident for the first file
412  m_incsvc->fireIncident(FileIncident(name(), "BeginInputFile", file->GetName()));
413  }
414 
415  if (!file) { //must be starting another file ...
416  auto& fnames = rctx->files();
417  //std::size_t fidx = rctx->fileIndex();
418  if( rctx->setFile("").isFailure() ) {
419  throw GaudiException("xAODEventSelector::next() - Fatal error when trying to setFile('')","xAODEventSelector",StatusCode::FAILURE);
420  }
421 
422  while( m_tevent_entries == 0 ) { //iterate through files until we have one with entries
423  if (m_collIdx < int(rctx->files().size())) {
424  const std::string& fname = fnames[m_collIdx];
425  if( rctx->setFile( fname ).isFailure() ) {
426  throw GaudiException("xAODEventSelector::next() - Fatal error when trying to setFile('" + fname + "')","xAODEventSelector",StatusCode::FAILURE);
427  }
428  ATH_MSG_DEBUG("TEvent entries = " << m_tevent_entries);
429  //fire incident for this file ..
430  m_incsvc->fireIncident(FileIncident(name(), "BeginInputFile", rctx->file()->GetName()));
431  } else {
432  // end of collections
433  return StatusCode::FAILURE; //this is a valid failure ... athena will interpret as 'finished looping'
434  }
435  if( m_tevent_entries==0) m_collIdx++;
436 
437 
438  } //end of while loop
439 
440  }
441 
442 
443  ATH_MSG_DEBUG("m_curEvt=" << m_curEvt);
444 
445  //Infer the local entry (entry of current file) from the global entry
446 
447  int64_t global_entry = rctx->entry(); //the actual event counter
448  int64_t entry = global_entry;
449  if (m_collEvts[m_collIdx].min_entries < 0) {
450  // need to trigger collmetadata...
451  const_cast<xAODEventSelector*>(this)->find_coll_idx(entry);
452  }
453  // rctx::entry is the *global* entry number.
454  // we need the local one...
455  entry = global_entry - m_collEvts[m_collIdx].min_entries; //actual entry in the current file
456 
457 
458 
459  if ( m_tevent_entries > entry ) {
460 
461  // Load the event:
462  if( m_tevent->getEntry( entry ) < 0 ) {
463  ATH_MSG_ERROR( "Failed to load entry " << static_cast< int >( entry ) );
464  throw GaudiException("xAODEventSelector::next() - xAOD::TEvent::getEntry returned less than 0 bytes","xAODEventSelector",StatusCode::FAILURE);
465  }
466 
467  ++m_nbrEvts;
468  m_curEvt = global_entry + 1;
469 
470  // std::cout << "--event-info--" << std::endl;
471  // event info
472 
473  // EventInfo is required, otherwise Athena will crash
474  const xAOD::EventInfo* xaodEventInfo = 0;
475  if(m_fillEventInfo) {
476  if(m_tevent->retrieve( xaodEventInfo , "EventInfo").isFailure()) {
477  ATH_MSG_ERROR("Could not find xAOD::EventInfo");
478  throw GaudiException("xAODEventSelector::next() - Could not find xAOD::EventInfo","xAODEventSelector",StatusCode::FAILURE);
479  }
480  }
481  EventType* evtType = new EventType;
482  //const std::size_t runNbr = (xaodEventInfo) ? xaodEventInfo->runNumber() : 0;
483  EventInfo* evtInfo = new EventInfo(
484  (xaodEventInfo) ? new EventID(xaodEventInfo->runNumber(), xaodEventInfo->eventNumber(), xaodEventInfo->timeStamp(), xaodEventInfo->timeStampNSOffset(), xaodEventInfo->lumiBlock(), xaodEventInfo->bcid()) : new EventID(0, m_curEvt-1,0 ), evtType);
485  if ( !m_dataStore->record( evtInfo, "EventInfo" ).isSuccess() ) {
486  ATH_MSG_ERROR ("Could not record EventInfo !");
487  delete evtInfo; evtInfo = 0;
488  throw GaudiException("xAODEventSelector::next() - Could not record EventInfo","xAODEventSelector",StatusCode::FAILURE);
489  }
490 
491  return StatusCode::SUCCESS;
492 
493  } else {
494  // file is depleted
495  auto& fnames = rctx->files();
496  std::size_t fidx = rctx->fileIndex();
497  m_incsvc->fireIncident(FileIncident(name(), "EndInputFile", fnames[fidx]));
498 
499  // prepare for next file, if any...
500  // std::cout << "=========================================================="
501  // << std::endl;
502  // std::cerr << "::switch to next file...\n";
503 
504  // iterate over our "cached" transient addresses,
505  // marking them as garbage and dropping the RootBranchAddress (as a side effect of
506  // ::setAddress(NULL).
507  // this way, the next time we hit ::createRootBranchAddress or ::updateAddress
508  // all internal states are kosher.
509 
510  /*
511  * Problem for rel22 --
512  * The proxyProviderSvc 'moves' the transient addresses created in this class
513  * and thus invalidates them.
514  * The sequence is proxyProviderSvc will call "loadAddresses" method below but
515  * when it puts them into a DataProxy it will move the addresses so they are now invalid
516  *
517  * Shortest route to fixing this is just to clear the addresses and not touch them again
518  */
519  self()->m_rootAddresses.clear();
520 
521  for (auto& iaddr : self()->m_rootAddresses) {
522  iaddr.second = false; // mark as invalid
523  SG::TransientAddress* taddr = iaddr.first;
524  taddr->setAddress(NULL);
525  }
526  const bool forceRemove = false;
527  CHECK( m_dataStore->clearStore(forceRemove) ); //must clear the storegate so that any tampering user did in EndInputFile incident is cleared
528  m_needReload = true;
529 
530  m_collIdx += 1;
531  CHECK( rctx->setFile("") );
532  return next(*rctx);
533  }
534 
535  // NOT REACHED
536  // std::cout << "***end of collections***" << std::endl;
537  // end of collections
538  //return StatusCode::FAILURE;
539 }
540 
541 StatusCode xAODEventSelector::next( Context& ctx, int jump ) const
542 {
543  ATH_MSG_DEBUG ("next(" << jump << ") : iEvt " << m_curEvt);
544 
545  if (self()->seek(ctx, m_curEvt + jump).isSuccess()) {
546  return StatusCode::FAILURE;
547  }
548  return next(ctx);
549 }
550 
552 xAODEventSelector::previous( IEvtSelector::Context& ctx ) const
553 {
554  return next( ctx, -1 );
555 }
556 
557 StatusCode
558 xAODEventSelector::previous( Context& ctx, int jump ) const
559 {
560  return next( ctx, -jump );
561 }
562 
564 xAODEventSelector::last( Context& /*ctxt*/ ) const
565 {
566  ATH_MSG_ERROR ("............. Last Event Not Implemented .............");
567  return StatusCode::FAILURE;
568 }
569 
570 
571 StatusCode
572 xAODEventSelector::rewind( Context& ctxt ) const
573 {
574  return self()->seek(ctxt, 0);
575 }
576 
578 xAODEventSelector::createContext( Context*& refCtx ) const
579 {
580  xAODEventContext *ctx = new xAODEventContext(this);
581  refCtx = ctx;
582  return StatusCode::SUCCESS;
583 }
584 
586 xAODEventSelector::createAddress( const Context& /*refCtx*/,
587  IOpaqueAddress*& /*addr*/ ) const
588 {
589  //std::cerr << "::TTES::createAddress()...\n";
590  return StatusCode::SUCCESS;
591 }
592 
594 xAODEventSelector::releaseContext( Context*& refCtxt ) const
595 {
596  if(refCtxt==0) return StatusCode::SUCCESS; //added to avoid warning from MetaDataSvc, which passes an empty context
597  xAODEventContext *ctx = dynamic_cast<xAODEventContext*>(refCtxt);
598  if ( ctx ) {
599  delete ctx; ctx = 0;
600  return StatusCode::SUCCESS;
601  }
602 
603  return StatusCode::FAILURE;
604 }
605 
607 xAODEventSelector::resetCriteria( const std::string&, Context& ) const
608 {
609  ATH_MSG_ERROR ("............. resetCriteria Not Implemented .............");
610  return StatusCode::FAILURE;
611 }
612 
614 // Non-const methods:
616 
622 xAODEventSelector::seek (Context& refCtxt, int evtnum) const
623 {
624  // std::cout << "::seek - evtnum=" << evtnum
625  // << " curevt=" << m_curEvt
626  // << " curcol=" << m_collIdx
627  // << std::endl;
628  long coll_idx = find_coll_idx(evtnum);
629  // std::cout << "::seek - evtnum=" << evtnum
630  // << " curevt=" << m_curEvt
631  // << " curcol=" << m_collIdx
632  // << " colidx=" << coll_idx
633  // << std::endl;
634  if (coll_idx == -1 && evtnum < m_curEvt) {
635  coll_idx = m_collIdx;
636  }
637 
638  if (coll_idx == -1) {
639  ATH_MSG_INFO("seek: reached end of input.");
640  return StatusCode::RECOVERABLE;
641  }
642 
643  if (coll_idx != m_collIdx) {
644  // tell everyone we switched files...
645  xAODEventContext* rctx = dynamic_cast<xAODEventContext*>(&refCtxt);
646  if (!rctx) {
647  return StatusCode::FAILURE;
648  }
649  ATH_CHECK(rctx->setFile(""));
650  }
651 
652  m_collIdx = coll_idx;
653  m_curEvt = evtnum;
654 
655  return StatusCode::SUCCESS;
656 }
657 
662 int
663 xAODEventSelector::curEvent (const Context& /*refCtxt*/) const
664 {
665  return m_curEvt;
666 }
667 
670 StatusCode
672 {
673  ATH_MSG_VERBOSE("I/O reinitialization...");
674 
675  ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
676  if (!iomgr.retrieve().isSuccess()) {
677  ATH_MSG_FATAL("Could not retrieve IoComponentMgr !");
678  return StatusCode::FAILURE;
679  }
680  if (!iomgr->io_hasitem(this)) {
681  ATH_MSG_FATAL("IoComponentMgr does not know about myself !");
682  return StatusCode::FAILURE;
683  }
684  std::vector<std::string> inputCollections = m_inputCollectionsName.value();
685 
686  for (std::size_t
687  i = 0,
688  imax = m_inputCollectionsName.value().size();
689  i < imax;
690  ++i) {
691  std::string &fname = inputCollections[i];
692  // std::cout << "--retrieve new name for [" << fname << "]...\n";
693  if (!iomgr->io_contains(this, fname)) {
694  ATH_MSG_ERROR("IoComponentMgr does not know about [" << fname << "] !");
695  return StatusCode::FAILURE;
696  }
697  if (!iomgr->io_retrieve(this, fname).isSuccess()) {
698  ATH_MSG_FATAL("Could not retrieve new value for [" << fname << "] !");
699  return StatusCode::FAILURE;
700  }
701  // std::cout << "--> [" << fname << "]\n" << std::flush;
702  }
703  // all good... copy over.
705 
706  // remove our EventInfo if any...
707  // {
708  // const bool force_remove = true;
709  // if (!m_dataStore->clearStore(force_remove).isSuccess()) {
710  // ATH_MSG_ERROR("could not clear event store!");
711  // return StatusCode::FAILURE;
712  // } else {
713  // ATH_MSG_INFO("sgdump: \n" << m_dataStore->dump());
714  // }
715  // }
716 
717  // std::cout << "--> do_init_io...\n" << std::flush;
718  if (!do_init_io().isSuccess()) {
719  return StatusCode::FAILURE;
720  }
721 
722  ATH_MSG_INFO("I/O reinitialization... [done]");
723  return StatusCode::SUCCESS;
724 }
725 
726 
730 StatusCode
732  tadList& /*tads*/)
733 {
734  // std::cerr << "TTES::preLoadAddresses(" << int(storeID)
735  // << "," << tads.size()
736  // << ")...\n";
737  return StatusCode::SUCCESS;
738 }
739 
741 StatusCode
743 {
744  if (m_needReload || m_rootAddresses.empty()) {
745  //CHECK(createMetaDataRootBranchAddresses());
746  return createRootBranchAddresses(storeID, tads);
747  }
748 
749  return StatusCode::SUCCESS;
750 }
751 
753 StatusCode
755  const EventContext& /*ctx*/)
756 {
757  // check if this tad is known to us.
758  if (tad) {
759  auto itr = m_rootAddresses.find(tad);
760  if ( itr != m_rootAddresses.end() && itr->second ) {
761  return StatusCode::SUCCESS;
762  }
763  ATH_MSG_DEBUG("updateAddress: address [" << tad->clID() << "#"
764  << tad->name() << ") NOT known to us.");
765  return StatusCode::FAILURE;
766  }
767 
768  // do nothing.
769  return StatusCode::SUCCESS;
770 }
772 
774 // Protected methods:
776 
777 
778 
779 
780 StatusCode
782  tadList &tads)
783 {
784  if (storeID != StoreID::EVENT_STORE) {
785  ATH_MSG_INFO("-- not the event-store --");
786  return(StatusCode::SUCCESS);
787  }
788 
789  if (0 == m_tfile) {
790  ATH_MSG_ERROR("null pointer to n-tuple !");
791  return StatusCode::FAILURE;
792  }
793 
794  TTree* inputTree = dynamic_cast<TTree*>(m_tfile->Get(m_tupleName.value().c_str()));
795 
796  if(inputTree!=0) {
797 
798 
799  ATH_MSG_DEBUG("Reading xAOD::EventFormat");
800 
801  // m_tevent->dump();
802 
803  const void* value_ptr = m_tevent; //passed as 'parameter' to the address object
804 
805  std::set<std::string> missingAux;
806 
807  for( auto itr = m_tevent->inputEventFormat()->begin(); itr!=m_tevent->inputEventFormat()->end();++itr) {
808  if(inputTree->GetBranch(itr->second.branchName().c_str())==0) continue; //skip branches that are not available in the input collection
809  ATH_MSG_VERBOSE("EFE:" << itr->first << " branchName = " << itr->second.branchName() << " className=" << itr->second.className());
810  CLID id = 0;
811  if( m_clidsvc->getIDOfTypeInfoName(itr->second.className(), id).isFailure() &&
812  m_clidsvc->getIDOfTypeName(itr->second.className(), id).isFailure()) {
813  //if this is an AuxStore (infer if key ends in Aux.), its possible we schema-evolved away from the version in the input file, but that this evolution is actually 'ok' in some cases. So don't print an error if the CLID is missing for an Aux, but we will print a warning at the end for these aux stores
814  if(itr->second.branchName().compare(itr->second.branchName().length()-4,4,"Aux.")==0) {
815  missingAux.insert( itr->second.className() );continue;
816  } else {
817  //vectors can be missing their std:: prefix, so add that and retry before failing
818  TString className = itr->second.className();
820  //ALT solution to this is do what RootNtupleEventSelector does: uses TClass:GetClass
821  //and GetTypeInfo() method to get the proper type info
822  TClass *cls = TClass::GetClass(className);
823  if(cls) {
824  const std::type_info *ti = cls->GetTypeInfo();
825  if(ti) className = System::typeinfoName(*ti);
826  }
827 
828  if( m_clidsvc->getIDOfTypeInfoName(className.Data(), id).isFailure() &&
829  m_clidsvc->getIDOfTypeName(className.Data(), id).isFailure()) {
830  ATH_MSG_WARNING("No CLID for class " << itr->second.className() << " , cannot read " << itr->second.branchName());
831  continue;
832  }
833  }
834  }
835 
836  const std::string br_name = itr->second.branchName();
837 
839  (POOL_ROOTTREE_StorageType, id,
840  m_tupleName.value(),
841  br_name,
842  (unsigned long)(value_ptr),
843  (unsigned long)(0)); //IMPORTANT THIS IS 0: signals to xAODBranchAddress to read event-level info (see setTEventAddress)
844  // recycle old rootaddress, if any.
845  SG::TransientAddress* taddr = NULL;
846  // FIXME: should we only iterate over m_rootAddresses which have been marked
847  // as invalid ? (ie: iaddr->second == false)
848  // probably not worth it... (but depends on the "occupancy")
849  for (auto
850  iaddr = m_rootAddresses.begin(),
851  iaddre= m_rootAddresses.end();
852  iaddr != iaddre;
853  ++iaddr) {
854  SG::TransientAddress *old = iaddr->first;
855  if (old->clID() == id &&
856  old->name() == br_name) {
857  // found a "cached" transient address which corresponds to this clid+key
858  // bind it to our new RootBranchAddress...
859  old->setAddress(addr);
860  taddr = old;
861  iaddr->second = true; // mark as valid
862  break;
863  }
864  }
865  if (taddr == NULL) {
866  taddr = new SG::TransientAddress(id, br_name, addr);
867  taddr->setProvider(this, storeID);
868  taddr->clearAddress(false);
869  // only add the *new* TransientAddress to the input list as the *old* ones
870  // are already tracked by the datastore (via the sticky proxies)
871  tads.push_back(taddr);
872  // note: we can store this taddr *b/c* we don't clearAddress it
873  // ie: b/c we just called clearAddress(false) so it will be recycled
874  // over the events.
875  m_rootAddresses.insert(std::make_pair(taddr, true));
876  }
877  // }
878  }
879 
880 
881  if(missingAux.size()) {
882  std::string allAux; for(auto& s : missingAux) allAux += s + ", ";
883  ATH_MSG_WARNING("The following AuxStore types are not directly accessible (missing CLID, possibly from schema evolution): " << allAux);
884  }
885  } //end if block of requiring input tree to exist
886  else {
887  ATH_MSG_DEBUG("No input collection " << m_tupleName.value() << " found in input file " << m_tfile->GetTitle() );
888  }
889 
890  m_needReload = false;
891  // remember that we need to fire a BeginInputFile incident.
892  // we can't fire it just now as some client may need the tree and its
893  // content loaded in the evtstore when their ::handle method is
894  // called.
895  // so we do it later.
896  //MOVED TO handle method - which is fired on BeginEvent after StoreGateSvc
897  //m_fireBIF = true;
898 
899  ATH_MSG_DEBUG("In xAODEventSelector::createRootBranchAddresses end ...");
900 
901  return StatusCode::SUCCESS;
902 }
903 
904 StatusCode
906 {
907 
908  ATH_MSG_DEBUG("In xAODEventSelector::createMetaDataRootBranchAddresses start ...");
909 
910  if ( 0 == m_tfile ) {
911  ATH_MSG_ERROR ("Could not get m_tfile !!");
912  throw "xAODEventSelector: Unable to get m_tfile";
913  }
914 
915  //FIXME JE
916  ATH_MSG_DEBUG("m_metadataName.value().c_str() = " << m_metadataName.value().c_str() );
917  TTree* tree = dynamic_cast<TTree*>(m_tfile->Get(m_metadataName.value().c_str()));
918  ATH_MSG_DEBUG("m_tfile = " << m_tfile );
919  ATH_MSG_DEBUG("tree = " << tree );
920  if (!tree) std::abort();
921  TObjArray *leaves = tree->GetListOfLeaves();
922  if (!leaves) {
923  ATH_MSG_INFO("no leaves!!");
924  return StatusCode::SUCCESS;
925  }
926 
927  // loop over leaves
928  for (Int_t i = 0; i < leaves->GetEntries(); ++i) {
929  TLeaf *leaf = (TLeaf *)leaves->At(i);
930  TBranch *branch = leaf->GetBranch();
931  if (branch) {
932 
933  CLID id = 0;
934  const void* value_ptr = m_tevent;
935  const std::string type_name = leaf->GetTypeName();
936  const std::string br_name = branch->GetName();
937  // Skip if type_name does contain xAOD, ie. is not an xAOD container
938  const std::string toCheck = "xAOD::";
939  if (type_name.find(toCheck) == std::string::npos) {
940  ATH_MSG_DEBUG("** Skip type-name = " << type_name << ", br_name = " << br_name );
941  continue;
942  }
943  const std::string sg_key = br_name;//m_tupleName.value()+"/"+br_name;
944  TClass *cls = TClass::GetClass(type_name.c_str());
945  const std::type_info *ti = 0;
946 
947  // Skip the EventFormat branch. That must not be disturbed by the
948  // generic metadata handling.
949  if( br_name == "EventFormat" ) continue;
950 
951  if (cls) {
952  ti = cls->GetTypeInfo();
953  // first, try to load a dict for that class...
954  if (ti) {
955  m_dictsvc->load_type(*ti);
956  }
957  if (!ti) {
958  ATH_MSG_DEBUG("could not find a type-info for [" <<
959  type_name << "]");
960  continue;
961  }
962 
963  // Find the clid for the typeInfo
965 
966  if (id == 0) {
967  ATH_MSG_DEBUG("** could not find a CLID for type-name ["
968  << type_name << "]");
969  continue;
970  }
971 
972 
973 
974  ATH_MSG_DEBUG("id = " << id << ", m_metadataName.value() = " << m_metadataName.value() << ", br_name = " << br_name << ", value_ptr = " << value_ptr);
976  (POOL_ROOTTREE_StorageType, id,
977  m_metadataName.value(),
978  br_name,
979  (unsigned long)(value_ptr),
980  (unsigned long)(1)); //IMPORTANT THIS IS 1: signals to BranchAddress to read metadata
981  if (!m_imetaStore->recordAddress(br_name, addr, true).isSuccess()) {
982  ATH_MSG_ERROR("could not record address at [" << br_name << "] in store ["
983  << m_imetaStore->name() << "]");
984  delete addr; addr = 0;
985  }
986  // SG::TransientAddress* taddr = new SG::TransientAddress
987  // (id, sg_key, addr);
988  // taddr->setProvider(this);
989  // taddr->clearAddress(true);
990  // tads.push_back(taddr);
991  }
992  }
993  }
994 
995  ATH_MSG_DEBUG("In xAODEventSelector::createMetaDataRootBranchAddresses end ...");
996 
997  return StatusCode::SUCCESS;
998 }
999 
1000 
1001 TFile*
1003 {
1004  TFile* file = NULL;
1005  if(fname.empty()) return file; //if blank, return 0
1006  RootGlobalsRestore rgr;
1007  //see if file already open
1008  file = (TFile*)gROOT->GetListOfFiles()->FindObject(fname.c_str());
1009  if (!file) {
1010  //open the file
1011  file = TFile::Open(fname.c_str(), "READ");
1012  if (file) file->SetName(fname.c_str());
1013  }
1014  //check file is ok before returning
1015  if (!file || file->IsZombie()) {
1016  ATH_MSG_ERROR("could not open next file in input collection ["
1017  << fname << "]");
1018  if (file) {
1019  file->Close();
1020  }
1021  return 0;
1022  }
1023  return file;
1024 }
1025 
1026 //move onto given file
1028 
1029  TFile* newFile = fetchNtupleFile(fname);
1030  if(!newFile && !fname.empty()) {
1031  ATH_MSG_FATAL( "xAODEventSelector: Unable to fetch Ntuple: " << fname);
1032  return StatusCode::FAILURE; //failed to load file
1033  }
1034 
1035  if(m_tfile && m_tfile != newFile) {
1036  const std::string currFile = m_tfile->GetName();
1037  //disconnect pool if necessary ... always fire this, hopefully it is safe even if not needed
1038  m_poolSvc->disconnectDb("PFN:"+currFile).ignore();
1039  //close existing file
1040  m_tfile->Close();
1041  //we should also cleanup after pool, in case it has left open files dangling
1042  }
1043  m_tfile = newFile;
1044  m_tevent_entries = 0; //will set in a moment
1045 
1046  if(!m_tfile) return StatusCode::SUCCESS; //must have been setting to blank file
1047 
1048  if(m_tevent->readFrom( m_tfile ).isFailure()) {
1049  ATH_MSG_FATAL( "xAODEventSelector: TEvent cannot read " << fname);
1050  return StatusCode::FAILURE;
1051  }
1052 
1054 
1055  //need to load metadata for file
1056  if (!m_imetaStore->clearStore().isSuccess()) {
1057  ATH_MSG_INFO("could not clear store [" << m_imetaStore.typeAndName() << "]");
1058  return StatusCode::FAILURE;
1059  }
1060 
1061 
1063  //ensure input file collection created
1064  ATH_MSG_DEBUG("Creating poolsvc collection for " << fname);
1065  m_poolSvc->createCollection( "ImplicitCollection" , "PFN:"+fname , fname ); //FIXME: this throws exceptions which get in the way of debugging with gdb :-(
1066 
1067  //metadata will be read by MetaDataSvc, triggered by the BeginInputFile call
1068  } else {
1069  if (!createMetaDataRootBranchAddresses().isSuccess()) {
1070  ATH_MSG_ERROR("Could not load metadata");
1071  }
1072  }
1073 
1074 
1075 
1076  return StatusCode::SUCCESS;
1077 
1078 }
1079 
1080 
1081 StatusCode
1083 {
1084  // std::cout << "::fetchNtuple..." << std::endl;
1085 
1086  // initialize some helper structures and data
1087  {
1088  CollMetaData zero;
1089  zero.min_entries = -1;
1090  zero.max_entries = -1;
1091  m_collEvts.resize(m_inputCollectionsName.value().size(), zero);
1092  m_collIdx = 0;
1093  }
1094 
1095 
1096 
1097  //CHECK( setFile( m_inputCollectionsName.value()[m_collIdx] ) );
1098 
1099 
1100  // std::cout << "::clear-root-addresses..." << std::endl;
1101  // reset the list of branches
1102  //m_rootAddresses.clear();
1103  m_needReload = true;
1104 
1105  // skip events we are asked to skip
1106  m_curEvt = m_skipEvts;
1107  m_nbrEvts = 0;
1108 
1109  // std::cout << "::fetchNtuple...[done]" << std::endl;
1110  return StatusCode::SUCCESS;
1111 }
1112 
1116 int
1118 {
1119  // std::cout << "--find_coll_idx(" << evtidx << ")..." << std::endl
1120  // << "--collsize: " << m_collEvts.size() << std::endl;
1121  for (std::size_t i = 0, imax = m_collEvts.size();
1122  i < imax;
1123  ++i) {
1124  // std::cout << "--[" << i << "]...\n";
1125  CollMetaData &itr = m_collEvts[i];
1126  if (itr.min_entries == -1) {
1127  TFile *file = fetchNtupleFile(m_inputCollectionsName.value()[i]);
1128  if (file) {
1129  long offset = 0;
1130  if (i > 0) {
1131  CollMetaData &jtr = m_collEvts[i-1];
1132  offset += jtr.max_entries;
1133  }
1134  itr.min_entries = offset;
1135  TTree* tree = dynamic_cast<TTree*>(file->Get(m_tupleName.value().c_str()));
1136  itr.max_entries = offset + ( (tree) ? tree->GetEntriesFast() : 0);
1137  } else {
1138  throw "xAODEventSelector: Unable to fetch ntuple";
1139  }
1140  }
1141  // std::cout << "--[" << i << "] => [" << itr.min_entries << ", "
1142  // << itr.max_entries << ") evtidx=[" << evtidx << "]"
1143  // << std::endl;
1144  if (itr.min_entries <= evtidx && evtidx < itr.max_entries) {
1145  return i;
1146  }
1147  }
1148  return -1;
1149 }
1150 
1151 
1152 int xAODEventSelector::size (Context& /*refCtxt*/) const {
1153  //use find_coll_idx to trigger a population of the m_collEvts ... dummy call with -1 to trigger all colls loaded
1154  find_coll_idx(-1);
1155  return m_collEvts.back().max_entries;
1156 }
1157 
1158 //not used for anything
1159 void xAODEventSelector::handle(const Incident& /*incident*/) {
1160 
1161 }
1162 
1163 } //> namespace Athena
xAOD::EventFormat_v1::end
const_iterator end() const
STL-like function for getting the end of the container.
Definition: EventFormat_v1.cxx:163
Athena::xAODEventContext::xAODEventContext
xAODEventContext(const xAODEventSelector *sel)
standard c-tor with initialization
Definition: xAODEventSelector.cxx:83
Athena::xAODEventSelector::m_nbrEvts
long m_nbrEvts
Number of Events read so far.
Definition: xAODEventSelector.h:197
Athena::xAODEventContext::ATLAS_NOT_THREAD_SAFE
StatusCode setFile ATLAS_NOT_THREAD_SAFE(const std::string &fname)
call to setFile on evtSel
Definition: xAODEventSelector.cxx:96
Athena::xAODEventSelector::m_ppSvc
ServiceHandle< IProxyProviderSvc > m_ppSvc
Handle to the proxy provider svc.
Definition: xAODEventSelector.h:182
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
Athena::xAODEventSelector::m_printEventProxyWarnings
bool m_printEventProxyWarnings
Definition: xAODEventSelector.h:240
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Athena::xAODEventContext::~xAODEventContext
virtual ~xAODEventContext()
standard d-tor
Definition: xAODEventSelector.cxx:85
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Athena::xAODEventSelector::m_printPerfStats
bool m_printPerfStats
Definition: xAODEventSelector.h:238
runHistoBuilders.toCheck
string toCheck
Definition: runHistoBuilders.py:166
Athena::xAODBranchAddress
Definition: xAODBranchAddress.h:31
Gaudi::Parsers::parse
StatusCode parse(std::tuple< Tup... > &tup, const Gaudi::Parsers::InputData &input)
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:284
Athena::xAODEventSelector::m_rootAddresses
std::unordered_map< SG::TransientAddress *, bool > m_rootAddresses
Definition: xAODEventSelector.h:221
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
RootGlobalsRestore.h
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
CLIDRegistry::typeinfoToCLID
static CLID typeinfoToCLID(const std::type_info &ti)
Return the CLID corresponding to a type_info.
Definition: CLIDRegistry.cxx:148
xAOD::IOStats::stats
ReadStats & stats()
Access the object belonging to the current thread.
Definition: IOStats.cxx:17
checkNSWValTree.inputTree
inputTree
Definition: checkNSWValTree.py:27
xAOD::PerfStats::start
void start(bool clear=true)
Start the statistics collection.
Athena::xAODEventContext::m_evtsel
const xAODEventSelector * m_evtsel
reference to the hosting event selector instance
Definition: xAODEventSelector.cxx:106
Athena::xAODEventSelector::m_skipEvts
long m_skipEvts
Number of events to skip at the beginning.
Definition: xAODEventSelector.h:194
Athena::xAODEventSelector::size
virtual int size(Context &refCtxt) const override
ICollectionSize interface
Definition: xAODEventSelector.cxx:1152
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
tree
TChain * tree
Definition: tile_monitor.h:30
EventInfo
EventInfo
Definition: EventTPCnv.cxx:47
xAOD::ReadStats::Print
void Print(::Option_t *option="") const
Print information about the collected statistics.
Athena::xAODEventContext::files
const std::vector< std::string > & files() const
access to the container of files
Definition: xAODEventSelector.cxx:92
SG::TransientAddress
Definition: TransientAddress.h:32
Athena::xAODEventContext::fileIndex
std::size_t fileIndex() const
access to the file iterator
Definition: xAODEventSelector.cxx:100
Athena::xAODEventContext
Definition: xAODEventSelector.cxx:80
Athena::xAODEventSelector::m_collEvts
std::vector< CollMetaData > m_collEvts
cache of the number of entries for each collection
Definition: xAODEventSelector.h:212
CaloClusterListBadChannel.cls
cls
Definition: CaloClusterListBadChannel.py:8
Athena::xAODEventSelector::CollMetaData::min_entries
long min_entries
number of entries up to this collection
Definition: xAODEventSelector.h:207
BuiltinsClids.h
Athena::xAODEventSelector::releaseContext
virtual StatusCode releaseContext(Context *&refCtxt) const override
Definition: xAODEventSelector.cxx:594
Athena::xAODEventSelector::m_inputCollectionsName
StringArrayProperty m_inputCollectionsName
List of input files containing TTree.
Definition: xAODEventSelector.h:185
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
Athena::xAODEventSelector::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: xAODEventSelector.cxx:373
Athena::xAODEventSelector::m_tupleName
StringProperty m_tupleName
Name of TTree to load from collection of input files.
Definition: xAODEventSelector.h:188
Athena::xAODEventSelector::finalize
virtual StatusCode finalize() override
Definition: xAODEventSelector.cxx:351
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Athena::xAODEventContext::file
const TFile * file() const
access to the current file
Definition: xAODEventSelector.cxx:94
IOStats.h
xAOD::EventInfo_v1::timeStampNSOffset
uint32_t timeStampNSOffset() const
Nanosecond time offset wrt. the time stamp.
Athena::xAODEventSelector::preLoadAddresses
virtual StatusCode preLoadAddresses(StoreID::type storeID, tadList &list) override
Definition: xAODEventSelector.cxx:731
Athena::xAODEventSelector::previous
virtual StatusCode previous(Context &refCtxt) const override
Definition: xAODEventSelector.cxx:552
PerfStats.h
Athena::xAODEventSelector::handle
virtual void handle(const Incident &incident) override
Definition: xAODEventSelector.cxx:1159
Athena::xAODEventSelector::m_accessMode
int m_accessMode
Definition: xAODEventSelector.h:232
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
atlasStyleMacro.icol
int icol
Definition: atlasStyleMacro.py:13
Athena::xAODEventSelector::m_tevent_entries
long m_tevent_entries
Definition: xAODEventSelector.h:230
Athena::xAODEventSelector::loadAddresses
virtual StatusCode loadAddresses(StoreID::type storeID, tadList &list) override
get all new addresses from Provider for this Event.
Definition: xAODEventSelector.cxx:742
Athena::xAODEventSelector::m_readMetadataWithPool
bool m_readMetadataWithPool
Definition: xAODEventSelector.h:236
Athena::xAODEventSelector::rewind
virtual StatusCode rewind(Context &refCtxt) const override
Definition: xAODEventSelector.cxx:572
Athena::xAODEventSelector::m_tevent
xAOD::xAODTEvent * m_tevent
current TEvent being read
Definition: xAODEventSelector.h:225
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:208
Athena::xAODEventSelector::m_curEvt
long m_curEvt
current event index
Definition: xAODEventSelector.h:200
Athena::xAODEventSelector::resetCriteria
virtual StatusCode resetCriteria(const std::string &cr, Context &ctx) const override
Definition: xAODEventSelector.cxx:607
JetTagCalibConfig.className
string className
Definition: JetTagCalibConfig.py:31
Athena::xAODEventSelector::createAddress
virtual StatusCode createAddress(const Context &refCtxt, IOpaqueAddress *&) const override
Definition: xAODEventSelector.cxx:586
Athena::xAODEventSelector::do_init_io
StatusCode do_init_io()
helper method to init the i/o components
Definition: xAODEventSelector.cxx:1082
TileAANtupleConfig.inputCollections
inputCollections
Definition: TileAANtupleConfig.py:133
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
StlVectorClids.h
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
xAOD::EventFormat_v1::begin
const_iterator begin() const
STL-like function for getting the beginning of the container.
Definition: EventFormat_v1.cxx:158
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ReadStats.h
Athena::xAODEventSelector::xAODEventSelector
xAODEventSelector(const std::string &name, ISvcLocator *svcLoc)
Constructor with parameters:
Definition: xAODEventSelector.cxx:109
lumiFormat.i
int i
Definition: lumiFormat.py:92
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
xAOD::TEvent::getEntries
::Long64_t getEntries() const
Get how many entries are available from the current input file(s)
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1293
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TEvent::getEntry
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0)
Function loading a given entry of the input TTree.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1324
AthService
Definition: AthService.h:32
sel
sel
Definition: SUSYToolsTester.cxx:92
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:201
L1CaloPhase1Monitoring.propVal
propVal
Definition: L1CaloPhase1Monitoring.py:349
Athena::xAODEventSelector::curEvent
virtual int curEvent(const Context &refCtxt) const override
return the current event number.
Definition: xAODEventSelector.cxx:663
file
TFile * file
Definition: tile_monitor.h:29
Athena::xAODEventSelector::io_reinit
virtual StatusCode io_reinit() override
Callback method to reinitialize the internal state of the component for I/O purposes (e....
Definition: xAODEventSelector.cxx:671
Athena::xAODEventSelector::m_poolSvc
ServiceHandle< IPoolSvc > m_poolSvc
Handle to the PoolSvc (used in Hybrid mode when user is reading metadata with pool)
Definition: xAODEventSelector.h:180
Athena::xAODEventSelector::initialize
virtual StatusCode initialize() override
Definition: xAODEventSelector.cxx:161
Athena::xAODEventSelector::next
virtual StatusCode next(Context &refCtxt) const override
Definition: xAODEventSelector.cxx:395
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Init.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
xAOD::xAODTEvent
Definition: xAODTEvent.h:23
Athena::xAODEventSelector::last
virtual StatusCode last(Context &refContext) const override
Definition: xAODEventSelector.cxx:564
xAOD::IOStats::instance
static IOStats & instance()
Singleton object accessor.
Definition: IOStats.cxx:11
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
xAODBranchAddress.h
xAOD::TEvent::setPrintEventProxyWarnings
void setPrintEventProxyWarnings(bool)
Function to silence warnings associated with broken element links.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:3697
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
checkRpcDigits.allGood
bool allGood
Loop over the SDOs & Digits.
Definition: checkRpcDigits.py:171
SG::TransientAddress::setProvider
void setProvider(IAddressProvider *provider, StoreID::type storeID)
Definition: TransientAddress.h:317
Athena::xAODEventSelector::setFile
StatusCode setFile(const std::string &fname)
switch to given file, loading metadata and triggering a beginInputFile incident
Definition: xAODEventSelector.cxx:1027
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
Athena::xAODEventSelector::CollMetaData
Definition: xAODEventSelector.h:205
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
pool::READ
@ READ
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:68
StlMapClids.h
Athena::xAODEventSelector::m_ometaStore
ServiceHandle< StoreGateSvc > m_ometaStore
Pointer to the StoreGateSvc output metadata store.
Definition: xAODEventSelector.h:172
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
Athena::xAODEventSelector::m_dictsvc
ServiceHandle< IDictLoaderSvc > m_dictsvc
Pointer to the IDictLoaderSvc.
Definition: xAODEventSelector.h:176
Athena::RootGlobalsRestore
Definition: RootGlobalsRestore.h:30
Athena::xAODEventSelector::createMetaDataRootBranchAddresses
StatusCode createMetaDataRootBranchAddresses() const
helper method to create proxies for the metadata store
Definition: xAODEventSelector.cxx:905
xAOD::PerfStats::instance
static PerfStats & instance()
Function accessing the singleton instance.
gErrorIgnoreLevel
int gErrorIgnoreLevel
SG::TransientAddress::setAddress
void setAddress(IOpaqueAddress *pAddress)
Retrieve primary clid.
Definition: TransientAddress.cxx:172
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CLIDRegistry.h
a static registry of CLID->typeName entries. NOT for general use. Use ClassIDSvc instead.
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
Athena::xAODEventSelector::createRootBranchAddresses
StatusCode createRootBranchAddresses(StoreID::type storeID, tadList &tads)
helper method to create proxies
Definition: xAODEventSelector.cxx:781
xAOD::TEvent::EAuxMode
EAuxMode
Auxiliary store "mode".
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:95
Athena::xAODEventSelector::updateAddress
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
update a transient Address
Definition: xAODEventSelector.cxx:754
IDictLoaderSvc.h
StoreID::type
type
Definition: StoreID.h:24
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:145
Athena::xAODEventSelector::m_fillEventInfo
bool m_fillEventInfo
Definition: xAODEventSelector.h:234
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TransientAddress.h
Athena::xAODEventSelector::m_metadataName
StringProperty m_metadataName
Name of TTree to load from metadata of input files.
Definition: xAODEventSelector.h:191
xAOD::TEvent::retrieve
StatusCode retrieve(const T *&obj, const std::string &key)
Retrieve either an input or an output object from the event.
Athena::xAODEventSelector::m_imetaStore
ServiceHandle< StoreGateSvc > m_imetaStore
Pointer to the StoreGateSvc input metadata store.
Definition: xAODEventSelector.h:170
xAOD::TEvent::inputEventFormat
const EventFormat * inputEventFormat() const
Get information about the input objects.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1603
Athena::xAODEventSelector::CollMetaData::max_entries
long max_entries
number of entries after this collection
Definition: xAODEventSelector.h:209
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
IAddressProvider::tadList
std::list< SG::TransientAddress * > tadList
Definition: IAddressProvider.h:32
xAOD::EventInfo_v1::timeStamp
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
Athena::xAODEventContext::entry
int64_t entry() const
access to the current event entry number
Definition: xAODEventSelector.cxx:102
Athena::xAODEventSelector::m_collectionType
StringProperty m_collectionType
Definition: xAODEventSelector.h:244
Athena::xAODEventSelector::fetchNtupleFile
TFile * fetchNtupleFile(const std::string &fname) const
helper method to retrieve the correct tuple
Definition: xAODEventSelector.cxx:1002
SG::TransientAddress::clearAddress
void clearAddress(const bool &flag)
Return the clearAddress flag.
Definition: TransientAddress.h:285
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
IProxyProviderSvc.h
xAOD::PerfStats::stop
void stop()
Stop the statistics collection.
xAOD::TEvent::readFrom
StatusCode readFrom(::TFile *file, Bool_t useTreeCache=kTRUE, const char *treeName=EVENT_TREE_NAME)
Connect the object to a new input file.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:364
xAODEventSelector.h
Athena::xAODEventSelector::m_collIdx
long m_collIdx
current collection index (into m_inputCollectionsName)
Definition: xAODEventSelector.h:203
TBranchElementClang.h
Include TBranchElement.h, suppressing clang warnings.
Athena::xAODEventSelector::m_tfile
TFile * m_tfile
current TFile being read
Definition: xAODEventSelector.h:228
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
Athena::xAODEventSelector
Class implementing the GAUDI IEvtSelector interface using ROOT TTree as a backend.
Definition: xAODEventSelector.h:53
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
Athena::xAODEventSelector::seek
virtual StatusCode seek(Context &refCtxt, int evtnum) const override
Seek to a given event number.
Definition: xAODEventSelector.cxx:622
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
checker_macros.h
Define macros for attributes used to control the static checker.
Athena::xAODEventContext::identifier
virtual void * identifier() const override
identifier method required by IEvtSelector::Context
Definition: xAODEventSelector.cxx:87
Athena::xAODEventSelector::m_incsvc
ServiceHandle< IIncidentSvc > m_incsvc
Handle to the incident service.
Definition: xAODEventSelector.h:178
Athena::xAODEventSelector::m_needReload
bool m_needReload
Definition: xAODEventSelector.h:216
StoreGateSvc.h
Athena::xAODEventSelector::m_clidsvc
ServiceHandle< IClassIDSvc > m_clidsvc
Pointer to the IClassIDSvc.
Definition: xAODEventSelector.h:174
CLASS_DEF.h
macros to associate a CLID to a type
Athena::xAODEventSelector::find_coll_idx
int find_coll_idx(int evtidx) const
helper method to get the collection index (into m_inputCollectionsName) for a given event index evtid...
Definition: xAODEventSelector.cxx:1117
Athena::xAODEventSelector::createContext
virtual StatusCode createContext(Context *&refpCtxt) const override
Definition: xAODEventSelector.cxx:578
zero
void zero(TH2 *h)
zero the contents of a 2d histogram
Definition: comparitor.cxx:435
Athena::xAODEventSelector::m_dataStore
ServiceHandle< StoreGateSvc > m_dataStore
Pointer to the StoreGateSvc event store.
Definition: xAODEventSelector.h:168
IEvtSelectorSeek
Abstract interface for seeking for an event selector.
Definition: IEvtSelectorSeek.h:28
Athena::xAODEventSelector::~xAODEventSelector
virtual ~xAODEventSelector()
Destructor:
Definition: xAODEventSelector.cxx:158
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31
ServiceHandle
Definition: ClusterMakerTool.h:37