53{
55 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
58 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
59 }
60 } else {
61 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
62 }
63 const double minstat = 1;
65 ERS_INFO(
"Too few entries: " <<
histogram->GetEntries() );
66 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
69 }
70
71 int start_from_last;
72 int n_bins;
73 int window_size;
74 double gthreshold;
75 double rthreshold;
76 std::pair<bool,double> grayValue;
77 try {
83 }
84 catch ( dqm_core::Exception & ex ) {
85 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
86 }
87 grayValue.first=true;
88 try {
90 }
91 catch ( dqm_core::Exception & ex ) {
92 grayValue.first=false;
93 grayValue.second=-1;
94 }
95 try {
97 }
98 catch ( dqm_core::Exception & ex ) {
100 }
101
102
103
105 ERS_INFO("'EqualityPrecision cannot be negative: it will be re-set to its absolute value.");
107 }
108 if(window_size<=0) {
109 ERS_INFO("You set search window size (WindowSize) <= 0: I will search the whole histogram.");
110 }
111 else {
112 if(n_bins>window_size) {
113 ERS_INFO("You set the minimum number of bins for throwing error/warning (NBins) larger than the window size (WindowSize): in this way the algorithm can never return error/warning. Setting NBins=WindowSize.");
114 n_bins=window_size;
115 }
116 }
117 if(n_bins<=0) {
118 ERS_INFO("You set the minimum number of bins for throwing error/warning (NBins) <= 0: in this way the algorithm would always return error. Setting NBins=1 (default value).");
119 n_bins=1;
120 }
123
124 dqm_core::Result*
result =
new dqm_core::Result();
125 TH1* resulthisto;
127 throw dqm_core::BadConfig( ERS_HERE, name, "TH2 received. This algorithm only works with TH1" );
128 }
else if (
histogram->InheritsFrom(
"TH1")) {
130 } else {
131 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
132 }
133
134 resulthisto->Reset();
135
136
137
139 if(start_from_last>=0)
140 i_currentLB-=start_from_last;
141 else
142 {
143 while(i_currentLB>=1)
144 {
145 if(
histogram->GetBinContent(i_currentLB)!=0)
break;
146 i_currentLB--;
147 }
148 }
149
150 if(i_currentLB<=0 || i_currentLB<n_bins)
151 {
152 ERS_DEBUG(1,"start_from_last parameter >= total number of bins, I just cannot do the check. Do nothing.");
154 }
155
156
157 int iLB=i_currentLB;
158 int countYellow=0;
159 int countRed=0;
160 int countGray=0;
161 while(iLB>=1 && (window_size<0 || (i_currentLB-iLB)<window_size))
162 {
166 {
167 countYellow++;
168 }
170 {
171 countRed++;
172 }
174 {
175 countGray++;
176 }
177
178 resulthisto->SetBinContent(iLB,content);
179 iLB--;
180 }
181
182
183 ERS_DEBUG(1,"Found " << countRed << " red bins and " << countYellow << " red bins. In a window of size " << window_size << " bins, starting at bin " << i_currentLB);
184 ERS_DEBUG(1,"To be compared with: " << n_bins);
185 ERS_DEBUG(1,"Green treshold=" << gthreshold << " Red threshold=" << rthreshold );
186
187 result->tags_[
"NRedBins"] = countRed;
188 result->tags_[
"NYellowBins"] = countYellow;
189 result->object_ = boost::shared_ptr<TObject>(resulthisto);
190 if(countRed>=n_bins)
191 {
192 result->status_ = dqm_core::Result::Red;
193 }
194 else if(countRed+countYellow>=n_bins)
195 {
196 result->status_ = dqm_core::Result::Yellow;
197 }
198 else if(countGray>=n_bins)
199 {
200 result->status_ = dqm_core::Result::Undefined;
201 }
202 else
203 {
204 result->status_ = dqm_core::Result::Green;
205 }
206
208
209}
BinHeightThreshold::binStatus CompareBinHeightThreshold(const std::string &type, double bincontent, double thresholdGr, double thresholdRed, std::pair< bool, double > valueGray)
bool checkUndefinedStatusValue(const std::string &type, double thresholdGr, double thresholdRed, std::pair< bool, double > valueGray)
void CheckThresholds(const std::string &type, double thresholdGr, double thresholdRed)
#define IsA
Declare the TObject style functions.