206 {
209
211 return StatusCode::SUCCESS;
212 }
213
214
215
217
218
220
221
222
223
224
225
226 std::unique_lock lockUnique(
m_slotMutex[ context.slot() ] );
227
228
229
230
232 {
235 tbb::concurrent_hash_map<AlgorithmIdentifier, TrigTimeStamp, AlgorithmIdentifierHashCompare>::const_accessor stopTimeAcessor;
238 } else {
239 eventStopTime = stopTimeAcessor->second.microsecondsSinceEpoch();
240 }
241 }
242
243
245 {
248 tbb::concurrent_hash_map<AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_accessor startAcessor;
251 } else {
252 eventStartTime = startAcessor->second.m_algStartTime.microsecondsSinceEpoch();
253 }
254 }
255
256
257 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator beginIt;
258 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator endIt;
259 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator
it;
261
262 ATH_MSG_DEBUG(
"Monitored event with " << std::distance(beginIt, endIt) <<
" AlgorithmPayload objects.");
263
264 std::map<size_t, size_t> aiToHandleIndex;
265 for (it = beginIt;
it != endIt; ++
it) {
266 const AlgorithmIdentifier& ai =
it->first;
267 const AlgorithmPayload&
ap =
it->second;
269
270
272 {
273 tbb::concurrent_hash_map<AlgorithmIdentifier, TrigTimeStamp, AlgorithmIdentifierHashCompare>::const_accessor stopTimeAcessor;
276 } else {
277 stopTime = stopTimeAcessor->second.microsecondsSinceEpoch();
278 }
279
280 }
281
282
283
284
285 if (startTime > stopTime) {
286 ATH_MSG_VERBOSE(
"Disregard start-time:" << startTime <<
" > stop-time:" << stopTime
288 continue;
289 }
290
291
292
293
294
295
296 if (startTime > eventStopTime) {
298 continue;
299 }
300 if (stopTime > eventStopTime) {
302 << " truncating its ending time stamp from " << stopTime << " to " << eventStopTime);
303 stopTime = eventStopTime;
304 }
305
306
307
308
309 if (stopTime < eventStartTime) {
311 continue;
312 }
313 if (startTime < eventStartTime) {
315 << " truncating its starting time stamp from " << startTime << " to " << eventStartTime);
317 }
318
319
321 costOutputHandle->push_back(
tc );
322
323
324 const uint32_t threadID =
static_cast<uint32_t>( std::hash< std::thread::id >()(
ap.m_algThreadID) );
326 {
327
329 const std::unordered_map<uint32_t, uint32_t>::const_iterator mapIt =
m_threadToCounterMap.find(threadID);
333 } else {
334 threadEnumerator = mapIt->second;
335 }
336 }
337
342 result &=
tc->setDetail(
"thread", threadEnumerator);
343 result &=
tc->setDetail(
"thash", threadID);
345 result &=
tc->setDetail(
"roi",
ap.m_algROIID);
346 result &=
tc->setDetail(
"start", startTime);
347 result &=
tc->setDetail(
"stop", stopTime);
348 if (!result)
ATH_MSG_WARNING(
"Failed to append one or more details to trigger cost TC");
349
350 aiToHandleIndex[ai.
m_hash] = costOutputHandle->size() - 1;
351 }
352
353 typedef tbb::concurrent_hash_map< AlgorithmIdentifier, std::vector<robmonitor::ROBDataMonitorStruct>, AlgorithmIdentifierHashCompare>::const_iterator ROBConstIt;
354 ROBConstIt beginRob;
355 ROBConstIt endRob;
356
358
359 for (ROBConstIt it = beginRob;
it != endRob; ++
it) {
360 size_t aiHash =
it->first.m_hash;
361
362 if (aiToHandleIndex.count(aiHash) == 0) {
364 }
365
366
367 for (
const robmonitor::ROBDataMonitorStruct& robData :
it->second) {
369 rosOutputHandle->push_back(
tc);
370
371
372 std::vector<uint32_t> robs_id;
373 std::vector<uint32_t> robs_size;
374 std::vector<unsigned> robs_history;
375 std::vector<unsigned short> robs_status;
376
381
383 robs_id.push_back(rob.second.rob_id);
384 robs_size.push_back(rob.second.rob_size);
385 robs_history.push_back(rob.second.rob_history);
386 robs_status.push_back(rob.second.isStatusOk());
387 }
388
390 result &=
tc->setDetail(
"alg_idx", aiToHandleIndex[aiHash]);
392 result &=
tc->setDetail<std::vector<uint32_t>>(
"robs_id", robs_id);
393 result &=
tc->setDetail<std::vector<uint32_t>>(
"robs_size", robs_size);
394 result &=
tc->setDetail<std::vector<unsigned>>(
"robs_history", robs_history);
395 result &=
tc->setDetail<std::vector<unsigned short>>(
"robs_status", robs_status);
398
399 if (!result)
ATH_MSG_WARNING(
"Failed to append one or more details to trigger cost ROS TC");
400 }
401 }
402
403 if (
msg().
level() <= MSG::VERBOSE) {
415 }
416 }
417
418 return StatusCode::SUCCESS;
419}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static const std::string hash2string(HLTHash, const std::string &category="TE")
hash function translating identifiers into names (via internal dictionary)
virtual StatusCode processAlg(const EventContext &context, const std::string &caller, const AuditType type) override
Implementation of ITrigCostSvc::processAlg.
Gaudi::Property< std::string > m_costFinalizeAlgName
Gaudi::Property< std::string > m_costSupervisorAlgName
TrigCostDataStore< std::vector< robmonitor::ROBDataMonitorStruct > > m_rosData
Thread-safe store of ROS data.
uint64_t start_time
map of ROBs requested
std::map< const uint32_t, robmonitor::ROBDataStruct > requested_ROBs
name of requesting algorithm
uint64_t end_time
start time of ROB request (microsec since epoch)
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
static AlgorithmIdentifier make(const EventContext &context, const std::string &caller, MsgStream &msg, const int16_t slotOverride=-1)
Construct an AlgorithmIdentifier.
std::string m_caller
Name of the algorithm.
std::string m_store
Name of the algorithm's store.
TrigConf::HLTHash callerHash(MsgStream &msg) const
TrigConf::HLTHash storeHash(MsgStream &msg) const
size_t m_hash
Hash of algorithm + store + realSlot.
StatusCode isValid() const
int16_t m_viewID
If not within an event view, then the m_iewID = s_noView = -1.