207 {
210
212 return StatusCode::SUCCESS;
213 }
214
215
216
218
219
221
222
223
224
225
226
227 std::unique_lock lockUnique(
m_slotMutex[ context.slot() ] );
228
229
230
231
233 {
236 tbb::concurrent_hash_map<AlgorithmIdentifier, TrigTimeStamp, AlgorithmIdentifierHashCompare>::const_accessor stopTimeAcessor;
239 } else {
240
241 eventStopTime = stopTimeAcessor->second.microsecondsSinceEpoch();
242 }
243 }
244
245
247 {
250 tbb::concurrent_hash_map<AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_accessor startAcessor;
253 } else {
254
255 eventStartTime = startAcessor->second.m_algStartTime.microsecondsSinceEpoch();
256 }
257 }
258
259
260 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator beginIt;
261 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator endIt;
262 tbb::concurrent_hash_map< AlgorithmIdentifier, AlgorithmPayload, AlgorithmIdentifierHashCompare>::const_iterator
it;
264
265 ATH_MSG_DEBUG(
"Monitored event with " << std::distance(beginIt, endIt) <<
" AlgorithmPayload objects.");
266
267 std::map<size_t, size_t> aiToHandleIndex;
268 for (it = beginIt;
it != endIt; ++
it) {
269 const AlgorithmIdentifier& ai =
it->first;
270 const AlgorithmPayload&
ap =
it->second;
272
273
275 {
276 tbb::concurrent_hash_map<AlgorithmIdentifier, TrigTimeStamp, AlgorithmIdentifierHashCompare>::const_accessor stopTimeAcessor;
279 } else {
280 stopTime = stopTimeAcessor->second.microsecondsSinceEpoch();
281 }
282
283 }
284
285
286
287
288 if (startTime > stopTime) {
289 ATH_MSG_VERBOSE(
"Disregard start-time:" << startTime <<
" > stop-time:" << stopTime
291 continue;
292 }
293
294
295
296
297
298
299 if (startTime > eventStopTime) {
301 continue;
302 }
303 if (stopTime > eventStopTime) {
305 << " truncating its ending time stamp from " << stopTime << " to " << eventStopTime);
306 stopTime = eventStopTime;
307 }
308
309
310
311
312 if (stopTime < eventStartTime) {
314 continue;
315 }
316 if (startTime < eventStartTime) {
318 << " truncating its starting time stamp from " << startTime << " to " << eventStartTime);
320 }
321
322
324 costOutputHandle->push_back(
tc );
325
326
327 const uint32_t threadID =
static_cast<uint32_t>( std::hash< std::thread::id >()(
ap.m_algThreadID) );
329 {
330
332 const std::unordered_map<uint32_t, uint32_t>::const_iterator mapIt =
m_threadToCounterMap.find(threadID);
336 } else {
337 threadEnumerator = mapIt->second;
338 }
339 }
340
345 result &=
tc->setDetail(
"thread", threadEnumerator);
346 result &=
tc->setDetail(
"thash", threadID);
348 result &=
tc->setDetail(
"roi",
ap.m_algROIID);
349 result &=
tc->setDetail(
"start", startTime);
350 result &=
tc->setDetail(
"stop", stopTime);
351 if (!result)
ATH_MSG_WARNING(
"Failed to append one or more details to trigger cost TC");
352
353 aiToHandleIndex[ai.
m_hash] = costOutputHandle->size() - 1;
354 }
355
356 typedef tbb::concurrent_hash_map< AlgorithmIdentifier, std::vector<robmonitor::ROBDataMonitorStruct>, AlgorithmIdentifierHashCompare>::const_iterator ROBConstIt;
357 ROBConstIt beginRob;
358 ROBConstIt endRob;
359
361
362 for (ROBConstIt it = beginRob;
it != endRob; ++
it) {
363 size_t aiHash =
it->first.m_hash;
364
365 if (aiToHandleIndex.count(aiHash) == 0) {
367 }
368
369
370 for (
const robmonitor::ROBDataMonitorStruct& robData :
it->second) {
372 rosOutputHandle->push_back(
tc);
373
374
375 std::vector<uint32_t> robs_id;
376 std::vector<uint32_t> robs_size;
377 std::vector<unsigned> robs_history;
378 std::vector<unsigned short> robs_status;
379
384
386 robs_id.push_back(rob.second.rob_id);
387 robs_size.push_back(rob.second.rob_size);
388 robs_history.push_back(rob.second.rob_history);
389 robs_status.push_back(rob.second.isStatusOk());
390 }
391
393 result &=
tc->setDetail(
"alg_idx", aiToHandleIndex[aiHash]);
395 result &=
tc->setDetail<std::vector<uint32_t>>(
"robs_id", robs_id);
396 result &=
tc->setDetail<std::vector<uint32_t>>(
"robs_size", robs_size);
397 result &=
tc->setDetail<std::vector<unsigned>>(
"robs_history", robs_history);
398 result &=
tc->setDetail<std::vector<unsigned short>>(
"robs_status", robs_status);
401
402 if (!result)
ATH_MSG_WARNING(
"Failed to append one or more details to trigger cost ROS TC");
403 }
404 }
405
406 if (
msg().
level() <= MSG::VERBOSE) {
418 }
419 }
420
421 return StatusCode::SUCCESS;
422}
#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.