ATLAS Offline Software
HLTMETComponents.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /* Algorithm: AlgHLTMETComponents does the following
6  * Check if any sub-detector component is empty. Empty means the following:
7  * overflow or underflow bins are filled or integral of histogram is zero.
8  * Author : Venkatesh Kaushik <venkat.kaushik@cern.ch>
9  * Date : March 2010
10  */
11 
12 #include <dqm_core/AlgorithmConfig.h>
15 #include <TH1.h>
16 #include <TH2.h>
17 #include <TF1.h>
18 #include <TClass.h>
19 #include <ers/ers.h>
20 #include <cmath>
21 
22 
23 #include <dqm_core/AlgorithmManager.h>
24 
25 static dqm_algorithms::HLTMETComponents myInstance;
26 
28 
29 {
30  dqm_core::AlgorithmManager::instance().registerAlgorithm("AlgHLTMETComponents", this);
31 }
32 
35 {
36 
37  return new HLTMETComponents();
38 }
39 
40 
43  const TObject & object,
44  const dqm_core::AlgorithmConfig & config)
45 {
46  const TH2 *histogram;
47 
48  if( object.IsA()->InheritsFrom( "TH2" ) ) {
49  histogram = static_cast<const TH2*>(&object);
50  int dimension = histogram->GetDimension();
51  if (dimension != 2 ){
52  throw dqm_core::BadConfig( ERS_HERE, name, "dimension != 2 " );
53  }
54  } else {
55  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH2" );
56  }
58 
59  int nXBins = histogram -> GetNbinsX(); // components
60  if(nXBins > 25) {
61  nXBins = 25;
62  }
63  const int nYBins = histogram -> GetNbinsY(); // SumEt per sampling
64 
65 
66  // read thresholds
67  int colflags[4];
68  colflags[0] = static_cast<int>(dqm_algorithms::tools::GetFirstFromMap("METYellowMin", config.getParameters(), 1));
69  colflags[1] = static_cast<int>(dqm_algorithms::tools::GetFirstFromMap("METYellowMax", config.getParameters(), nXBins));
70  colflags[2] = static_cast<int>(dqm_algorithms::tools::GetFirstFromMap("METRedMin", config.getParameters(), 1));
71  colflags[3] = static_cast<int>(dqm_algorithms::tools::GetFirstFromMap("METRedMax", config.getParameters(), nXBins));
72  // read options
73  bool doflags[2];
74  doflags[0] = static_cast<bool>(dqm_algorithms::tools::GetFirstFromMap("DoYellowFlag", config.getParameters(), 1));
75  doflags[1] = static_cast<bool>(dqm_algorithms::tools::GetFirstFromMap("DoRedFlag", config.getParameters(), 1));
76 
78  colflags[0] = ((colflags[0] > 0) && (colflags[0] <= nXBins)) ? colflags[0] : 1;
79  colflags[1] = ((colflags[1] >= colflags[0]) && (colflags[1] <= nXBins)) ? colflags[1] : nXBins;
80  colflags[2] = ((colflags[2] > 0) && (colflags[2] <= nXBins)) ? colflags[2] : 1;
81  colflags[3] = ((colflags[3] >= colflags[2]) && (colflags[3] <= nXBins)) ? colflags[3] : nXBins;
82  bool yellowFlagComp = false, redFlagComp = false;
83  int ycnt = 0, rcnt = 0;
84 
85  // yellow flag
86  float epsilon = 1.e-3;
87  if(doflags[0]) {
88  for( int j = colflags[0]; j <= colflags[1]; j++ ) {
89  TString binLabel = histogram->GetXaxis()->GetBinLabel(j);
90  TH1D *hprojy = histogram->ProjectionY(Form("hpy1yf%02d_%s",j,binLabel.Data()),j,j+1,"egoff");
91  if(hprojy) {
92  float uflow = std::abs(hprojy->GetBinContent(0));
93  float oflow = std::abs(hprojy->GetBinContent(nYBins+1));
94  float btotal = hprojy->Integral();
95 
96  // flag true if overflow/underflow has entries or if histo is empty
97  // denoting missing component
98  if(((uflow > epsilon) || (oflow > epsilon)) && (btotal < epsilon)) {
99  yellowFlagComp = true;
100  // count bins flagged as yellow
101  ycnt++;
102  } // if uflow
103  delete hprojy; hprojy = 0;
104  } // if hprojy
105  } // for
106  } // if doflags[0]
107 
108  // red flag
109  if(doflags[1]) {
110  for( int j = colflags[2]; j <= colflags[3]; j++ ) {
111  TString binLabel = histogram->GetXaxis()->GetBinLabel(j);
112  TH1D *hprojy = histogram->ProjectionY(Form("hpy1rf%02d_%s",j,binLabel.Data()),j,j+1,"egoff");
113  if(hprojy) {
114  float uflow = std::abs(hprojy->GetBinContent(0));
115  float oflow = std::abs(hprojy->GetBinContent(nYBins+1));
116  float btotal = hprojy->Integral();
117  // flag true if overflow/underflow has entries or if histo is empty
118  // denoting missing component
119  if(((uflow > epsilon) || (oflow > epsilon)) && (btotal < epsilon)) {
120  redFlagComp = true;
121  rcnt++;
122  } // if uflow
123  delete hprojy; hprojy = 0;
124  } // if hprojy
125  } // for
126  } // if doflags[1]
127 
128  // set results (default green,
129  result->status_ = dqm_core::Result::Green;
130  if(doflags[0] && yellowFlagComp) {
131  result->status_ = dqm_core::Result::Yellow;
132  }
133  if(doflags[1] && redFlagComp) {
134  result->status_ = dqm_core::Result::Red;
135  }
136  result->tags_["YellowMETComponents"] = ycnt;
137  result->tags_["RedMETComponents"] = rcnt;
138 
140 
141  return result;
142 }
143 
144 void
146 {
147 
148  out << "HLT MET Components: Of the 25 components (24 calo samplings and 1 muon component of MET) ";
149  out << "Check if any sub-detector component is empty. Empty means any of the following:";
150  out << " overflow/underflow bins are filled, or integral of histogram is zero. " << std::endl;
151  out<< "Each component (25 of them) are bins on abscissa and the 1d histograms represent the quantity (SumEt)" << std::endl;
152 
153 }
154 
get_generator_info.result
result
Definition: get_generator_info.py:21
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
TH1D
Definition: rootspy.cxx:342
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqm_algorithms::HLTMETComponents
Definition: HLTMETComponents.h:21
dqm_algorithms::HLTMETComponents::printDescription
void printDescription(std::ostream &out)
Definition: HLTMETComponents.cxx:145
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
TH1D::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:347
dqm_algorithms::HLTMETComponents::clone
HLTMETComponents * clone()
Definition: HLTMETComponents.cxx:34
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
python.handimod.Green
int Green
Definition: handimod.py:524
TH2
Definition: rootspy.cxx:373
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
dqm_algorithms::HLTMETComponents::HLTMETComponents
HLTMETComponents()
Definition: HLTMETComponents.cxx:27
AlgorithmHelper.h
pickleTool.object
object
Definition: pickleTool.py:30
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
HLTMETComponents.h
histogram
std::string histogram
Definition: chains.cxx:52
dqm_algorithms::HLTMETComponents::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition: HLTMETComponents.cxx:42