ATLAS Offline Software
Loading...
Searching...
No Matches
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
26
28
29{
30 dqm_core::AlgorithmManager::instance().registerAlgorithm("AlgHLTMETComponents", this);
31}
32
39
40
41dqm_core::Result *
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
77 dqm_core::Result* result = new dqm_core::Result();
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
144void
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
static dqm_algorithms::BinContentComp myInstance
std::string histogram
Definition chains.cxx:52
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
void printDescription(std::ostream &out)
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
#define IsA
Declare the TObject style functions.