ATLAS Offline Software
Loading...
Searching...
No Matches
EventSelectorByteStream.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 BYTESTREAMCNVSVC_EVENTSELECTORBYTESTREAM_H
6#define BYTESTREAMCNVSVC_EVENTSELECTORBYTESTREAM_H
7
18
19#include "GaudiKernel/IEvtSelector.h"
20#include "GaudiKernel/ServiceHandle.h"
21#include "GaudiKernel/ToolHandle.h"
22#include "GaudiKernel/IIoComponent.h"
23
31
35#include <mutex>
36#include <optional>
37
38// Forward declarations.
39class ISvcLocator;
42
43// Class EventSelectorByteStream.
45 public extends<::AthService, IEvtSelector, IEvtSelectorSeek, IEventShare, IIoComponent, ISecondaryEventSelector>
46{
47public:
49 EventSelectorByteStream(const std::string& name, ISvcLocator* svcloc);
52
54 virtual StatusCode initialize() override;
55 virtual StatusCode start() override;
56 virtual StatusCode stop() override;
57 virtual StatusCode finalize() override;
58
59 //-------------------------------------------------
60 // IEventSelector
62 virtual StatusCode createContext(Context*& it) const override;
64 virtual StatusCode next(Context& it) const override;
67 virtual StatusCode next(Context& it, int jump) const override;
69 virtual StatusCode previous(Context& it) const override;
72 virtual StatusCode previous(Context& it, int jump) const override;
73
75 virtual StatusCode last(Context& it) const override;
77 virtual StatusCode rewind(Context& it) const override;
78
81 virtual StatusCode createAddress(const Context& it,IOpaqueAddress*& iop) const override;
82
84 virtual StatusCode releaseContext(Context*& it) const override;
85
89 virtual StatusCode resetCriteria(const std::string& criteria, Context& context) const override;
90
91 //-------------------------------------------------
92 // IEventSelectorSeek
96 virtual StatusCode seek (Context& /* it */, int evtnum) const override;
97
100 virtual int curEvent (const Context& it) const override;
101
104 virtual int size (Context& it) const override;
105
106 //-------------------------------------------------
107 // IEventShare
109 virtual StatusCode makeServer(int num) override;
110
112 virtual StatusCode makeClient(int num) override;
113
116 virtual StatusCode share(int evtnum) override;
117
120 virtual StatusCode readEvent(int maxevt) override;
121
122 //-------------------------------------------------
123 // IIoComponent
125 virtual StatusCode io_reinit() override;
126
127protected:
128 using mutex_t = std::recursive_mutex;
129 using lock_t = std::lock_guard<mutex_t>;
130
131 //-------------------------------------------------
132 // ISecondaryEventSelector
134 virtual StatusCode nextHandleFileTransition(IEvtSelector::Context& ctxt) const override;
136 virtual StatusCode nextWithSkip(IEvtSelector::Context& ctxt) const override;
138 virtual StatusCode recordAttributeList() const override;
140 virtual StatusCode fillAttributeList(coral::AttributeList *attrList, const std::string &suffix, bool copySource) const override;
141 // Disconnect DB if all events from the source FID were processed and the Selector moved to another file
142 virtual bool disconnectIfFinished(const SG::SourceID &fid) const override;
143
144private: // internal member functions
145 StatusCode nextImpl(Context& it, lock_t& lock) const;
146 StatusCode nextImpl(Context& it, int jump, lock_t& lock) const;
147 StatusCode previousImpl(Context& it, lock_t& lock) const;
148 StatusCode previousImpl(Context& it, int jump, lock_t& lock) const;
149 StatusCode nextHandleFileTransitionImpl(IEvtSelector::Context& ctxt,
150 lock_t& lock) const;
151 StatusCode nextWithSkipImpl(IEvtSelector::Context& ctxt,
152 lock_t& lock) const;
153 StatusCode recordAttributeListImpl(lock_t& lock) const;
154 StatusCode fillAttributeListImpl(coral::AttributeList *attrList, const std::string &suffix, bool copySource,
155 lock_t& lock) const;
156
158 StatusCode reinit(lock_t& lock);
159 StatusCode openNewRun(lock_t& lock) const;
160 void nextFile(lock_t& lock) const;
162 int findEvent(int evtNum, lock_t& lock) const;
163 StoreGateSvc* eventStore() const;
164
165private: // properties
166 // FIXME: A Gaudi EventSelector is not meant to have mutable state.
167 // Any needed state is meant to be kept in the Context object.
168 // So the mutable members here should instead be kept in
169 // EventContextByteStream. However, making that work would
170 // require redesigning other Athena interfaces. So for now,
171 // just add a mutex to protect access to them.
173 mutable int m_fileCount ATLAS_THREAD_SAFE = 0;
174 mutable std::vector<int> m_numEvt ATLAS_THREAD_SAFE;
175 mutable std::vector<int> m_firstEvt ATLAS_THREAD_SAFE;
176 mutable std::vector<std::string>::const_iterator m_inputCollectionsIterator ATLAS_THREAD_SAFE;
177 mutable std::vector<long> m_skipEventSequence ATLAS_THREAD_SAFE;
178 mutable long m_NumEvents ATLAS_THREAD_SAFE = 0; // Number of Events read so far.
179 mutable ToolHandle<IAthenaIPCTool> m_eventStreamingTool ATLAS_THREAD_SAFE {this, "SharedMemoryTool", "", ""};
180
182 Gaudi::Property<bool> m_isSecondary{this, "IsSecondary", false, ""};
183
184 Gaudi::Property<std::string> m_eventSourceName{this, "ByteStreamInputSvc", "", ""};
185 Gaudi::Property<bool> m_procBadEvent{this, "ProcessBadEvent", false, ""};
186 Gaudi::Property<int> m_maxBadEvts{this, "MaxBadEvents", -1, ""};
187
190 SmartIF<IByteStreamInputSvc> m_eventSource;
191 Gaudi::Property<std::vector<std::string>> m_inputCollectionsProp{this, "Input", {}, ""};
192 void inputCollectionsHandler(Gaudi::Details::PropertyBase&);
193 ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc", ""};
194
195 Gaudi::Property<long> m_skipEvents{this, "SkipEvents", 0, ""}; // Number of events to skip at the beginning
196 Gaudi::Property<std::vector<long>> m_skipEventSequenceProp{this, "SkipEventSequence", {}, ""};
197
200 mutable std::optional<InputFileIncidentGuard> m_inputFileGuard ATLAS_THREAD_SAFE;
201
203 ToolHandleArray<IAthenaSelectorTool> m_helperTools{this, "HelperTools", {}, "Helper tools executed by EventSelector"};
204 ToolHandle<IAthenaSelectorTool> m_counterTool{this, "CounterTool", "", ""};
205
209 Gaudi::Property<bool> m_overrideRunNumber{this, "OverrideRunNumber", false, ""};
210 Gaudi::Property<bool> m_filebased{this, "FileBased", true, ""};
211
212 Gaudi::CheckedProperty<uint32_t> m_runNo{this, "RunNumber", 0, ""};
213 Gaudi::CheckedProperty<uint64_t> m_firstEventNo{this, "FirstEvent", 1, ""};
214 Gaudi::CheckedProperty<uint64_t> m_eventsPerRun{this, "EventsPerRun", 1000000, ""};
215 Gaudi::CheckedProperty<uint32_t> m_firstLBNo{this, "FirstLB", 0, ""};
216 Gaudi::CheckedProperty<uint32_t> m_eventsPerLB{this, "EventsPerLB", 1000, ""};
217 Gaudi::CheckedProperty<uint32_t> m_initTimeStamp{this, "InitialTimeStamp", 0, ""};
218 Gaudi::Property<uint32_t> m_timeStampInterval{this, "TimeStampInterval", 0, ""};
219};
220
221#endif // BYTESTREAMCNVSVC_EVENTSELECTORBYTESTREAM_H
This file contains the class definition for the IAthenaSelectorTool class.
This file contains the interface for the ByteStreamInputSvc classes.
Extension to IEvtSelector to allow for seeking.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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.
Define macros for attributes used to control the static checker.
This class provides the Context for EventSelectorByteStream.
virtual StatusCode initialize() override
Implementation of Service base class methods.
virtual StatusCode stop() override
Gaudi::Property< bool > m_isSecondary
IsSecondary, know if this is an instance of secondary event selector.
virtual StatusCode previous(Context &it, int jump) const override
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.
Gaudi::Property< std::string > m_eventSourceName
ToolHandle< IAthenaSelectorTool > m_counterTool
virtual StatusCode share(int evtnum) override
Request to share a given event number.
Gaudi::Property< bool > m_filebased
Gaudi::Property< uint32_t > m_timeStampInterval
virtual StatusCode resetCriteria(const std::string &criteria, Context &context) const override
Set a selection criteria.
std::lock_guard< mutex_t > lock_t
SmartIF< IByteStreamInputSvc > m_eventSource
Gaudi::CheckedProperty< uint32_t > m_firstLBNo
virtual StatusCode readEvent(int maxevt) override
Read the next maxevt events.
EventContextByteStream * m_endIter
int findEvent(int evtNum, lock_t &lock) const
Search for event with number evtNum.
virtual StatusCode releaseContext(Context *&it) const override
virtual StatusCode makeServer(int num) override
Make this a server.
virtual StatusCode next(Context &it, int jump) const override
virtual bool disconnectIfFinished(const SG::SourceID &fid) const override
Gaudi::CheckedProperty< uint64_t > m_eventsPerRun
StatusCode nextImpl(Context &it, int jump, lock_t &lock) const
virtual StatusCode nextWithSkip(IEvtSelector::Context &ctxt) const override
Go to next event and skip if necessary.
ToolHandleArray< IAthenaSelectorTool > m_helperTools
HelperTools, vector of names of AlgTools that are executed by the EventSelector.
virtual StatusCode finalize() override
StatusCode previousImpl(Context &it, lock_t &lock) const
virtual StatusCode last(Context &it) const override
Gaudi::CheckedProperty< uint32_t > m_initTimeStamp
Gaudi::CheckedProperty< uint32_t > m_eventsPerLB
Gaudi::Property< bool > m_overrideRunNumber
The following are included for compatibility with McEventSelector and are not really used.
Gaudi::Property< bool > m_procBadEvent
process bad events, which fail check_tree().
Gaudi::CheckedProperty< uint32_t > m_runNo
virtual StatusCode createContext(Context *&it) const override
create context
virtual StatusCode createAddress(const Context &it, IOpaqueAddress *&iop) const override
virtual StatusCode makeClient(int num) override
Make this a client.
virtual int curEvent(const Context &it) const override
Return the current event number.
ServiceHandle< IIncidentSvc > m_incidentSvc
StatusCode nextImpl(Context &it, lock_t &lock) const
StatusCode fillAttributeListImpl(coral::AttributeList *attrList, const std::string &suffix, bool copySource, lock_t &lock) const
void nextFile(lock_t &lock) const
StatusCode nextHandleFileTransitionImpl(IEvtSelector::Context &ctxt, lock_t &lock) const
virtual StatusCode rewind(Context &it) const override
StatusCode reinit(lock_t &lock)
Reinitialize the service when a fork() occurred/was-issued.
Gaudi::Property< std::vector< std::string > > m_inputCollectionsProp
virtual StatusCode next(Context &it) const override
int m_fileCount ATLAS_THREAD_SAFE
number of files to process.
StatusCode openNewRun(lock_t &lock) const
virtual StatusCode io_reinit() override
Callback method to reinitialize the internal state of the component for I/O purposes (e....
virtual ~EventSelectorByteStream()
Standard Destructor.
Gaudi::Property< std::vector< long > > m_skipEventSequenceProp
StoreGateSvc * eventStore() const
void inputCollectionsHandler(Gaudi::Details::PropertyBase &)
virtual StatusCode start() override
virtual StatusCode recordAttributeList() const override
Record AttributeList in StoreGate.
virtual StatusCode seek(Context &, int evtnum) const override
Seek to a given event number.
StatusCode nextWithSkipImpl(IEvtSelector::Context &ctxt, lock_t &lock) const
StatusCode recordAttributeListImpl(lock_t &lock) const
Gaudi::CheckedProperty< uint64_t > m_firstEventNo
EventContextByteStream * m_beginIter
virtual StatusCode nextHandleFileTransition(IEvtSelector::Context &ctxt) const override
Handle file transition at the next iteration.
StatusCode previousImpl(Context &it, int jump, lock_t &lock) const
Gaudi::Property< long > m_skipEvents
virtual StatusCode previous(Context &it) const override
Gaudi::Property< int > m_maxBadEvts
number of bad events allowed before quitting.
EventSelectorByteStream(const std::string &name, ISvcLocator *svcloc)
Standard Constructor.
Interface class for managing ROB for both online and offline.
The Athena Transient Store API.