ATLAS Offline Software
Loading...
Searching...
No Matches
EventSelectorByteStream.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 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
30
34#include <mutex>
35
36// Forward declarations.
37class ISvcLocator;
40
41// Class EventSelectorByteStream.
43 public extends<::AthService, IEvtSelector, IEvtSelectorSeek, IEventShare, IIoComponent, ISecondaryEventSelector>
44{
45public:
47 EventSelectorByteStream(const std::string& name, ISvcLocator* svcloc);
50
52 virtual StatusCode initialize() override;
53 virtual StatusCode start() override;
54 virtual StatusCode stop() override;
55 virtual StatusCode finalize() override;
56
57 //-------------------------------------------------
58 // IEventSelector
60 virtual StatusCode createContext(Context*& it) const override;
62 virtual StatusCode next(Context& it) const override;
65 virtual StatusCode next(Context& it, int jump) const override;
67 virtual StatusCode previous(Context& it) const override;
70 virtual StatusCode previous(Context& it, int jump) const override;
71
73 virtual StatusCode last(Context& it) const override;
75 virtual StatusCode rewind(Context& it) const override;
76
79 virtual StatusCode createAddress(const Context& it,IOpaqueAddress*& iop) const override;
80
82 virtual StatusCode releaseContext(Context*& it) const override;
83
87 virtual StatusCode resetCriteria(const std::string& criteria, Context& context) const override;
88
89 //-------------------------------------------------
90 // IEventSelectorSeek
94 virtual StatusCode seek (Context& /* it */, int evtnum) const override;
95
98 virtual int curEvent (const Context& it) const override;
99
102 virtual int size (Context& it) const override;
103
104 //-------------------------------------------------
105 // IEventShare
107 virtual StatusCode makeServer(int num) override;
108
110 virtual StatusCode makeClient(int num) override;
111
114 virtual StatusCode share(int evtnum) override;
115
118 virtual StatusCode readEvent(int maxevt) override;
119
120 //-------------------------------------------------
121 // IIoComponent
123 virtual StatusCode io_reinit() override;
124
125protected:
126 using mutex_t = std::recursive_mutex;
127 using lock_t = std::lock_guard<mutex_t>;
128
129 //-------------------------------------------------
130 // ISecondaryEventSelector
132 virtual StatusCode nextHandleFileTransition(IEvtSelector::Context& ctxt) const override;
134 virtual StatusCode nextWithSkip(IEvtSelector::Context& ctxt) const override;
136 virtual StatusCode recordAttributeList() const override;
138 virtual StatusCode fillAttributeList(coral::AttributeList *attrList, const std::string &suffix, bool copySource) const override;
139 // Disconnect DB if all events from the source FID were processed and the Selector moved to another file
140 virtual bool disconnectIfFinished(const SG::SourceID &fid) const override;
141
142private: // internal member functions
143 StatusCode nextImpl(Context& it, lock_t& lock) const;
144 StatusCode nextImpl(Context& it, int jump, lock_t& lock) const;
145 StatusCode previousImpl(Context& it, lock_t& lock) const;
146 StatusCode previousImpl(Context& it, int jump, lock_t& lock) const;
147 StatusCode nextHandleFileTransitionImpl(IEvtSelector::Context& ctxt,
148 lock_t& lock) const;
149 StatusCode nextWithSkipImpl(IEvtSelector::Context& ctxt,
150 lock_t& lock) const;
151 StatusCode recordAttributeListImpl(lock_t& lock) const;
152 StatusCode fillAttributeListImpl(coral::AttributeList *attrList, const std::string &suffix, bool copySource,
153 lock_t& lock) const;
154
156 StatusCode reinit(lock_t& lock);
157 StatusCode openNewRun(lock_t& lock) const;
158 void nextFile(lock_t& lock) const;
160 int findEvent(int evtNum, lock_t& lock) const;
161 StoreGateSvc* eventStore() const;
162
163private: // properties
164 // FIXME: A Gaudi EventSelector is not meant to have mutable state.
165 // Any needed state is meant to be kept in the Context object.
166 // So the mutable members here should instead be kept in
167 // EventContextByteStream. However, making that work would
168 // require redesigning other Athena interfaces. So for now,
169 // just add a mutex to protect access to them.
171 mutable int m_fileCount ATLAS_THREAD_SAFE = 0;
172 mutable std::vector<int> m_numEvt ATLAS_THREAD_SAFE;
173 mutable std::vector<int> m_firstEvt ATLAS_THREAD_SAFE;
174 mutable std::vector<std::string>::const_iterator m_inputCollectionsIterator ATLAS_THREAD_SAFE;
175 mutable std::vector<long> m_skipEventSequence ATLAS_THREAD_SAFE;
176 mutable long m_NumEvents ATLAS_THREAD_SAFE = 0; // Number of Events read so far.
177 mutable ToolHandle<IAthenaIPCTool> m_eventStreamingTool ATLAS_THREAD_SAFE {this, "SharedMemoryTool", "", ""};
178
180 Gaudi::Property<bool> m_isSecondary{this, "IsSecondary", false, ""};
181
182 Gaudi::Property<std::string> m_eventSourceName{this, "ByteStreamInputSvc", "", ""};
183 Gaudi::Property<bool> m_procBadEvent{this, "ProcessBadEvent", false, ""};
184 Gaudi::Property<int> m_maxBadEvts{this, "MaxBadEvents", -1, ""};
185
188 SmartIF<IByteStreamInputSvc> m_eventSource;
189 Gaudi::Property<std::vector<std::string>> m_inputCollectionsProp{this, "Input", {}, ""};
190 void inputCollectionsHandler(Gaudi::Details::PropertyBase&);
191 ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc", ""};
192
193 Gaudi::Property<long> m_skipEvents{this, "SkipEvents", 0, ""}; // Number of events to skip at the beginning
194 Gaudi::Property<std::vector<long>> m_skipEventSequenceProp{this, "SkipEventSequence", {}, ""};
195
198
200 ToolHandleArray<IAthenaSelectorTool> m_helperTools{this, "HelperTools", {}, "Helper tools executed by EventSelector"};
201 ToolHandle<IAthenaSelectorTool> m_counterTool{this, "CounterTool", "", ""};
202
206 Gaudi::Property<bool> m_overrideRunNumber{this, "OverrideRunNumber", false, ""};
207 Gaudi::Property<bool> m_filebased{this, "FileBased", true, ""};
208
209 Gaudi::CheckedProperty<uint32_t> m_runNo{this, "RunNumber", 0, ""};
210 Gaudi::CheckedProperty<uint64_t> m_firstEventNo{this, "FirstEvent", 1, ""};
211 Gaudi::CheckedProperty<uint64_t> m_eventsPerRun{this, "EventsPerRun", 1000000, ""};
212 Gaudi::CheckedProperty<uint32_t> m_firstLBNo{this, "FirstLB", 0, ""};
213 Gaudi::CheckedProperty<uint32_t> m_eventsPerLB{this, "EventsPerLB", 1000, ""};
214 Gaudi::CheckedProperty<uint32_t> m_initTimeStamp{this, "InitialTimeStamp", 0, ""};
215 Gaudi::Property<uint32_t> m_timeStampInterval{this, "TimeStampInterval", 0, ""};
216};
217
218#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.
Abstract interface for secondary event selectors.
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 int size(Context &it) const override
Always returns -1.
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.