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.

151  : SimpleTest(name) {
152  rangeInitialized_ = false;
154  }

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

Member Function Documentation

◆ getAlgoName()

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

Definition at line 155 of file QTest.h.

155 { return "ContentsXRange"; }

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

◆ runTest()

float ContentsXRange::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 32 of file QTest.cc.

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 }

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

◆ 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.

159  {
160  xmin_ = xmin;
161  xmax_ = xmax;
162  rangeInitialized_ = true;
163  }

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().

ContentsXRange::xmin_
double xmin_
Definition: QTest.h:166
MonitorElementData::Kind::TH1S
MonitorElementData::Kind::TH1F
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDAxes::x
dqmdumpme.first
first
Definition: dqmdumpme.py:55
relmon_rootfiles_spy.contents
contents
Definition: relmon_rootfiles_spy.py:129
SimpleTest::SimpleTest
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:124
dqmdumpme.last
last
Definition: dqmdumpme.py:56
h
QCriterion::verbose_
int verbose_
Definition: QTest.h:110
ContentsXRange::rangeInitialized_
bool rangeInitialized_
Definition: QTest.h:168
QCriterion::setAlgoName
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:96
ContentsXRange::getAlgoName
static std::string getAlgoName()
Definition: QTest.h:155
ContentsXRange::xmax_
double xmax_
Definition: QTest.h:167
MonitorElementData::Kind::TH1D
SimpleTest::badChannels_
std::vector< DQMChannel > badChannels_
Definition: QTest.h:139
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
ContentsXRange::setAllowedXRange
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram's X-range)
Definition: QTest.h:159
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61