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
8#include "GaudiKernel/ThreadLocalContext.h"
10
12
13#include "TrigCostAnalysis.h"
14#include "CostData.h"
15
20#include "monitors/MonitorROS.h"
24
25
26TrigCostAnalysis::TrigCostAnalysis( const std::string& name, ISvcLocator* pSvcLocator ) :
27 AthAlgorithm(name, pSvcLocator),
28 m_metadataTree(nullptr),
31}
32
33
35 ATH_MSG_VERBOSE("In initialize()");
36
37 ATH_MSG_DEBUG("Reading from " << m_costDataKey.key() << ", " << m_HLTMenuKey.key());
38 ATH_CHECK( m_costDataKey.initialize() );
39 ATH_CHECK( m_rosDataKey.initialize() );
40 ATH_CHECK( m_HLTMenuKey.initialize() );
41
43
44
45 if (!m_enhancedBiasTool.name().empty()) {
46 ATH_CHECK( m_enhancedBiasTool.retrieve() );
47 } else {
48 ATH_MSG_DEBUG("No EnhancedBiasTool. Not doing additional weighting.");
49 if (m_useEBWeights) {
50 ATH_MSG_FATAL("Configured to use Enhanced Bias weights. Must supply weighting tool.");
51 return StatusCode::FAILURE;
52 }
53 }
54
56
57 if (not m_additionalHashMap.empty()) {
58 std::string hashFile = PathResolverFindCalibFile( m_additionalHashMap );
59 if (hashFile.empty()) {
60 ATH_MSG_WARNING("Could not retrieve " << m_additionalHashMap << ", won't load additional hash maps.");
61 } else {
63 }
64 }
65
66 m_costROSData.initialize(m_rosToRob);
67
68 ATH_CHECK( m_histSvc->regTree("/COSTSTREAM/metadata", std::make_unique<TTree>("metadata", "metadata")) );
69 ATH_CHECK( m_histSvc->getTree("/COSTSTREAM/metadata", m_metadataTree) );
70
71 return StatusCode::SUCCESS;
72}
73
76 ATH_CHECK( hltMenuHandle.isValid() );
77 ATH_MSG_INFO("Configuring from " << m_HLTMenuKey << " with " << hltMenuHandle->size() << " chains");
78 using boost::property_tree::ptree;
79
80 // Populate the reverse-hashing dictionary with all ALG NAMES.
81 // Obtain a mapping from NAME to TYPE from the configuration JSON
82 m_storeIdentifiers.clear();
83 const ptree& menuData = hltMenuHandle->data();
84 for (const auto& sequencer : menuData.get_child("sequencers")) {
85 ATH_MSG_VERBOSE("Found Sequencer:" << sequencer.first);
86 for (const auto& alg : sequencer.second) {
87 // Data stored in Gaudi format of "AlgClassType/AlgInstanceName"
88 size_t breakPoint = alg.second.data().find('/');
89 std::string algType = alg.second.data().substr(0, breakPoint);
90 std::string algName = alg.second.data().substr(breakPoint+1, alg.second.data().size());
91 std::replace(algType.begin(), algType.end(), ':', '_');
92 std::replace(algName.begin(), algName.end(), ':', '_');
93 m_algTypeMap[ TrigConf::HLTUtils::string2hash(algName, "ALG") ] = algType;
94 ATH_MSG_VERBOSE("AlgType:" << algType << ", AlgName:" << algName );
95 if (algType.find("EventViewCreatorAlgorithm") != std::string::npos) {
96 ATH_MSG_VERBOSE(algType << " is identified as a ViewCreator");
97 m_storeIdentifiers.insert(std::move(algName));
98 }
99 }
100 }
101
102 // Call TrigConf::HLTUtils::string2hash(chain.name()) for all the chains to cache the hash to name mapping
103 std::vector<TrigConf::Chain> chains;
104 ATH_CHECK( m_algToChainTool->getAllChains(chains));
105 for (const TrigConf::Chain& chain : chains) {
106 HLT::Identifier(chain.name());
108
109 // Populate legs' names
110 const size_t legsSize {chain.legMultiplicities().size()};
111 for (size_t counter = 0; legsSize > 1 && counter < legsSize; ++counter){
112 HLT::Identifier l = TrigCompositeUtils::createLegName(chain.namehash(), counter);
114 }
115 }
116
117 // Save identifiers and classes for additional HLTJobOptions map
118 if (not m_additionalHashList.empty()){
119 for (const std::string& entry : m_additionalHashList){
120 size_t breakPoint = entry.find('/');
121 if (breakPoint != std::string::npos){
122 std::string algType = entry.substr(0, breakPoint);
123 const std::string algName = entry.substr(breakPoint+1, entry.size());
124 std::replace(algType.begin(), algType.end(), ':', '_');
125 m_algTypeMap[ TrigConf::HLTUtils::string2hash(algName, "ALG") ] = std::move(algType);
126 } else {
128 }
129 }
130 }
131
132 // As an initial guess, 25 should be a good uper maximum for the number of expected View instances.
134 return StatusCode::SUCCESS;
135}
136
137// TODO. Do a proper atomic check of m_maxViewsNumber. Call this from within the Monitor code.
139 if (max <= m_maxViewsNumber) {
140 return StatusCode::SUCCESS;
141 }
142 const size_t current = m_maxViewsNumber;
144 ATH_MSG_DEBUG("Extending maximum View instances from " << current << " to " << max);
145 for (size_t viewID = current; viewID <= m_maxViewsNumber; ++ viewID) {
146 // Allow for this many individual View instances
147 for (const std::string& store : m_storeIdentifiers) {
148 std::stringstream ss;
149 ss << store << "_view_" << viewID;
150 TrigConf::HLTUtils::string2hash(ss.str(), "STORE");
151 }
152 // And this many global Slots. Though, in general, it will be the Views which are driving this.
153 std::stringstream ss;
154 ss << viewID << "_StoreGateSvc_Impl";
155 TrigConf::HLTUtils::string2hash(ss.str(), "STORE");
156 }
157 return StatusCode::SUCCESS;
158}
159
160float TrigCostAnalysis::getWeight(const EventContext& context) {
161 // TODO Prescale of CostMon chain for P1
162 double ebWeight = 1.0;
163 if (m_useEBWeights) {
164 ebWeight = m_enhancedBiasTool->getEBWeight(context);
165 ATH_MSG_DEBUG("EB Weight is " << ebWeight);
166 }
167 return m_baseEventWeight * ebWeight;
168}
169
170
171TH1* TrigCostAnalysis::bookGetPointer(TH1* hist, const std::string& tDir) const {
172 std::string histName(hist->GetName());
173 std::string bookingString = "/COSTSTREAM/" + tDir + "/" + histName;
174
175 if (!((m_histSvc->regHist(bookingString, hist)).isSuccess())) {
176 ATH_MSG_WARNING( "Problem registering histogram with name " << histName);
177 return nullptr;
178 }
179
180 return hist;
181}
182
183
185 const EventContext& context = Gaudi::Hive::currentContext();
186
187 MonitoredRange* range = nullptr;
188 ATH_CHECK(getRange(context, range));
189
190 if (!range) {
191
192 ATH_MSG_DEBUG("Not monitoring event");
193 return StatusCode::SUCCESS;
194
195 }
196
197 ATH_MSG_DEBUG("Monitoring event " << context.eventID().event_number() << " in LB " << context.eventID().lumi_block() << " in range " << range->getName());
198
200 ATH_CHECK( costDataHandle.isValid() );
201
203 ATH_CHECK( rosDataHandle.isValid() );
204
205
206 if (!m_metadataDataKey.empty()){
208 if (metadataDataHandle.isValid()){
209 for (const xAOD::TrigComposite* tc : *metadataDataHandle) {
210 try {
211 std::lock_guard<std::mutex> lock(m_addHostnameMutex);
212 m_hostnames.insert(tc->getDetail<std::string>("hostname"));
213 } catch ( const std::exception& ) {
214 ATH_MSG_WARNING("Missing HLT_RuntimeMetadata EDM hostname for event " << context.eventID().event_number());
215 }
216
217 }
218 }
219 else {
220 ATH_MSG_DEBUG("Not valid HLT_RuntimeMetadata handle for the event " << context.eventID().event_number());
221 }
222 }
223
224 // Save indexes of algorithm in costDataHandle
225 std::map<std::string, std::set<size_t>> chainToAlgIdx;
226 std::map<std::string, std::set<size_t>> chainToUniqAlgs; // List for unique algorithms for each chain
227 std::map<std::string, std::map<int16_t, std::set<size_t>>> seqToAlgIdx; // Map of algorithms split in views
228 std::map<std::string, std::set<std::string>> algToChain;
229 m_algToChainTool->cacheSGKeys(context);
230 ATH_CHECK( m_algToChainTool->getChainsForAllAlgs(context, algToChain) );
231
232 // Retrieve active sequences and algorithms
233 std::map<std::string, std::string> algToSeq;
234 ATH_CHECK(m_algToChainTool->getAllActiveSequences(context, algToSeq));
235
236 for (const xAOD::TrigComposite* tc : *costDataHandle) {
237 const uint32_t nameHash = tc->getDetail<TrigConf::HLTHash>("alg");
238 const std::string algName = TrigConf::HLTUtils::hash2string(nameHash, "ALG");
239
240 size_t i = 0;
241 if(m_excludeAlgsFromChain.find(algName) != m_excludeAlgsFromChain.end()) continue;
242
243 for (const std::string& chain : algToChain[algName]){
244 chainToAlgIdx[chain].insert(tc->index());
245 ++i;
246 }
247
248 if (i == 1){
249 ATH_MSG_DEBUG("Algorithm " << algName << " executed uniquely for " << *algToChain[algName].begin() << " chain");
250 chainToUniqAlgs[*algToChain[algName].begin()].insert(tc->index());
251 }
252
253 if (algToSeq.count(algName)){
254 const int16_t view = tc->getDetail<int16_t>("view");
255 seqToAlgIdx[algToSeq[algName]][view].insert(tc->index());
256 }
257 }
258
259 const std::set<TrigCompositeUtils::DecisionID> seededChains = m_algToChainTool->retrieveActiveChains(context, "HLTNav_L1");
260 std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo> seededChainsInfo;
261
262 // Skip empty events, where only cost chain was active
263 bool skipMonitoringThisEvent = false;
264 if ((seededChains.size() == 1 && seededChains.count(TrigConf::HLTUtils::string2hash("HLT_noalg_CostMonDS_L1All")))
265 || (seededChains.size() == 2 && seededChains.count(TrigConf::HLTUtils::string2hash("HLT_noalg_CostMonDS_L1All")) && seededChains.count(TrigConf::HLTUtils::string2hash("HLT_noalg_L1All"))) ){
266 skipMonitoringThisEvent = true;
267 }
268
269 for (auto id : seededChains){
271 ATH_CHECK(m_algToChainTool->getChainInfo(context, id, chainInfo));
272 seededChainsInfo.push_back(std::move(chainInfo));
273 }
274
275 const uint32_t onlineSlot = getOnlineSlot( costDataHandle.get() );
276 CostData costData;
277 ATH_CHECK( costData.set(costDataHandle.get(), rosDataHandle.get(), onlineSlot) );
279 costData.setChainToAlgMap(chainToAlgIdx);
280 costData.setChainToUniqAlgMap(chainToUniqAlgs);
281 costData.setSequencersMap(seqToAlgIdx);
282 costData.setSeededChains(seededChainsInfo);
283 costData.setLb( context.eventID().lumi_block() );
284 costData.setTypeMap( m_algTypeMap );
285 if (!m_enhancedBiasTool.name().empty() && !m_enhancedBiasTool->isMC()) {
286 double liveTime = m_enhancedBiasTool->getEBLiveTime(context);
287 bool liveTimeIsPerEvent = true;
288 if (liveTime == 0.0) { // Note: This comes from a direct "return 0.", hence no delta
289 liveTime = m_enhancedBiasTool->getLBLength(context);
290 liveTimeIsPerEvent = false;
291 }
292 costData.setLivetime( liveTime, liveTimeIsPerEvent );
293 }
294
295 ATH_CHECK( range->newEvent( costData, getWeight(context), skipMonitoringThisEvent ) );
296
297 if (checkDoFullEventDump(context, costData)) {
298 ATH_CHECK( dumpEvent(context) );
299 }
300
301 return StatusCode::SUCCESS;
302}
303
304
305bool TrigCostAnalysis::checkDoFullEventDump(const EventContext& context, const CostData& costData) {
306 if (costData.isMasterSlot()
308 and context.eventID().event_number() % m_fullEventDumpProbability == 0)
309 {
311 return true;
312 }
313 return false;
314}
315
316
318 ATH_CHECK(range != nullptr);
320 ATH_CHECK( range->addMonitor(std::make_unique<MonitorAlgorithm>("Algorithm_HLT", range)) );
321 ATH_MSG_DEBUG("Registering Algorithm_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
322 }
324 ATH_CHECK( range->addMonitor(std::make_unique<MonitorAlgorithmClass>("Algorithm_Class_HLT", range)) );
325 ATH_MSG_DEBUG("Registering Algorithm_Class_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
326 }
327 if (m_doMonitorGlobal) {
328 ATH_CHECK( range->addMonitor(std::make_unique<MonitorGlobal>("Global_HLT", range)) );
329 ATH_MSG_DEBUG("Registering Global_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
330 }
332 ATH_CHECK( range->addMonitor(std::make_unique<MonitorThreadOccupancy>("Thread_Occupancy_HLT", range)) );
333 ATH_MSG_DEBUG("Registering Thread_Occupancy_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
334 }
335 if (m_doMonitorROS) {
336 ATH_CHECK( range->addMonitor(std::make_unique<MonitorROS>("ROS_HLT", range)) );
337 ATH_MSG_DEBUG("Registering ROS_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
338 }
339 if (m_doMonitorChain) {
340 ATH_CHECK( range->addMonitor(std::make_unique<MonitorChain>("Chain_HLT", range)) );
341 ATH_MSG_DEBUG("Registering Chain_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
342 }
344 ATH_CHECK( range->addMonitor(std::make_unique<MonitorChainAlgorithm>("Chain_Algorithm_HLT", range)) );
345 ATH_MSG_DEBUG("Registering Chain_Algorihtm_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
346 }
348 ATH_CHECK( range->addMonitor(std::make_unique<MonitorSequence>("Sequence_HLT", range)) );
349 ATH_MSG_DEBUG("Registering Sequence_HLT Monitor for range " << range->getName() << ". Size:" << range->getMonitors().size());
350 }
351 // if (m_do...) {}
352
353 // Set the verbosity for the monitors
354 for (const std::unique_ptr<MonitorBase>& monitor : range->getMonitors()){
355 monitor->msg().setLevel(msg().level());
356 }
357
358 return StatusCode::SUCCESS;
359}
360
361
362StatusCode TrigCostAnalysis::getRange(const EventContext& context, MonitoredRange*& range) {
363 std::string rangeName;
364 range = nullptr;
365 constexpr bool includeEndOfLB = false;
366
367 if (m_singleTimeRange) {
368 rangeName = m_singleTimeRangeName;
369 } else {
370 const EventIDBase::number_type lumiBlock = context.eventID().lumi_block();
371 const size_t lumiBlockRangeStart = lumiBlock - (lumiBlock % m_TimeRangeLengthLB);
372 const size_t lumiBlockRangeStop = lumiBlockRangeStart + m_TimeRangeLengthLB - 1;
373 std::stringstream ss;
374 ss << "LumiBlock_" << std::setfill('0') << std::setw(5) << lumiBlockRangeStart;
375 if (includeEndOfLB && lumiBlockRangeStop != lumiBlockRangeStart) {
376 ss << "_" << lumiBlockRangeStop;
377 }
378 rangeName = ss.str();
379 }
380
381 std::unordered_map<std::string, std::unique_ptr<MonitoredRange>>::iterator it;
382 it = m_monitoredRanges.find(rangeName);
383
384 // If we don't have a MonitoredRange with this name, try and make one.
385 if (it == m_monitoredRanges.end()) {
386 if (m_monitoredRanges.size() < m_maxTimeRange) {
387 auto result = m_monitoredRanges.insert(
388 std::make_pair(rangeName, std::make_unique<MonitoredRange>(rangeName, this))
389 );
390 it = result.first; // Returns pair. First: map iterator. Second: insertion boolean
391 ATH_CHECK(registerMonitors( it->second.get() ));
392 } else {
393 range = nullptr; // Not monitoring any more ranges
394 return StatusCode::SUCCESS;
395 }
396 }
397
398 range = it->second.get(); // Pointer to MonitoredRange
399 return StatusCode::SUCCESS;
400}
401
403 // Online, Slot 0 can be configured as the master-slot. In this mode, events in Slot 0
404 // hoover up data about algorithm executions in other slots too.
405 // This all-slots data stored in the master slot is exploited by dumpEvent, and some specialist monitors.
406 // Other monitors will want to avoid it for fear of double-counting
407 if (costCollection->size() == 0) {
408 return 0;
409 }
410 const uint32_t initialSlot = costCollection->at(0)->getDetail<uint32_t>("slot");
411 for ( const xAOD::TrigComposite* tc : *costCollection ) {
412 const uint32_t algSlot = tc->getDetail<uint32_t>("slot");
413 if (algSlot == 0 or algSlot != initialSlot) {
414 return 0; // If we see a zero, or two different slot numbers, then we're in the master slot
415 }
416 }
417 // If we saw exclusivly one non-zero slot, then we're in that slot
418 return initialSlot;
419}
420
421
422StatusCode TrigCostAnalysis::dumpEvent(const EventContext& context) const {
425
426 std::stringstream ss;
427 size_t algID = 0;
428
429 for ( const xAOD::TrigComposite* tc : *costDataHandle ) {
430 const uint64_t start = tc->getDetail<uint64_t>("start"); // in mus
431 const uint64_t stop = tc->getDetail<uint64_t>("stop"); // in mus
432 const uint32_t slot = tc->getDetail<uint32_t>("slot");
433 const uint64_t start_ms_round = std::llround( start * 1e-3 ); // in ms
434 const uint64_t stop_ms_round = std::llround( stop * 1e-3 ); // in ms
435 const uint32_t threadID = tc->getDetail<uint32_t>("thread");
436
437 ss << "{id:" << algID++;
438 ss << ", group:" << threadID;
439 ss << ", className:'slot" << slot << "'";
440 ss << ", content:'" << TrigConf::HLTUtils::hash2string( tc->getDetail<TrigConf::HLTHash>("alg"), "ALG");
441 ss << "<br>" << TrigConf::HLTUtils::hash2string( tc->getDetail<TrigConf::HLTHash>("store"), "STORE") << "'";
442 ss << ", duration:" << (stop - start); // For tooltip display: in mus
443 ss << ", start:" << start_ms_round; // in ms
444 if (stop_ms_round > start_ms_round) {
445 ss << ", end:" << stop_ms_round;
446 } else {
447 ss << ", type:'point'";
448 }
449 ss << "}," << std::endl;
450 }
451
452 ATH_MSG_DEBUG("Full Event Summary for event " << context.eventID().event_number());
453 ATH_MSG_DEBUG(ss.str());
454 // TODO Persist this
455
456 return StatusCode::SUCCESS;
457}
458
459
461 ATH_MSG_VERBOSE("In finalize()");
462
464 return StatusCode::SUCCESS;
465}
466
467
469 if (!m_metadataTree) {
470 return;
471 }
472
473 auto runNumber = m_enhancedBiasTool->getRunNumber();
474 m_metadataTree->Branch("runNumber", &runNumber);
475
476 std::string hostnamesList = "";
477 if (m_hostnames.size() > 1){
478 ATH_MSG_DEBUG("Found many hostnames for this run");
479 for (const auto& name : m_hostnames) hostnamesList += name + ",";
480 hostnamesList.pop_back();
481 } else if (m_hostnames.size() == 1) {
482 hostnamesList = *m_hostnames.begin();
483 }
484 m_metadataTree->Branch("hostname", &hostnamesList);
485
487 std::string menuStr;
488 if ( hltMenuHandle.isValid() ){
489 std::stringstream ss;
490 boost::property_tree::json_parser::write_json(ss, hltMenuHandle->data());
491 menuStr = ss.str();
492 m_metadataTree->Branch("HLTMenu", &menuStr);
493 }
494
495 bool ChainMonitor = m_doMonitorChain;
496 bool ChainAlgorithmMonitor = m_doMonitorChainAlgorithm;
497 bool AlgorithmMonitor = m_doMonitorAlgorithm;
498 bool AlgorithmClassMonitor = m_doMonitorAlgorithmClass;
499 bool ROSMonitor = m_doMonitorROS;
500 bool GlobalsMonitor = m_doMonitorGlobal;
501 bool ThreadMonitor = m_doMonitorThreadOccupancy;
502
503 m_metadataTree->Branch("ChainMonitor", &ChainMonitor);
504 m_metadataTree->Branch("ChainAlgorithmMonitor", &ChainAlgorithmMonitor);
505 m_metadataTree->Branch("AlgorithmMonitor", &AlgorithmMonitor);
506 m_metadataTree->Branch("AlgorithmClassMonitor", &AlgorithmClassMonitor);
507 m_metadataTree->Branch("ROSMonitor", &ROSMonitor);
508 m_metadataTree->Branch("GlobalsMonitor", &GlobalsMonitor);
509 m_metadataTree->Branch("ThreadMonitor", &ThreadMonitor);
510
511 float BaseEventWeight = m_baseEventWeight;
512 std::string AdditionalHashMap = m_additionalHashMap;
513 bool DoEBWeighting = m_useEBWeights;
514
515 m_metadataTree->Branch("AdditionalHashMap", &AdditionalHashMap);
516 m_metadataTree->Branch("DoEBWeighting", &DoEBWeighting);
517 m_metadataTree->Branch("BaseEventWeight", &BaseEventWeight);
518
519 std::string atlasProject = std::getenv("AtlasProject");
520 std::string atlasVersion = std::getenv("AtlasVersion");
521 m_metadataTree->Branch("AtlasProject", &atlasProject);
522 m_metadataTree->Branch("AtlasVersion", &atlasVersion);
523
524
525 std::string processedRanges;
527 processedRanges = m_singleTimeRangeName;
528 }
529 else {
530 std::stringstream ss;
531 for(const auto& rangePair : m_monitoredRanges){
532 ss << rangePair.first << ": ";
533 std::string lbrange = rangePair.first.substr(strlen("LumiBlock_"));
534 ss << " Lumiblocks " << std::stoi(lbrange) << " to " << std::stoi(lbrange) + m_TimeRangeLengthLB << ", ";
535 }
536 processedRanges = ss.str();
537 ATH_MSG_INFO("Processed ranges: " << processedRanges);
538 }
539
540 m_metadataTree->Branch("ProcessedRanges", &processedRanges);
541
542 m_metadataTree->Fill();
543}
#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)
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 with parameters:
MsgStream & msg() const
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.
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
virtual StatusCode execute() final
Monitor event, unless max range limit reached and event outside of all ranges.
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.