ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrigSignatureMoni Class Reference

#include <TrigSignatureMoni.h>

Inheritance diagram for TrigSignatureMoni:
Collaboration diagram for TrigSignatureMoni:

Classes

class  RateHistogram
 

Public Member Functions

 TrigSignatureMoni (const std::string &name, ISvcLocator *pSvcLocator)
 
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 nBCIDs () const
 
int nSequenceBins () const
 
int nSteps () const
 
int nBaseSteps () 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 &) 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::map< unsigned int, int > m_chainIDToBinMap
 Chain id to histogram bin map. More...
 
std::map< std::string, int > m_nameToBinMap
 Sequence/group/bunchgroup name to bin map. More...
 
std::map< std::string, int > m_sequenceToBinMap
 Sequence to bin map for sequence histogram. More...
 
std::map< unsigned int, std::set< std::string > > m_chainIDToBunchMap
 Chain ID to bunchgroup name map. More...
 
std::map< std::string, TrigCompositeUtils::DecisionIDContainerm_groupToChainMap
 Group name to chain objects map. More...
 
std::map< std::string, TrigCompositeUtils::DecisionIDContainerm_streamToChainMap
 Stream name to chain objects map, excluding express. More...
 
std::map< std::string, TrigCompositeUtils::DecisionIDContainerm_expressChainMap
 Stream name to chain objects map, including only express. More...
 

Detailed Description

Definition at line 36 of file TrigSignatureMoni.h.

Constructor & Destructor Documentation

◆ TrigSignatureMoni()

TrigSignatureMoni::TrigSignatureMoni ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 13 of file TrigSignatureMoni.cxx.

14  : base_class(name, pSvcLocator)
15 {}

Member Function Documentation

◆ execute()

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

Definition at line 298 of file TrigSignatureMoni.cxx.

298  {
299 
301 
302  const TrigCompositeUtils::Decision* l1SeededChains = nullptr; // Activated by L1
303  const TrigCompositeUtils::Decision* unprescaledChains = nullptr; // Activated and passed prescale check
304  for (const TrigCompositeUtils::Decision* d : *l1Decisions) {
305  if (d->name() == "l1seeded") {
306  l1SeededChains = d;
307  } else if (d->name() == "unprescaled") {
308  unprescaledChains = d;
309  }
310  }
311 
312  if (l1SeededChains == nullptr || unprescaledChains == nullptr) {
313  ATH_MSG_ERROR("Unable to read in the summary from the HLTSeeding.");
314  return StatusCode::FAILURE;
315  }
316 
317  auto fillL1 = [&](int index) -> StatusCode {
319  TrigCompositeUtils::decisionIDs(l1Decisions->at(index), ids);
320  ATH_MSG_DEBUG( "L1 " << index << " N positive decisions " << ids.size() );
322  ATH_CHECK(fillRate(ids, index + 1));
323  if (!ids.empty()){
324  m_passHistogram->Fill(1, double(index + 1));
325  m_rateHistogram.fill(1, double(index + 1));
326  }
327  return StatusCode::SUCCESS;
328  };
329 
330  // Fill histograms with L1 decisions in and after prescale
331  ATH_CHECK(fillL1(0));
332  ATH_CHECK(fillL1(1));
333 
334  // Fill HLT steps
335  int step = 0;
336  for ( auto& ctool: m_decisionCollectorTools ) {
337  std::vector<TrigCompositeUtils::DecisionID> stepSum;
338  std::set<std::string> stepSequences;
339  ctool->getDecisions( stepSum, context );
340  ctool->getSequencesPerEvent( stepSequences, context );
341  ATH_MSG_DEBUG( " Step " << step << " decisions (for decisions): " << stepSum.size() );
342  TrigCompositeUtils::DecisionIDContainer stepUniqueSum( stepSum.begin(), stepSum.end() );
343  ATH_CHECK( fillPassEvents( stepUniqueSum, 3+step ) );
344  ATH_CHECK( fillSequences( stepSequences ) );
345  ++step;
346  }
347 
348  step = 0;
349  for ( auto& ctool: m_featureCollectorTools ) {
350  std::vector<TrigCompositeUtils::DecisionID> stepSum;
351  std::set<std::string> stepSequences;
352  ctool->getDecisions( stepSum, context );
353  ATH_MSG_DEBUG( " Step " << step << " decisions (for features): " << stepSum.size() );
354  TrigCompositeUtils::DecisionIDContainer stepUniqueSum( stepSum.begin(), stepSum.end() );
355  ATH_CHECK( fillDecisionCount( stepSum, 3+step ) );
356  ++step;
357  }
358 
359  // Collect the final decisions
361  ATH_CHECK( finalDecisionsHandle.isValid() );
363  const TrigCompositeUtils::Decision* decisionObject = TrigCompositeUtils::getTerminusNode(*finalDecisionsHandle);
364  if (!decisionObject) {
365  ATH_MSG_WARNING("Unable to locate trigger navigation terminus node. Cannot tell which chains passed the event.");
366  } else {
367  TrigCompositeUtils::decisionIDs(decisionObject, finalIDs);
368  }
369 
370  // Collect the express stream decisions
372  const TrigCompositeUtils::Decision* expressDecisionObject = TrigCompositeUtils::getExpressTerminusNode(*finalDecisionsHandle);
373  if (!expressDecisionObject) {
374  ATH_MSG_WARNING("Unable to locate trigger navigation express terminus node. Cannot tell which chains passed the express stream in this event.");
375  } else {
376  TrigCompositeUtils::decisionIDs(expressDecisionObject, expressFinalIDs);
377  }
378 
379  // Fill the histograms with output counts/rate
380  const int countOutputRow {nSteps()-1};
381  const int rateOutputRow {nBaseSteps()-1};
384  ATH_CHECK( fillPassEvents(finalIDs, countOutputRow));
385  ATH_CHECK( fillRate(finalIDs, rateOutputRow));
386 
387  // Fill the histograms with express counts/rate
388  const int countExpressRow {nSteps()};
389  const int rateExpressRow {nBaseSteps()};
391  ATH_CHECK( fillPassEvents(expressFinalIDs, countExpressRow));
392  ATH_CHECK( fillRate(expressFinalIDs, rateExpressRow));
393 
394  // Fill the "All" column in counts/rate histograms
395  if (!finalIDs.empty()) {
396  m_passHistogram->Fill(1, double(countOutputRow));
397  m_rateHistogram.fill(1, double(rateOutputRow));
398  }
399  if (!expressFinalIDs.empty()) {
400  m_passHistogram->Fill(1, double(countExpressRow));
401  m_rateHistogram.fill(1, double(rateExpressRow));
402  }
403 
404  return StatusCode::SUCCESS;
405 }

◆ fillDecisionCount()

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

Definition at line 236 of file TrigSignatureMoni.cxx.

236  {
237  for (TrigCompositeUtils::DecisionID id : dc) {
240  auto id2bin = m_chainIDToBinMap.find( chain );
241  if ( id2bin == m_chainIDToBinMap.end()) {
242  ATH_MSG_WARNING("HLT chain " << HLT::Identifier(chain) << " not configured to be monitored");
243  } else {
244  m_countHistogram->Fill(id2bin->second, double(row));
245  }
246  }
247 
248  return StatusCode::SUCCESS;
249 
250 }

◆ fillHistogram()

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

Definition at line 216 of file TrigSignatureMoni.cxx.

216  {
217  for (TrigCompositeUtils::DecisionID id : dc) {
218  auto id2bin = m_chainIDToBinMap.find( id );
219  if ( id2bin == m_chainIDToBinMap.end() && HLT::Identifier(id).name().find("leg") != 0 ) {
220  ATH_MSG_WARNING( "HLT chain " << HLT::Identifier(id) << " not configured to be monitored" );
221  } else {
222  histogram->Fill( id2bin->second, double(row) );
223  }
224  }
225  return StatusCode::SUCCESS;
226 }

◆ fillPassEvents()

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

Definition at line 232 of file TrigSignatureMoni.cxx.

232  {
233  return fillHistogram(dc, row, m_passHistogram);
234 }

◆ fillRate()

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

Definition at line 228 of file TrigSignatureMoni.cxx.

228  {
229  return fillHistogram(dc, row, m_rateHistogram.getBuffer());
230 }

◆ fillSequences()

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

Definition at line 252 of file TrigSignatureMoni.cxx.

252  {
253  for (const std::string& seq : sequences) {
255  }
256 
257  return StatusCode::SUCCESS;
258 }

◆ fillStreamsAndGroups()

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

Definition at line 260 of file TrigSignatureMoni.cxx.

260  {
261  const int countOutputRow {nSteps()-1};
262  const int rateOutputRow {nBaseSteps()-1};
263  for (const auto& name : nameToChainsMap) {
264  for (TrigCompositeUtils::DecisionID id : dc) {
265  if (name.second.find(id) != name.second.end()){
266  double bin = m_nameToBinMap.at(name.first);
267  m_countHistogram->Fill(bin, countOutputRow);
268  m_rateHistogram.fill(bin, rateOutputRow);
269  m_passHistogram->Fill(bin, countOutputRow);
270  break;
271  }
272  }
273  }
274  return StatusCode::SUCCESS;
275 }

◆ handle()

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

Definition at line 277 of file TrigSignatureMoni.cxx.

277  {
278  // Create and start timer after fork
279  if (incident.type() == AthenaInterprocess::UpdateAfterFork::type()) {
281  ATH_MSG_WARNING("Timer is already running. UpdateAfterFork incident called more than once?");
282  return;
283  }
284 
285  // Prevent from publishing empty histograms
286  if (nBinsX() > 0) {
288  }
289 
290  if (nSequenceBins() > 0) {
292  }
293 
294  ATH_MSG_DEBUG("Started rate timer");
295  }
296 }

◆ initHist()

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

Definition at line 431 of file TrigSignatureMoni.cxx.

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

◆ initialize()

StatusCode TrigSignatureMoni::initialize ( )
overridevirtual

Definition at line 17 of file TrigSignatureMoni.cxx.

17  {
18  ATH_CHECK(m_l1DecisionsKey.initialize());
19  ATH_CHECK(m_finalDecisionKey.initialize());
24  ATH_CHECK(m_histSvc.retrieve());
25 
26  ATH_CHECK(m_incidentSvc.retrieve());
28 
29  return StatusCode::SUCCESS;
30 }

◆ initSeqHist()

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

Definition at line 480 of file TrigSignatureMoni.cxx.

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

◆ nBaseSteps()

int TrigSignatureMoni::nBaseSteps ( ) const
private

Definition at line 427 of file TrigSignatureMoni.cxx.

427  {
428  return 4; // in, after ps, out, express
429 }

◆ nBCIDs()

int TrigSignatureMoni::nBCIDs ( ) const
private

◆ nBinsX() [1/2]

int TrigSignatureMoni::nBinsX ( ) const
private

Definition at line 411 of file TrigSignatureMoni.cxx.

411  {
412  return m_chainIDToBinMap.size() + m_groupToChainMap.size() + m_streamToChainMap.size() + m_expressChainMap.size() + 1;
413 }

◆ nBinsX() [2/2]

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

Definition at line 407 of file TrigSignatureMoni.cxx.

407  {
408  return nChains(hltMenuHandle) + m_groupToChainMap.size() + m_streamToChainMap.size() + m_expressChainMap.size();
409 }

◆ nChains()

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

Definition at line 415 of file TrigSignatureMoni.cxx.

415  {
416  return hltMenuHandle->size() + 1; // Chains + "All"
417 }

◆ nSequenceBins()

int TrigSignatureMoni::nSequenceBins ( ) const
private

Definition at line 419 of file TrigSignatureMoni.cxx.

419  {
420  return m_sequenceToBinMap.size();
421 }

◆ nSteps()

int TrigSignatureMoni::nSteps ( ) const
private

Definition at line 423 of file TrigSignatureMoni.cxx.

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

◆ start()

StatusCode TrigSignatureMoni::start ( )
overridevirtual

Definition at line 32 of file TrigSignatureMoni.cxx.

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

◆ stop()

StatusCode TrigSignatureMoni::stop ( )
overridevirtual

Definition at line 123 of file TrigSignatureMoni.cxx.

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

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.

◆ m_chainIDToBinMap

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

Chain id to histogram bin map.

Definition at line 114 of file TrigSignatureMoni.h.

◆ m_chainIDToBunchMap

std::map<unsigned int, std::set<std::string> > TrigSignatureMoni::m_chainIDToBunchMap
private

Chain ID to bunchgroup name map.

Definition at line 117 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.

◆ 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.

◆ m_expressChainMap

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

Stream name to chain objects map, including only express.

Definition at line 120 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.

◆ 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.

◆ m_groupToChainMap

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

Group name to chain objects map.

Definition at line 118 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.

◆ m_HLTMenuKey

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

Definition at line 94 of file TrigSignatureMoni.h.

◆ m_incidentSvc

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

Definition at line 97 of file TrigSignatureMoni.h.

◆ 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.

◆ 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.

◆ m_L1MenuKey

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

Definition at line 95 of file TrigSignatureMoni.h.

◆ m_nameToBinMap

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

Sequence/group/bunchgroup name to bin map.

Definition at line 115 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::map<std::string, int> TrigSignatureMoni::m_sequenceToBinMap
private

Sequence to bin map for sequence histogram.

Definition at line 116 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 119 of file TrigSignatureMoni.h.


The documentation for this class was generated from the following files:
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
query_example.row
row
Definition: query_example.py:24
TrigSignatureMoni::m_groupToChainMap
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_groupToChainMap
Group name to chain objects map.
Definition: TrigSignatureMoni.h:118
TrigSignatureMoni::RateHistogram::getTimer
std::unique_ptr< Athena::AlgorithmTimer > & getTimer()
Definition: TrigSignatureMoni.cxx:522
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
fitman.sz
sz
Definition: fitman.py:527
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
hist_file_dump.d
d
Definition: hist_file_dump.py:137
plotmaker.hist
hist
Definition: plotmaker.py:148
TrigSignatureMoni::m_streamToChainMap
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_streamToChainMap
Stream name to chain objects map, excluding express.
Definition: TrigSignatureMoni.h:119
TrigSignatureMoni::m_HLTMenuKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Definition: TrigSignatureMoni.h:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
bin
Definition: BinsDiffFromStripMedian.h:43
TrigSignatureMoni::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: TrigSignatureMoni.h:95
TrigSignatureMoni::fillRate
StatusCode fillRate(const TrigCompositeUtils::DecisionIDContainer &, int) const
Definition: TrigSignatureMoni.cxx:228
TrigSignatureMoni::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: TrigSignatureMoni.h:98
TrigSignatureMoni::initSeqHist
StatusCode initSeqHist(LockedHandle< TH2 > &, std::set< std::string > &)
Definition: TrigSignatureMoni.cxx:480
TrigSignatureMoni::fillSequences
StatusCode fillSequences(const std::set< std::string > &) const
Definition: TrigSignatureMoni.cxx:252
x
#define x
TrigSignatureMoni::m_sequenceToBinMap
std::map< std::string, int > m_sequenceToBinMap
Sequence to bin map for sequence histogram.
Definition: TrigSignatureMoni.h:116
TrigSignatureMoni::initHist
StatusCode initHist(LockedHandle< TH2 > &, SG::ReadHandle< TrigConf::HLTMenu > &, bool=true)
Definition: TrigSignatureMoni.cxx:431
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
TrigSignatureMoni::m_expressChainMap
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_expressChainMap
Stream name to chain objects map, including only express.
Definition: TrigSignatureMoni.h:120
TrigSignatureMoni::fillStreamsAndGroups
StatusCode fillStreamsAndGroups(const std::map< std::string, TrigCompositeUtils::DecisionIDContainer > &, const TrigCompositeUtils::DecisionIDContainer &) const
Definition: TrigSignatureMoni.cxx:260
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigCompositeUtils::getTerminusNode
const Decision * getTerminusNode(SG::ReadHandle< DecisionContainer > &container)
Definition: TrigCompositeUtilsRoot.cxx:243
TrigSignatureMoni::nChains
int nChains(SG::ReadHandle< TrigConf::HLTMenu > &) const
Definition: TrigSignatureMoni.cxx:415
TrigSignatureMoni::RateHistogram::startTimer
void startTimer(unsigned int duration, unsigned int intervals)
Definition: TrigSignatureMoni.cxx:530
TrigSignatureMoni::nSequenceBins
int nSequenceBins() const
Definition: TrigSignatureMoni.cxx:419
beamspotman.steps
int steps
Definition: beamspotman.py:505
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigSignatureMoni::fillHistogram
StatusCode fillHistogram(const TrigCompositeUtils::DecisionIDContainer &, int, LockedHandle< TH2 > &) const
Definition: TrigSignatureMoni.cxx:216
TrigConf::HLTMenu::streams
std::vector< DataStructure > streams() const
Accessor to the connected output streams.
Definition: HLTMenu.cxx:65
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigCompositeUtils::getExpressTerminusNode
const Decision * getExpressTerminusNode(const DecisionContainer &container)
Returns the express-accept navigation node from a collection or nullptr if missing.
Definition: TrigCompositeUtilsRoot.cxx:251
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
calibdata.exception
exception
Definition: calibdata.py:496
TrigSignatureMoni::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Definition: TrigSignatureMoni.h:97
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigSignatureMoni::m_chainIDToBunchMap
std::map< unsigned int, std::set< std::string > > m_chainIDToBunchMap
Chain ID to bunchgroup name map.
Definition: TrigSignatureMoni.h:117
TrigSignatureMoni::fillDecisionCount
StatusCode fillDecisionCount(const std::vector< TrigCompositeUtils::DecisionID > &, int) const
Definition: TrigSignatureMoni.cxx:236
TrigSignatureMoni::RateHistogram::init
StatusCode init(const std::string &histoName, const std::string &histoTitle, const int x, const int y, const std::string &registerPath, const ServiceHandle< ITHistSvc > &histSvc)
Definition: TrigSignatureMoni.cxx:502
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
TrigSignatureMoni::m_sequenceHistogram
RateHistogram m_sequenceHistogram
Definition: TrigSignatureMoni.h:112
TrigSignatureMoni::nSteps
int nSteps() const
Definition: TrigSignatureMoni.cxx:423
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigSignatureMoni::m_decisionCollectorTools
ToolHandleArray< DecisionCollectorTool > m_decisionCollectorTools
Definition: TrigSignatureMoni.h:105
TrigConf::HLTMenu::size
std::size_t size() const
Accessor to the number of HLT chains.
Definition: HLTMenu.cxx:35
TrigSignatureMoni::m_chainIDToBinMap
std::map< unsigned int, int > m_chainIDToBinMap
Chain id to histogram bin map.
Definition: TrigSignatureMoni.h:114
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
TrigSignatureMoni::m_featureCollectorTools
ToolHandleArray< DecisionCollectorTool > m_featureCollectorTools
Definition: TrigSignatureMoni.h:106
TrigConf::DataStructure
Base class for Trigger configuration data and wrapper around underlying representation.
Definition: DataStructure.h:37
TrigSignatureMoni::m_intervals
Gaudi::Property< unsigned int > m_intervals
Definition: TrigSignatureMoni.h:103
TrigSignatureMoni::nBinsX
int nBinsX() const
Definition: TrigSignatureMoni.cxx:411
AthenaInterprocess::UpdateAfterFork::type
static const std::string & type()
Incident type.
Definition: Incidents.h:49
TrigSignatureMoni::m_nameToBinMap
std::map< std::string, int > m_nameToBinMap
Sequence/group/bunchgroup name to bin map.
Definition: TrigSignatureMoni.h:115
python.PyAthena.v
v
Definition: PyAthena.py:154
TrigCompositeUtils::isLegId
bool isLegId(const HLT::Identifier &legIdentifier)
Recognise whether the chain ID is a leg ID.
Definition: TrigCompositeUtilsRoot.cxx:204
DeMoScan.index
string index
Definition: DeMoScan.py:364
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
y
#define y
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrigSignatureMoni::m_finalDecisionKey
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalDecisionKey
Definition: TrigSignatureMoni.h:93
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
HLT::Identifier::name
std::string name() const
reports human redable name if it is enabled or, empty string
Definition: HLTIdentifier.cxx:14
TrigSignatureMoni::RateHistogram::fill
void fill(const double x, const double y) const
Definition: TrigSignatureMoni.cxx:526
TrigSignatureMoni::nBaseSteps
int nBaseSteps() const
Definition: TrigSignatureMoni.cxx:427
LArCellBinning.step
step
Definition: LArCellBinning.py:158
TrigSignatureMoni::fillPassEvents
StatusCode fillPassEvents(const TrigCompositeUtils::DecisionIDContainer &, int) const
Definition: TrigSignatureMoni.cxx:232
TrigCompositeUtils::getIDFromLeg
HLT::Identifier getIDFromLeg(const HLT::Identifier &legIdentifier)
Generate the HLT::Identifier which corresponds to the chain name from the leg name.
Definition: TrigCompositeUtilsRoot.cxx:180
TrigConf::Chain
HLT chain configuration.
Definition: TrigConfData/TrigConfData/HLTChain.h:18
TrigSignatureMoni::m_duration
Gaudi::Property< unsigned int > m_duration
Definition: TrigSignatureMoni.h:102
TrigSignatureMoni::RateHistogram::stopTimer
void stopTimer()
Definition: TrigSignatureMoni.cxx:536
TrigSignatureMoni::m_bookingPath
Gaudi::Property< std::string > m_bookingPath
Definition: TrigSignatureMoni.h:99
TrigSignatureMoni::m_l1DecisionsKey
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_l1DecisionsKey
Definition: TrigSignatureMoni.h:92
histogram
std::string histogram
Definition: chains.cxx:52
TrigSignatureMoni::m_rateHistogram
RateHistogram m_rateHistogram
Definition: TrigSignatureMoni.h:111