ATLAS Offline Software
xAODEventSelector.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // xAODEventSelector.h
8 // Header file for class xAODEventSelector
9 // Author: Johannes Elmsheuser, Will Buttinger
11 #ifndef ATHENAROOTCOMPS_ATHENA_XAODEVENTSELECTOR_H
12 #define ATHENAROOTCOMPS_ATHENA_XAODEVENTSELECTOR_H 1
13 
14 // framework includes
17 #include "GaudiKernel/IEvtSelector.h"
18 #include "GaudiKernel/IIoComponent.h"
19 #include "GaudiKernel/IIncidentSvc.h"
20 #include "GaudiKernel/MsgStream.h"
21 #include "Gaudi/Property.h"
22 #include "GaudiKernel/ServiceHandle.h"
25 
26 #include "PoolSvc/IPoolSvc.h"
27 
28 #include "TFile.h"
29 
30 #include "xAODTEvent.h"
31 
32 #include <unordered_map>
33 
34 // Forward declaration
35 class ISvcLocator;
36 class StoreGateSvc;
37 class TTree;
38 class IClassIDSvc;
39 class IDictLoaderSvc;
40 namespace Athena { class xAODEventContext; }
41 
42 namespace Athena {
43 
48  virtual public IEvtSelector,
49  virtual public IEvtSelectorSeek,
50  virtual public IAddressProvider,
51  virtual public IIoComponent, virtual public IIncidentListener,
52  public ::AthService
53 {
55 
56 
57 
59  // Public methods:
61  public:
62 
64  xAODEventSelector( const std::string& name, ISvcLocator* svcLoc );
65 
67  virtual ~xAODEventSelector();
68 
69  // Athena hooks
70  virtual StatusCode initialize() override;
71  virtual StatusCode finalize() override;
72  virtual StatusCode queryInterface( const InterfaceID& riid,
73  void** ppvInterface ) override;
74 
75  virtual void handle(const Incident& incident) override;
76 
79  virtual StatusCode createContext( Context*& refpCtxt ) const override;
80 
81  virtual StatusCode last( Context& refContext ) const override;
82  virtual StatusCode next( Context& refCtxt ) const override;
83  virtual StatusCode next( Context& refCtxt, int jump ) const override;
84  virtual StatusCode previous( Context& refCtxt ) const override;
85  virtual StatusCode previous( Context& refCtxt, int jump ) const override;
86  virtual StatusCode rewind( Context& refCtxt ) const override;
87 
88  virtual StatusCode createAddress( const Context& refCtxt,
89  IOpaqueAddress*& ) const override;
90  virtual StatusCode releaseContext( Context*& refCtxt ) const override;
91  virtual StatusCode resetCriteria( const std::string& cr,
92  Context& ctx )const override;
94 
97 
101  virtual StatusCode seek (Context& refCtxt, int evtnum) const override;
102 
107  virtual int curEvent (const Context& refCtxt) const override;
109 
112  virtual StatusCode io_reinit() override;
113 
117  virtual
118  StatusCode preLoadAddresses(StoreID::type storeID, tadList& list) override;
119 
121  virtual
122  StatusCode loadAddresses(StoreID::type storeID, tadList& list) override;
123 
125  virtual
126  StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress* tad,
127  const EventContext& ctx) override;
129 
131  virtual int size (Context& refCtxt) const override;
132 
133 
134  private:
135 
137  StatusCode createRootBranchAddresses(StoreID::type storeID,
138  tadList &tads);
139 
140 
142  TFile* fetchNtupleFile(const std::string& fname) const;
143 
145  StatusCode createMetaDataRootBranchAddresses() const;
146 
148  StatusCode do_init_io();
149 
151  StatusCode setFile(const std::string& fname);
152 
156  int find_coll_idx(int evtidx) const;
157 
159  xAODEventSelector *self() const
160  { return const_cast<xAODEventSelector*>(this); }
161 
163  // Private data:
165  private:
166 
183 
185  StringArrayProperty m_inputCollectionsName;
186 
188  StringProperty m_tupleName;
189 
191  StringProperty m_metadataName;
192 
195 
197  mutable long m_nbrEvts;
198 
200  mutable long m_curEvt;
201 
203  mutable long m_collIdx;
204 
205  struct CollMetaData {
210  };
212  mutable std::vector<CollMetaData> m_collEvts;
213 
214 
215  // flag to trigger reloading of root branch addresses
216  mutable bool m_needReload;
217 
218  // the list of transient addresses we "manage" or know about
219  // these addresses are the things we can retrieve from the TEvent
220  // for the event data
221  std::unordered_map<SG::TransientAddress*, bool> m_rootAddresses;
222 
223 
226 
228  mutable TFile* m_tfile;
229 
230  mutable long m_tevent_entries; //used to cache getEntries result of tevent
231 
232  int m_accessMode; //tevent access mode
233 
234  bool m_fillEventInfo = false; //if true, will fill EventInfo from xAOD::EventInfo
235 
236  bool m_readMetadataWithPool = false; //interacts with PoolSvc to create collections, needed by MetaDataSvc
237 
238  bool m_printPerfStats = false; //should we monitor the touched input branches?
239 
240  bool m_printEventProxyWarnings = true;
241 
242 #ifndef XAOD_ANALYSIS
243  //these are here just for compatibility with RecExCommon ... we were trying to use this selector in recexcommon jobs for a bit
244  StringProperty m_collectionType;
245 #endif
246 
247 };
248 
250 // Inline methods:
252 
253 } //> namespace Athena
254 
255 #endif //> ATHENAROOTCOMPS_ATHENA_XAODEVENTSELECTOR_H
Athena::xAODEventSelector::m_nbrEvts
long m_nbrEvts
Number of Events read so far.
Definition: xAODEventSelector.h:197
Athena::xAODEventSelector::m_ppSvc
ServiceHandle< IProxyProviderSvc > m_ppSvc
Handle to the proxy provider svc.
Definition: xAODEventSelector.h:182
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
Athena::xAODEventSelector::m_rootAddresses
std::unordered_map< SG::TransientAddress *, bool > m_rootAddresses
Definition: xAODEventSelector.h:221
IDictLoaderSvc
Definition: IDictLoaderSvc.h:37
Athena::xAODEventSelector::m_skipEvts
long m_skipEvts
Number of events to skip at the beginning.
Definition: xAODEventSelector.h:194
initialize
void initialize()
Definition: run_EoverP.cxx:894
SG::TransientAddress
Definition: TransientAddress.h:32
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
Athena::xAODEventSelector::CollMetaData::min_entries
long min_entries
number of entries up to this collection
Definition: xAODEventSelector.h:207
Athena::xAODEventSelector::m_inputCollectionsName
StringArrayProperty m_inputCollectionsName
List of input files containing TTree.
Definition: xAODEventSelector.h:185
Athena::xAODEventSelector::m_tupleName
StringProperty m_tupleName
Name of TTree to load from collection of input files.
Definition: xAODEventSelector.h:188
Athena::xAODEventSelector::m_accessMode
int m_accessMode
Definition: xAODEventSelector.h:232
Athena::xAODEventSelector::m_tevent_entries
long m_tevent_entries
Definition: xAODEventSelector.h:230
Athena::xAODEventSelector::m_tevent
xAOD::xAODTEvent * m_tevent
current TEvent being read
Definition: xAODEventSelector.h:225
Athena::xAODEventSelector::m_curEvt
long m_curEvt
current event index
Definition: xAODEventSelector.h:200
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthService
Definition: AthService.h:32
IAddressProvider
interface for IOA providers
Definition: IAddressProvider.h:28
xAODTEvent.h
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
xAOD::xAODTEvent
Definition: xAODTEvent.h:23
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
Athena::xAODEventSelector::CollMetaData
Definition: xAODEventSelector.h:205
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Athena::xAODEventSelector::m_ometaStore
ServiceHandle< StoreGateSvc > m_ometaStore
Pointer to the StoreGateSvc output metadata store.
Definition: xAODEventSelector.h:172
Athena::xAODEventSelector::m_dictsvc
ServiceHandle< IDictLoaderSvc > m_dictsvc
Pointer to the IDictLoaderSvc.
Definition: xAODEventSelector.h:176
IPoolSvc.h
This file contains the class definition for the IPoolSvc interface class.
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
StoreID::type
type
Definition: StoreID.h:24
Athena::xAODEventSelector::m_metadataName
StringProperty m_metadataName
Name of TTree to load from metadata of input files.
Definition: xAODEventSelector.h:191
Athena::xAODEventSelector::m_imetaStore
ServiceHandle< StoreGateSvc > m_imetaStore
Pointer to the StoreGateSvc input metadata store.
Definition: xAODEventSelector.h:170
Athena::xAODEventSelector::CollMetaData::max_entries
long max_entries
number of entries after this collection
Definition: xAODEventSelector.h:209
IAddressProvider::tadList
std::list< SG::TransientAddress * > tadList
Definition: IAddressProvider.h:32
Athena::xAODEventSelector::m_collectionType
StringProperty m_collectionType
Definition: xAODEventSelector.h:244
AthService.h
IAddressProvider.h
Athena::xAODEventSelector::m_collIdx
long m_collIdx
current collection index (into m_inputCollectionsName)
Definition: xAODEventSelector.h:203
Athena::xAODEventSelector::m_tfile
TFile * m_tfile
current TFile being read
Definition: xAODEventSelector.h:228
Athena::xAODEventSelector
Class implementing the GAUDI IEvtSelector interface using ROOT TTree as a backend.
Definition: xAODEventSelector.h:53
IEvtSelectorSeek.h
Extension to IEvtSelector to allow for seeking.
checker_macros.h
Define macros for attributes used to control the static checker.
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
Athena::xAODEventSelector::m_clidsvc
ServiceHandle< IClassIDSvc > m_clidsvc
Pointer to the IClassIDSvc.
Definition: xAODEventSelector.h:174
Athena::xAODEventSelector::m_dataStore
ServiceHandle< StoreGateSvc > m_dataStore
Pointer to the StoreGateSvc event store.
Definition: xAODEventSelector.h:168
Athena::ATLAS_NOT_THREAD_SAFE
void DebugAids::stacktraceLine ATLAS_NOT_THREAD_SAFE(IOFD fd, unsigned long addr)
Write out stack trace line to FD.
Definition: SealDebug.cxx:328
IEvtSelectorSeek
Abstract interface for seeking for an event selector.
Definition: IEvtSelectorSeek.h:28
Trk::previous
@ previous
Definition: BinningData.h:32
ServiceHandle< StoreGateSvc >