ATLAS Offline Software
Loading...
Searching...
No Matches
xAODEventSelector.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2024 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
35class ISvcLocator;
36class StoreGateSvc;
37class TTree;
38class IClassIDSvc;
39class IDictLoaderSvc;
40namespace Athena { class xAODEventContext; }
41
42namespace Athena {
43
48 public extends<::AthService,
49 IEvtSelector,
50 IEvtSelectorSeek,
51 IAddressProvider,
52 IIoComponent,
53 IIncidentListener>
54{
56
57
58
60 // Public methods:
62 public:
63
65 xAODEventSelector( const std::string& name, ISvcLocator* svcLoc );
66
68 virtual ~xAODEventSelector();
69
70 // Athena hooks
71 virtual StatusCode initialize() override;
72 virtual StatusCode finalize() override;
73
74 virtual void handle(const Incident& incident) override;
75
78 virtual StatusCode createContext( Context*& refpCtxt ) const override;
79
80 virtual StatusCode last( Context& refContext ) const override;
81 virtual StatusCode next( Context& refCtxt ) const override;
82 virtual StatusCode next( Context& refCtxt, int jump ) const override;
83 virtual StatusCode previous( Context& refCtxt ) const override;
84 virtual StatusCode previous( Context& refCtxt, int jump ) const override;
85 virtual StatusCode rewind( Context& refCtxt ) const override;
86
87 virtual StatusCode createAddress( const Context& refCtxt,
88 IOpaqueAddress*& ) const override;
89 virtual StatusCode releaseContext( Context*& refCtxt ) const override;
90 virtual StatusCode resetCriteria( const std::string& cr,
91 Context& ctx )const override;
93
96
100 virtual StatusCode seek (Context& refCtxt, int evtnum) const override;
101
106 virtual int curEvent (const Context& refCtxt) const override;
108
111 virtual StatusCode io_reinit() override;
112
116 virtual
117 StatusCode preLoadAddresses(StoreID::type storeID, tadList& list) override;
118
120 virtual
121 StatusCode loadAddresses(StoreID::type storeID, tadList& list) override;
122
124 virtual
125 StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress* tad,
126 const EventContext& ctx) override;
128
130 virtual int size (Context& refCtxt) const override;
131
132
133 private:
134
136 StatusCode createRootBranchAddresses(StoreID::type storeID,
137 tadList &tads);
138
139
141 TFile* fetchNtupleFile(const std::string& fname) const;
142
144 StatusCode createMetaDataRootBranchAddresses() const;
145
147 StatusCode do_init_io();
148
150 StatusCode setFile(const std::string& fname);
151
155 int find_coll_idx(int evtidx) const;
156
159 { return const_cast<xAODEventSelector*>(this); }
160
162 // Private data:
164 private:
165
182
184 StringArrayProperty m_inputCollectionsName;
185
187 StringProperty m_tupleName;
188
190 StringProperty m_metadataName;
191
194
196 mutable long m_nbrEvts;
197
199 mutable long m_curEvt;
200
202 mutable long m_collIdx;
203
209 };
210
211 mutable std::vector<CollMetaData> m_collEvts;
212
213
214 // flag to trigger reloading of root branch addresses
215 mutable bool m_needReload;
216
217 // the list of transient addresses we "manage" or know about
218 // these addresses are the things we can retrieve from the TEvent
219 // for the event data
220 std::unordered_map<SG::TransientAddress*, bool> m_rootAddresses;
221
222
225
227 mutable TFile* m_tfile;
228
229 mutable long m_tevent_entries; //used to cache getEntries result of tevent
230
231 int m_accessMode; //tevent access mode
232
233 bool m_fillEventInfo = false; //if true, will fill EventInfo from xAOD::EventInfo
234
235 bool m_readMetadataWithPool = false; //interacts with PoolSvc to create collections, needed by MetaDataSvc
236
237 bool m_printPerfStats = false; //should we monitor the touched input branches?
238
240
241#ifndef XAOD_ANALYSIS
242 //these are here just for compatibility with RecExCommon ... we were trying to use this selector in recexcommon jobs for a bit
243 StringProperty m_collectionType;
244#endif
245
246};
247
249// Inline methods:
251
252} //> namespace Athena
253
254#endif //> ATHENAROOTCOMPS_ATHENA_XAODEVENTSELECTOR_H
Extension to IEvtSelector to allow for seeking.
This file contains the class definition for the IPoolSvc interface class.
Define macros for attributes used to control the static checker.
event selector context ... just holds reference back to the selector
ServiceHandle< StoreGateSvc > m_ometaStore
Pointer to the StoreGateSvc output metadata store.
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
update a transient Address
virtual int size(Context &refCtxt) const override
ICollectionSize interface
StringProperty m_tupleName
Name of TTree to load from collection of input files.
virtual StatusCode next(Context &refCtxt) const override
xAODEventSelector(const std::string &name, ISvcLocator *svcLoc)
Constructor with parameters:
long m_nbrEvts
Number of Events read so far.
ServiceHandle< IDictLoaderSvc > m_dictsvc
Pointer to the IDictLoaderSvc.
TFile * m_tfile
current TFile being read
virtual StatusCode resetCriteria(const std::string &cr, Context &ctx) const override
StringArrayProperty m_inputCollectionsName
List of input files containing TTree.
StatusCode createRootBranchAddresses(StoreID::type storeID, tadList &tads)
helper method to create proxies
int find_coll_idx(int evtidx) const
helper method to get the collection index (into m_inputCollectionsName) for a given event index evtid...
StatusCode createMetaDataRootBranchAddresses() const
helper method to create proxies for the metadata store
virtual StatusCode releaseContext(Context *&refCtxt) const override
StringProperty m_metadataName
Name of TTree to load from metadata of input files.
xAOD::xAODTEvent * m_tevent
current TEvent being read
xAODEventSelector * self() const
non-const access to self (b/c next() is const)
std::vector< CollMetaData > m_collEvts
cache of the number of entries for each collection
StatusCode do_init_io()
helper method to init the i/o components
virtual StatusCode io_reinit() override
Callback method to reinitialize the internal state of the component for I/O purposes (e....
ServiceHandle< IProxyProviderSvc > m_ppSvc
Handle to the proxy provider svc.
virtual StatusCode loadAddresses(StoreID::type storeID, tadList &list) override
get all new addresses from Provider for this Event.
ServiceHandle< StoreGateSvc > m_dataStore
Pointer to the StoreGateSvc event store.
StatusCode setFile(const std::string &fname)
switch to given file, loading metadata and triggering a beginInputFile incident
virtual StatusCode previous(Context &refCtxt) const override
std::unordered_map< SG::TransientAddress *, bool > m_rootAddresses
virtual int curEvent(const Context &refCtxt) const override
return the current event number.
ServiceHandle< IIncidentSvc > m_incsvc
Handle to the incident service.
virtual StatusCode createAddress(const Context &refCtxt, IOpaqueAddress *&) const override
virtual StatusCode finalize() override
ServiceHandle< IClassIDSvc > m_clidsvc
Pointer to the IClassIDSvc.
virtual StatusCode last(Context &refContext) const override
virtual StatusCode seek(Context &refCtxt, int evtnum) const override
Seek to a given event number.
TFile * fetchNtupleFile(const std::string &fname) const
helper method to retrieve the correct tuple
long m_curEvt
current event index
ServiceHandle< IPoolSvc > m_poolSvc
Handle to the PoolSvc (used in Hybrid mode when user is reading metadata with pool)
virtual StatusCode createContext(Context *&refpCtxt) const override
long m_skipEvts
Number of events to skip at the beginning.
virtual StatusCode rewind(Context &refCtxt) const override
long m_collIdx
current collection index (into m_inputCollectionsName)
virtual void handle(const Incident &incident) override
virtual StatusCode preLoadAddresses(StoreID::type storeID, tadList &list) override
ServiceHandle< StoreGateSvc > m_imetaStore
Pointer to the StoreGateSvc input metadata store.
a simple interface to interact with the Reflex dictionaries and abstract/workaround a few ROOT bugs.
The Athena Transient Store API.
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
StatusCode ROOTMessageFilterSvc::initialize ATLAS_NOT_THREAD_SAFE()
Return the file descriptor fataldump() uses for output.
void initialize()
long max_entries
number of entries after this collection
long min_entries
number of entries up to this collection