ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEventSelectorByteStream.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Trigger includes
8
9// Athena includes
18
19// =============================================================================
20// Standard constructor
21// =============================================================================
22TrigEventSelectorByteStream::TrigEventSelectorByteStream(const std::string& name, ISvcLocator* svcLoc)
23: base_class(name, svcLoc),
24 m_eventSource("ByteStreamInputSvc", name),
25 m_evtStore("StoreGateSvc", name) {
26 declareProperty("ByteStreamInputSvc", m_eventSource);
27}
28
29// =============================================================================
30// Standard destructor
31// =============================================================================
33
34// =============================================================================
35// Implementation of Service::initialize
36// =============================================================================
38{
39 ATH_MSG_VERBOSE("start of " << __FUNCTION__);
40
41 ATH_CHECK(m_eventSource.retrieve());
42 ATH_CHECK(m_evtStore.retrieve());
43
44 ATH_MSG_VERBOSE("end of " << __FUNCTION__);
45 return StatusCode::SUCCESS;
46}
47
48// =============================================================================
49// Implementation of Service::finalize
50// =============================================================================
52{
53 ATH_MSG_VERBOSE("start of " << __FUNCTION__);
54 if (m_eventSource.release().isFailure()) {
55 ATH_MSG_WARNING("Cannot release the event source service");
56 }
57 ATH_MSG_VERBOSE("end of " << __FUNCTION__);
58 return StatusCode::SUCCESS;
59}
60
61// =============================================================================
62// Implementation of IEvtSelector::next(Context&)
63// There is actually no event selection here, we process all events online
64// =============================================================================
65StatusCode TrigEventSelectorByteStream::next(IEvtSelector::Context& /*c*/) const
66{
67 ATH_MSG_VERBOSE("start of " << __FUNCTION__);
68
69 // RawEvent is a typedef for FullEventFragment
70 const RawEvent* ptrRawEvent = nullptr;
71
72 // Try to get the next event from the event source
73 try {
74 ptrRawEvent = m_eventSource->nextEvent();
75 }
76 catch (const hltonl::Exception::NoMoreEvents& e) {
77 ATH_MSG_INFO(e.what());
78 throw; // rethrow NoMoreEvents
79 }
81 ATH_MSG_DEBUG(e.what());
82 throw; // rethrow NoEventsTemporarily
83 }
85 ATH_MSG_ERROR(e.what());
86 throw; // rethrow EventSourceCorrupted
87 }
89 ATH_MSG_INFO(e.what());
90 throw; // rethrow MissingCTPFragment
91 }
92 catch (const hltonl::Exception::BadCTPFragment& e) {
93 ATH_MSG_INFO(e.what());
94 throw; // rethrow BadCTPFragment
95 }
96 catch (const std::exception& e) {
97 ATH_MSG_ERROR("Failed to get next event from the event source, std::exception caught: " << e.what());
98 return StatusCode::FAILURE;
99 }
100 catch (...) {
101 ATH_MSG_ERROR("Failed to get next event from the event source, unknown exception caught");
102 return StatusCode::FAILURE;
103 }
104
105 // Check if something was returned
106 if (ptrRawEvent == nullptr) {
107 ATH_MSG_ERROR("Failed to get next event from the event source, nullptr returned");
108 return StatusCode::FAILURE;
109 }
110
111 ATH_MSG_VERBOSE("end of " << __FUNCTION__);
112 return StatusCode::SUCCESS;
113}
114
115// =============================================================================
116// Implementation of IEvtSelector::createContext(Context*&)
117// =============================================================================
118StatusCode TrigEventSelectorByteStream::createContext(IEvtSelector::Context*& c) const
119{
121 return StatusCode::SUCCESS;
122}
123
124// =============================================================================
125// Implementation of IEvtSelector::releaseContext(Context*&)
126// =============================================================================
127StatusCode TrigEventSelectorByteStream::releaseContext(IEvtSelector::Context*& /*c*/) const
128{
129 // this does nothing
130 return StatusCode::SUCCESS;
131}
132
133// =============================================================================
134// Implementation of IEvtSelector::createAddress(Context&,IOpaqueAddress*&)
135// =============================================================================
136StatusCode TrigEventSelectorByteStream::createAddress(const IEvtSelector::Context& /*c*/, IOpaqueAddress*& iop) const
137{
138 ATH_MSG_VERBOSE("start of " << __FUNCTION__);
139
140 // Get the EventContext via event store because the interface doesn't allow passing it explicitly as an argument
141 // and we don't want to use ThreadLocalContext. Don't use ReadHandle here because it calls ThreadLocalContext if
142 // not given a context (which we want to retrieve).
143 const EventContext* eventContext = nullptr;
144 ATH_CHECK(m_evtStore->retrieve(eventContext));
145
146 // Create and record ByteStreamAddress for xAOD::EventInfo
149 addr->setEventContext(*eventContext);
150 iop = addr.get();
151 ATH_CHECK(m_evtStore->recordAddress("EventInfo",std::move(addr)));
152 ATH_MSG_DEBUG("Recorded new ByteStreamAddress for xAOD::EventInfo with event context " << *eventContext);
153
154 // Create and record ByteStreamAddress for xAOD::EventAuxInfo
156 (new ByteStreamAddress(ClassID_traits<xAOD::EventAuxInfo>::ID(), "EventInfoAux.", ""));
157 auxaddr->setEventContext(*eventContext);
158 ATH_CHECK(m_evtStore->recordAddress("EventInfoAux.", std::move(auxaddr)));
159 ATH_MSG_DEBUG("Recorded new ByteStreamAddress for xAOD::EventAuxInfo with event context " << *eventContext);
160
161 ATH_MSG_VERBOSE("end of " << __FUNCTION__);
162 return StatusCode::SUCCESS;
163}
164
165// =============================================================================
166// Unimplemented methods of IEvtSelector
167// =============================================================================
168#define TRIGEVENTSELECTORBYTESTREAM_UNIMPL \
169 ATH_MSG_FATAL("Misconfiguration - the method " << __FUNCTION__ << " cannot be used online"); \
170 return StatusCode::FAILURE;
171
172StatusCode TrigEventSelectorByteStream::next(IEvtSelector::Context& /*c*/, int /*jump*/) const
173{
175}
176
177StatusCode TrigEventSelectorByteStream::previous(IEvtSelector::Context& /*c*/) const
178{
180}
181
182StatusCode TrigEventSelectorByteStream::previous(IEvtSelector::Context& /*c*/, int /*jump*/) const
183{
185}
186
187StatusCode TrigEventSelectorByteStream::last(IEvtSelector::Context& /*refContext*/) const
188{
190}
191
192StatusCode TrigEventSelectorByteStream::rewind(IEvtSelector::Context& /*c*/) const
193{
195}
196
197StatusCode TrigEventSelectorByteStream::resetCriteria(const std::string& /*cr*/, IEvtSelector::Context& /*c*/) const
198{
200}
201
202// =============================================================================
203// Context implementation
204// =============================================================================
206: m_evtSelector(selector) {}
207
210
212
214{
215 IEvtSelector* id ATLAS_THREAD_SAFE = const_cast<IEvtSelector*>(m_evtSelector);
216 return id;
217}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Assign a CLID to EventContext.
This file contains the interface for the ByteStreamInputSvc classes.
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
#define TRIGEVENTSELECTORBYTESTREAM_UNIMPL
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Simple smart pointer for Gaudi-style refcounted objects.
T * get()
Get the pointer.
Event Selector context for TrigEventSelectorByteStream.
const IEvtSelector * m_evtSelector
pointer to the event selector
virtual void * identifier() const override
Implementation of IEvtSelector::Context::identifier.
Context(const IEvtSelector *selector)
Constructor from a selector.
virtual ~TrigEventSelectorByteStream()
Standard destructor.
virtual StatusCode createAddress(const IEvtSelector::Context &c, IOpaqueAddress *&iop) const override
virtual StatusCode rewind(IEvtSelector::Context &c) const override
virtual StatusCode previous(IEvtSelector::Context &c) const override
virtual StatusCode resetCriteria(const std::string &cr, IEvtSelector::Context &c) const override
virtual StatusCode createContext(IEvtSelector::Context *&c) const override
virtual StatusCode releaseContext(IEvtSelector::Context *&c) const override
ServiceHandle< IByteStreamInputSvc > m_eventSource
TrigEventSelectorByteStream(const std::string &name, ISvcLocator *svcLoc)
Standard constructor.
virtual StatusCode finalize() override
ServiceHandle< StoreGateSvc > m_evtStore
virtual StatusCode next(IEvtSelector::Context &c) const override
virtual StatusCode last(IEvtSelector::Context &refContext) const override
virtual StatusCode initialize() override
Thrown if the CTP ROBFragment for a new event has non-zero status word or other errors.
Thrown if event source throws an exception when new event is requested.
Thrown if the CTP ROBFragment cannot be retrieved for a new event.
Thrown if the event source cannot provide new events temporarily, e.g.
Thrown if all events are already read from the input and another one is requested.