142 {
143 dqm_core::Result*
result =
new dqm_core::Result();
144
145
146 int NWarnings = 0;
147 int NErrors = 0;
148 int NGoodPrint = 0;
149
152
153
154 if (!
data.IsA()->InheritsFrom(
"TH1")) {
155 throw dqm_core::BadConfig(ERS_HERE, name, "does not inherit from TH1");
156 }
157 const TH1*
h =
static_cast<const TH1*
>(&
data);
158 if (
h->GetDimension() > 2) {
159 throw dqm_core::BadConfig(ERS_HERE, name, "dimension > 2 ");
160 }
161
162
166
167
168 int UseValue;
169 int TypeValue;
170 try {
173 }
174 catch (dqm_core::Exception & ex) {
175 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
176 }
177 if ( UseValue == 0 ) ERS_INFO("UseValue == 0 is meaningless");
178
179
180
181
182 if (
data.IsA()->InheritsFrom(
"TProfile") ) {
184
186
187
188 std::vector<BinThresh::mask_limits> Limits;
189 try {
191 }
192 catch (dqm_core::Exception & ex) {
193 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
194 }
195
196
198 if ((UseValue > 0 && Limits[bin].WarningValue > Limits[bin].ErrorValue) ||
199 (UseValue < 0 && Limits[bin].WarningValue < Limits[bin].ErrorValue)) {
200
201 if ( !Limits[bin].Mask ) {
202 std::string problem_message = Form("Incompatible Warning and Error Values in bin_%d : Warning = %e -> Error = %e", bin + 1, Limits[bin].WarningValue, Limits[bin].ErrorValue);
203 ERS_INFO(problem_message.c_str());
204 }
205 }
206 }
207
208
209 double h_entries = hp->GetEntries();
210 if ( TypeValue ) {
212 Limits[
bin].WarningValue = Limits[
bin].WarningValue * h_entries;
213 Limits[
bin].ErrorValue = Limits[
bin].ErrorValue * h_entries;
214 }
215 }
216
217
219 double bincon = hp->GetBinContent(bin + 1);
220 if ( !Limits[bin].Mask && hp->GetBinEntries(bin + 1) >= BinMinEntries ) {
221
222 if ((UseValue == 1 && bincon >= Limits[bin].ErrorValue) ||
223 (UseValue > 1 && bincon > Limits[bin].ErrorValue) ||
224 (UseValue == -1 && bincon <= Limits[bin].ErrorValue) ||
225 (UseValue < -1 && bincon < Limits[bin].ErrorValue) ) {
226 NErrors++;
227 if ( NErrors + NWarnings + NGoodPrint <= Publish ) {
228 double binval = hp->GetXaxis()->GetBinCenter(bin + 1);
229
230
231
232
233 std::string binname = Form(
"%s_ErrorBin(%u | %.*e)",
name.c_str(), bin, 2, binval);
234
235 if ( TypeValue > 0.5 ) {
236 result->tags_[binname.c_str()] = (bincon / h_entries);
237 } else {
238 result->tags_[binname.c_str()] = bincon;
239 }
240 }
241 }
242
243 else if ((UseValue == 1 && bincon >= Limits[bin].WarningValue) ||
244 (UseValue > 1 && bincon > Limits[bin].WarningValue) ||
245 (UseValue == -1 && bincon <= Limits[bin].WarningValue) ||
246 (UseValue < -1 && bincon < Limits[bin].WarningValue) ) {
247 NWarnings++;
248 if ( TypePublish >= 1 && NErrors + NWarnings + NGoodPrint <= Publish ) {
249 float binval = hp->GetXaxis()->GetBinCenter(bin + 1);
250
251
252
253 std::string binname = Form(
"%s_WarningBin(%u | %.*e)",
name.c_str(), bin, 2, binval);
254 if ( TypeValue > 0.5 ) {
255 result->tags_[binname.c_str()] = (bincon / h_entries);
256 } else {
257 result->tags_[binname.c_str()] = bincon;
258 }
259 }
260 }
261
262 else {
263 NGoodPrint++;
264 if ( TypePublish >= 2 && NErrors + NWarnings + NGoodPrint <= Publish ) {
265 float binval = hp->GetXaxis()->GetBinCenter(bin + 1);
266
267
268
269 std::string binname = Form(
"%s_GoodBin(%u | %.*e)",
name.c_str(), bin, 2, binval);
270 if ( TypeValue > 0.5 ) {
271 result->tags_[binname.c_str()] = (bincon / h_entries);
272 } else {
273 result->tags_[binname.c_str()] = bincon;
274 }
275 }
276 }
277 }
278 }
279 }
280
281
282
283
284 if ( (!
data.IsA()->InheritsFrom(
"TProfile")) &&
h->GetDimension() == 1 ) {
286
287
288 std::vector<BinThresh::mask_limits> Limits;
289 try {
291 }
292 catch (dqm_core::Exception & ex) {
293 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
294 }
295
296
298 if ((UseValue > 0 && Limits[bin].WarningValue > Limits[bin].ErrorValue) ||
299 (UseValue < 0 && Limits[bin].WarningValue < Limits[bin].ErrorValue)) {
300
301 if ( !Limits[bin].Mask ) {
302 std::string problem_message = Form("Incompatible Warning and Error Values in bin_%d : Warning = %e -> Error = %e", bin + 1, Limits[bin].WarningValue, Limits[bin].ErrorValue);
303 ERS_INFO(problem_message.c_str());
304 }
305 }
306 }
307
308
309 double h_entries =
h->GetEntries();
310 if ( TypeValue ) {
312 Limits[
bin].WarningValue = Limits[
bin].WarningValue * h_entries;
313 Limits[
bin].ErrorValue = Limits[
bin].ErrorValue * h_entries;
314 }
315 }
316
317
319 double bincon =
h->GetBinContent(bin + 1);
320 if ( !Limits[bin].Mask ) {
321
322 if ((UseValue == 1 && bincon >= Limits[bin].ErrorValue) ||
323 (UseValue > 1 && bincon > Limits[bin].ErrorValue) ||
324 (UseValue == -1 && bincon <= Limits[bin].ErrorValue) ||
325 (UseValue < -1 && bincon < Limits[bin].ErrorValue) ) {
326 NErrors++;
327 if ( NErrors + NWarnings + NGoodPrint <= Publish ) {
328 double binval =
h->GetXaxis()->GetBinCenter(bin + 1);
329
330
331
332
333 std::string binname = Form(
"%s_ErrorBin(%u | %.*e)",
name.c_str(), bin, 2, binval);
334
335 if ( TypeValue > 0.5 ) {
336 result->tags_[binname.c_str()] = (bincon / h_entries);
337 } else {
338 result->tags_[binname.c_str()] = bincon;
339 }
340 }
341 }
342
343 else if ((UseValue == 1 && bincon >= Limits[bin].WarningValue) ||
344 (UseValue > 1 && bincon > Limits[bin].WarningValue) ||
345 (UseValue == -1 && bincon <= Limits[bin].WarningValue) ||
346 (UseValue < -1 && bincon < Limits[bin].WarningValue) ) {
347 NWarnings++;
348 if ( TypePublish >= 1 && NErrors + NWarnings + NGoodPrint <= Publish ) {
349 float binval =
h->GetXaxis()->GetBinCenter(bin + 1);
350
351
352
353 std::string binname = Form(
"%s_WarningBin(%u | %.*e)",
name.c_str(), bin, 2, binval);
354 if ( TypeValue > 0.5 ) {
355 result->tags_[binname.c_str()] = (bincon / h_entries);
356 } else {
357 result->tags_[binname.c_str()] = bincon;
358 }
359 }
360 }
361
362 else {
363 NGoodPrint++;
364 if ( TypePublish >= 2 && NErrors + NWarnings + NGoodPrint <= Publish ) {
365 float binval =
h->GetXaxis()->GetBinCenter(bin + 1);
366
367
368
369 std::string binname = Form(
"%s_GoodBin(%u | %.*e)",
name.c_str(), bin, 2, binval);
370 if ( TypeValue > 0.5 ) {
371 result->tags_[binname.c_str()] = (bincon / h_entries);
372 } else {
373 result->tags_[binname.c_str()] = bincon;
374 }
375 }
376 }
377 }
378 }
379 }
380
381
382
383
384 if ( (!
data.IsA()->InheritsFrom(
"TProfile")) &&
h->GetDimension() == 2 ) {
387
388
389 std::vector< std::vector<BinThresh::mask_limits> > Limits;
390 try {
392 }
393 catch (dqm_core::Exception & ex) {
394 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
395 }
396
397
400 if ( (UseValue > 0 && Limits[binX][binY].WarningValue > Limits[binX][binY].ErrorValue) ||
401 (UseValue < 0 && Limits[binX][binY].WarningValue < Limits[binX][binY].ErrorValue)) {
402
403 if ( !Limits[binX][binY].Mask ) {
404 std::string problem_message = Form("Incompatible Warning and Error Values in bin_%d_%d : Warning = %e -> Error = %e", binX + 1, binY + 1, Limits[binX][binY].WarningValue, Limits[binX][binY].ErrorValue);
405 ERS_INFO(problem_message.c_str());
406 }
407 }
408 }}
409
410
411 double h_entries =
h->GetEntries();
412 if ( TypeValue ) {
415 Limits[
binX][
binY].WarningValue = Limits[
binX][
binY].WarningValue * h_entries;
417 }}
418 }
419
420
423 double bincon =
h->GetBinContent(binX + 1, binY + 1);
424 if ( !Limits[binX][binY].Mask ) {
425
426 if ( (UseValue == 1 && bincon >= Limits[binX][binY].ErrorValue) ||
427 (UseValue > 1 && bincon > Limits[binX][binY].ErrorValue) ||
428 (UseValue == -1 && bincon <= Limits[binX][binY].ErrorValue) ||
429 (UseValue < -1 && bincon < Limits[binX][binY].ErrorValue) ) {
430 NErrors++;
431 if ( NErrors + NWarnings + NGoodPrint <= Publish ) {
432 float binvalX =
h->GetXaxis()->GetBinCenter(binX + 1);
433 float binvalY =
h->GetYaxis()->GetBinCenter(binY + 1);
434 std::string binname = Form(
"%s_ErrorBin((%u,%u) | %.*e,%.*e)",
name.c_str(), binX, binY, 2, binvalX, 2, binvalY);
435
436 if ( TypeValue > 0.5 ) {
437 result->tags_[binname.c_str()] = (bincon / h_entries);
438 } else {
439 result->tags_[binname.c_str()] = bincon;
440 }
441 }
442 }
443
444 else if ( (UseValue == 1 && bincon >= Limits[binX][binY].WarningValue) ||
445 (UseValue > 1 && bincon > Limits[binX][binY].WarningValue) ||
446 (UseValue == -1 && bincon <= Limits[binX][binY].WarningValue) ||
447 (UseValue < -1 && bincon < Limits[binX][binY].WarningValue) ) {
448 NWarnings++;
449 if ( TypePublish >= 1 && NErrors + NWarnings + NGoodPrint <= Publish ) {
450 float binvalX =
h->GetXaxis()->GetBinCenter(binX + 1);
451 float binvalY =
h->GetYaxis()->GetBinCenter(binY + 1);
452 std::string binname = Form(
"%s_WarningBin((%u,%u) | %.*e,%.*e)",
name.c_str(), binX, binY, 2, binvalX, 2, binvalY);
453 if ( TypeValue > 0.5 ) {
454 result->tags_[binname.c_str()] = (bincon / h_entries);
455 } else {
456 result->tags_[binname.c_str()] = bincon;
457 }
458 }
459 }
460
461 else {
462 NGoodPrint++;
463 if ( TypePublish >= 2 && NErrors + NWarnings + NGoodPrint <= Publish ) {
464 float binvalX =
h->GetXaxis()->GetBinCenter(binX + 1);
465 float binvalY =
h->GetYaxis()->GetBinCenter(binY + 1);
466 std::string binname = Form(
"%s_GoodBin((%u,%u) | %.*e,%.*e)",
name.c_str(), binX, binY, 2, binvalX, 2, binvalY);
467 if ( TypeValue > 0.5 ) {
468 result->tags_[binname.c_str()] = (bincon / h_entries);
469 } else {
470 result->tags_[binname.c_str()] = bincon;
471 }
472 }
473 }
474 }
475 }}
476 }
477
478
479 if ( Publish >= 0 ) {
480 std::string pub_error = Form(
"%s_Bin_Errors",
name.c_str());
481 result->tags_[pub_error.c_str()] = NErrors;
482 if ( TypePublish >= 1 ) {
483 std::string pub_warning = Form(
"%s_Bin_Warnings",
name.c_str());
484 result->tags_[pub_warning.c_str()] = NWarnings;
485 }
486 }
487
488
489 if ( (NErrors == 0) && (NWarnings == 0) )
result->status_ = dqm_core::Result::Green;
490 if ( (NErrors == 0) && (NWarnings > 0) )
result->status_ = dqm_core::Result::Yellow;
491 if ( (NErrors > 0) )
result->status_ = dqm_core::Result::Red;
492
493 return(result);
494 }
char data[hepevt_bytes_allocation_ATLAS]
int BinMinEntries_GetFromMap(const std::map< std::string, double > ¶ms)
int Publish_GetFromMap(const std::map< std::string, double > ¶ms)
std::vector< BinThresh::mask_limits > Limits1D_GetFromMap(const std::map< std::string, double > ¶ms, const std::map< std::string, double > &warning_params, const std::map< std::string, double > &error_params)
std::vector< std::vector< BinThresh::mask_limits > > Limits2D_GetFromMap(const std::map< std::string, double > ¶ms, const std::map< std::string, double > &warning_params, const std::map< std::string, double > &error_params)
int UseValue_GetFromMap(const std::map< std::string, double > ¶ms)
int TypeValue_GetFromMap(const std::map< std::string, double > ¶ms)
int TypePublish_GetFromMap(const std::map< std::string, double > ¶ms)
TProfile(*args, **kwargs)