CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
ContentsXRange Class Reference

#include <QTest.h>

Inheritance diagram for ContentsXRange:
SimpleTest QCriterion

Public Member Functions

 ContentsXRange (const std::string &name)
 
float runTest (const MonitorElement *me) override
 
virtual void setAllowedXRange (double xmin, double xmax)
 set allowed range in X-axis (default values: histogram's X-range) More...
 
- Public Member Functions inherited from SimpleTest
std::vector< DQMChannelgetBadChannels () const override
 get vector of channels that failed test (not always relevant!) More...
 
void setMinimumEntries (unsigned n)
 set minimum # of entries needed More...
 
 SimpleTest (const std::string &name, bool keepBadChannels=false)
 
- Public Member Functions inherited from QCriterion
std::string algoName () const
 get algorithm name More...
 
std::string getMessage () const
 get message attached to test More...
 
std::string getName () const
 get name of quality test More...
 
int getStatus () const
 get test status More...
 
void init ()
 initialize values More...
 
 QCriterion (std::string qtname)
 
float runTest (const MonitorElement *me, QReport &qr, DQMNet::QValue &qv)
 
void setErrorProb (float prob)
 
void setWarningProb (float prob)
 set probability limit for warning and error (default: 90% and 50%) More...
 
virtual ~QCriterion ()=default
 

Static Public Member Functions

static std::string getAlgoName ()
 

Protected Attributes

bool rangeInitialized_
 
double xmax_
 
double xmin_
 
- Protected Attributes inherited from SimpleTest
std::vector< DQMChannelbadChannels_
 
bool keepBadChannels_
 
unsigned minEntries_
 
- Protected Attributes inherited from QCriterion
std::string algoName_
 name of quality test More...
 
float errorProb_
 
std::string message_
 quality test status More...
 
float prob_
 name of algorithm More...
 
std::string qtname_
 
int status_
 
int verbose_
 
float warningProb_
 message attached to test More...
 

Additional Inherited Members

- Public Types inherited from QCriterion
typedef dqm::legacy::MonitorElement MonitorElement
 (class should be created by DQMStore class) More...
 
- Static Public Attributes inherited from QCriterion
static const float ERROR_PROB_THRESHOLD = 0.50
 
static const float WARNING_PROB_THRESHOLD = 0.90
 default "probability" values for setting warnings & errors when running tests More...
 
- Protected Member Functions inherited from SimpleTest
void setMessage () override
 set status & message after test has run More...
 
- Protected Member Functions inherited from QCriterion
void setAlgoName (std::string name)
 set algorithm name More...
 
void setVerbose (int verbose)
 probability limits for warnings, errors More...
 

Detailed Description

Definition at line 149 of file QTest.h.

Constructor & Destructor Documentation

◆ ContentsXRange()

ContentsXRange::ContentsXRange ( const std::string &  name)
inline

Definition at line 151 of file QTest.h.

References getAlgoName(), rangeInitialized_, and QCriterion::setAlgoName().

151  : SimpleTest(name) {
152  rangeInitialized_ = false;
154  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:96
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:124
bool rangeInitialized_
Definition: QTest.h:168
static std::string getAlgoName()
Definition: QTest.h:155

Member Function Documentation

◆ getAlgoName()

static std::string ContentsXRange::getAlgoName ( )
inlinestatic

Definition at line 155 of file QTest.h.

Referenced by ContentsXRange(), and QualityTester::makeQCriterion().

155 { return "ContentsXRange"; }

◆ runTest()

float ContentsXRange::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 32 of file QTest.cc.

References newFWLiteAna::bin, relmon_rootfiles_spy::contents, gather_cfg::cout, dqmdumpme::first, h, dqmdumpme::last, hlt_dqm_clientPB-live_cfg::me, MonitorElementData::TH1D, MonitorElementData::TH1F, MonitorElementData::TH1S, and x.

32  {
33  badChannels_.clear();
34 
35  if (!me)
36  return -1;
37  if (!me->getRootObject())
38  return -1;
39  TH1* h = nullptr;
40 
41  if (verbose_ > 1)
42  std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me->getFullname() << "\n";
43  // -- TH1F
44  if (me->kind() == MonitorElement::Kind::TH1F) {
45  h = me->getTH1F();
46  }
47  // -- TH1S
48  else if (me->kind() == MonitorElement::Kind::TH1S) {
49  h = me->getTH1S();
50  }
51  // -- TH1D
52  else if (me->kind() == MonitorElement::Kind::TH1D) {
53  h = me->getTH1D();
54  } else {
55  if (verbose_ > 0)
56  std::cout << "QTest:ContentsXRange"
57  << " ME " << me->getFullname() << " does not contain TH1F/TH1S/TH1D, exiting\n";
58  return -1;
59  }
60 
61  if (!rangeInitialized_) {
62  if (h->GetXaxis())
63  setAllowedXRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
64  else
65  return -1;
66  }
67  int ncx = h->GetXaxis()->GetNbins();
68  // use underflow bin
69  int first = 0; // 1
70  // use overflow bin
71  int last = ncx + 1; // ncx
72  // all entries
73  double sum = 0;
74  // entries outside X-range
75  double fail = 0;
76  int bin;
77  for (bin = first; bin <= last; ++bin) {
78  double contents = h->GetBinContent(bin);
79  double x = h->GetBinCenter(bin);
80  sum += contents;
81  if (x < xmin_ || x > xmax_)
82  fail += contents;
83  }
84 
85  if (sum == 0)
86  return 1;
87  // return fraction of entries within allowed X-range
88  return (sum - fail) / sum;
89 }
int verbose_
Definition: QTest.h:110
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:159
bool rangeInitialized_
Definition: QTest.h:168
static std::string getAlgoName()
Definition: QTest.h:155
double xmax_
Definition: QTest.h:167
std::vector< DQMChannel > badChannels_
Definition: QTest.h:139
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ setAllowedXRange()

virtual void ContentsXRange::setAllowedXRange ( double  xmin,
double  xmax 
)
inlinevirtual

set allowed range in X-axis (default values: histogram's X-range)

Definition at line 159 of file QTest.h.

References rangeInitialized_, TrackerOfflineValidation_Dqm_cff::xmax, xmax_, TrackerOfflineValidation_Dqm_cff::xmin, and xmin_.

Member Data Documentation

◆ rangeInitialized_

bool ContentsXRange::rangeInitialized_
protected

Definition at line 168 of file QTest.h.

Referenced by ContentsXRange(), and setAllowedXRange().

◆ xmax_

double ContentsXRange::xmax_
protected

Definition at line 167 of file QTest.h.

Referenced by setAllowedXRange().

◆ xmin_

double ContentsXRange::xmin_
protected

Definition at line 166 of file QTest.h.

Referenced by setAllowedXRange().