ATLAS Offline Software
Loading...
Searching...
No Matches
EventSelectorAthenaPool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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"
20
29
30#include <map>
31#include <atomic>
32#include <cstdint>
33#include <memory>
34
35// Forward declarations
36class IIncidentSvc;
37class IOpaqueAddress;
38class ISvcLocator;
41class StoreGateSvc;
42namespace pool {
44}
45
50 public extends<::AthService, IEvtSelector, IEvtSelectorSeek, IEventShare, IIoComponent, IIncidentListener, ISecondaryEventSelector>
51{
52
53public: // Constructor and Destructor
55 EventSelectorAthenaPool(const std::string& name, ISvcLocator* pSvcLocator);
58
60 virtual StatusCode initialize() override;
61 virtual StatusCode start() override;
62 virtual StatusCode stop() override;
63 virtual StatusCode finalize() override;
64
65 //-------------------------------------------------
66 // IEventSelector
68 virtual StatusCode createContext(IEvtSelector::Context*& ctxt) const override;
69
71 virtual StatusCode next(IEvtSelector::Context& ctxt) const override;
74 virtual StatusCode next(IEvtSelector::Context& ctxt, int jump) const override;
75
77 virtual StatusCode previous(IEvtSelector::Context& ctxt) const override;
80 virtual StatusCode previous(IEvtSelector::Context& ctxt, int jump) const override;
81
83 virtual StatusCode last(IEvtSelector::Context& ctxt) const override;
84
86 virtual StatusCode rewind(IEvtSelector::Context& ctxt) const override;
87
90 virtual StatusCode createAddress(const IEvtSelector::Context& ctxt, IOpaqueAddress*& iop) const override;
91
93 virtual StatusCode releaseContext(IEvtSelector::Context*& ctxt) const override;
94
98 virtual StatusCode resetCriteria(const std::string& criteria, IEvtSelector::Context& ctxt) const override;
99
100 //-------------------------------------------------
101 // IEventSelectorSeek
105 virtual StatusCode seek(Context& ctxt, int evtnum) const override;
106
109 virtual int curEvent (const Context& ctxt) const override;
110
113 virtual int size (Context& ctxt) const override;
114
115 //-------------------------------------------------
116 // IEventShare
118 virtual StatusCode makeServer(int num) override;
119
121 virtual StatusCode makeClient(int num) override;
122
125 virtual StatusCode share(int evtnum) override;
126
129 virtual StatusCode readEvent(int maxevt) override;
130
131 //-------------------------------------------------
132 // IIoComponent
134 virtual StatusCode io_reinit() override;
136 virtual StatusCode io_finalize() override;
137
138 //-------------------------------------------------
139 // IIncidentListener
141 virtual void handle(const Incident& incident) override;
142
143protected:
144 //-------------------------------------------------
145 // ISecondaryEventSelector
147 virtual StatusCode nextHandleFileTransition(IEvtSelector::Context& ctxt) const override;
149 virtual StatusCode nextWithSkip(IEvtSelector::Context& ctxt) const override;
151 virtual StatusCode recordAttributeList() const override;
153 virtual StatusCode fillAttributeList(coral::AttributeList *attrList, const std::string &suffix, bool copySource) const override;
154 // Disconnect DB if all events from the source FID were processed and the Selector moved to another file
155 virtual bool disconnectIfFinished(const SG::SourceID &fid) const override;
156
157private: // internal member functions
159 StoreGateSvc* eventStore() const;
161 StatusCode reinit() const;
163 std::unique_ptr<PoolCollectionConverter> getCollectionCnv(bool throwIncidents = false) const;
165 int findEvent(int evtNum) const;
167 void fireEndFileIncidents(bool isLastFile) const;
168
169private: // data
171
172
173 mutable std::unique_ptr<PoolCollectionConverter> m_poolCollectionConverter ATLAS_THREAD_SAFE {};
174 mutable pool::ICollectionCursor* m_headerIterator ATLAS_THREAD_SAFE {};
175 mutable Guid m_guid ATLAS_THREAD_SAFE {};
176 mutable std::map<SG::SourceID, int> m_activeEventsPerSource ATLAS_THREAD_SAFE;
177
178 ServiceHandle<IAthenaPoolCnvSvc> m_athenaPoolCnvSvc{this, "ConversionService", "AthenaPoolCnvSvc", ""};
179 ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc", ""};
180
181private: // properties
183 Gaudi::Property<bool> m_isSecondary{this, "IsSecondary", false, ""};
185 Gaudi::Property<bool> m_processMetadata{this, "ProcessMetadata", true, ""};
187 Gaudi::Property<std::string> m_collectionType{this, "CollectionType", "ImplicitCollection", ""};
189 Gaudi::Property<std::string> m_collectionTree{this, "CollectionTree", APRDefaults::TTreeNames::DataHeader, ""};
191 // TODO: check if really not used anywhere
192 Gaudi::Property<std::string> m_connection{this, "Connection", "", ""};
194 Gaudi::Property<std::string> m_attrListKey{this, "AttributeListKey", "Input", ""};
195
197 Gaudi::Property<std::vector<std::string>> m_inputCollectionsProp{this, "InputCollections", {}, ""};
198 mutable std::vector<std::string>::const_iterator m_inputCollectionsIterator ATLAS_THREAD_SAFE;
199 void inputCollectionsHandler(Gaudi::Details::PropertyBase&);
201 mutable bool m_inputCollectionsChanged ATLAS_THREAD_SAFE;
202
205 Gaudi::Property<bool> m_keepInputFilesOpen{this, "KeepInputFilesOpen", false, ""};
206
208 mutable ToolHandleArray<IAthenaSelectorTool> m_helperTools ATLAS_THREAD_SAFE {this, "HelperTools", {}, ""};
209 ToolHandle<IAthenaSelectorTool> m_counterTool{this, "CounterTool", "", ""};
210 ToolHandle<IAthenaIPCTool> m_eventStreamingTool{this, "SharedMemoryTool", "", ""};
212 Gaudi::Property<int> m_makeStreamingToolClient{this,"MakeStreamingToolClient",0};
213
217 Gaudi::CheckedProperty<uint32_t> m_runNo{this, "RunNumber", 0, ""};
218 Gaudi::CheckedProperty<uint32_t> m_oldRunNo{this, "OldRunNumber", 0, ""};
219 Gaudi::Property<bool> m_overrideRunNumber{this, "OverrideRunNumber", false, ""};
220 Gaudi::Property<bool> m_overrideRunNumberFromInput{this, "OverrideRunNumberFromInput", false, ""};
221 // TODO: check if not really used
222 Gaudi::CheckedProperty<uint64_t> m_firstEventNo{this, "FirstEvent", 1, ""};
223 // TODO: check if not really used
224 Gaudi::CheckedProperty<uint64_t> m_eventsPerRun{this, "EventsPerRun", 1000000, ""};
225 Gaudi::CheckedProperty<uint32_t> m_firstLBNo{this, "FirstLB", 0, ""};
226 Gaudi::CheckedProperty<uint32_t> m_eventsPerLB{this, "EventsPerLB", 1000, ""};
227 Gaudi::CheckedProperty<uint32_t> m_initTimeStamp{this, "InitialTimeStamp", 0, ""};
228 Gaudi::Property<uint32_t> m_timeStampInterval{this, "TimeStampInterval", 0, ""};
229
230 mutable std::atomic_long m_curCollection{};
231 mutable std::vector<int> m_numEvt ATLAS_THREAD_SAFE;
232 mutable std::vector<int> m_firstEvt ATLAS_THREAD_SAFE;
233
235 Gaudi::Property<int> m_skipEvents{this, "SkipEvents", 0, ""};
236 Gaudi::Property<std::vector<long>> m_skipEventSequenceProp{this, "SkipEventSequence", {}, ""};
238 Gaudi::Property<std::string> m_skipEventRangesProp{this, "SkipEventRanges", {}, ""};
239 mutable std::vector<std::pair<long,long>> m_skipEventRanges ATLAS_THREAD_SAFE;
240
241 mutable std::atomic_int m_evtCount{}; // internal count of events
242 mutable std::atomic_bool m_firedIncident{};
243
244 typedef std::mutex CallMutex;
246
248
252};
253
254#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.
Abstract interface for secondary event selectors.
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
std::unique_ptr< PoolCollectionConverter > getCollectionCnv(bool throwIncidents=false) const
Return pointer to new PoolCollectionConverter.
Gaudi::Property< bool > m_isSecondary
IsSecondary, know if this is an instance of secondary event selector.
virtual StatusCode makeClient(int num) override
Make this a client.
Gaudi::Property< bool > m_overrideRunNumberFromInput
virtual StatusCode nextWithSkip(IEvtSelector::Context &ctxt) const override
Go to next event and skip if necessary.
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 StatusCode share(int evtnum) override
Request to share a given event number.
virtual int curEvent(const Context &ctxt) const override
Return the current event number.
virtual StatusCode createContext(IEvtSelector::Context *&ctxt) const override
create context
Gaudi::Property< std::string > m_attrListKey
AttributeList SG key.
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.
void fireEndFileIncidents(bool isLastFile) const
Fires the EndInputFile incident (if there is an open file) at end of selector.
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.
std::unique_ptr< PoolCollectionConverter > m_poolCollectionConverter ATLAS_THREAD_SAFE
ToolHandle< IAthenaSelectorTool > m_counterTool
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.
virtual StatusCode seek(Context &ctxt, int evtnum) const override
Seek to a given event number.
SG::SlotSpecificObj< SG::SourceID > m_sourceID
Gaudi::Property< std::string > m_collectionTree
CollectionTree, prefix of the collection TTree: default = "POOLContainer".
ToolHandle< IAthenaIPCTool > m_eventStreamingTool
Gaudi::Property< std::string > m_connection
Connection, connection string.
virtual StatusCode last(IEvtSelector::Context &ctxt) const override
virtual StatusCode makeServer(int num) override
Make this a server.
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...
Gaudi::CheckedProperty< uint32_t > m_oldRunNo
Gaudi::Property< std::string > m_collectionType
CollectionType, type of the collection: default = "ImplicitCollection".
virtual StatusCode finalize() override
virtual bool disconnectIfFinished(const SG::SourceID &fid) const override
Gaudi::Property< std::vector< std::string > > m_inputCollectionsProp
InputCollections, vector with names of the input collections.
EventContextAthenaPool * m_endIter
Gaudi::Property< int > m_makeStreamingToolClient
Make this instance a Streaming Client during first iteration automatically.
virtual StatusCode readEvent(int maxevt) override
Read the next maxevt events.
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.
virtual int size(Context &ctxt) const override
Return the size of the collection.
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
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition Guid.h:25
This class provides an interface to POOL collections.
Maintain a set of objects, one per slot.
The Athena Transient Store API.
An interface used to navigate the result of a query on a collection.
pool namespace
Definition libname.h:15
static constexpr const char * DataHeader
Definition APRDefaults.h:14