87 {
89
90
91
92
93 const EventContext* eventContext = nullptr;
94 if (
m_evtStore->retrieve(eventContext).isFailure()) {
95 ATH_MSG_ERROR(
"Failed to retrieve EventContext from the event store, new event cannot be read");
96 return nullptr;
97 }
98
99 ATH_MSG_DEBUG(
"Reading new event for event context " << *eventContext);
100
101
103
104
105 cache->releaseEvent();
106
107 auto monLBN = Monitored::Scalar<uint16_t>(
"getNext_LBN",
m_maxLB);
108 auto monNoEvent = Monitored::Scalar<bool>("getNext_noEvent", false);
110 try {
111 auto t_getNext = Monitored::Timer<std::chrono::duration<float, std::milli>>("TIME_getNext");
114 }
115 else {
116 status = fetch<hltinterface::DataCollector::Status>([&]{
return hltinterface::DataCollector::instance()->getNext(cache->rawData); });
117 }
119 }
120 catch (const std::exception& ex) {
121 ATH_MSG_ERROR(
"Failed to read new event, caught an unexpected exception: " << ex.what()
122 << ". Throwing hltonl::Exception::EventSourceCorrupted" );
123 throw hltonl::Exception::EventSourceCorrupted();
124 }
125 catch (...) {
126 ATH_MSG_ERROR(
"Failed to read new event, caught an unexpected exception. "
127 << "Throwing hltonl::Exception::EventSourceCorrupted" );
128 throw hltonl::Exception::EventSourceCorrupted();
129 }
131 ATH_MSG_DEBUG(
"DataCollector::getNext returned STOP - no more events available");
132 throw hltonl::Exception::NoMoreEvents();
133 }
135 ATH_MSG_DEBUG(
"DataCollector::getNext returned NO_EVENT - no events available temporarily");
136 monNoEvent = true;
137 auto mon = Monitored::Group(
m_monTool, monLBN, monNoEvent);
138 throw hltonl::Exception::NoEventsTemporarily();
139 }
141 ATH_MSG_ERROR(
"Unhandled return Status " <<
static_cast<int>(status) <<
" from DataCollector::getNext");
142 return nullptr;
143 }
145
146
147 cache->fullEventFragment.reset(
new RawEvent(cache->rawData.get()));
148
149
151 m_maxLB = cache->fullEventFragment->lumi_block();
153 }
154
155
156 auto numROBs = Monitored::Scalar<int>("L1Result_NumROBs",
157 cache->fullEventFragment->nchildren());
158 auto fragSize = Monitored::Scalar<float>("L1Result_FullEvFragSize",
159 cache->fullEventFragment->fragment_size_word()*wordsToKiloBytes);
160 std::vector<eformat::read::ROBFragment> robVec;
161 cache->fullEventFragment->robs(robVec);
162 std::vector<std::string> subdetNameVec;
163 for (const eformat::read::ROBFragment& rob : robVec) {
164 eformat::helper::SourceIdentifier sid(rob.rob_source_id());
165 subdetNameVec.push_back(sid.human_detector());
166 }
168 auto mon = Monitored::Group(
m_monTool, numROBs, fragSize, subdets, monLBN, monNoEvent);
169
170
173
174
176 const eformat::helper::SourceIdentifier sid{eformat::SubDetector::TDAQ_CTP,
178 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vrobf;
180 if (vrobf.empty()) {
181 ATH_MSG_INFO(
"The CTP ROB fragment 0x" << std::hex << sid.code() << std::dec <<
" is missing. "
182 << "Throwing hltonl::Exception::MissingCTPFragment");
183 throw hltonl::Exception::MissingCTPFragment();
184 }
185 uint32_t robStatus = vrobf.at(0)->nstatus()>0 ? *(vrobf.at(0)->
status()) : 0;
186 if (robStatus!=0) {
187 std::string hexStatus(8, char{0});
188 std::to_chars(hexStatus.data(), hexStatus.data()+hexStatus.size(), robStatus, 16);
189 ATH_MSG_INFO(
"The CTP ROB fragment 0x" << std::hex << sid.code() << std::dec <<
" has non-zero status word: 0x"
190 << hexStatus << ". Throwing hltonl::Exception::BadCTPFragment");
191 throw hltonl::Exception::BadCTPFragment("Non-zero ROB status 0x"+hexStatus);
192 }
193 try {
194 vrobf.at(0)->check();
195 }
196 catch (const std::exception& ex) {
197 ATH_MSG_INFO(
"The CTP ROB fragment 0x" << std::hex << sid.code() << std::dec <<
" is corrupted: "
198 << ex.what() << ". Throwing hltonl::Exception::BadCTPFragment");
199 throw hltonl::Exception::BadCTPFragment(ex.what());
200 }
201 }
202
203
204 return cache->fullEventFragment.get();
205}
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.