ATLAS Offline Software
Loading...
Searching...
No Matches
TrigCostAnalysis.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#define BOOST_BIND_GLOBAL_PLACEHOLDERS // silence Boost pragma message (fixed in Boost 1.76)
6#include <boost/property_tree/json_parser.hpp>
7
9
11
12#include "TrigCostAnalysis.h"
13#include "CostData.h"
14
19#include "monitors/MonitorROS.h"
23#include <format>
24
25TrigCostAnalysis::TrigCostAnalysis( const std::string& name, ISvcLocator* pSvcLocator ) :
26 AthAlgorithm(name, pSvcLocator),
27 m_metadataTree(nullptr),
30}
31
32
34 ATH_MSG_VERBOSE("In initialize()");
35
36 ATH_MSG_DEBUG("Reading from " << m_costDataKey.key() << ", " << m_HLTMenuKey.key());
37 ATH_CHECK( m_costDataKey.initialize() );
38 ATH_CHECK( m_rosDataKey.initialize() );
39 ATH_CHECK( m_HLTMenuKey.initialize() );
40
42
43
44 if (!m_enhancedBiasTool.name().empty()) {
45 ATH_CHECK( m_enhancedBiasTool.retrieve() );
46 } else {
47 ATH_MSG_DEBUG("No EnhancedBiasTool. Not doing additional weighting.");
48 if (m_useEBWeights) {
49 ATH_MSG_FATAL("Configured to use Enhanced Bias weights. Must supply weighting tool.");
50 return StatusCode::FAILURE;
51 }
52 }
53
55
56 if (not m_additionalHashMap.empty()) {
57 std::string hashFile = PathResolverFindCalibFile( m_additionalHashMap );
58 if (hashFile.empty()) {
59 ATH_MSG_WARNING("Could not retrieve " << m_additionalHashMap << ", won't load additional hash maps.");
60 } else {
62 }
63 }
64
65 m_costROSData.initialize(m_rosToRob);
66
67 ATH_CHECK( m_histSvc->regTree("/COSTSTREAM/metadata", std::make_unique<TTree>("metadata", "metadata")) );
68 ATH_CHECK( m_histSvc->getTree("/COSTSTREAM/metadata", m_metadataTree) );
69
70 return StatusCode::SUCCESS;
71}
72
75 ATH_CHECK( hltMenuHandle.isValid() );
76 ATH_MSG_INFO("Configuring from " << m_HLTMenuKey << " with " << hltMenuHandle->size() << " chains");
77 using boost::property_tree::ptree;
78
79 // Populate the reverse-hashing dictionary with all ALG NAMES.
80 // Obtain a mapping from NAME to TYPE from the configuration JSON
81 m_storeIdentifiers.clear();
82 const ptree& menuData = hltMenuHandle->data();
83 for (const auto& sequencer : menuData.get_child("sequencers")) {
84 ATH_MSG_VERBOSE("Found Sequencer:" << sequencer.first);
85 for (const auto& alg : sequencer.second) {
86 // Data stored in Gaudi format of "AlgClassType/AlgInstanceName"
87 size_t breakPoint = alg.second.data().find('/');
88 std::string algType = alg.second.data().substr(0, breakPoint);
89 std::string algName = alg.second.data().substr(breakPoint+1, alg.second.data().size());
90 std::replace(algType.begin(), algType.end(), ':', '_');
91 std::replace(algName.begin(), algName.end(), ':', '_');
92 m_algTypeMap[ TrigConf::HLTUtils::string2hash(algName, "ALG") ] = algType;
93 ATH_MSG_VERBOSE("AlgType:" << algType << ", AlgName:" << algName );
94 if (algType.find("EventViewCreatorAlgorithm") != std::string::npos) {
95 ATH_MSG_VERBOSE(algType << " is identified as a ViewCreator");
96 m_storeIdentifiers.insert(std::move(algName));
97 }
98 }
99 }
100
101 // Call TrigConf::HLTUtils::string2hash(chain.name()) for all the chains to cache the hash to name mapping
102 std::vector<TrigConf::Chain> chains;
103 ATH_CHECK( m_algToChainTool->getAllChains(chains));
104 for (const TrigConf::Chain& chain : chains) {
105 HLT::Identifier(chain.name());
107
108 // Populate legs' names
109 const size_t legsSize {chain.legMultiplicities().size()};
110 for (size_t counter = 0; legsSize > 1 && counter < legsSize; ++counter){
111 HLT::Identifier l = TrigCompositeUtils::createLegName(chain.namehash(), counter);
113 }
114 }
115
116 // Save identifiers and classes for additional HLTJobOptions map
117 if (not m_additionalHashList.empty()){
118 for (const std::string& entry : m_additionalHashList){
119 size_t breakPoint = entry.find('/');
120 if (breakPoint != std::string::npos){
121 std::string algType = entry.substr(0, breakPoint);
122 const std::string algName = entry.substr(breakPoint+1, entry.size());
123 std::replace(algType.begin(), algType.end(), ':', '_');
124 m_algTypeMap[ TrigConf::HLTUtils::string2hash(algName, "ALG") ] = std::move(algType);
125 } else {
127 }
128 }
129 }
130
131 // As an initial guess, 25 should be a good uper maximum for the number of expected View instances.
133 return StatusCode::SUCCESS;
134}
135
136// TODO. Do a proper atomic check of m_maxViewsNumber. Call this from within the Monitor code.
138 if (max <= m_maxViewsNumber) {
139 return StatusCode::SUCCESS;
140 }
141
142 const size_t current = m_maxViewsNumber;
144
145 ATH_MSG_DEBUG(std::format("Extending maximum View instances from {} to {}", current, max));
146
147 for (size_t viewID = current; viewID <= m_maxViewsNumber; ++viewID) {
148 // Allow for this many individual View instances
149 for (const std::string& store : m_storeIdentifiers) {
151 std::format("{}_view_{}", store, viewID), "STORE");
152 }
153
154 // And this many global Slots. Though, in general, it will be the Views which are driving this.
156 std::format("{}_StoreGateSvc_Impl", viewID), "STORE");
157 }
158
159 return StatusCode::SUCCESS;
160}
161
162float TrigCostAnalysis::getWeight(const EventContext& context) {
163 // TODO Prescale of CostMon chain for P1
164 double ebWeight = 1.0;
165 if (m_useEBWeights) {
166 ebWeight = m_enhancedBiasTool->getEBWeight(context);
167 ATH_MSG_DEBUG("EB Weight is " << ebWeight);
168 }
169 return m_baseEventWeight * ebWeight;
170}
171
172
173TH1* TrigCostAnalysis::bookGetPointer(TH1* hist, const std::string& tDir) const {
174 std::string histName(hist->GetName());
175 std::string bookingString = "/COSTSTREAM/" + tDir + "/" + histName;
176
177 if (!((m_histSvc->regHist(bookingString, hist)).isSuccess())) {
178 ATH_MSG_WARNING( "Problem registering histogram with name " << histName);
179 return nullptr;
180 }
181
182 return hist;
183}
184
185
186StatusCode TrigCostAnalysis::execute(const EventContext& ctx) {
187 const EventContext& context = ctx;
188
189 MonitoredRange* range = nullptr;
190 ATH_CHECK(getRange(context, range));
191
192 if (!range) {
193
194 ATH_MSG_DEBUG("Not monitoring event");
195 return StatusCode::SUCCESS;
196
197 }
198
199 ATH_MSG_DEBUG("Monitoring event " << context.eventID().event_number() << " in LB " << context.eventID().lumi_block() << " in range " << range->getName());
200
202 ATH_CHECK( costDataHandle.isValid() );
203
205 ATH_CHECK( rosDataHandle.isValid() );
206
207
208 if (!m_metadataDataKey.empty()){
210 if (metadataDataHandle.isValid()){
211 for (const xAOD::TrigComposite* tc : *metadataDataHandle) {
212 try {
213 std::lock_guard<std::mutex> lock(m_addHostnameMutex);
214 m_hostnames.insert(tc->getDetail<std::string>("hostname"));
215 } catch ( const std::exception& ) {
216 ATH_MSG_WARNING("Missing HLT_RuntimeMetadata EDM hostname for event " << context.eventID().event_number());
217 }
218
219 }
220 }
221 else {
222 ATH_MSG_DEBUG("Not valid HLT_RuntimeMetadata handle for the event " << context.eventID().event_number());
223 }
224 }
225
226 // Save indexes of algorithm in costDataHandle
227 std::map<std::string, std::set<size_t>> chainToAlgIdx;
228 std::map<std::string, std::set<size_t>> chainToUniqAlgs; // List for unique algorithms for each chain
229 std::map<std::string, std::map<int16_t, std::set<size_t>>> seqToAlgIdx; // Map of algorithms split in views
230 std::map<std::string, std::set<std::string>> algToChain;
231 m_algToChainTool->cacheSGKeys(context);
232 ATH_CHECK( m_algToChainTool->getChainsForAllAlgs(context, algToChain) );
233
234 // Retrieve active sequences and algorithms
235 std::map<std::string, std::string> algToSeq;
236 ATH_CHECK(m_algToChainTool->getAllActiveSequences(context, algToSeq));
237
238 for (const xAOD::TrigComposite* tc : *costDataHandle) {
239 const uint32_t nameHash = tc->getDetail<TrigConf::HLTHash>("alg");
240 const std::string algName = TrigConf::HLTUtils::hash2string(nameHash, "ALG");
241
242 size_t i = 0;
243 if(m_excludeAlgsFromChain.find(algName) != m_excludeAlgsFromChain.end()) continue;
244
245 for (const std::string& chain : algToChain[algName]){
246 chainToAlgIdx[chain].insert(tc->index());
247 ++i;
248 }
249
250 if (i == 1){
251 ATH_MSG_DEBUG("Algorithm " << algName << " executed uniquely for " << *algToChain[algName].begin() << " chain");
252 chainToUniqAlgs[*algToChain[algName].begin()].insert(tc->index());
253 }
254
255 if (algToSeq.count(algName)){
256 const int16_t view = tc->getDetail<int16_t>("view");
257 seqToAlgIdx[algToSeq[algName]][view].insert(tc->index());
258 }
259 }
260
261 const std::set<TrigCompositeUtils::DecisionID> seededChains = m_algToChainTool->retrieveActiveChains(context, "HLTNav_L1");
262 std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo> seededChainsInfo;
263
264 // Skip empty events, where only cost chain was active
265 bool skipMonitoringThisEvent = false;
266 if ((seededChains.size() == 1 && seededChains.count(TrigConf::HLTUtils::string2hash("HLT_noalg_CostMonDS_L1All")))
267 || (seededChains.size() == 2 && seededChains.count(TrigConf::HLTUtils::string2hash("HLT_noalg_CostMonDS_L1All")) && seededChains.count(TrigConf::HLTUtils::string2hash("HLT_noalg_L1All"))) ){
268 skipMonitoringThisEvent = true;
269 }
270
271 for (auto id : seededChains){
273 ATH_CHECK(m_algToChainTool->getChainInfo(context, id, chainInfo));
274 seededChainsInfo.push_back(std::move(chainInfo));
275 }
276
277 const uint32_t onlineSlot = getOnlineSlot( costDataHandle.get() );
278 CostData costData;
279 ATH_CHECK( costData.set(costDataHandle.get(), rosDataHandle.get(), onlineSlot) );
281 costData.setChainToAlgMap(chainToAlgIdx);
282 costData.setChainToUniqAlgMap(chainToUniqAlgs);
283 costData.setSequencersMap(seqToAlgIdx);
284 costData.setSeededChains(seededChainsInfo);
285 costData.setLb( context.eventID().lumi_block() );
286 costData.setTypeMap( m_algTypeMap );
287 if (!m_enhancedBiasTool.name().empty() && !m_enhancedBiasTool->isMC()) {
288 double liveTime = m_enhancedBiasTool->getEBLiveTime(context);
289 bool liveTimeIsPerEvent = true;
290 if (liveTime == 0.0) { // Note: This comes from a direct "return 0.", hence no delta
291 liveTime = m_enhancedBiasTool->getLBLength(context);
292 liveTimeIsPerEvent = false;
293 }
294 costData.setLivetime( liveTime, liveTimeIsPerEvent );
295 }
296
297 ATH_CHECK( range->newEvent( costData, getWeight(context), skipMonitoringThisEvent ) );
298
299 if (checkDoFullEventDump(context, costData)) {
300 ATH_CHECK( dumpEvent(context) );
301 }
302
303 return StatusCode::SUCCESS;
304}
305
306
307bool TrigCostAnalysis::checkDoFullEventDump(const EventContext& context, const CostData& costData) {
308 if (costData.isMasterSlot()
310 and context.eventID().event_number() % m_fullEventDumpProbability == 0)
311 {
313 return true;
314 }
315 return false;
316}
317
318
320 ATH_CHECK(range != nullptr);
322 ATH_CHECK( range->addMonitor(std::make_unique<MonitorAlgorithm>("Algorithm_HLT", range)) );
323 ATH_MSG_DEBUG("Registering Algorithm_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
324 }
326 ATH_CHECK( range->addMonitor(std::make_unique<MonitorAlgorithmClass>("Algorithm_Class_HLT", range)) );
327 ATH_MSG_DEBUG("Registering Algorithm_Class_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
328 }
329 if (m_doMonitorGlobal) {
330 ATH_CHECK( range->addMonitor(std::make_unique<MonitorGlobal>("Global_HLT", range)) );
331 ATH_MSG_DEBUG("Registering Global_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
332 }
334 ATH_CHECK( range->addMonitor(std::make_unique<MonitorThreadOccupancy>("Thread_Occupancy_HLT", range)) );
335 ATH_MSG_DEBUG("Registering Thread_Occupancy_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
336 }
337 if (m_doMonitorROS) {
338 ATH_CHECK( range->addMonitor(std::make_unique<MonitorROS>("ROS_HLT", range)) );
339 ATH_MSG_DEBUG("Registering ROS_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
340 }
341 if (m_doMonitorChain) {
342 ATH_CHECK( range->addMonitor(std::make_unique<MonitorChain>("Chain_HLT", range)) );
343 ATH_MSG_DEBUG("Registering Chain_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
344 }
346 ATH_CHECK( range->addMonitor(std::make_unique<MonitorChainAlgorithm>("Chain_Algorithm_HLT", range)) );
347 ATH_MSG_DEBUG("Registering Chain_Algorihtm_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
348 }
350 ATH_CHECK( range->addMonitor(std::make_unique<MonitorSequence>("Sequence_HLT", range)) );
351 ATH_MSG_DEBUG("Registering Sequence_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
352 }
353 // if (m_do...) {}
354
355 // Set the verbosity for the monitors
356 for (const std::unique_ptr<MonitorBase>& monitor : range->getMonitors()){
357 monitor->msg().setLevel(msg().level());
358 }
359
360 return StatusCode::SUCCESS;
361}
362
363
364StatusCode TrigCostAnalysis::getRange(const EventContext& context, MonitoredRange*& range)
365{
366 range = nullptr;
367 constexpr bool includeEndOfLB = false;
368
369 std::string rangeName;
370 if (m_singleTimeRange) {
371 rangeName = m_singleTimeRangeName;
372 } else {
373 const auto lumiBlock = context.eventID().lumi_block();
374 const size_t start = lumiBlock - (lumiBlock % m_TimeRangeLengthLB);
375 const size_t stop = start + m_TimeRangeLengthLB - 1;
376
377 if (includeEndOfLB && stop != start) {
378 rangeName = std::format("LumiBlock_{:05}_{}", start, stop);
379 } else {
380 rangeName = std::format("LumiBlock_{:05}", start);
381 }
382 }
383
384 // Fast path — range already exists
385 if (auto it = m_monitoredRanges.find(rangeName); it != m_monitoredRanges.end()) {
386 range = it->second.get();
387 return StatusCode::SUCCESS;
388 }
389
390 // We don't have this range yet — check if we are allowed to create more
391 if (m_monitoredRanges.size() >= m_maxTimeRange) {
392 return StatusCode::SUCCESS; // range stays nullptr
393 }
394
395 auto [it, inserted] = m_monitoredRanges.try_emplace(
396 rangeName,
397 std::make_unique<MonitoredRange>(rangeName, this)
398 );
399
400 if (!inserted) {
401 range = it->second.get();
402 return StatusCode::SUCCESS;
403 }
404
405 ATH_CHECK(registerMonitors(it->second.get()));
406 range = it->second.get();
407 return StatusCode::SUCCESS;
408}
409
411 // Online, Slot 0 can be configured as the master-slot. In this mode, events in Slot 0
412 // hoover up data about algorithm executions in other slots too.
413 // This all-slots data stored in the master slot is exploited by dumpEvent, and some specialist monitors.
414 // Other monitors will want to avoid it for fear of double-counting
415 if (costCollection->size() == 0) {
416 return 0;
417 }
418 const uint32_t initialSlot = costCollection->at(0)->getDetail<uint32_t>("slot");
419 for ( const xAOD::TrigComposite* tc : *costCollection ) {
420 const uint32_t algSlot = tc->getDetail<uint32_t>("slot");
421 if (algSlot == 0 or algSlot != initialSlot) {
422 return 0; // If we see a zero, or two different slot numbers, then we're in the master slot
423 }
424 }
425 // If we saw exclusivly one non-zero slot, then we're in that slot
426 return initialSlot;
427}
428
429
430StatusCode TrigCostAnalysis::dumpEvent(const EventContext& context) const {
433
434 std::stringstream ss;
435 size_t algID = 0;
436
437 for ( const xAOD::TrigComposite* tc : *costDataHandle ) {
438 const uint64_t start = tc->getDetail<uint64_t>("start"); // in mus
439 const uint64_t stop = tc->getDetail<uint64_t>("stop"); // in mus
440 const uint32_t slot = tc->getDetail<uint32_t>("slot");
441 const uint64_t start_ms_round = std::llround( start * 1e-3 ); // in ms
442 const uint64_t stop_ms_round = std::llround( stop * 1e-3 ); // in ms
443 const uint32_t threadID = tc->getDetail<uint32_t>("thread");
444
445 ss << "{id:" << algID++;
446 ss << ", group:" << threadID;
447 ss << ", className:'slot" << slot << "'";
448 ss << ", content:'" << TrigConf::HLTUtils::hash2string( tc->getDetail<TrigConf::HLTHash>("alg"), "ALG");
449 ss << "<br>" << TrigConf::HLTUtils::hash2string( tc->getDetail<TrigConf::HLTHash>("store"), "STORE") << "'";
450 ss << ", duration:" << (stop - start); // For tooltip display: in mus
451 ss << ", start:" << start_ms_round; // in ms
452 if (stop_ms_round > start_ms_round) {
453 ss << ", end:" << stop_ms_round;
454 } else {
455 ss << ", type:'point'";
456 }
457 ss << "},\n";
458 }
459
460 ATH_MSG_DEBUG("Full Event Summary for event " << context.eventID().event_number());
461 ATH_MSG_DEBUG(ss.str());
462 // TODO Persist this
463
464 return StatusCode::SUCCESS;
465}
466
467
469 ATH_MSG_VERBOSE("In finalize()");
470
472 return StatusCode::SUCCESS;
473}
474
475
477 if (!m_metadataTree) {
478 return;
479 }
480
481 auto runNumber = m_enhancedBiasTool->getRunNumber();
482 m_metadataTree->Branch("runNumber", &runNumber);
483
484 std::string hostnamesList = "";
485 if (m_hostnames.size() > 1){
486 ATH_MSG_DEBUG("Found many hostnames for this run");
487 for (const auto& name : m_hostnames) hostnamesList += name + ",";
488 hostnamesList.pop_back();
489 } else if (m_hostnames.size() == 1) {
490 hostnamesList = *m_hostnames.begin();
491 }
492 m_metadataTree->Branch("hostname", &hostnamesList);
493
495 std::string menuStr;
496 if ( hltMenuHandle.isValid() ){
497 std::stringstream ss;
498 boost::property_tree::json_parser::write_json(ss, hltMenuHandle->data());
499 menuStr = ss.str();
500 m_metadataTree->Branch("HLTMenu", &menuStr);
501 }
502
503 bool ChainMonitor = m_doMonitorChain;
504 bool ChainAlgorithmMonitor = m_doMonitorChainAlgorithm;
505 bool AlgorithmMonitor = m_doMonitorAlgorithm;
506 bool AlgorithmClassMonitor = m_doMonitorAlgorithmClass;
507 bool ROSMonitor = m_doMonitorROS;
508 bool GlobalsMonitor = m_doMonitorGlobal;
509 bool ThreadMonitor = m_doMonitorThreadOccupancy;
510
511 m_metadataTree->Branch("ChainMonitor", &ChainMonitor);
512 m_metadataTree->Branch("ChainAlgorithmMonitor", &ChainAlgorithmMonitor);
513 m_metadataTree->Branch("AlgorithmMonitor", &AlgorithmMonitor);
514 m_metadataTree->Branch("AlgorithmClassMonitor", &AlgorithmClassMonitor);
515 m_metadataTree->Branch("ROSMonitor", &ROSMonitor);
516 m_metadataTree->Branch("GlobalsMonitor", &GlobalsMonitor);
517 m_metadataTree->Branch("ThreadMonitor", &ThreadMonitor);
518
519 float BaseEventWeight = m_baseEventWeight;
520 std::string AdditionalHashMap = m_additionalHashMap;
521 bool DoEBWeighting = m_useEBWeights;
522
523 m_metadataTree->Branch("AdditionalHashMap", &AdditionalHashMap);
524 m_metadataTree->Branch("DoEBWeighting", &DoEBWeighting);
525 m_metadataTree->Branch("BaseEventWeight", &BaseEventWeight);
526
527 std::string atlasProject = std::getenv("AtlasProject");
528 std::string atlasVersion = std::getenv("AtlasVersion");
529 m_metadataTree->Branch("AtlasProject", &atlasProject);
530 m_metadataTree->Branch("AtlasVersion", &atlasVersion);
531
532
533 std::string processedRanges;
535 processedRanges = m_singleTimeRangeName;
536 }
537 else {
538 std::stringstream ss;
539 for(const auto& rangePair : m_monitoredRanges){
540 ss << rangePair.first << ": ";
541 std::string lbrange = rangePair.first.substr(strlen("LumiBlock_"));
542 ss << " Lumiblocks " << std::stoi(lbrange) << " to " << std::stoi(lbrange) + m_TimeRangeLengthLB << ", ";
543 }
544 processedRanges = ss.str();
545 ATH_MSG_INFO("Processed ranges: " << processedRanges);
546 }
547
548 m_metadataTree->Branch("ProcessedRanges", &processedRanges);
549
550 m_metadataTree->Fill();
551}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
boost::property_tree::ptree ptree
static Double_t ss
static Double_t tc
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
#define max(a, b)
Definition cfImp.cxx:41
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
bool isMasterSlot() const
Definition CostData.cxx:107
void setLb(uint32_t lb)
Setter of effective P1 walltime represented by the current event.
Definition CostData.cxx:53
void setSequencersMap(const std::map< std::string, std::map< int16_t, std::set< size_t > > > &seqToAlg)
Set the sequence to alg idx map.
Definition CostData.cxx:142
void setCostROSData(const CostROSData &costROSData)
Set ROS to ROB map.
Definition CostData.cxx:49
void setTypeMap(const std::unordered_map< uint32_t, std::string > &typeMap)
Set internal type map pointer.
Definition CostData.cxx:130
void setChainToAlgMap(const std::map< std::string, std::set< size_t > > &algToChains)
Set the alg name to chains map.
Definition CostData.cxx:134
void setSeededChains(const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > &seededChains)
Set the seeded chains set.
Definition CostData.cxx:163
void setLivetime(float time, bool liveTimeIsPerEvent)
Setter of effective P1 walltime represented by the current event, or the current lumi block.
Definition CostData.cxx:61
void setChainToUniqAlgMap(const std::map< std::string, std::set< size_t > > &algToChains)
Set the chain to its unique alg names map.
Definition CostData.cxx:138
StatusCode set(const xAOD::TrigCompositeContainer *costCollection, const xAOD::TrigCompositeContainer *rosCollection, uint32_t onlineSlot)
Cache the cost and ros collections, after formally requesting it from storegate.
Definition CostData.cxx:20
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
Container which represents a time range and holds a collection of Monitors which monitor this range.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
static const std::string hash2string(HLTHash, const std::string &category="TE")
hash function translating identifiers into names (via internal dictionary)
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
static void file2hashes(const std::string &fileName="hashes2string.txt")
debugging output of internal dictionary
Gaudi::Property< bool > m_useEBWeights
uint32_t getOnlineSlot(const xAOD::TrigCompositeContainer *costCollection) const
Return the slot used to process the event online.
std::unordered_map< std::string, std::unique_ptr< MonitoredRange > > m_monitoredRanges
Owned storage of Ranges.
Gaudi::Property< bool > m_singleTimeRange
Gaudi::Property< std::set< std::string > > m_excludeAlgsFromChain
Gaudi::Property< std::vector< std::string > > m_additionalHashList
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_metadataDataKey
Gaudi::Property< bool > m_doMonitorAlgorithm
Gaudi::Property< bool > m_doMonitorChainAlgorithm
Gaudi::Property< bool > m_doMonitorROS
virtual StatusCode finalize() final
Currently a noop for this algorithm.
Gaudi::Property< float > m_baseEventWeight
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Public method forwarded to this class' AthHistogramAlgorithm::bookGetPointer base.
ServiceHandle< ITHistSvc > m_histSvc
Gaudi::Property< bool > m_doMonitorSequence
std::atomic< size_t > m_maxViewsNumber
What is the maximum number of View instances we've so far cached string hashes to cover?
virtual StatusCode start()
Retrieve menu handle.
virtual StatusCode execute(const EventContext &ctx) final
Monitor event, unless max range limit reached and event outside of all ranges.
void writeMetadata()
Write to outpute tree (if any) the metadata needed downstream.
ToolHandle< IEnhancedBiasWeighter > m_enhancedBiasTool
Gaudi::Property< size_t > m_maxFullEventDumps
Gaudi::Property< std::string > m_additionalHashMap
Gaudi::Property< std::map< std::string, std::vector< uint32_t > > > m_rosToRob
std::mutex m_addHostnameMutex
Mutex to update set below.
StatusCode getRange(const EventContext &context, MonitoredRange *&range)
Return or construct and return a Range for the Context.
std::unordered_map< uint32_t, std::string > m_algTypeMap
Cache of algorithm's type, read from configuration data.
Gaudi::Property< size_t > m_maxTimeRange
Gaudi::Property< bool > m_doMonitorThreadOccupancy
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_rosDataKey
StatusCode registerMonitors(MonitoredRange *range)
Populate a newly minted Range object with all configured Monitors.
Gaudi::Property< bool > m_doMonitorGlobal
Gaudi::Property< size_t > m_TimeRangeLengthLB
StatusCode checkUpdateMaxView(const size_t max)
High watermark for pre-cached string hashes for the SLOT category.
virtual StatusCode initialize() final
Retrieve tools and initialise read handles.
CostROSData m_costROSData
Cached CostROSData class with details needed for ROS monitoring.
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_costDataKey
TTree * m_metadataTree
Used to write out some metadata needed by post-processing (e.g.
TrigCostAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
Construct TrigCostAnalysis.
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
ToolHandle< TrigCompositeUtils::AlgToChainTool > m_algToChainTool
std::set< std::string > m_storeIdentifiers
Identifiers of object stores, needed to cache STORE string-hash values.
Gaudi::Property< bool > m_doMonitorChain
StatusCode dumpEvent(const EventContext &context) const
Dump event algorithm execution data in ASCII format.
Gaudi::Property< bool > m_doMonitorAlgorithmClass
Gaudi::Property< uint64_t > m_fullEventDumpProbability
std::atomic< size_t > m_fullEventDumps
Counter to keep track of how many events have been full-dumped.
Gaudi::Property< std::string > m_singleTimeRangeName
float getWeight(const EventContext &context)
Compute global event weight to correct for online prescales.
bool checkDoFullEventDump(const EventContext &context, const CostData &costData)
Check if event dumping should be performed for the current event.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
HLT::Identifier createLegName(const HLT::Identifier &chainIdentifier, size_t counter)
Generate the HLT::Identifier which corresponds to a specific leg of a given chain.
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.