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
 (class should be created by DQMStore class) 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

- 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 255 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 258 of file QTest.h.

References QCriterion::setAlgoName().

258  : SimpleTest(name)
259  {
260  rangeInitialized_ = false;
262  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:79
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:139
bool rangeInitialized_
Definition: QTest.h:275
static std::string getAlgoName()
Definition: QTest.h:263

Member Function Documentation

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

Definition at line 263 of file QTest.h.

References QCriterion::runTest().

Referenced by QTestConfigure::enableTests(), QTestConfigure::EnableXRangeTest(), and QTestParameterNames::QTestParameterNames().

263 { return "ContentsXRange"; }
float ContentsXRange::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 588 of file QTest.cc.

References stringResolutionProvider_cfi::bin, relmon_rootfiles_spy::contents, gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, cmsPerfPublish::fail(), plotBeamSpotDB::first, MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), MonitorElement::kind(), and plotBeamSpotDB::last.

589 {
590  badChannels_.clear();
591 
592  if (!me)
593  return -1;
594  if (!me->getRootObject())
595  return -1;
596  TH1* h=nullptr;
597 
598  if (verbose_>1)
599  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
600  << me-> getFullname() << "\n";
601  // -- TH1F
602  if (me->kind()==MonitorElement::DQM_KIND_TH1F )
603  {
604  h = me->getTH1F();
605  }
606  // -- TH1S
607  else if ( me->kind()==MonitorElement::DQM_KIND_TH1S )
608  {
609  h = me->getTH1S();
610  }
611  // -- TH1D
612  else if ( me->kind()==MonitorElement::DQM_KIND_TH1D )
613  {
614  h = me->getTH1D();
615  }
616  else
617  {
618  if (verbose_>0) std::cout << "QTest:ContentsXRange"
619  << " ME " << me->getFullname()
620  << " does not contain TH1F/TH1S/TH1D, exiting\n";
621  return -1;
622  }
623 
624  if (!rangeInitialized_)
625  {
626  if ( h->GetXaxis() )
627  setAllowedXRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
628  else
629  return -1;
630  }
631  int ncx = h->GetXaxis()->GetNbins();
632  // use underflow bin
633  int first = 0; // 1
634  // use overflow bin
635  int last = ncx+1; // ncx
636  // all entries
637  double sum = 0;
638  // entries outside X-range
639  double fail = 0;
640  int bin;
641  for (bin = first; bin <= last; ++bin)
642  {
643  double contents = h->GetBinContent(bin);
644  double x = h->GetBinCenter(bin);
645  sum += contents;
646  if (x < xmin_ || x > xmax_)fail += contents;
647  }
648 
649  if (sum==0) return 1;
650  // return fraction of entries within allowed X-range
651  return (sum - fail)/sum;
652 
653 }
TH1F * getTH1F() const
int verbose_
Definition: QTest.h:119
TObject * getRootObject() const
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:267
bool rangeInitialized_
Definition: QTest.h:275
static std::string getAlgoName()
Definition: QTest.h:263
double xmax_
Definition: QTest.h:274
bin
set the eta bin as selection string.
const std::string getFullname() const
get full name of ME including Pathname
std::vector< DQMChannel > badChannels_
Definition: QTest.h:161
TH1D * getTH1D() const
TH1S * getTH1S() const
def fail(errstr="")
Kind kind() const
Get the type of the monitor element.
virtual void ContentsXRange::setAllowedXRange ( double  xmin,
double  xmax 
)
inlinevirtual

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

Definition at line 267 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 275 of file QTest.h.

double ContentsXRange::xmax_
protected

Definition at line 274 of file QTest.h.

double ContentsXRange::xmin_
protected

Definition at line 274 of file QTest.h.