107 if (!castSuccessful || !hltResult) {
108 ATH_MSG_ERROR(
"Failed to convert DataObject to HLTResultMT");
109 return StatusCode::FAILURE;
116 return StatusCode::FAILURE;
119 const uint16_t hltRodMinorVersion16 = (hltRodMinorVersion.first << 8u) | hltRodMinorVersion.second;
120 ATH_MSG_DEBUG(
"HLT ROD minor version is " << hltRodMinorVersion.first <<
"." << hltRodMinorVersion.second
121 <<
" (0x" << MSG::hex << hltRodMinorVersion16 << MSG::dec <<
")");
126 ATH_MSG_ERROR(
"Failed to obtain a pointer to RawEventWrite");
127 return StatusCode::FAILURE;
135 std::set<eformat::helper::SourceIdentifier> resultIdsToWrite;
136 bool debugEvent=
false;
137 std::string unknownTypeStreams;
138 for (
const eformat::helper::StreamTag& st : hltResult->
getStreamTags()) {
140 if (isUnknownStreamTag(st)) {
141 unknownTypeStreams += st.type +
"_" + st.name +
" ";
144 if (isDebugStreamTag(st)) debugEvent=
true;
146 if (st.robs.empty() && st.dets.empty()) {
147 eformat::helper::SourceIdentifier sid(eformat::SubDetector::TDAQ_HLT, fullResultModuleId);
148 resultIdsToWrite.insert(sid);
151 for (
const uint32_t robid : st.robs) {
152 eformat::helper::SourceIdentifier sid(robid);
153 if (sid.subdetector_id() == eformat::SubDetector::TDAQ_HLT)
154 resultIdsToWrite.insert(sid);
158 if (!debugEvent && !unknownTypeStreams.empty()) {
159 ATH_MSG_ERROR(
"Found stream tag(s) with unknown type: " << unknownTypeStreams);
160 return StatusCode::FAILURE;
167 writableStreamTags.erase(
168 std::remove_if(writableStreamTags.begin(),writableStreamTags.end(),std::not_fn(isDebugStreamTag)),
169 writableStreamTags.end()
171 for (eformat::helper::StreamTag& st : writableStreamTags) {
178 uint32_t nStreamTagWords = eformat::helper::size_word(hltResult->
getStreamTags());
179 cache->
streamTagData = std::make_unique<uint32_t[]>(nStreamTagWords);
184 catch (
const std::exception& e) {
185 ATH_MSG_ERROR(
"StreamTag encoding failed, caught an unexpected std::exception " << e.what());
186 return StatusCode::FAILURE;
189 ATH_MSG_ERROR(
"StreamTag encoding failed, caught an unexpected exception");
190 return StatusCode::FAILURE;
197 re->hlt_info(hltBits.size(), hltBits.data());
200 ATH_MSG_DEBUG(
"Iterating over " << resultIdsToWrite.size() <<
" HLT result IDs to assemble output data");
201 const std::unordered_map<uint16_t, std::vector<uint32_t>>& serialisedData = hltResult->
getSerialisedData();
202 for (
const eformat::helper::SourceIdentifier& resultId : resultIdsToWrite) {
204 const auto it = serialisedData.find(resultId.module_id());
205 if (it==serialisedData.end()) {
207 ATH_MSG_DEBUG(
"HLT result with ID 0x" << MSG::hex << resultId.code() << MSG::dec
208 <<
" requested by a debug stream tag, but missing in the serialised data - skipping this result");
211 ATH_MSG_ERROR(
"HLT result with ID 0x" << MSG::hex << resultId.code() << MSG::dec
212 <<
" requested by a stream tag, but missing in the serialised data");
213 return StatusCode::FAILURE;
215 const std::vector<uint32_t>&
data = it->second;
218 auto hltROB = std::make_unique<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment>(
223 re->lvl1_trigger_type(),
229 hltROB->rod_minor_version(hltRodMinorVersion16);
231 const std::vector<uint32_t>& status = hltResult->
getRobStatus(resultId.module_id());
232 hltROB->status(status.size(), status.data());
234 re->append(hltROB.get());
236 ATH_MSG_DEBUG(
"Appended data for HLT result ID 0x" << MSG::hex << resultId.code() << MSG::dec <<
" with "
237 <<
data.size() <<
" words of serialised payload to the output full event");
241 if ( pAddr !=
nullptr ) pAddr->release();
243 pAddr =
static_cast<IOpaqueAddress*
>(bsAddr);
247 return StatusCode::SUCCESS;