ATLAS Offline Software
Loading...
Searching...
No Matches
dqm_algorithms::BinThresh Class Reference

#include <BinThresh.h>

Inheritance diagram for dqm_algorithms::BinThresh:
Collaboration diagram for dqm_algorithms::BinThresh:

Classes

struct  mask_limits

Public Member Functions

 BinThresh ()
virtual ~BinThresh ()
virtual dqm_core::Algorithm * clone ()
virtual dqm_core::Result * execute (const std::string &name, const TObject &data, const dqm_core::AlgorithmConfig &config)
virtual void printDescription (std::ostream &out)

Protected Member Functions

int Publish_GetFromMap (const std::map< std::string, double > &params)
int TypePublish_GetFromMap (const std::map< std::string, double > &params)
int UseValue_GetFromMap (const std::map< std::string, double > &params)
int TypeValue_GetFromMap (const std::map< std::string, double > &params)
int BinMinEntries_GetFromMap (const std::map< std::string, double > &params)
std::vector< BinThresh::mask_limitsLimits1D_GetFromMap (const std::map< std::string, double > &params, 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 > &params, const std::map< std::string, double > &warning_params, const std::map< std::string, double > &error_params)

Protected Attributes

std::string m_name
int m_NbinsX
int m_NbinsY

Detailed Description

Definition at line 18 of file BinThresh.h.

Constructor & Destructor Documentation

◆ BinThresh()

dqm_algorithms::BinThresh::BinThresh ( )

Definition at line 119 of file BinThresh.cxx.

121 : m_name("BinThresh")
122 , m_NbinsX(-1)
123 , m_NbinsY(-1)
124 {
125 dqm_core::AlgorithmManager::instance().registerAlgorithm( m_name, this );
126
127 //NOTE: name will yield the entire directory structure
128 //leading up to the algorithm instance.
129 //This directory structure is used by other features such as result->tag.
130 }

◆ ~BinThresh()

dqm_algorithms::BinThresh::~BinThresh ( )
virtual

Definition at line 133 of file BinThresh.cxx.

135 {
136 }

Member Function Documentation

◆ BinMinEntries_GetFromMap()

int dqm_algorithms::BinThresh::BinMinEntries_GetFromMap ( const std::map< std::string, double > & params)
protected

Definition at line 551 of file BinThresh.cxx.

552 {
553 std::map<std::string, double>::const_iterator it = params.find(binMinEntriesStr);
554 if ( it != params.end() ) {
555 return((int) it->second);
556 }else {
557 return(0);
558 }
559 }

◆ clone()

dqm_core::Algorithm * dqm_algorithms::BinThresh::clone ( )
virtual

Definition at line 140 of file BinThresh.cxx.

142 {
143 return new BinThresh(*this);
144 }

◆ execute()

dqm_core::Result * dqm_algorithms::BinThresh::execute ( const std::string & name,
const TObject & data,
const dqm_core::AlgorithmConfig & config )
virtual

Definition at line 148 of file BinThresh.cxx.

150 {
151 dqm_core::Result* result = new dqm_core::Result();
152
153 //Worst Case Summary default = Good
154 int NWarnings = 0;
155 int NErrors = 0;
156 int NGoodPrint = 0;
157 //Histogram dimension default = no dimensions
158 m_NbinsX = -1;
159 m_NbinsY = -1;
160
161 //Get data
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); // h cannot be null
166 if (h->GetDimension() > 2) {
167 throw dqm_core::BadConfig(ERS_HERE, name, "dimension > 2 ");
168 }
169
170 //Get optional parameters
171 int Publish = Publish_GetFromMap(config.getParameters());
172 int TypePublish = TypePublish_GetFromMap(config.getParameters());
173 int BinMinEntries = BinMinEntries_GetFromMap(config.getParameters());
174
175 //Get mandatory parameters
176 int UseValue;
177 int TypeValue;
178 try {
179 UseValue = UseValue_GetFromMap(config.getParameters());
180 TypeValue = TypeValue_GetFromMap(config.getParameters());
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 // Profile case
189 //**********
190 if ( data.IsA()->InheritsFrom("TProfile") ) {
191 const TProfile* hp = static_cast<const TProfile*>(&data);
192 //ASSUME: dimension = 1
193 m_NbinsX = hp->GetNbinsX();
194
195 //Get threshold limits & masks
196 std::vector<BinThresh::mask_limits> Limits;
197 try {
198 Limits = Limits1D_GetFromMap(config.getParameters(), config.getGreenThresholds(), config.getRedThresholds());
199 }
200 catch (dqm_core::Exception & ex) {
201 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
202 }
203 //CHECK
204 //Verify threshold limit consistencies
205 for(int bin = 0; bin < m_NbinsX; bin++) {
206 if ((UseValue > 0 && Limits[bin].WarningValue > Limits[bin].ErrorValue) ||
207 (UseValue < 0 && Limits[bin].WarningValue < Limits[bin].ErrorValue)) {
208 //Masked thresholds might be used for a different algorithm configuration
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 //Rescale Thresholds to test fractional distribution
217 double h_entries = hp->GetEntries();
218 if ( TypeValue ) {
219 for (int bin = 0; bin < m_NbinsX; bin++) {
220 Limits[bin].WarningValue = Limits[bin].WarningValue * h_entries;
221 Limits[bin].ErrorValue = Limits[bin].ErrorValue * h_entries;
222 }
223 }
224
225 //Check all bins
226 for (int bin = 0; bin < m_NbinsX; bin++) {
227 double bincon = hp->GetBinContent(bin + 1);
228 if ( !Limits[bin].Mask && hp->GetBinEntries(bin + 1) >= BinMinEntries ) {
229 //Check for and Print errors
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 ) { //Publish Errors
236 double binval = hp->GetXaxis()->GetBinCenter(bin + 1);
237 //Give bin number as well as bin center
238 //Use scientific notation (e) to be compatible with all axis scales
239 //Include 2 digits after decimal (.*, with *=2) so that partitions up to 1000 are covered.
240 //If using fractional thresholds, then print fractional values.
241 std::string binname = Form("%s_ErrorBin(%u | %.*e)", name.c_str(), bin, 2, binval);
242 //From() ~ printf() (s ~ string, u ~ unsigned int, .*e ~ scientific)
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 //Check for and Print warnings, if no Errors found
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 ) { //Publish Warnings
257 float binval = hp->GetXaxis()->GetBinCenter(bin + 1);
258 //Use scientific notation (e) to be compatible with all axis scales
259 //Include 2 digits after decimal (.*, with *=2) so that partitions up to 1000 are covered.
260 //If using fractional thresholds, then print fractional values.
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 //Print remaining bins
270 else {
271 NGoodPrint++;
272 if ( TypePublish >= 2 && NErrors + NWarnings + NGoodPrint <= Publish ) { //Publish Good Bins
273 float binval = hp->GetXaxis()->GetBinCenter(bin + 1);
274 //Use scientific notation (e) to be compatible with all axis scales
275 //Include 2 digits after decimal (.*, with *=2) so that partitions up to 1000 are covered.
276 //If using fractional thresholds, then print fractional values.
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 // 1D Histogram case
291 //**********
292 if ( (! data.IsA()->InheritsFrom("TProfile")) && h->GetDimension() == 1 ) {
293 m_NbinsX = h->GetNbinsX();
294
295 //Get threshold limits & masks
296 std::vector<BinThresh::mask_limits> Limits;
297 try {
298 Limits = Limits1D_GetFromMap(config.getParameters(), config.getGreenThresholds(), config.getRedThresholds());
299 }
300 catch (dqm_core::Exception & ex) {
301 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
302 }
303 //CHECK
304 //Verify threshold limit consistencies
305 for(int bin = 0; bin < m_NbinsX; bin++) {
306 if ((UseValue > 0 && Limits[bin].WarningValue > Limits[bin].ErrorValue) ||
307 (UseValue < 0 && Limits[bin].WarningValue < Limits[bin].ErrorValue)) {
308 //Masked thresholds might be used for a different algorithm configuration
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 //Rescale Thresholds to test fractional distribution
317 double h_entries = h->GetEntries();
318 if ( TypeValue ) {
319 for (int bin = 0; bin < m_NbinsX; bin++) {
320 Limits[bin].WarningValue = Limits[bin].WarningValue * h_entries;
321 Limits[bin].ErrorValue = Limits[bin].ErrorValue * h_entries;
322 }
323 }
324
325 //Check all bins
326 for (int bin = 0; bin < m_NbinsX; bin++) {
327 double bincon = h->GetBinContent(bin + 1);
328 if ( !Limits[bin].Mask ) {
329 //Check for and Print errors
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 ) { //Publish Errors
336 double binval = h->GetXaxis()->GetBinCenter(bin + 1);
337 //Give bin number as well as bin center
338 //Use scientific notation (e) to be compatible with all axis scales
339 //Include 2 digits after decimal (.*, with *=2) so that partitions up to 1000 are covered.
340 //If using fractional thresholds, then print fractional values.
341 std::string binname = Form("%s_ErrorBin(%u | %.*e)", name.c_str(), bin, 2, binval);
342 //From() ~ printf() (s ~ string, u ~ unsigned int, .*e ~ scientific)
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 //Check for and Print warnings, if no Errors found
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 ) { //Publish Warnings
357 float binval = h->GetXaxis()->GetBinCenter(bin + 1);
358 //Use scientific notation (e) to be compatible with all axis scales
359 //Include 2 digits after decimal (.*, with *=2) so that partitions up to 1000 are covered.
360 //If using fractional thresholds, then print fractional values.
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 //Print remaining bins
370 else {
371 NGoodPrint++;
372 if ( TypePublish >= 2 && NErrors + NWarnings + NGoodPrint <= Publish ) { //Publish Good Bins
373 float binval = h->GetXaxis()->GetBinCenter(bin + 1);
374 //Use scientific notation (e) to be compatible with all axis scales
375 //Include 2 digits after decimal (.*, with *=2) so that partitions up to 1000 are covered.
376 //If using fractional thresholds, then print fractional values.
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 // 2D Histogram case
391 //**********
392 if ( (! data.IsA()->InheritsFrom("TProfile")) && h->GetDimension() == 2 ) {
393 m_NbinsX = h->GetNbinsX();
394 m_NbinsY = h->GetNbinsY();
395
396 //Get threshold limits & masks
397 std::vector< std::vector<BinThresh::mask_limits> > Limits;
398 try {
399 Limits = Limits2D_GetFromMap(config.getParameters(), config.getGreenThresholds(), config.getRedThresholds());
400 }
401 catch (dqm_core::Exception & ex) {
402 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
403 }
404 //CHECK
405 //Verify threshold limit consistencies
406 for(int binX = 0; binX < m_NbinsX; binX++) {
407 for(int binY = 0; binY < m_NbinsY; binY++) {
408 if ( (UseValue > 0 && Limits[binX][binY].WarningValue > Limits[binX][binY].ErrorValue) ||
409 (UseValue < 0 && Limits[binX][binY].WarningValue < Limits[binX][binY].ErrorValue)) {
410 //Masked thresholds might be used for a different algorithm configuration
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 //Rescale Thresholds to test fractional distribution
419 double h_entries = h->GetEntries();
420 if ( TypeValue ) {
421 for (int binX = 0; binX < m_NbinsX; binX++) {
422 for (int binY = 0; binY < m_NbinsY; binY++) {
423 Limits[binX][binY].WarningValue = Limits[binX][binY].WarningValue * h_entries;
424 Limits[binX][binY].ErrorValue = Limits[binX][binY].ErrorValue * h_entries;
425 }}
426 }
427
428 //Check all bins
429 for (int binX = 0; binX < m_NbinsX; binX++) {
430 for (int binY = 0; binY < m_NbinsY; binY++) {
431 double bincon = h->GetBinContent(binX + 1, binY + 1);
432 if ( !Limits[binX][binY].Mask ) {
433 //Check for and Print errors
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 ) { //Publish Errors
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 //From() ~ printf() (s ~ string, u ~ unsigned int, .*e ~ scientific)
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 //Check for and Print warnings
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 ) { //Publish Warnings
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 //Print remaining bins
469 else {
470 NGoodPrint++;
471 if ( TypePublish >= 2 && NErrors + NWarnings + NGoodPrint <= Publish ) { //Publish Good Bins
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 //Print Number of Errors & Warnings
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 //Set Flag as worst case summary of all bins
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]
Definition HepEvt.cxx:11
int BinMinEntries_GetFromMap(const std::map< std::string, double > &params)
int Publish_GetFromMap(const std::map< std::string, double > &params)
std::vector< BinThresh::mask_limits > Limits1D_GetFromMap(const std::map< std::string, double > &params, 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 > &params, 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 > &params)
int TypeValue_GetFromMap(const std::map< std::string, double > &params)
int TypePublish_GetFromMap(const std::map< std::string, double > &params)
@ binX
Definition BinningType.h:47
@ binY
Definition BinningType.h:48

◆ Limits1D_GetFromMap()

std::vector< BinThresh::mask_limits > dqm_algorithms::BinThresh::Limits1D_GetFromMap ( const std::map< std::string, double > & params,
const std::map< std::string, double > & warning_params,
const std::map< std::string, double > & error_params )
protected

Definition at line 561 of file BinThresh.cxx.

564 {
565 std::map<std::string, double>::const_iterator warning_map_bin;
566 std::map<std::string, double>::const_iterator error_map_bin;
567 std::map<std::string, double>::const_iterator mask_map_bin;
568
569 //Make Default Limit Values & Masking
570 BinThresh::mask_limits default_Limits;
571 default_Limits.WarningValue = 0.0;
572 default_Limits.ErrorValue = 0.0;
573 default_Limits.Mask = true;
574
575 //Check for Value_All thresholds to use for all bins
576 warning_map_bin = warning_params.find(valueAllStr);
577 error_map_bin = error_params.find(valueAllStr);
578 if ( warning_map_bin != warning_params.end() &&
579 error_map_bin != error_params.end() ) {
580 default_Limits.WarningValue = warning_map_bin->second;
581 default_Limits.ErrorValue = error_map_bin->second;
582 default_Limits.Mask = false;
583 }
584
585 //Make default threshold & mask
586 std::vector<BinThresh::mask_limits> Limits(m_NbinsX, default_Limits);
587
588 //Get specific bin limits and unmasked bins
589 for ( int bin = 0; bin < m_NbinsX; bin++ ) {
590 std::string value_bin = Form("Value_%d", bin + 1);
591 //Get thresholds for bin
592 warning_map_bin = warning_params.find(value_bin.c_str());
593 error_map_bin = error_params.find(value_bin.c_str());
594 if ( warning_map_bin != warning_params.end() &&
595 error_map_bin != error_params.end() ) {
596 Limits[bin].WarningValue = warning_map_bin->second;
597 Limits[bin].ErrorValue = error_map_bin->second;
598 Limits[bin].Mask = false;
599 }
600
601 //Mask out specified bins
602 //The masking that is explicitly defined takes precedence over the implied masking from the thresholds
603 std::string mask_bin = Form("Mask_%d", bin + 1);
604 mask_map_bin = params.find(mask_bin.c_str());
605 if ( mask_map_bin != params.end() ) {
606 if(mask_map_bin->second > 0.5) Limits[bin].Mask = true;
607 //UnMasking should never be necessary
608 }
609 }
610
611 return(Limits);
612 }

◆ Limits2D_GetFromMap()

std::vector< std::vector< BinThresh::mask_limits > > dqm_algorithms::BinThresh::Limits2D_GetFromMap ( const std::map< std::string, double > & params,
const std::map< std::string, double > & warning_params,
const std::map< std::string, double > & error_params )
protected

Definition at line 614 of file BinThresh.cxx.

617 {
618 std::map<std::string, double>::const_iterator warning_map_bin;
619 std::map<std::string, double>::const_iterator error_map_bin;
620 std::map<std::string, double>::const_iterator mask_map_bin;
621
622 //Make Default Limit Values & Masking
623 BinThresh::mask_limits default_Limits;
624 default_Limits.WarningValue = 0.0;
625 default_Limits.ErrorValue = 0.0;
626 default_Limits.Mask = true;
627
628 //Check for Value_All thresholds to use for all bins
629 warning_map_bin = warning_params.find(valueAllStr);
630 error_map_bin = error_params.find(valueAllStr);
631 if ( warning_map_bin != warning_params.end() &&
632 error_map_bin != error_params.end() ) {
633 default_Limits.WarningValue = warning_map_bin->second;
634 default_Limits.ErrorValue = error_map_bin->second;
635 default_Limits.Mask = false;
636 }
637
638 //Make default threshold & mask
639 std::vector< std::vector<BinThresh::mask_limits> > Limits(m_NbinsX, std::vector<BinThresh::mask_limits>(m_NbinsY, default_Limits));
640
641 //Get specific bin limits and unmasked bins
642 for ( int binX = 0; binX < m_NbinsX; binX++ ) {
643 for ( int binY = 0; binY < m_NbinsY; binY++ ) {
644 std::string value_bin = Form("Value_%d_%d", binX + 1, binY + 1);
645 //Get thresholds for bin
646 warning_map_bin = warning_params.find(value_bin.c_str());
647 error_map_bin = error_params.find(value_bin.c_str());
648 if ( warning_map_bin != warning_params.end() &&
649 error_map_bin != error_params.end() ) {
650 Limits[binX][binY].WarningValue = warning_map_bin->second;
651 Limits[binX][binY].ErrorValue = error_map_bin->second;
652 Limits[binX][binY].Mask = false;
653 }
654
655 //Mask out specified bins
656 //The masking that is explicitly defined takes precedence over the implied masking from the thresholds
657 std::string mask_bin = Form("Mask_%d_%d", binX + 1, binY + 1);
658 mask_map_bin = params.find(mask_bin.c_str());
659 if ( mask_map_bin != params.end() ) {
660 if(mask_map_bin->second > 0.5) Limits[binX][binY].Mask = true;
661 //UnMasking should never be necessary
662 }
663 }}
664
665 return(Limits);
666 }

◆ printDescription()

void dqm_algorithms::BinThresh::printDescription ( std::ostream & out)
virtual

Definition at line 37 of file BinThresh.cxx.

39 {
40 std::string message;
41 message += "\n";
42 message += "Algorithm: \"" + m_name + "\"\n";
43 message += "Description: Defines a warning and an error threshold for individual bins.\n";
44 message += " The status is the worst case summary of individual bin comparisons.\n";
45 message += " Some of the parameter names depend on whether the histogram is 1D or 2D.\n";
46 message += "Mandatory Parameter: UseValue:\n";
47 message += " 1: Flag bin contents >= Value\n";
48 message += " >1: Flag bin contents > Value\n";
49 message += " -1: Flag bin contents <= Value\n";
50 message += " <-1: Flag bin contents < Value\n";
51 message += "Mandatory Parameter: TypeValue:\n";
52 message += " 0: Value is compared to total entries in bin\n";
53 message += " 1: Value is compared to fraction of entries in histogram appearing in bin\n";
54 message += " This also determines how the bin contents will be listed if published.\n";
55 message += "Optional Parameter: Publish: Default = -1\n";
56 message += " -1: Print no values\n";
57 message += " 0: Print the number of bins exceeding their threshold\n";
58 message += " # > 0: Print bins exceeding their thresholds individually\n";
59 message += " At most # bins are printed, and the excess is also listed\n";
60 message += "Optional Parameter: TypePublish: Default = 0\n";
61 message += " 0: Print only bins exceeding their error threshold Values\n";
62 message += " 1: Print only bins exceeding their error or warning threshold Values\n";
63 message += " 2: Print all unmasked bins\n";
64 message += "Profile Configuration:\n";
65 message += "Optional Parameter: BinMinEntries: Default = 0\n";
66 message += " Minimum number of entries in a TProfile (1D only) for a bin to be checked against thresolds\n";
67 message += " If a bin does not have a sufficient number of entries it also will not be printed\n";
68 message += "1D Histogram Configuration:\n";
69 message += "Limits: Value_#\n";
70 message += " Arguments are given for individual bins.\n";
71 message += " To make a single threshold check, set Warning:Value == Error:Value\n";
72 message += " Example of asserting the thresholds for a 3 bin histogram with the 2nd bin masked\n";
73 message += " ***In thresholds declaration:\n";
74 message += " limits Value_1 {\n";
75 message += " warning = 0.0\n";
76 message += " error = 0.5\n";
77 message += " }\n";
78 message += " limits Value_3 {\n";
79 message += " warning = 2.0\n";
80 message += " error = 2.5\n";
81 message += " }\n";
82 message += "Limits: Value_All\n";
83 message += " Unmasks and sets thresholds uniformly for all bins.\n";
84 message += " Example of alternative declaration of the 3 bins histogram thresholds and masking above:\n";
85 message += " ***In algorithm declaration\n";
86 message += " Mask_2 = 1\n";
87 message += " ***In thresholds declaration:\n";
88 message += " limits Value_All {\n";
89 message += " warning = 0.0\n";
90 message += " error = 0.5\n";
91 message += " }\n";
92 message += " limits Value_3 {\n";
93 message += " warning = 2.0\n";
94 message += " error = 2.5\n";
95 message += " }\n";
96 message += "Optional Parameters: Mask_# Default = See Note below.\n";
97 message += " 1: Mask bin\n";
98 message += "2D Histogram Configuration:\n";
99 message += "Limits: Value_#_#\n";
100 message += " Arguments are given for individual bins.\n";
101 message += " Example of setting the X = 1, Y = 2 bin thresholds:\n";
102 message += " ***In thresholds declaration:\n";
103 message += " limits Value_1_2 {\n";
104 message += " warning = 2.0\n";
105 message += " error = 2.5\n";
106 message += " }\n";
107 message += "Optional Parameters: Mask_#_# Default = See Note below.\n";
108 message += " 1: Mask bin\n";
109 message += " Example of masking the X = 1, Y = 2 bin:\n";
110 message += " ***In algorithm declaration\n";
111 message += " Mask_1_2 = 1\n";
112 message += "Note Mask_## = 1 has precedence over the unmasking from a Value_## declaration\n";
113 message += "and that Value_## settings take precedence over the Value_All settings.\n";
114 message += "The un-masking option Mask_## = 0 is ignored in order to avoid unmasking an unconfigured bin.";
115
116 out << message << std::endl;
117 }

◆ Publish_GetFromMap()

int dqm_algorithms::BinThresh::Publish_GetFromMap ( const std::map< std::string, double > & params)
protected

Definition at line 508 of file BinThresh.cxx.

509 {
510 std::map<std::string, double>::const_iterator it = params.find(publishStr);
511 if ( it != params.end() ) {
512 return((int) it->second);
513 }else {
514 return(0);
515 }
516 }

◆ TypePublish_GetFromMap()

int dqm_algorithms::BinThresh::TypePublish_GetFromMap ( const std::map< std::string, double > & params)
protected

Definition at line 518 of file BinThresh.cxx.

519 {
520 std::map<std::string, double>::const_iterator it = params.find(typePublishStr);
521 if ( it != params.end() ) {
522 if ( it->second > 1.5 ) return(2);
523 else if ( it->second > 0.5 ) return(1);
524 else return(0);
525 }else {
526 return(0);
527 }
528 }

◆ TypeValue_GetFromMap()

int dqm_algorithms::BinThresh::TypeValue_GetFromMap ( const std::map< std::string, double > & params)
protected

Definition at line 540 of file BinThresh.cxx.

541 {
542 std::map<std::string, double>::const_iterator it = params.find(typeValueStr);
543 if ( it != params.end() ) {
544 if ( it->second > 0.5 ) return(1);
545 else return(0);
546 }else {
547 return(0);
548 }
549 }

◆ UseValue_GetFromMap()

int dqm_algorithms::BinThresh::UseValue_GetFromMap ( const std::map< std::string, double > & params)
protected

Definition at line 530 of file BinThresh.cxx.

531 {
532 std::map<std::string, double>::const_iterator it = params.find(useValueStr);
533 if ( it != params.end() ) {
534 return((int) it->second);
535 }else {
536 return(0);
537 }
538 }

Member Data Documentation

◆ m_name

std::string dqm_algorithms::BinThresh::m_name
protected

Definition at line 40 of file BinThresh.h.

◆ m_NbinsX

int dqm_algorithms::BinThresh::m_NbinsX
protected

Definition at line 43 of file BinThresh.h.

◆ m_NbinsY

int dqm_algorithms::BinThresh::m_NbinsY
protected

Definition at line 44 of file BinThresh.h.


The documentation for this class was generated from the following files: