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
32
33#include <memory>
34#include <optional>
35#include <unordered_map>
36
37// Forward declaration
38class ISvcLocator;
39class StoreGateSvc;
40class TTree;
41class IClassIDSvc;
42class IDictLoaderSvc;
43namespace Athena { class xAODEventContext; }
44
45namespace Athena {
46
51 public extends<::AthService,
52 IEvtSelector,
53 IEvtSelectorSeek,
54 IAddressProvider,
55 IIoComponent,
56 IIncidentListener>
57{
59
60
61
63 // Public methods:
65 public:
66
68 xAODEventSelector( const std::string& name, ISvcLocator* svcLoc );
69
71 virtual ~xAODEventSelector();
72
73 // Athena hooks
74 virtual StatusCode initialize() override;
75 virtual StatusCode stop() override;
76 virtual StatusCode finalize() override;
77
78 virtual void handle(const Incident& incident) override;
79
82 virtual StatusCode createContext( Context*& refpCtxt ) const override;
83
84 virtual StatusCode last( Context& refContext ) const override;
85 virtual StatusCode next( Context& refCtxt ) const override;
86 virtual StatusCode next( Context& refCtxt, int jump ) const override;
87 virtual StatusCode previous( Context& refCtxt ) const override;
88 virtual StatusCode previous( Context& refCtxt, int jump ) const override;
89 virtual StatusCode rewind( Context& refCtxt ) const override;
90
91 virtual StatusCode createAddress( const Context& refCtxt,
92 IOpaqueAddress*& ) const override;
93 virtual StatusCode releaseContext( Context*& refCtxt ) const override;
94 virtual StatusCode resetCriteria( const std::string& cr,
95 Context& ctx )const override;
97
100
104 virtual StatusCode seek (Context& refCtxt, int evtnum) const override;
105
110 virtual int curEvent (const Context& refCtxt) const override;
112
115 virtual StatusCode io_reinit() override;
116
120 virtual
121 StatusCode preLoadAddresses(StoreID::type storeID, tadList& list) override;
122
124 virtual
125 StatusCode loadAddresses(StoreID::type storeID, tadList& list) override;
126
128 virtual
129 StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress* tad,
130 const EventContext& ctx) override;
132
134 virtual int size (Context& refCtxt) const override;
135
136
137 private:
138
140 StatusCode createRootBranchAddresses(StoreID::type storeID,
141 tadList &tads);
142
143
145 TFile* fetchNtupleFile(const std::string& fname) const;
146
148 StatusCode createMetaDataRootBranchAddresses() const;
149
151 StatusCode do_init_io();
152
154 StatusCode setFile(const std::string& fname);
155
159 int find_coll_idx(int evtidx) const;
160
163 { return const_cast<xAODEventSelector*>(this); }
164
166 // Private data:
168 private:
169
186
188 StringArrayProperty m_inputCollectionsName;
189
192
194 mutable long m_nbrEvts;
195
197 mutable long m_curEvt;
198
200 mutable long m_collIdx;
201
207 };
208
209 mutable std::vector<CollMetaData> m_collEvts;
210
211
212 // flag to trigger reloading of root branch addresses
213 mutable bool m_needReload;
214
215 // the list of transient addresses we "manage" or know about
216 // these addresses are the things we can retrieve from the TEvent
217 // for the event data
218 std::unordered_map<SG::TransientAddress*, bool> m_rootAddresses;
219
220
222 mutable std::unique_ptr<xAOD::Event> m_event;
223
225 mutable TFile* m_tfile;
226
227 mutable long m_event_entries; //used to cache getEntries result of event
228
229 int m_accessMode; //tevent access mode
230
231 bool m_isRNTuple = false; //input files store event data in RNTuple, decided from the first file
232
233 bool m_fillEventInfo = false; //if true, will fill EventInfo from xAOD::EventInfo
234
235 bool m_readMetadataWithPool = false; //metadata read by MetaDataSvc via AthenaPoolCnvSvc instead of TEvent
236
237 bool m_printPerfStats = false; //should we monitor the touched input branches?
238
240
242 mutable std::optional<InputFileIncidentGuard> m_inputFileGuard;
243};
244
246// Inline methods:
248
249} //> namespace Athena
250
251#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
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 or RNTuple.
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
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).
std::unique_ptr< xAOD::Event > m_event
current Event being read (xAODTEvent for TTree or xAODREvent for RNTuple)
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....
Definition AthDsoUtils.h:10
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