ATLAS Offline Software
Loading...
Searching...
No Matches
TrigSignatureMoni Class Reference

#include <TrigSignatureMoni.h>

Inheritance diagram for TrigSignatureMoni:

Classes

class  RateHistogram

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode start () override
virtual StatusCode execute (const EventContext &context) const override
virtual StatusCode stop () override
virtual void handle (const Incident &incident) override

Private Member Functions

int nBinsX (SG::ReadHandle< TrigConf::HLTMenu > &) const
int nBinsX () const
int nChains (SG::ReadHandle< TrigConf::HLTMenu > &) const
int nSteps () const
StatusCode initHist (LockedHandle< TH2 > &, SG::ReadHandle< TrigConf::HLTMenu > &, bool=true)
StatusCode initSeqHist (LockedHandle< TH2 > &, std::set< std::string > &)
StatusCode fillDecisionCount (const std::vector< TrigCompositeUtils::DecisionID > &, int) const
StatusCode fillPassEvents (const TrigCompositeUtils::DecisionIDContainer &, int) const
StatusCode fillRate (const TrigCompositeUtils::DecisionIDContainer &, int) const
StatusCode fillHistogram (const TrigCompositeUtils::DecisionIDContainer &, int, LockedHandle< TH2 > &) const
StatusCode fillSequences (const std::set< std::string > &) const
StatusCode fillStreamsAndGroups (const std::map< std::string, TrigCompositeUtils::DecisionIDContainer > &, const TrigCompositeUtils::DecisionIDContainer &, int) const

Private Attributes

SG::ReadHandleKey< TrigCompositeUtils::DecisionContainerm_l1DecisionsKey { this, "L1Decisions", "HLTSeedingSummary", "Chains activated after the L1" }
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainerm_finalDecisionKey { this, "FinalDecisionKey", "HLTNav_Summary", "Final stage of all decisions" }
SG::ReadHandleKey< TrigConf::HLTMenum_HLTMenuKey { this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu" }
SG::ReadHandleKey< TrigConf::L1Menum_L1MenuKey { this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "L1 Menu" }
ServiceHandle< IIncidentSvc > m_incidentSvc { this, "IncidentSvc", "IncidentSvc", "Incident service"}
ServiceHandle< ITHistSvc > m_histSvc { this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" }
Gaudi::Property< std::string > m_bookingPath { this, "HistPath", "/EXPERT/HLTFramework", "Booking path for the histogram"}
Gaudi::Property< unsigned int > m_duration {this, "RateIntegrationDuration", 10, "Integration time for the rate histogram in seconds"}
Gaudi::Property< unsigned int > m_intervals {this, "RateIntegrationIntervals", 6, "Number of the rate histogram publications"}
ToolHandleArray< DecisionCollectorToolm_decisionCollectorTools { this, "DecisionCollectorTools", {}, "Tools that collect decisions (yes/no) for steps" }
ToolHandleArray< DecisionCollectorToolm_featureCollectorTools { this, "FeatureCollectorTools", {}, "Tools that collect decision counts for specific features for steps" }
LockedHandle< TH2 > m_passHistogram ATLAS_THREAD_SAFE
LockedHandle< TH2 > m_countHistogram ATLAS_THREAD_SAFE
RateHistogram m_rateHistogram
RateHistogram m_sequenceHistogram
std::unordered_map< unsigned int, int > m_chainIDToBinMap
 Chain id to histogram bin map.
std::unordered_map< std::string, int > m_nameToBinMap
 Sequence/group/bunchgroup name to bin map.
std::unordered_map< std::string, int > m_sequenceToBinMap
 Sequence to bin map for sequence histogram.
std::map< std::string, TrigCompositeUtils::DecisionIDContainerm_groupToChainMap
 Group name to chain objects map.
std::map< std::string, TrigCompositeUtils::DecisionIDContainerm_streamToChainMap
 Stream name to chain objects map, excluding express.
std::map< std::string, TrigCompositeUtils::DecisionIDContainerm_expressChainMap
 Stream name to chain objects map, including only express.

Detailed Description

Definition at line 37 of file TrigSignatureMoni.h.

Member Function Documentation

◆ execute()

StatusCode TrigSignatureMoni::execute ( const EventContext & context) const
overridevirtual

Definition at line 308 of file TrigSignatureMoni.cxx.

308 {
309
310 SG::ReadHandle<TrigCompositeUtils::DecisionContainer> l1Decisions = SG::makeHandle(m_l1DecisionsKey, context);
311
312 [[maybe_unused]] static const bool sanityCheckDone = [&] {
313 if (l1Decisions->at(INPUT-1)->name() == "l1seeded" &&
314 l1Decisions->at(AFTER_PS-1)->name() == "unprescaled") {
315 return true;
316 }
317 throw GaudiException(m_l1DecisionsKey.key() + " does not contain the expected entries",
318 name(), StatusCode::FAILURE);
319 }();
320
321 auto fillL1 = [&](int index) -> StatusCode {
323 TrigCompositeUtils::decisionIDs(l1Decisions->at(index-1), ids);
324 ATH_MSG_DEBUG( "L1 " << index-1 << " N positive decisions " << ids.size() );
326 ATH_CHECK(fillPassEvents(ids, index));
327 ATH_CHECK(fillRate(ids, index));
328 if (!ids.empty()){
329 m_passHistogram->Fill(1, static_cast<double>(index));
330 m_rateHistogram.fill(1, static_cast<double>(index));
331 }
332 return StatusCode::SUCCESS;
333 };
334
335 // Fill histograms with L1 decisions in and after prescale
336 ATH_CHECK(fillL1(INPUT));
337 ATH_CHECK(fillL1(AFTER_PS));
338
339 // Fill HLT steps
340 int step = 0;
341 std::vector<TrigCompositeUtils::DecisionID> stepSum;
342 std::set<std::string> stepSequences;
343 for ( auto& ctool: m_decisionCollectorTools ) {
344 ctool->getDecisions( stepSum, stepSequences, context );
345 ATH_MSG_DEBUG( " Step " << step << " decisions (for decisions): " << stepSum.size() );
346 TrigCompositeUtils::DecisionIDContainer stepUniqueSum( stepSum.begin(), stepSum.end() );
347 ATH_CHECK( fillPassEvents( stepUniqueSum, 3+step ) );
348 ATH_CHECK( fillSequences( stepSequences ) );
349 ++step;
350 stepSum.clear();
351 stepSequences.clear();
352 }
353
354 step = 0;
355 for ( auto& ctool: m_featureCollectorTools ) {
356 stepSum.clear();
357 ctool->getDecisions( stepSum, context );
358 ATH_MSG_DEBUG( " Step " << step << " decisions (for features): " << stepSum.size() );
359 ATH_CHECK( fillDecisionCount( stepSum, 3+step ) );
360 ++step;
361 }
362
363 // Collect the final decisions
364 SG::ReadHandle<TrigCompositeUtils::DecisionContainer> finalDecisionsHandle = SG::makeHandle( m_finalDecisionKey, context );
365 ATH_CHECK( finalDecisionsHandle.isValid() );
367 const TrigCompositeUtils::Decision* decisionObject = TrigCompositeUtils::getTerminusNode(*finalDecisionsHandle);
368 if (!decisionObject) {
369 ATH_MSG_WARNING("Unable to locate trigger navigation terminus node. Cannot tell which chains passed the event.");
370 } else {
371 TrigCompositeUtils::decisionIDs(decisionObject, finalIDs);
372 }
373
374 // Collect the express stream decisions
376 const TrigCompositeUtils::Decision* expressDecisionObject = TrigCompositeUtils::getExpressTerminusNode(*finalDecisionsHandle);
377 if (!expressDecisionObject) {
378 ATH_MSG_WARNING("Unable to locate trigger navigation express terminus node. Cannot tell which chains passed the express stream in this event.");
379 } else {
380 TrigCompositeUtils::decisionIDs(expressDecisionObject, expressFinalIDs);
381 }
382
383 // Fill the histograms with output counts/rate
384 const int countOutputRow {nSteps() + OUTPUT};
387 ATH_CHECK( fillPassEvents(finalIDs, countOutputRow));
388 ATH_CHECK( fillRate(finalIDs, OUTPUT));
389
390 // Fill the histograms with express counts/rate
391 const int countExpressRow {nSteps() + EXPRESS};
392 // express stream rate is filled into OUTPUT bin on purpose
395 ATH_CHECK( fillPassEvents(expressFinalIDs, countExpressRow));
396 ATH_CHECK( fillRate(expressFinalIDs, EXPRESS));
397
398 // Fill the "All" column in counts/rate histograms
399 if (!finalIDs.empty()) {
400 m_passHistogram->Fill(1, static_cast<double>(countOutputRow));
401 m_rateHistogram.fill(1, static_cast<double>(OUTPUT));
402 }
403 if (!expressFinalIDs.empty()) {
404 m_passHistogram->Fill(1, static_cast<double>(countExpressRow));
405 m_rateHistogram.fill(1, static_cast<double>(EXPRESS));
406 }
407
408 return StatusCode::SUCCESS;
409}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode fillPassEvents(const TrigCompositeUtils::DecisionIDContainer &, int) const
StatusCode fillRate(const TrigCompositeUtils::DecisionIDContainer &, int) const
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_streamToChainMap
Stream name to chain objects map, excluding express.
StatusCode fillDecisionCount(const std::vector< TrigCompositeUtils::DecisionID > &, int) const
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_l1DecisionsKey
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_expressChainMap
Stream name to chain objects map, including only express.
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_groupToChainMap
Group name to chain objects map.
StatusCode fillSequences(const std::set< std::string > &) const
RateHistogram m_rateHistogram
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalDecisionKey
StatusCode fillStreamsAndGroups(const std::map< std::string, TrigCompositeUtils::DecisionIDContainer > &, const TrigCompositeUtils::DecisionIDContainer &, int) const
ToolHandleArray< DecisionCollectorTool > m_decisionCollectorTools
ToolHandleArray< DecisionCollectorTool > m_featureCollectorTools
str index
Definition DeMoScan.py:362
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const Decision * getExpressTerminusNode(const DecisionContainer &container)
Returns the express-accept navigation node from a collection or nullptr if missing.
std::set< DecisionID > DecisionIDContainer
const Decision * getTerminusNode(SG::ReadHandle< DecisionContainer > &container)
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.

◆ fillDecisionCount()

StatusCode TrigSignatureMoni::fillDecisionCount ( const std::vector< TrigCompositeUtils::DecisionID > & dc,
int row ) const
private

Definition at line 244 of file TrigSignatureMoni.cxx.

244 {
245 for (TrigCompositeUtils::DecisionID id : dc) {
248 auto id2bin = m_chainIDToBinMap.find( chain );
249 if ( id2bin == m_chainIDToBinMap.end()) {
250 ATH_MSG_WARNING("HLT chain " << HLT::Identifier(chain) << " not configured to be monitored");
251 } else {
252 m_countHistogram->Fill(id2bin->second, static_cast<double>(row));
253 }
254 }
255
256 return StatusCode::SUCCESS;
257}
std::unordered_map< unsigned int, int > m_chainIDToBinMap
Chain id to histogram bin map.
unsigned int DecisionID
HLT::Identifier getIDFromLeg(const HLT::Identifier &legIdentifier)
Generate the HLT::Identifier which corresponds to the chain name from the leg name.
bool isLegId(const HLT::Identifier &legIdentifier)
Recognise whether the chain ID is a leg ID.

◆ fillHistogram()

StatusCode TrigSignatureMoni::fillHistogram ( const TrigCompositeUtils::DecisionIDContainer & dc,
int row,
LockedHandle< TH2 > & histogram ) const
private

Definition at line 217 of file TrigSignatureMoni.cxx.

217 {
218
219 // This locks the histogram handle for the entire duration of the function,
220 // which is faster than (un)locking the handle many times during the loop.
221 auto lockedHist = *histogram;
222
223 for (TrigCompositeUtils::DecisionID id : dc) {
224 auto id2bin = m_chainIDToBinMap.find( id );
225 if ( id2bin != m_chainIDToBinMap.end() ) {
226 lockedHist->Fill( id2bin->second, static_cast<double>(row) );
227 }
228 else {
229 if ( !TrigCompositeUtils::isLegId(HLT::Identifier(id)) )
230 ATH_MSG_WARNING( "HLT chain " << HLT::Identifier(id) << " not configured to be monitored" );
231 }
232 }
233 return StatusCode::SUCCESS;
234}
std::string histogram
Definition chains.cxx:52

◆ fillPassEvents()

StatusCode TrigSignatureMoni::fillPassEvents ( const TrigCompositeUtils::DecisionIDContainer & dc,
int row ) const
private

Definition at line 240 of file TrigSignatureMoni.cxx.

240 {
241 return fillHistogram(dc, row, m_passHistogram);
242}
StatusCode fillHistogram(const TrigCompositeUtils::DecisionIDContainer &, int, LockedHandle< TH2 > &) const

◆ fillRate()

StatusCode TrigSignatureMoni::fillRate ( const TrigCompositeUtils::DecisionIDContainer & dc,
int row ) const
private

Definition at line 236 of file TrigSignatureMoni.cxx.

236 {
237 return fillHistogram(dc, row, m_rateHistogram.getBuffer());
238}

◆ fillSequences()

StatusCode TrigSignatureMoni::fillSequences ( const std::set< std::string > & sequences) const
private

Definition at line 259 of file TrigSignatureMoni.cxx.

259 {
260 for (const std::string& seq : sequences) {
262 }
263
264 return StatusCode::SUCCESS;
265}
std::unordered_map< std::string, int > m_sequenceToBinMap
Sequence to bin map for sequence histogram.
RateHistogram m_sequenceHistogram

◆ fillStreamsAndGroups()

StatusCode TrigSignatureMoni::fillStreamsAndGroups ( const std::map< std::string, TrigCompositeUtils::DecisionIDContainer > & nameToChainsMap,
const TrigCompositeUtils::DecisionIDContainer & dc,
int row ) const
private

Definition at line 267 of file TrigSignatureMoni.cxx.

267 {
268
269 // Adjust bin index for those histograms that monitor all steps
270 int rowWithSteps = row;
271 if (row==OUTPUT || row==EXPRESS) rowWithSteps += m_decisionCollectorTools.size();
272
273 for (const auto& [name, decisions] : nameToChainsMap) {
274 for (TrigCompositeUtils::DecisionID id : dc) {
275 if (decisions.contains(id)) {
276 const double bin = m_nameToBinMap.at(name);
277 m_rateHistogram.fill(bin, row);
278 m_countHistogram->Fill(bin, rowWithSteps);
279 m_passHistogram->Fill(bin, rowWithSteps);
280 break;
281 }
282 }
283 }
284 return StatusCode::SUCCESS;
285}
std::unordered_map< std::string, int > m_nameToBinMap
Sequence/group/bunchgroup name to bin map.
row
Appending html table to final .html summary file.

◆ handle()

void TrigSignatureMoni::handle ( const Incident & incident)
overridevirtual

Definition at line 287 of file TrigSignatureMoni.cxx.

287 {
288 // Create and start timer after fork
289 if (incident.type() == AthenaInterprocess::UpdateAfterFork::type()) {
290 if (m_rateHistogram.getTimer() || m_sequenceHistogram.getTimer()) {
291 ATH_MSG_WARNING("Timer is already running. UpdateAfterFork incident called more than once?");
292 return;
293 }
294
295 // Prevent from publishing empty histograms
296 if (nBinsX() > 0) {
298 }
299
300 if (!m_sequenceToBinMap.empty()) {
302 }
303
304 ATH_MSG_DEBUG("Started rate timer");
305 }
306}
static const std::string & type()
Incident type.
Definition Incidents.h:49
Gaudi::Property< unsigned int > m_intervals
Gaudi::Property< unsigned int > m_duration

◆ initHist()

StatusCode TrigSignatureMoni::initHist ( LockedHandle< TH2 > & hist,
SG::ReadHandle< TrigConf::HLTMenu > & hltMenuHandle,
bool steps = true )
private

Definition at line 427 of file TrigSignatureMoni.cxx.

427 {
428 TAxis* x = hist->GetXaxis();
429 x->SetBinLabel(1, "All");
430 int bin = 2; // 1 is for total count, (remember bin numbering in ROOT starts from 1)
431
432 std::set<std::string> sortedChainsList;
433 for ( const TrigConf::Chain& chain: *hltMenuHandle ) {
434 sortedChainsList.insert( chain.name() );
435 }
436
437 for ( const std::string& chainName: sortedChainsList ) {
438 x->SetBinLabel( bin, chainName.c_str() );
439 m_chainIDToBinMap[ HLT::Identifier( chainName ).numeric() ] = bin;
440 bin++;
441 }
442
443
444 for ( const auto& stream : m_streamToChainMap){
445 x->SetBinLabel( bin, ("str_"+stream.first).c_str());
446 m_nameToBinMap[ stream.first ] = bin;
447 bin++;
448 }
449
450 for ( const auto& stream : m_expressChainMap){
451 x->SetBinLabel( bin, ("str_"+stream.first).c_str());
452 m_nameToBinMap[ stream.first ] = bin;
453 bin++;
454 }
455
456 for ( const auto& group : m_groupToChainMap){
457 x->SetBinLabel( bin, ("grp_"+group.first.substr(group.first.find(':')+1)).c_str() );
458 m_nameToBinMap[ group.first ] = bin;
459 bin++;
460 }
461
462
463 TAxis* y = hist->GetYaxis();
464 y->SetBinLabel(INPUT, steps ? "L1" : "Input");
465 y->SetBinLabel(AFTER_PS, "AfterPS");
466 for ( size_t i = 0; steps && i < m_decisionCollectorTools.size(); ++i) {
467 y->SetBinLabel(3 + i, std::format("Step {:d}", i).c_str());
468 }
469 y->SetBinLabel(y->GetNbins()-1, "Output"); // Second to last bin
470 y->SetBinLabel(y->GetNbins(), "Express"); // Last bin
471
472 return StatusCode::SUCCESS;
473}
#define y
#define x

◆ initialize()

StatusCode TrigSignatureMoni::initialize ( )
overridevirtual

Definition at line 25 of file TrigSignatureMoni.cxx.

25 {
26 ATH_CHECK(m_l1DecisionsKey.initialize());
27 ATH_CHECK(m_finalDecisionKey.initialize());
28 ATH_CHECK(m_HLTMenuKey.initialize());
29 ATH_CHECK(m_L1MenuKey.initialize());
32 ATH_CHECK(m_histSvc.retrieve());
33
34 ATH_CHECK(m_incidentSvc.retrieve());
36
37 return StatusCode::SUCCESS;
38}
ServiceHandle< ITHistSvc > m_histSvc
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
ServiceHandle< IIncidentSvc > m_incidentSvc
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey

◆ initSeqHist()

StatusCode TrigSignatureMoni::initSeqHist ( LockedHandle< TH2 > & hist,
std::set< std::string > & sequenceSet )
private

Definition at line 475 of file TrigSignatureMoni.cxx.

475 {
476 TAxis* x = hist->GetXaxis();
477 int bin = 1;
478
479 // Set bin labels
480 for (const std::string& seqName : sequenceSet) {
481 x->SetBinLabel(bin, seqName.c_str());
482 m_sequenceToBinMap[seqName] = bin;
483 ++bin;
484 }
485
486 TAxis* y = hist->GetYaxis();
487 y->SetBinLabel(1, "Rate");
488
489 return StatusCode::SUCCESS;
490}

◆ nBinsX() [1/2]

int TrigSignatureMoni::nBinsX ( ) const
private

Definition at line 415 of file TrigSignatureMoni.cxx.

415 {
416 return m_chainIDToBinMap.size() + m_groupToChainMap.size() + m_streamToChainMap.size() + m_expressChainMap.size() + 1;
417}

◆ nBinsX() [2/2]

int TrigSignatureMoni::nBinsX ( SG::ReadHandle< TrigConf::HLTMenu > & hltMenuHandle) const
private

Definition at line 411 of file TrigSignatureMoni.cxx.

411 {
412 return nChains(hltMenuHandle) + m_groupToChainMap.size() + m_streamToChainMap.size() + m_expressChainMap.size();
413}
int nChains(SG::ReadHandle< TrigConf::HLTMenu > &) const

◆ nChains()

int TrigSignatureMoni::nChains ( SG::ReadHandle< TrigConf::HLTMenu > & hltMenuHandle) const
private

Definition at line 419 of file TrigSignatureMoni.cxx.

419 {
420 return hltMenuHandle->size() + 1; // Chains + "All"
421}

◆ nSteps()

int TrigSignatureMoni::nSteps ( ) const
private

Definition at line 423 of file TrigSignatureMoni.cxx.

423 {
424 return m_decisionCollectorTools.size();
425}

◆ start()

StatusCode TrigSignatureMoni::start ( )
overridevirtual

Definition at line 40 of file TrigSignatureMoni.cxx.

40 {
41 SG::ReadHandle<TrigConf::L1Menu> l1MenuHandle = SG::makeHandle(m_L1MenuKey);
42 SG::ReadHandle<TrigConf::HLTMenu> hltMenuHandle = SG::makeHandle(m_HLTMenuKey);
43 ATH_CHECK(hltMenuHandle.isValid());
44
45 // Retrieve chain information from menus
46 m_groupToChainMap.clear();
47 m_streamToChainMap.clear();
48 m_expressChainMap.clear();
49
50 std::unordered_map<std::string,std::string> mapStrNameToTypeName; // e.g. {Main -> physics_Main}
51 try {
52 for (const TrigConf::DataStructure& stream : hltMenuHandle->streams()) {
53 mapStrNameToTypeName.insert({stream.getAttribute("name"), stream.getAttribute("type")+"_"+stream.getAttribute("name")});
54 }
55 } catch (const std::exception& ex) {
56 ATH_MSG_ERROR("Exception reading stream tag configuration from the HLT menu: " << ex.what());
57 return StatusCode::FAILURE;
58 }
59
60 for (const TrigConf::Chain& chain : *hltMenuHandle) {
61 for (const std::string& group : chain.groups()) {
62 // Save chains per RATE group
63 if (group.starts_with( "RATE")){
64 m_groupToChainMap[group].insert(HLT::Identifier(chain.name()));
65 }
66 }
67
68 // Save chain to stream map
69 for (const std::string& streamName : chain.streams()){
70 const auto it = mapStrNameToTypeName.find(streamName);
71 if (it==mapStrNameToTypeName.cend()) {
72 ATH_MSG_ERROR("Stream name " << streamName << " assigned to chain " << chain.name()
73 << " is missing from menu streams definition");
74 return StatusCode::FAILURE;
75 }
76 if (it->second == "express_express") {
77 m_expressChainMap[it->second].insert(HLT::Identifier(chain.name()));
78 } else {
79 m_streamToChainMap[it->second].insert(HLT::Identifier(chain.name()));
80 }
81 }
82 }
83
84 // Prepare the histograms
85
86 // Initialize SignatureAcceptance and DecisionCount histograms that will monitor
87 // chains, groups and sequences per each step
88 const int x {nBinsX(hltMenuHandle)};
89 const int y {nSteps() + N_BINS};
90 ATH_MSG_DEBUG( "Histogram " << x << " x " << y << " bins");
91 std::unique_ptr<TH2> hSA = std::make_unique<TH2I>("SignatureAcceptance", "Raw acceptance of signatures in;chain;step", x, 1, x + 1, y, 1, y + 1);
92 std::unique_ptr<TH2> hDC = std::make_unique<TH2I>("DecisionCount", "Positive decisions count per step;chain;step", x, 1, x + 1, y, 1, y + 1);
93
94 ATH_CHECK(m_histSvc->regShared(m_bookingPath + "/" + name() + "/SignatureAcceptance", std::move(hSA), m_passHistogram));
95 ATH_CHECK(m_histSvc->regShared(m_bookingPath + "/" + name() + "/DecisionCount", std::move(hDC), m_countHistogram));
96
97 ATH_CHECK(initHist(m_passHistogram, hltMenuHandle));
98 ATH_CHECK(initHist(m_countHistogram, hltMenuHandle));
99
100 // Initialize Rate histogram to save the rates of positive decisions in given interval
101 // per chain/group/sequence per in, after ps, out steps
102 if ( x > 0 ){
103 const std::string outputRateName = std::format("Rate{:d}s", m_duration.value());
104 m_rateHistogram.init(outputRateName, "Rate of positive decisions;chain;step", x, N_BINS,
105 std::format("{}/{}/{}", m_bookingPath.value(), name(), outputRateName), m_histSvc).ignore();
106 ATH_CHECK(initHist(m_rateHistogram.getHistogram(), hltMenuHandle, false));
107 ATH_CHECK(initHist(m_rateHistogram.getBuffer(), hltMenuHandle, false));
108 }
109
110 // Initialize SequencesExecutionRate histogram to save the rates of sequences execution
111 // Save sequences names to be monitored
112 std::set<std::string> sequencesSet;
113 for (auto& ctool: m_decisionCollectorTools){
114 ctool->getSequencesNames(sequencesSet);
115 }
116 const int xc = sequencesSet.size();
117 const int yc {1}; // Only rate, this histogram is really 1 D
118 if (xc > 0){
119 const std::string outputSequenceName = std::format("SequencesExecutionRate{:d}s", m_duration.value());
120 m_sequenceHistogram.init(outputSequenceName, "Rate of sequences execution;sequence;rate", xc, yc,
121 std::format("{}/{}/{}", m_bookingPath.value(), name(), outputSequenceName), m_histSvc).ignore();
122
123 ATH_CHECK(initSeqHist(m_sequenceHistogram.getHistogram(), sequencesSet));
124 ATH_CHECK(initSeqHist(m_sequenceHistogram.getBuffer(), sequencesSet));
125 }
126
127 return StatusCode::SUCCESS;
128}
#define ATH_MSG_ERROR(x)
StatusCode initHist(LockedHandle< TH2 > &, SG::ReadHandle< TrigConf::HLTMenu > &, bool=true)
StatusCode initSeqHist(LockedHandle< TH2 > &, std::set< std::string > &)
Gaudi::Property< std::string > m_bookingPath

◆ stop()

StatusCode TrigSignatureMoni::stop ( )
overridevirtual

Definition at line 130 of file TrigSignatureMoni.cxx.

130 {
131 m_rateHistogram.stopTimer();
132 m_sequenceHistogram.stopTimer();
133
134 if (m_chainIDToBinMap.empty()) {
135 ATH_MSG_INFO( "No chains configured, no counts to print" );
136 return StatusCode::SUCCESS;
137 }
138
139 SG::ReadHandle<TrigConf::HLTMenu> hltMenuHandle = SG::makeHandle(m_HLTMenuKey);
140 ATH_CHECK(hltMenuHandle.isValid());
141
142 // Retrieve information whether chain was active in Step
143 std::unordered_map<std::string, std::set<int>> chainToStepsId;
144 for (const TrigConf::Chain& chain : *hltMenuHandle){
145 int nstep {1}; // Start from step=1
146 for (const std::string& seqName : chain.sequencers()){
147 // Example sequencer name is "Step1_FastCalo_electron", we need only information about Step + number
148 std::smatch stepNameMatch;
149 std::regex_search(seqName.begin(), seqName.end(), stepNameMatch, std::regex("[Ss]tep[0-9]+"));
150
151 std::string stepName = stepNameMatch[0];
152 stepName[0] = std::toupper(stepName[0]); // Fix "stepX" -> "StepX"
153 // Check that the step name is set with the same position in the execution (empty steps support)
154 if (std::format("Step{:d}", nstep) == stepName) {
155 chainToStepsId[chain.name()].insert(nstep);
156 } else {
157 ATH_MSG_DEBUG("Missing counts for step" << nstep << " in chain " << chain.name());
158 }
159 nstep++;
160 }
161 }
162
163 auto collToString = [&](int xbin, const LockedHandle<TH2>& hist, int startOfset=0, int endOffset=0){
164 std::string v;
165 const int stepsSize = hist->GetYaxis()->GetNbins() - N_BINS;
166 for (int ybin = 1; ybin <= hist->GetYaxis()->GetNbins()-endOffset; ++ybin) {
167 if (ybin > startOfset) {
168 // Skip steps where chain wasn't active
169 // ybins are for all axis labes, steps are in bins from 3 to stepsSize + 2
170 const std::string chainName = m_passHistogram->GetXaxis()->GetBinLabel(xbin);
171
172 if (ybin < 3 || ybin > stepsSize + 2 || chainToStepsId[chainName].contains(ybin - 2)) {
173 v += std::format("{:<11d}", static_cast<int>(hist->GetBinContent(xbin, ybin)));
174 } else {
175 v += std::format("{:<11s}", "-");
176 }
177 } else {
178 v += std::format("{:<11s}", " ");
179 }
180 }
181 return v;
182 };
183
184 std::string v;
185 v += std::format("{:<11s}", "L1");
186 v += std::format("{:<11s}", "AfterPS");
187 for (int bin = 1; bin <= m_passHistogram->GetYaxis()->GetNbins()-N_BINS; ++bin) {
188 v += std::format("Step{:<7d}", bin);
189 }
190 v += std::format("{:<11s}", "Output");
191 v += std::format("{:<11s}", "Express");
192
193 ATH_MSG_INFO("Chains passing step (1st row events & 2nd row decision counts):");
194 ATH_MSG_INFO(std::format("{:<30s}", "ChainName") << v);
195
196 /*
197 comment for future dev:
198 for combined chains we find x2 the number of decisions, because we count both the HypoAlg and the combo Alg decisions
199 */
200
201 for (int bin = 1; bin <= (*m_passHistogram)->GetXaxis()->GetNbins(); ++bin) {
202 const std::string chainName = m_passHistogram->GetXaxis()->GetBinLabel(bin);
203 const std::string chainID = std::to_string(HLT::Identifier(chainName));
204 if (chainName.starts_with( "HLT")) { // print only for chains
205 ATH_MSG_INFO( std::format("{:s} #{:s}", chainName, chainID) );
206 ATH_MSG_INFO( std::format("{:<30s}", std::format("-- #{} Events", chainID)) << collToString( bin, m_passHistogram) );
207 ATH_MSG_INFO( std::format("{:<30s}", std::format("-- #{} Features", chainID)) << collToString( bin, m_countHistogram , 2, 1 ) );
208 }
209 if (chainName.starts_with( "All")){
210 ATH_MSG_INFO( std::format("{:<30s}", chainName) << collToString( bin, m_passHistogram) );
211 }
212 }
213
214 return StatusCode::SUCCESS;
215}
#define ATH_MSG_INFO(x)
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

LockedHandle<TH2> m_passHistogram TrigSignatureMoni::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 109 of file TrigSignatureMoni.h.

◆ ATLAS_THREAD_SAFE [2/2]

LockedHandle<TH2> m_countHistogram TrigSignatureMoni::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 110 of file TrigSignatureMoni.h.

◆ m_bookingPath

Gaudi::Property<std::string> TrigSignatureMoni::m_bookingPath { this, "HistPath", "/EXPERT/HLTFramework", "Booking path for the histogram"}
private

Definition at line 99 of file TrigSignatureMoni.h.

99{ this, "HistPath", "/EXPERT/HLTFramework", "Booking path for the histogram"};

◆ m_chainIDToBinMap

std::unordered_map<unsigned int, int> TrigSignatureMoni::m_chainIDToBinMap
private

Chain id to histogram bin map.

Definition at line 115 of file TrigSignatureMoni.h.

◆ m_decisionCollectorTools

ToolHandleArray<DecisionCollectorTool> TrigSignatureMoni::m_decisionCollectorTools { this, "DecisionCollectorTools", {}, "Tools that collect decisions (yes/no) for steps" }
private

Definition at line 105 of file TrigSignatureMoni.h.

105{ this, "DecisionCollectorTools", {}, "Tools that collect decisions (yes/no) for steps" };

◆ m_duration

Gaudi::Property<unsigned int> TrigSignatureMoni::m_duration {this, "RateIntegrationDuration", 10, "Integration time for the rate histogram in seconds"}
private

Definition at line 102 of file TrigSignatureMoni.h.

102{this, "RateIntegrationDuration", 10, "Integration time for the rate histogram in seconds"};

◆ m_expressChainMap

std::map<std::string, TrigCompositeUtils::DecisionIDContainer> TrigSignatureMoni::m_expressChainMap
private

Stream name to chain objects map, including only express.

Definition at line 122 of file TrigSignatureMoni.h.

◆ m_featureCollectorTools

ToolHandleArray<DecisionCollectorTool> TrigSignatureMoni::m_featureCollectorTools { this, "FeatureCollectorTools", {}, "Tools that collect decision counts for specific features for steps" }
private

Definition at line 106 of file TrigSignatureMoni.h.

106{ this, "FeatureCollectorTools", {}, "Tools that collect decision counts for specific features for steps" };

◆ m_finalDecisionKey

SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> TrigSignatureMoni::m_finalDecisionKey { this, "FinalDecisionKey", "HLTNav_Summary", "Final stage of all decisions" }
private

Definition at line 93 of file TrigSignatureMoni.h.

93{ this, "FinalDecisionKey", "HLTNav_Summary", "Final stage of all decisions" };

◆ m_groupToChainMap

std::map<std::string, TrigCompositeUtils::DecisionIDContainer> TrigSignatureMoni::m_groupToChainMap
private

Group name to chain objects map.

Definition at line 120 of file TrigSignatureMoni.h.

◆ m_histSvc

ServiceHandle<ITHistSvc> TrigSignatureMoni::m_histSvc { this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" }
private

Definition at line 98 of file TrigSignatureMoni.h.

98{ this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" };

◆ m_HLTMenuKey

SG::ReadHandleKey<TrigConf::HLTMenu> TrigSignatureMoni::m_HLTMenuKey { this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu" }
private

Definition at line 94 of file TrigSignatureMoni.h.

94{ this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu" };

◆ m_incidentSvc

ServiceHandle<IIncidentSvc> TrigSignatureMoni::m_incidentSvc { this, "IncidentSvc", "IncidentSvc", "Incident service"}
private

Definition at line 97 of file TrigSignatureMoni.h.

97{ this, "IncidentSvc", "IncidentSvc", "Incident service"};

◆ m_intervals

Gaudi::Property<unsigned int> TrigSignatureMoni::m_intervals {this, "RateIntegrationIntervals", 6, "Number of the rate histogram publications"}
private

Definition at line 103 of file TrigSignatureMoni.h.

103{this, "RateIntegrationIntervals", 6, "Number of the rate histogram publications"};

◆ m_l1DecisionsKey

SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> TrigSignatureMoni::m_l1DecisionsKey { this, "L1Decisions", "HLTSeedingSummary", "Chains activated after the L1" }
private

Definition at line 92 of file TrigSignatureMoni.h.

92{ this, "L1Decisions", "HLTSeedingSummary", "Chains activated after the L1" };

◆ m_L1MenuKey

SG::ReadHandleKey<TrigConf::L1Menu> TrigSignatureMoni::m_L1MenuKey { this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "L1 Menu" }
private

Definition at line 95 of file TrigSignatureMoni.h.

95{ this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "L1 Menu" };

◆ m_nameToBinMap

std::unordered_map<std::string, int> TrigSignatureMoni::m_nameToBinMap
private

Sequence/group/bunchgroup name to bin map.

Definition at line 116 of file TrigSignatureMoni.h.

◆ m_rateHistogram

RateHistogram TrigSignatureMoni::m_rateHistogram
private

Definition at line 111 of file TrigSignatureMoni.h.

◆ m_sequenceHistogram

RateHistogram TrigSignatureMoni::m_sequenceHistogram
private

Definition at line 112 of file TrigSignatureMoni.h.

◆ m_sequenceToBinMap

std::unordered_map<std::string, int> TrigSignatureMoni::m_sequenceToBinMap
private

Sequence to bin map for sequence histogram.

Definition at line 117 of file TrigSignatureMoni.h.

◆ m_streamToChainMap

std::map<std::string, TrigCompositeUtils::DecisionIDContainer> TrigSignatureMoni::m_streamToChainMap
private

Stream name to chain objects map, excluding express.

Definition at line 121 of file TrigSignatureMoni.h.


The documentation for this class was generated from the following files: