ATLAS Offline Software
TileTriggerMonitor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include <dqm_core/AlgorithmConfig.h>
12 #include <TH1.h>
13 #include <TH2.h>
14 #include <TF1.h>
15 #include <TClass.h>
16 #include <ers/ers.h>
17 #include <set>
18 
19 
20 #include <dqm_core/AlgorithmManager.h>
21 
22 static dqm_algorithms::TileTriggerMonitor myInstance;
23 
25 
26 {
27  dqm_core::AlgorithmManager::instance().registerAlgorithm("TileTriggerMonitor", this);
28 }
29 
32 {
33 
34  return new TileTriggerMonitor();
35 }
36 
37 
40  const TObject & object,
41  const dqm_core::AlgorithmConfig & config)
42 {
43  const TH1 * histogram;
44  if( object.IsA()->InheritsFrom( "TH1" ) ) {
45  histogram = static_cast<const TH1*>(&object);
46  if (histogram->GetDimension() > 2 ){
47  throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
48  }
49  } else {
50  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
51  }
52 
54  //Count each category of the bins, if you find a red bin show red, if you find a yellow bin show yellow
55  std::vector<int> range=dqm_algorithms::tools::GetBinRange(histogram, config.getParameters());
56  std::set<int> ignoredBins;
57  const int oneIgnoredBin = static_cast<int>(dqm_algorithms::tools::GetFirstFromMap( "IgnoredBins", config.getParameters(), -1));
58  if (oneIgnoredBin > 0) {
59  ignoredBins.insert(oneIgnoredBin);
60  } else {
61  std::string ignoredBinsString = dqm_algorithms::tools::GetFirstFromMap( "IgnoredBins", config.getGenericParameters(), "");
62  if (!ignoredBinsString.empty()) {
63  std::string IgnoredBin;
64  std::istringstream is(ignoredBinsString);
65  while (std::getline(is, IgnoredBin, ';')) {
66  ignoredBins.insert(std::stoi(IgnoredBin));
67  }
68  }
69  }
70 
71  int worstStatus = -3;
72  for ( int towerNum = range.at(0); towerNum <= range.at(1); ++towerNum ) {
73  double inputCont = histogram->GetBinContent(towerNum);
74  if (ignoredBins.count(towerNum)) continue;
75  if (inputCont>worstStatus) worstStatus=inputCont; //if you want to have a test for every bin remove the for loop and replace execute with 1D black bin algorithm
76  if (inputCont>0) dqm_algorithms::tools::PublishBin(histogram,towerNum,0,inputCont,result);
77  }
78 
79  result->tags_["BinContent"] = worstStatus;
80  if(worstStatus==2) result->status_ = dqm_core::Result::Red;
81  else if(worstStatus==1) result->status_ = dqm_core::Result::Yellow;
82  else if(worstStatus==0) result->status_ = dqm_core::Result::Green;
83  else {
84  result->status_ = dqm_core::Result::Disabled;
85  }
86 
87  return result;
88 
89 
90 }
91 
92 
93 void
95 {
96  //put optional description for developers
97  out<<"Red bin: The tower has experienced a large spike in rate. The large spike threshold algorithm is written in TilePPMContainerSpike in TriggerMonitor in L1Calo's git repository. \n" << std::endl;
98 
99  out<<"Yellow bin: The tower has experienced a spike in rate. The spike threshold algorithm is written in TilePPMContainerSpike in TriggerMonitor in L1Calo's git repository. \n" << std::endl;
100 
101  out<<"Black bin: This tower is disabled\n" << std::endl;
102 
103  out<<"Optional Parameter, Publish Bin: Publishes the content of the bins that are different than result." << std::endl;
104 
105  out<<"Optional Parameter, IgnoredBins: Ignores the content of the bin if you do not want a bin's result dominating a histogram" << std::endl;
106 }
107 
TileTriggerMonitor.h
dqm_algorithms::tools::GetBinRange
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:380
get_generator_info.result
result
Definition: get_generator_info.py:21
dqm_algorithms::TileTriggerMonitor::printDescription
void printDescription(std::ostream &out)
Definition: TileTriggerMonitor.cxx:94
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqm_algorithms::tools::PublishBin
void PublishBin(const TH1 *histogram, int xbin, int ybin, double content, dqm_core::Result *result)
Definition: AlgorithmHelper.cxx:426
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
dqm_algorithms::TileTriggerMonitor::TileTriggerMonitor
TileTriggerMonitor()
Definition: TileTriggerMonitor.cxx:24
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.handimod.Green
int Green
Definition: handimod.py:524
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AlgorithmHelper.h
dqm_algorithms::TileTriggerMonitor
Definition: TileTriggerMonitor.h:19
pickleTool.object
object
Definition: pickleTool.py:30
dqm_algorithms::TileTriggerMonitor::clone
TileTriggerMonitor * clone()
Definition: TileTriggerMonitor.cxx:31
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
histogram
std::string histogram
Definition: chains.cxx:52
dqm_algorithms::TileTriggerMonitor::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition: TileTriggerMonitor.cxx:39