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