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

Constructor & Destructor Documentation

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

Definition at line 259 of file QTest.h.

References QCriterion::setAlgoName().

259  : SimpleTest(name)
260  {
261  rangeInitialized_ = false;
263  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:80
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:140
bool rangeInitialized_
Definition: QTest.h:276
static std::string getAlgoName()
Definition: QTest.h:264

Member Function Documentation

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

Definition at line 264 of file QTest.h.

References QCriterion::runTest().

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

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

Reimplemented from QCriterion.

Definition at line 589 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.

590 {
591  badChannels_.clear();
592 
593  if (!me)
594  return -1;
595  if (!me->getRootObject())
596  return -1;
597  TH1* h=nullptr;
598 
599  if (verbose_>1)
600  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
601  << me-> getFullname() << "\n";
602  // -- TH1F
603  if (me->kind()==MonitorElement::DQM_KIND_TH1F )
604  {
605  h = me->getTH1F();
606  }
607  // -- TH1S
608  else if ( me->kind()==MonitorElement::DQM_KIND_TH1S )
609  {
610  h = me->getTH1S();
611  }
612  // -- TH1D
613  else if ( me->kind()==MonitorElement::DQM_KIND_TH1D )
614  {
615  h = me->getTH1D();
616  }
617  else
618  {
619  if (verbose_>0) std::cout << "QTest:ContentsXRange"
620  << " ME " << me->getFullname()
621  << " does not contain TH1F/TH1S/TH1D, exiting\n";
622  return -1;
623  }
624 
625  if (!rangeInitialized_)
626  {
627  if ( h->GetXaxis() )
628  setAllowedXRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
629  else
630  return -1;
631  }
632  int ncx = h->GetXaxis()->GetNbins();
633  // use underflow bin
634  int first = 0; // 1
635  // use overflow bin
636  int last = ncx+1; // ncx
637  // all entries
638  double sum = 0;
639  // entries outside X-range
640  double fail = 0;
641  int bin;
642  for (bin = first; bin <= last; ++bin)
643  {
644  double contents = h->GetBinContent(bin);
645  double x = h->GetBinCenter(bin);
646  sum += contents;
647  if (x < xmin_ || x > xmax_)fail += contents;
648  }
649 
650  if (sum==0) return 1;
651  // return fraction of entries within allowed X-range
652  return (sum - fail)/sum;
653 
654 }
TH1F * getTH1F() const
int verbose_
Definition: QTest.h:120
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:268
bool rangeInitialized_
Definition: QTest.h:276
static std::string getAlgoName()
Definition: QTest.h:264
double xmax_
Definition: QTest.h:275
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:162
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 268 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 276 of file QTest.h.

double ContentsXRange::xmax_
protected

Definition at line 275 of file QTest.h.

double ContentsXRange::xmin_
protected

Definition at line 275 of file QTest.h.