CMS 3D CMS Logo

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

Algorithm for testing if histogram's mean value is near expected value. More...

#include <QTest.h>

Inheritance diagram for MeanWithinExpected:
SimpleTest QCriterion

Public Member Functions

 MeanWithinExpected (const std::string &name)
 
float runTest (const MonitorElement *me) override
 
void setExpectedMean (double mean)
 
void useRange (double xmin, double xmax)
 
void useRMS ()
 
void useSigma (double expectedSigma)
 
- 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

double expMean_
 
double sigma_
 
bool useRange_
 
bool useRMS_
 
bool useSigma_
 
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

Algorithm for testing if histogram's mean value is near expected value.

Definition at line 516 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 519 of file QTest.h.

References QCriterion::setAlgoName().

519  : SimpleTest(name)
520  {
522  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:80
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:140
static std::string getAlgoName()
Definition: QTest.h:523

Member Function Documentation

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

Definition at line 523 of file QTest.h.

References QCriterion::runTest().

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

523 { return "MeanWithinExpected"; }
float MeanWithinExpected::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 1735 of file QTest.cc.

References gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::getEntries(), MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), h, MonitorElement::kind(), and SiStripPI::mean.

1736 {
1737  if (!me)
1738  return -1;
1739  if (!me->getRootObject())
1740  return -1;
1741  TH1* h=nullptr;
1742 
1743  if (verbose_>1)
1744  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1745  << me-> getFullname() << "\n";
1746 
1747  if (minEntries_ != 0 && me->getEntries() < minEntries_) return -1;
1748 
1749  if (me->kind()==MonitorElement::DQM_KIND_TH1F)
1750  {
1751  h = me->getTH1F(); //access Test histo
1752  }
1753  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
1754  {
1755  h = me->getTH1S(); //access Test histo
1756  }
1757  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
1758  {
1759  h = me->getTH1D(); //access Test histo
1760  }
1761  else {
1762  if (verbose_>0)
1763  std::cout << "QTest:MeanWithinExpected"
1764  << " ME " << me->getFullname()
1765  << " does not contain TH1F/TH1S/TH1D, exiting\n";
1766  return -1;
1767  }
1768 
1769 
1770  if (useRange_) {
1771  double mean = h->GetMean();
1772  if (mean <= xmax_ && mean >= xmin_)
1773  return 1;
1774  else
1775  return 0;
1776  }
1777  else if (useSigma_)
1778  {
1779  if (sigma_ != 0.)
1780  {
1781  double chi = (h->GetMean() - expMean_)/sigma_;
1782  return TMath::Prob(chi*chi, 1);
1783  }
1784  else
1785  {
1786  if (verbose_>0)
1787  std::cout << "QTest:MeanWithinExpected"
1788  << " Error, sigma_ is zero, exiting\n";
1789  return 0;
1790  }
1791  }
1792  else if (useRMS_)
1793  {
1794  if (h->GetRMS() != 0.)
1795  {
1796  double chi = (h->GetMean() - expMean_)/h->GetRMS();
1797  return TMath::Prob(chi*chi, 1);
1798  }
1799  else
1800  {
1801  if (verbose_>0)
1802  std::cout << "QTest:MeanWithinExpected"
1803  << " Error, RMS is zero, exiting\n";
1804  return 0;
1805  }
1806  }
1807  else {
1808  if (verbose_>0)
1809  std::cout << "QTest:MeanWithinExpected"
1810  << " Error, neither Range, nor Sigma, nor RMS, exiting\n";
1811  return -1; }
1812 }
double xmin_
Definition: QTest.h:537
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
TH1F * getTH1F() const
int verbose_
Definition: QTest.h:120
TObject * getRootObject() const
static std::string getAlgoName()
Definition: QTest.h:523
double sigma_
Definition: QTest.h:535
const std::string getFullname() const
get full name of ME including Pathname
double getEntries() const
get # of entries
double expMean_
Definition: QTest.h:536
TH1D * getTH1D() const
TH1S * getTH1S() const
unsigned minEntries_
Definition: QTest.h:161
Kind kind() const
Get the type of the monitor element.
void MeanWithinExpected::setExpectedMean ( double  mean)
inline
void MeanWithinExpected::useRange ( double  xmin,
double  xmax 
)

Definition at line 1814 of file QTest.cc.

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

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1815 {
1816  useRange_ = true;
1817  useSigma_ = useRMS_ = false;
1818  xmin_ = xmin; xmax_ = xmax;
1819  if (xmin_ > xmax_)
1820  if (verbose_>0)
1821  std::cout << "QTest:MeanWithinExpected"
1822  << " Illogical range: (" << xmin_ << ", " << xmax_ << "\n";
1823 }
double xmin_
Definition: QTest.h:537
int verbose_
Definition: QTest.h:120
double xmax_
Definition: QTest.h:537
void MeanWithinExpected::useRMS ( )

Definition at line 1835 of file QTest.cc.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1836 {
1837  useRMS_ = true;
1838  useSigma_ = useRange_ = false;
1839 }
void MeanWithinExpected::useSigma ( double  expectedSigma)

Definition at line 1824 of file QTest.cc.

References gather_cfg::cout.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1825 {
1826  useSigma_ = true;
1827  useRMS_ = useRange_ = false;
1828  sigma_ = expectedSigma;
1829  if (sigma_ == 0)
1830  if (verbose_>0)
1831  std::cout << "QTest:MeanWithinExpected"
1832  << " Expected sigma = " << sigma_ << "\n";
1833 }
int verbose_
Definition: QTest.h:120
double sigma_
Definition: QTest.h:535

Member Data Documentation

double MeanWithinExpected::expMean_
protected

Definition at line 536 of file QTest.h.

double MeanWithinExpected::sigma_
protected

Definition at line 535 of file QTest.h.

bool MeanWithinExpected::useRange_
protected

Definition at line 534 of file QTest.h.

bool MeanWithinExpected::useRMS_
protected

Definition at line 532 of file QTest.h.

bool MeanWithinExpected::useSigma_
protected

Definition at line 533 of file QTest.h.

double MeanWithinExpected::xmax_
protected

Definition at line 537 of file QTest.h.

double MeanWithinExpected::xmin_
protected

Definition at line 537 of file QTest.h.