94 {
96
97
99
100
101
102 cache->clear();
103
104
105 HLT::HLTResultMT* hltResult = nullptr;
107 if (!castSuccessful || !hltResult) {
108 ATH_MSG_ERROR(
"Failed to convert DataObject to HLTResultMT");
109 return StatusCode::FAILURE;
110 }
111
112
116 return StatusCode::FAILURE;
117 }
118
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 << ")");
122
123
126 ATH_MSG_ERROR(
"Failed to obtain a pointer to RawEventWrite");
127 return StatusCode::FAILURE;
128 }
130
131
133
134
135 std::set<eformat::helper::SourceIdentifier> resultIdsToWrite;
136 bool debugEvent=false;
137 std::string unknownTypeStreams;
138 for (
const eformat::helper::StreamTag& st : hltResult->
getStreamTags()) {
139
140 if (isUnknownStreamTag(st)) {
141 unknownTypeStreams +=
st.type +
"_" +
st.name +
" ";
142 }
143
144 if (isDebugStreamTag(st)) debugEvent=true;
145
146 if (
st.robs.empty() &&
st.dets.empty()) {
147 eformat::helper::SourceIdentifier sid(eformat::SubDetector::TDAQ_HLT, fullResultModuleId);
148 resultIdsToWrite.insert(sid);
149 }
150
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);
155 }
156 }
157
158 if (!debugEvent && !unknownTypeStreams.empty()) {
159 ATH_MSG_ERROR(
"Found stream tag(s) with unknown type: " << unknownTypeStreams);
160 return StatusCode::FAILURE;
161 }
162
163
164
165 if (debugEvent) {
167 writableStreamTags.erase(
168 std::remove_if(writableStreamTags.begin(),writableStreamTags.end(),std::not_fn(isDebugStreamTag)),
169 writableStreamTags.end()
170 );
171 for (eformat::helper::StreamTag& st : writableStreamTags) {
174 }
175 }
176
177
179 cache->streamTagData = std::make_unique<uint32_t[]>(nStreamTagWords);
180 try {
181
182 eformat::helper::encode(hltResult->
getStreamTags(),nStreamTagWords,cache->streamTagData.get());
183 }
184 catch (const std::exception& e) {
185 ATH_MSG_ERROR(
"StreamTag encoding failed, caught an unexpected std::exception " <<
e.what());
186 return StatusCode::FAILURE;
187 }
188 catch (...) {
189 ATH_MSG_ERROR(
"StreamTag encoding failed, caught an unexpected exception");
190 return StatusCode::FAILURE;
191 }
193 re->stream_tag(nStreamTagWords, cache->streamTagData.get());
194
195
197 re->hlt_info(hltBits.size(), hltBits.data());
198
199
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) {
203
204 const auto it = serialisedData.find(resultId.module_id());
205 if (it==serialisedData.end()) {
206 if (debugEvent) {
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");
209 continue;
210 }
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;
214 }
215 const std::vector<uint32_t>&
data =
it->second;
216
217
218 auto hltROB = std::make_unique<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment>(
219 resultId.code(),
223 re->lvl1_trigger_type(),
224 0,
227 eformat::STATUS_BACK
228 );
229 hltROB->rod_minor_version(hltRodMinorVersion16);
230
233
234 re->append(hltROB.get());
235 cache->robFragments.push_back(std::move(hltROB));
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");
238 }
239
240
241 if ( pAddr != nullptr ) pAddr->release();
242 ByteStreamAddress* bsAddr =
new ByteStreamAddress(
classID(), pObj->registry()->name(),
"");
243 pAddr = static_cast<IOpaqueAddress*>(bsAddr);
244 pAddr->addRef();
245
247 return StatusCode::SUCCESS;
248}
const boost::regex re(r_e)
#define ATH_MSG_VERBOSE(x)
char data[hepevt_bytes_allocation_ATLAS]
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
SG::SlotSpecificObj< Cache > m_cache
const std::vector< uint32_t > & getHltBitsAsWords() const
Const-getter for HLT bits as uint32_t array. Ordering: PassRaw, Prescaled.
RODMinorVersion getVersion() const
ROD minor version getter.
const std::vector< eformat::helper::StreamTag > & getStreamTags() const
Const-getter for stream tags.
std::pair< uint8_t, uint8_t > RODMinorVersion
Type to store decoded ROD minor version (16-bit version split into two 8-bit numbers)
const std::unordered_map< uint16_t, std::vector< uint32_t > > & getSerialisedData() const
Serialised data getter.
const std::vector< uint32_t > & getStatus() const
Full event status reference getter (1 bit-mask status word + error code words)
const std::vector< uint32_t > & getRobStatus(uint16_t moduleId) const
Status words for ROB with given moduleId.
std::vector< eformat::helper::StreamTag > & getStreamTagsNonConst()
Non-const-getter for stream tags needed by the result maker to remove disabled ROBs/SubDets.
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
Cache tracking memory allocation for serialised stream tag data and ROBFragment objects.