208 {
211
213 return StatusCode::SUCCESS;
214 }
215
216
217
219
220
222
223
224
225
226
227
228 std::unique_lock lockUnique(
m_slotMutex[ context.slot() ] );
229
230
231
232
234 {
237 tbb::concurrent_hash_map<AlgorithmIdentifier, TrigTimeStamp, AlgorithmIdentifierHashCompare>::const_accessor stopTimeAcessor;
240 } else {
241
242 eventStopTime = stopTimeAcessor->second.microsecondsSinceEpoch();
243 }
244 }
245
246
248 {
251 tbb::concurrent_hash_map<AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_accessor startAcessor;
254 } else {
255
256 eventStartTime = startAcessor->second.m_algStartTime.microsecondsSinceEpoch();
257 }
258 }
259
260
261 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator beginIt;
262 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator endIt;
263 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator
it;
265
266 ATH_MSG_DEBUG(
"Monitored event with " << std::distance(beginIt, endIt) <<
" AlgorithmPayload objects.");
267
268 std::map<size_t, size_t> aiToHandleIndex;
269 for (it = beginIt;
it != endIt; ++
it) {
270 const AlgorithmIdentifier& ai =
it->first;
271 const AlgorithmPayload&
ap =
it->second;
273
274
276 {
277 tbb::concurrent_hash_map<AlgorithmIdentifier, TrigTimeStamp, AlgorithmIdentifierHashCompare>::const_accessor stopTimeAcessor;
280 } else {
281 stopTime = stopTimeAcessor->second.microsecondsSinceEpoch();
282 }
283
284 }
285
286
287
288
289 if (startTime > stopTime) {
290 ATH_MSG_VERBOSE(
"Disregard start-time:" << startTime <<
" > stop-time:" << stopTime
292 continue;
293 }
294
295
296
297
298
299
300 if (startTime > eventStopTime) {
302 continue;
303 }
304 if (stopTime > eventStopTime) {
306 << " truncating its ending time stamp from " << stopTime << " to " << eventStopTime);
307 stopTime = eventStopTime;
308 }
309
310
311
312
313 if (stopTime < eventStartTime) {
315 continue;
316 }
317 if (startTime < eventStartTime) {
319 << " truncating its starting time stamp from " << startTime << " to " << eventStartTime);
321 }
322
323
325 costOutputHandle->push_back(
tc );
326
327
328 const uint32_t threadID =
static_cast<uint32_t>( std::hash< std::thread::id >()(
ap.m_algThreadID) );
330 {
331
333 const std::unordered_map<uint32_t, uint32_t>::const_iterator mapIt =
m_threadToCounterMap.find(threadID);
337 } else {
338 threadEnumerator = mapIt->second;
339 }
340 }
341
346 result &=
tc->setDetail(
"thread", threadEnumerator);
347 result &=
tc->setDetail(
"thash", threadID);
349 result &=
tc->setDetail(
"roi",
ap.m_algROIID);
350 result &=
tc->setDetail(
"start", startTime);
351 result &=
tc->setDetail(
"stop", stopTime);
352 if (!result)
ATH_MSG_WARNING(
"Failed to append one or more details to trigger cost TC");
353
354 aiToHandleIndex[ai.
m_hash] = costOutputHandle->size() - 1;
355 }
356
357 typedef tbb::concurrent_hash_map< AlgorithmIdentifier, std::vector<robmonitor::ROBDataMonitorStruct>, AlgorithmIdentifierHashCompare>::const_iterator ROBConstIt;
358 ROBConstIt beginRob;
359 ROBConstIt endRob;
360
362
363 for (ROBConstIt it = beginRob;
it != endRob; ++
it) {
364 size_t aiHash =
it->first.m_hash;
365
366 if (aiToHandleIndex.count(aiHash) == 0) {
368 }
369
370
371 for (
const robmonitor::ROBDataMonitorStruct& robData :
it->second) {
373 rosOutputHandle->push_back(
tc);
374
375
376 std::vector<uint32_t> robs_id;
377 std::vector<uint32_t> robs_size;
378 std::vector<unsigned> robs_history;
379 std::vector<unsigned short> robs_status;
380
385
387 robs_id.push_back(rob.second.rob_id);
388 robs_size.push_back(rob.second.rob_size);
389 robs_history.push_back(rob.second.rob_history);
390 robs_status.push_back(rob.second.isStatusOk());
391 }
392
394 result &=
tc->setDetail(
"alg_idx", aiToHandleIndex[aiHash]);
396 result &=
tc->setDetail<std::vector<uint32_t>>(
"robs_id", robs_id);
397 result &=
tc->setDetail<std::vector<uint32_t>>(
"robs_size", robs_size);
398 result &=
tc->setDetail<std::vector<unsigned>>(
"robs_history", robs_history);
399 result &=
tc->setDetail<std::vector<unsigned short>>(
"robs_status", robs_status);
402
403 if (!result)
ATH_MSG_WARNING(
"Failed to append one or more details to trigger cost ROS TC");
404 }
405 }
406
407 if (
msg().
level() <= MSG::VERBOSE) {
419 }
420 }
421
422 return StatusCode::SUCCESS;
423}
#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.