ATLAS Offline Software
Loading...
Searching...
No Matches
xAODEventSelector.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 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"
26
27#include "PoolSvc/IPoolSvc.h"
28
29#include "TFile.h"
30
31#include "xAODTEvent.h"
32
33#include <optional>
34#include <unordered_map>
35
36// Forward declaration
37class ISvcLocator;
38class StoreGateSvc;
39class TTree;
40class IClassIDSvc;
41class IDictLoaderSvc;
42namespace Athena { class xAODEventContext; }
43
44namespace Athena {
45
50 public extends<::AthService,
51 IEvtSelector,
52 IEvtSelectorSeek,
53 IAddressProvider,
54 IIoComponent,
55 IIncidentListener>
56{
58
59
60
62 // Public methods:
64 public:
65
67 xAODEventSelector( const std::string& name, ISvcLocator* svcLoc );
68
70 virtual ~xAODEventSelector();
71
72 // Athena hooks
73 virtual StatusCode initialize() override;
74 virtual StatusCode stop() override;
75 virtual StatusCode finalize() override;
76
77 virtual void handle(const Incident& incident) override;
78
81 virtual StatusCode createContext( Context*& refpCtxt ) const override;
82
83 virtual StatusCode last( Context& refContext ) const override;
84 virtual StatusCode next( Context& refCtxt ) const override;
85 virtual StatusCode next( Context& refCtxt, int jump ) const override;
86 virtual StatusCode previous( Context& refCtxt ) const override;
87 virtual StatusCode previous( Context& refCtxt, int jump ) const override;
88 virtual StatusCode rewind( Context& refCtxt ) const override;
89
90 virtual StatusCode createAddress( const Context& refCtxt,
91 IOpaqueAddress*& ) const override;
92 virtual StatusCode releaseContext( Context*& refCtxt ) const override;
93 virtual StatusCode resetCriteria( const std::string& cr,
94 Context& ctx )const override;
96
99
103 virtual StatusCode seek (Context& refCtxt, int evtnum) const override;
104
109 virtual int curEvent (const Context& refCtxt) const override;
111
114 virtual StatusCode io_reinit() override;
115
119 virtual
120 StatusCode preLoadAddresses(StoreID::type storeID, tadList& list) override;
121
123 virtual
124 StatusCode loadAddresses(StoreID::type storeID, tadList& list) override;
125
127 virtual
128 StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress* tad,
129 const EventContext& ctx) override;
131
133 virtual int size (Context& refCtxt) const override;
134
135
136 private:
137
139 StatusCode createRootBranchAddresses(StoreID::type storeID,
140 tadList &tads);
141
142
144 TFile* fetchNtupleFile(const std::string& fname) const;
145
147 StatusCode createMetaDataRootBranchAddresses() const;
148
150 StatusCode do_init_io();
151
153 StatusCode setFile(const std::string& fname);
154
158 int find_coll_idx(int evtidx) const;
159
162 { return const_cast<xAODEventSelector*>(this); }
163
165 // Private data:
167 private:
168
185
187 StringArrayProperty m_inputCollectionsName;
188
190 StringProperty m_tupleName;
191
193 StringProperty m_metadataName;
194
197
199 mutable long m_nbrEvts;
200
202 mutable long m_curEvt;
203
205 mutable long m_collIdx;
206
212 };
213
214 mutable std::vector<CollMetaData> m_collEvts;
215
216
217 // flag to trigger reloading of root branch addresses
218 mutable bool m_needReload;
219
220 // the list of transient addresses we "manage" or know about
221 // these addresses are the things we can retrieve from the TEvent
222 // for the event data
223 std::unordered_map<SG::TransientAddress*, bool> m_rootAddresses;
224
225
228
230 mutable TFile* m_tfile;
231
232 mutable long m_tevent_entries; //used to cache getEntries result of tevent
233
234 int m_accessMode; //tevent access mode
235
236 bool m_fillEventInfo = false; //if true, will fill EventInfo from xAOD::EventInfo
237
238 bool m_readMetadataWithPool = false; //interacts with PoolSvc to create collections, needed by MetaDataSvc
239
240 bool m_printPerfStats = false; //should we monitor the touched input branches?
241
243
245 mutable std::optional<InputFileIncidentGuard> m_inputFileGuard;
246
247#ifndef XAOD_ANALYSIS
248 //these are here just for compatibility with RecExCommon ... we were trying to use this selector in recexcommon jobs for a bit
249 StringProperty m_collectionType;
250#endif
251
252};
253
255// Inline methods:
257
258} //> namespace Athena
259
260#endif //> ATHENAROOTCOMPS_ATHENA_XAODEVENTSELECTOR_H
Extension to IEvtSelector to allow for seeking.
This file contains the class definition for the IPoolSvc interface class.
RAII guard that guarantees a matching end-incident for every begin-incident.
size_t size() const
Number of registered mappings.
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.
std::optional< InputFileIncidentGuard > m_inputFileGuard
RAII guard: guarantees a matching EndInputFile for every BeginInputFile.
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
update a transient Address
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
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 stop() 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....
find_coll_idx(-1, coll_idx, tuple_idx)
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