ATLAS Offline Software
Loading...
Searching...
No Matches
EventSelectorAthenaPool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef EVENTSELECTORATHENAPOOL_H
6#define EVENTSELECTORATHENAPOOL_H
7
12
13#include "GaudiKernel/IEvtSelector.h"
14#include "GaudiKernel/IIoComponent.h"
15#include "GaudiKernel/IIncidentListener.h"
16#include "GaudiKernel/ServiceHandle.h"
17#include "GaudiKernel/ToolHandle.h"
19
25#include "PoolSvc/IPoolSvc.h"
27
29
30#include <map>
31#include <atomic>
32#include <cstdint>
33#include <memory>
34#include <optional>
35
36// Forward declarations
37class IIncidentSvc;
38class IOpaqueAddress;
39class ISvcLocator;
41class StoreGateSvc;
42class IPoolSvc;
43namespace pool {
44 class Collection;
45 class CollectionCursor;
46}
47
52 public extends<::AthService, IEvtSelector, IEvtSelectorSeek, IIoComponent, IIncidentListener, ISecondaryEventSelector>
53{
54
55public: // Constructor and Destructor
57 EventSelectorAthenaPool(const std::string& name, ISvcLocator* pSvcLocator);
60
62 virtual StatusCode initialize() override;
63 virtual StatusCode start() override;
64 virtual StatusCode stop() override;
65 virtual StatusCode finalize() override;
66
67 //-------------------------------------------------
68 // IEventSelector
70 virtual StatusCode createContext(IEvtSelector::Context*& ctxt) const override;
71
73 virtual StatusCode next(IEvtSelector::Context& ctxt) const override;
76 virtual StatusCode next(IEvtSelector::Context& ctxt, int jump) const override;
77
79 virtual StatusCode previous(IEvtSelector::Context& ctxt) const override;
82 virtual StatusCode previous(IEvtSelector::Context& ctxt, int jump) const override;
83
85 virtual StatusCode last(IEvtSelector::Context& ctxt) const override;
86
88 virtual StatusCode rewind(IEvtSelector::Context& ctxt) const override;
89
92 virtual StatusCode createAddress(const IEvtSelector::Context& ctxt, IOpaqueAddress*& iop) const override;
93
95 virtual StatusCode releaseContext(IEvtSelector::Context*& ctxt) const override;
96
100 virtual StatusCode resetCriteria(const std::string& criteria, IEvtSelector::Context& ctxt) const override;
101
102 //-------------------------------------------------
103 // IEventSelectorSeek
107 virtual StatusCode seek(Context& ctxt, int evtnum) const override;
108
111 virtual int curEvent (const Context& ctxt) const override;
112
115 virtual int size (Context& ctxt) const override;
116
117 //-------------------------------------------------
118 // IIoComponent
120 virtual StatusCode io_reinit() override;
122 virtual StatusCode io_finalize() override;
123
124 //-------------------------------------------------
125 // IIncidentListener
127 virtual void handle(const Incident& incident) override;
128
129protected:
130 //-------------------------------------------------
131 // ISecondaryEventSelector
133 virtual StatusCode nextHandleFileTransition(IEvtSelector::Context& ctxt) const override;
135 virtual StatusCode nextWithSkip(IEvtSelector::Context& ctxt) const override;
137 virtual StatusCode recordAttributeList() const override;
139 virtual StatusCode fillAttributeList(coral::AttributeList *attrList, const std::string &suffix, bool copySource) const override;
141 virtual bool disconnectIfFinished(const SG::SourceID &fid) const override;
142
143private: // internal member functions
145 StoreGateSvc* eventStore() const;
147 StatusCode reinit() const;
149 std::unique_ptr<pool::Collection> getCollection(bool throwIncidents = false) const;
151 StatusCode openCollection(std::string& inputCollection,
152 std::unique_ptr<pool::Collection>& poolCollection,
153 std::string* lastError = nullptr) const;
155 void disconnectCollection() const;
157 int findEvent(int evtNum) const;
158
159private: // data
161 mutable std::unique_ptr<pool::Collection> m_poolCollection ATLAS_THREAD_SAFE {};
162 mutable std::string m_curCollectionName ATLAS_THREAD_SAFE;
163 mutable std::unique_ptr<pool::CollectionCursor> m_headerIterator ATLAS_THREAD_SAFE {};
164 mutable Guid m_guid ATLAS_THREAD_SAFE {};
165 mutable std::map<SG::SourceID, int> m_activeEventsPerSource ATLAS_THREAD_SAFE;
167 mutable std::optional<InputFileIncidentGuard> m_inputFileGuard ATLAS_THREAD_SAFE;
168
169 ServiceHandle<IAthenaPoolCnvSvc> m_athenaPoolCnvSvc{this, "ConversionService", "AthenaPoolCnvSvc", ""};
170 ServiceHandle<IPoolSvc> m_poolSvc{this, "PoolSvc", "PoolSvc", ""};
171 ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc", ""};
172
173private: // properties
175 Gaudi::Property<bool> m_isSecondary{this, "IsSecondary", false, ""};
177 Gaudi::Property<bool> m_processMetadata{this, "ProcessMetadata", true, ""};
178
180 std::string m_attrListKey{"Input"};
181
183 Gaudi::Property<std::vector<std::string>> m_inputCollectionsProp{this, "InputCollections", {}, ""};
184 mutable std::vector<std::string>::const_iterator m_inputCollectionsIterator ATLAS_THREAD_SAFE;
185 void inputCollectionsHandler(Gaudi::Details::PropertyBase&);
187 mutable bool m_inputCollectionsChanged ATLAS_THREAD_SAFE;
188
191 Gaudi::Property<bool> m_keepInputFilesOpen{this, "KeepInputFilesOpen", false, ""};
192
194 mutable ToolHandleArray<IAthenaSelectorTool> m_helperTools ATLAS_THREAD_SAFE {this, "HelperTools", {}, ""};
195 ToolHandle<IAthenaSelectorTool> m_counterTool{this, "CounterTool", "", ""};
196
200 Gaudi::CheckedProperty<uint32_t> m_runNo{this, "RunNumber", 0, ""};
201 Gaudi::CheckedProperty<uint32_t> m_oldRunNo{this, "OldRunNumber", 0, ""};
202 Gaudi::Property<bool> m_overrideRunNumber{this, "OverrideRunNumber", false, ""};
203 Gaudi::Property<bool> m_overrideRunNumberFromInput{this, "OverrideRunNumberFromInput", false, ""};
204 // TODO: check if not really used
205 Gaudi::CheckedProperty<uint64_t> m_firstEventNo{this, "FirstEvent", 1, ""};
206 // TODO: check if not really used
207 Gaudi::CheckedProperty<uint64_t> m_eventsPerRun{this, "EventsPerRun", 1000000, ""};
208 Gaudi::CheckedProperty<uint32_t> m_firstLBNo{this, "FirstLB", 0, ""};
209 Gaudi::CheckedProperty<uint32_t> m_eventsPerLB{this, "EventsPerLB", 1000, ""};
210 Gaudi::CheckedProperty<uint32_t> m_initTimeStamp{this, "InitialTimeStamp", 0, ""};
211 Gaudi::Property<uint32_t> m_timeStampInterval{this, "TimeStampInterval", 0, ""};
212
213 mutable std::atomic_long m_curCollection{};
214 mutable std::vector<int> m_numEvt ATLAS_THREAD_SAFE;
215 mutable std::vector<int> m_firstEvt ATLAS_THREAD_SAFE;
216
218 Gaudi::Property<int> m_skipEvents{this, "SkipEvents", 0, ""};
219 Gaudi::Property<std::vector<long>> m_skipEventSequenceProp{this, "SkipEventSequence", {}, ""};
221 Gaudi::Property<std::string> m_skipEventRangesProp{this, "SkipEventRanges", {}, ""};
222 mutable std::vector<std::pair<long,long>> m_skipEventRanges ATLAS_THREAD_SAFE;
223
224 mutable std::atomic_int m_evtCount{}; // internal count of events
225 mutable std::atomic_bool m_firedIncident{};
226
227 typedef std::mutex CallMutex;
229
231
235
239};
240
241#endif
Maintain a set of objects, one per slot.
This file contains the class definition for the Guid class (migrated from POOL).
This file contains the class definition for the IAthenaPoolCnvSvc interface class.
This file contains the class definition for the IAthenaSelectorTool class.
Extension to IEvtSelector to allow for seeking.
This file contains the class definition for the IPoolSvc interface class.
Abstract interface for secondary event selectors.
RAII guard that guarantees a matching end-incident for every begin-incident.
size_t size() const
Number of registered mappings.
This class provides the context to access an event from POOL persistent store.
EventSelectorAthenaPool(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Gaudi::CheckedProperty< uint64_t > m_firstEventNo
virtual StatusCode start() override
Gaudi::Property< bool > m_isSecondary
IsSecondary, know if this is an instance of secondary event selector.
Gaudi::Property< bool > m_overrideRunNumberFromInput
virtual StatusCode nextWithSkip(IEvtSelector::Context &ctxt) const override
Go to next event and skip if necessary.
std::unique_ptr< pool::Collection > getCollection(bool throwIncidents=false) const
Return pointer to new Collection.
virtual StatusCode initialize() override
Required of all Gaudi Services.
Gaudi::Property< int > m_skipEvents
SkipEvents, numbers of events to skip: default = 0.
Gaudi::Property< bool > m_processMetadata
ProcessMetadata, switch on firing of FileIncidents which will trigger processing of metadata: default...
virtual int curEvent(const Context &ctxt) const override
Return the current event number.
virtual StatusCode createContext(IEvtSelector::Context *&ctxt) const override
create context
friend class EventSelectorAthenaPoolSharedIO
make the EventSelectorAthenaPoolSharedIO a friend so it can access the internal EventSelectorAthenaPo...
virtual StatusCode io_finalize() override
Callback method to finalize the internal state of the component for I/O purposes (e....
Gaudi::Property< std::vector< long > > m_skipEventSequenceProp
friend class DoubleEventSelectorAthenaPool
make the DoubleEventSelectorAthenaPool a friend so it can access the internal EventSelectorAthenaPool...
Gaudi::CheckedProperty< uint32_t > m_initTimeStamp
void inputCollectionsHandler(Gaudi::Details::PropertyBase &)
virtual StatusCode io_reinit() override
Callback method to reinitialize the internal state of the component for I/O purposes (e....
virtual StatusCode resetCriteria(const std::string &criteria, IEvtSelector::Context &ctxt) const override
Set a selection criteria.
StatusCode reinit() const
Reinitialize the service when a fork() occurred/was-issued.
StoreGateSvc * eventStore() const
Return pointer to active event SG.
virtual StatusCode releaseContext(IEvtSelector::Context *&ctxt) const override
virtual StatusCode stop() override
ServiceHandle< IIncidentSvc > m_incidentSvc
virtual StatusCode next(IEvtSelector::Context &ctxt) const override
virtual ~EventSelectorAthenaPool()
Destructor.
ToolHandle< IAthenaSelectorTool > m_counterTool
ServiceHandle< IPoolSvc > m_poolSvc
virtual StatusCode fillAttributeList(coral::AttributeList *attrList, const std::string &suffix, bool copySource) const override
Fill AttributeList with specific items from the selector and a suffix.
std::string m_attrListKey
AttributeList SG key.
virtual StatusCode seek(Context &ctxt, int evtnum) const override
Seek to a given event number.
SG::SlotSpecificObj< SG::SourceID > m_sourceID
virtual StatusCode last(IEvtSelector::Context &ctxt) const override
Gaudi::CheckedProperty< uint64_t > m_eventsPerRun
Gaudi::CheckedProperty< uint32_t > m_eventsPerLB
virtual StatusCode createAddress(const IEvtSelector::Context &ctxt, IOpaqueAddress *&iop) const override
virtual void handle(const Incident &incident) override
Incident service handle listening for BeginProcessing and EndProcessing.
virtual StatusCode previous(IEvtSelector::Context &ctxt) const override
ServiceHandle< IAthenaPoolCnvSvc > m_athenaPoolCnvSvc
virtual StatusCode rewind(IEvtSelector::Context &ctxt) const override
Gaudi::Property< bool > m_keepInputFilesOpen
KeepInputFilesOpen, boolean flag to keep files open after PoolCollection reaches end: default = false...
void disconnectCollection() const
Disconnect current collection DB if open.
Gaudi::CheckedProperty< uint32_t > m_oldRunNo
virtual StatusCode finalize() override
virtual bool disconnectIfFinished(const SG::SourceID &fid) const override
Disconnect DB if all events from the source FID were processed and the Selector moved to another file...
Gaudi::Property< std::vector< std::string > > m_inputCollectionsProp
InputCollections, vector with names of the input collections.
EventContextAthenaPool * m_endIter
StatusCode openCollection(std::string &inputCollection, std::unique_ptr< pool::Collection > &poolCollection, std::string *lastError=nullptr) const
Open a collection by name.
virtual StatusCode nextHandleFileTransition(IEvtSelector::Context &ctxt) const override
Handle file transition at the next iteration.
virtual StatusCode recordAttributeList() const override
Record AttributeList in StoreGate.
Gaudi::CheckedProperty< uint32_t > m_runNo
The following are included for compatibility with McEventSelector and are not really used.
int findEvent(int evtNum) const
Search for event with number evtNum.
Gaudi::Property< bool > m_overrideRunNumber
Gaudi::Property< std::string > m_skipEventRangesProp
Skip Events - comma separated list of event to skip, ranges with '-': <start> - <end>.
Gaudi::Property< uint32_t > m_timeStampInterval
Gaudi::CheckedProperty< uint32_t > m_firstLBNo
std::unique_ptr< pool::Collection > m_poolCollection ATLAS_THREAD_SAFE
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition Guid.h:25
This class provides the interface to the APR persistency software.
Definition IPoolSvc.h:33
Maintain a set of objects, one per slot.
The Athena Transient Store API.
Reader object for Collections.
Read-only collection implementation.
Definition Collection.h:26