63 {
65
66
67
68
69 const EventContext* eventContext = nullptr;
70 if (
m_evtStore->retrieve(eventContext).isFailure()) {
71 ATH_MSG_ERROR(
"Failed to retrieve EventContext from the event store, new event cannot be read");
72 return nullptr;
73 }
74
75 ATH_MSG_DEBUG(
"Reading new event for event context " << *eventContext);
76
77
79
80
81 cache->releaseEvent();
82
83 using DCStatus = hltinterface::DataCollector::Status;
84 DCStatus
status = DCStatus::NO_EVENT;
85 auto monLBN = Monitored::Scalar<uint16_t>(
"getNext_LBN",
m_maxLB);
86 auto monNoEvent = Monitored::Scalar<bool>("getNext_noEvent", false);
87 try {
88 auto t_getNext = Monitored::Timer<std::chrono::duration<float, std::milli>>("TIME_getNext");
89 status = hltinterface::DataCollector::instance()->getNext(cache->rawData);
91 }
92 catch (const std::exception& ex) {
93 ATH_MSG_ERROR(
"Failed to read new event, caught an unexpected exception: " << ex.what()
94 << ". Throwing hltonl::Exception::EventSourceCorrupted" );
95 throw hltonl::Exception::EventSourceCorrupted();
96 }
97 catch (...) {
98 ATH_MSG_ERROR(
"Failed to read new event, caught an unexpected exception. "
99 << "Throwing hltonl::Exception::EventSourceCorrupted" );
100 throw hltonl::Exception::EventSourceCorrupted();
101 }
102
103 if (status == DCStatus::STOP) {
104 ATH_MSG_DEBUG(
"DataCollector::getNext returned STOP - no more events available");
105 throw hltonl::Exception::NoMoreEvents();
106 }
107 else if (status == DCStatus::NO_EVENT) {
108 ATH_MSG_DEBUG(
"DataCollector::getNext returned NO_EVENT - no events available temporarily");
109 monNoEvent = true;
110 auto mon = Monitored::Group(
m_monTool, monLBN, monNoEvent);
111 throw hltonl::Exception::NoEventsTemporarily();
112 }
113 else if (status != DCStatus::OK) {
114 ATH_MSG_ERROR(
"Unhandled return Status " <<
static_cast<int>(status) <<
" from DataCollector::getNext");
115 return nullptr;
116 }
118
119
120 cache->fullEventFragment.reset(
new RawEvent(cache->rawData.get()));
121
122
124 m_maxLB = cache->fullEventFragment->lumi_block();
126 }
127
128
129 auto numROBs = Monitored::Scalar<int>("L1Result_NumROBs",
130 cache->fullEventFragment->nchildren());
131 auto fragSize = Monitored::Scalar<float>("L1Result_FullEvFragSize",
132 cache->fullEventFragment->fragment_size_word()*wordsToKiloBytes);
133 std::vector<eformat::read::ROBFragment> robVec;
134 cache->fullEventFragment->robs(robVec);
135 std::vector<std::string> subdetNameVec;
136 for (const eformat::read::ROBFragment& rob : robVec) {
137 eformat::helper::SourceIdentifier sid(rob.rob_source_id());
138 subdetNameVec.push_back(sid.human_detector());
139 }
141 auto mon = Monitored::Group(
m_monTool, numROBs, fragSize, subdets, monLBN, monNoEvent);
142
143
146
147
149 const eformat::helper::SourceIdentifier sid{eformat::SubDetector::TDAQ_CTP,
151 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vrobf;
153 if (vrobf.empty()) {
154 ATH_MSG_INFO(
"The CTP ROB fragment 0x" << std::hex << sid.code() << std::dec <<
" is missing. "
155 << "Throwing hltonl::Exception::MissingCTPFragment");
156 throw hltonl::Exception::MissingCTPFragment();
157 }
158 uint32_t robStatus = vrobf.at(0)->nstatus()>0 ? *(vrobf.at(0)->
status()) : 0;
159 if (robStatus!=0) {
160 std::string hexStatus(8, char{0});
161 std::to_chars(hexStatus.data(), hexStatus.data()+hexStatus.size(), robStatus, 16);
162 ATH_MSG_INFO(
"The CTP ROB fragment 0x" << std::hex << sid.code() << std::dec <<
" has non-zero status word: 0x"
163 << hexStatus << ". Throwing hltonl::Exception::BadCTPFragment");
164 throw hltonl::Exception::BadCTPFragment("Non-zero ROB status 0x"+hexStatus);
165 }
166 try {
167 vrobf.at(0)->check();
168 }
169 catch (const std::exception& ex) {
170 ATH_MSG_INFO(
"The CTP ROB fragment 0x" << std::hex << sid.code() << std::dec <<
" is corrupted: "
171 << ex.what() << ". Throwing hltonl::Exception::BadCTPFragment");
172 throw hltonl::Exception::BadCTPFragment(ex.what());
173 }
174 }
175
176
177 return cache->fullEventFragment.get();
178}
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.