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 (see Core/interface/DQMDefinitions.h) More...
 
void setErrorProb (float prob)
 
void setWarningProb (float prob)
 set probability limit for warning and error (default: 90% and 50%) More...
 

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...
 
- Protected Member Functions inherited from SimpleTest
void setMessage () override
 set status & message after test has run More...
 
- Protected Member Functions inherited from QCriterion
void init ()
 initialize values More...
 
 QCriterion (std::string qtname)
 
float runTest (const MonitorElement *me, QReport &qr, DQMNet::QValue &qv)
 
void setAlgoName (std::string name)
 set algorithm name More...
 
void setVerbose (int verbose)
 probability limits for warnings, errors More...
 
virtual ~QCriterion ()=default
 

Detailed Description

Definition at line 183 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 185 of file QTest.h.

References QCriterion::setAlgoName().

185  : SimpleTest(name) {
186  rangeInitialized_ = false;
188  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:95
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:158
bool rangeInitialized_
Definition: QTest.h:202
static std::string getAlgoName()
Definition: QTest.h:189

Member Function Documentation

static std::string ContentsXRange::getAlgoName ( )
inlinestatic
float ContentsXRange::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 36 of file QTest.cc.

References newFWLiteAna::bin, relmon_rootfiles_spy::contents, gather_cfg::cout, dqmdumpme::first, dqm::impl::MonitorElement::getFullname(), dqm::legacy::MonitorElement::getRootObject(), dqm::legacy::MonitorElement::getTH1D(), dqm::legacy::MonitorElement::getTH1F(), dqm::legacy::MonitorElement::getTH1S(), h, dqm::impl::MonitorElement::kind(), dqmdumpme::last, MonitorElementData::TH1D, MonitorElementData::TH1F, and MonitorElementData::TH1S.

36  {
37  badChannels_.clear();
38 
39  if (!me)
40  return -1;
41  if (!me->getRootObject())
42  return -1;
43  TH1* h = nullptr;
44 
45  if (verbose_ > 1)
46  std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me->getFullname() << "\n";
47  // -- TH1F
48  if (me->kind() == MonitorElement::Kind::TH1F) {
49  h = me->getTH1F();
50  }
51  // -- TH1S
52  else if (me->kind() == MonitorElement::Kind::TH1S) {
53  h = me->getTH1S();
54  }
55  // -- TH1D
56  else if (me->kind() == MonitorElement::Kind::TH1D) {
57  h = me->getTH1D();
58  } else {
59  if (verbose_ > 0)
60  std::cout << "QTest:ContentsXRange"
61  << " ME " << me->getFullname() << " does not contain TH1F/TH1S/TH1D, exiting\n";
62  return -1;
63  }
64 
65  if (!rangeInitialized_) {
66  if (h->GetXaxis())
67  setAllowedXRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
68  else
69  return -1;
70  }
71  int ncx = h->GetXaxis()->GetNbins();
72  // use underflow bin
73  int first = 0; // 1
74  // use overflow bin
75  int last = ncx + 1; // ncx
76  // all entries
77  double sum = 0;
78  // entries outside X-range
79  double fail = 0;
80  int bin;
81  for (bin = first; bin <= last; ++bin) {
82  double contents = h->GetBinContent(bin);
83  double x = h->GetBinCenter(bin);
84  sum += contents;
85  if (x < xmin_ || x > xmax_)
86  fail += contents;
87  }
88 
89  if (sum == 0)
90  return 1;
91  // return fraction of entries within allowed X-range
92  return (sum - fail) / sum;
93 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int verbose_
Definition: QTest.h:138
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:193
virtual TH1F * getTH1F() const
Kind kind() const
Get the type of the monitor element.
virtual TH1S * getTH1S() const
const std::string getFullname() const
get full name of ME including Pathname
bool rangeInitialized_
Definition: QTest.h:202
static std::string getAlgoName()
Definition: QTest.h:189
double xmax_
Definition: QTest.h:201
virtual TH1D * getTH1D() const
std::vector< DQMChannel > badChannels_
Definition: QTest.h:173
TObject * getRootObject() const override
virtual void ContentsXRange::setAllowedXRange ( double  xmin,
double  xmax 
)
inlinevirtual

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

Definition at line 193 of file QTest.h.

References TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Referenced by QTestConfigure::EnableXRangeTest().

Member Data Documentation

bool ContentsXRange::rangeInitialized_
protected

Definition at line 202 of file QTest.h.

double ContentsXRange::xmax_
protected

Definition at line 201 of file QTest.h.

double ContentsXRange::xmin_
protected

Definition at line 200 of file QTest.h.