CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 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

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

- 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

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

Definition at line 401 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 403 of file QTest.h.

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

void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:96
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:124
static std::string getAlgoName()
Definition: QTest.h:404

Member Function Documentation

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

Definition at line 404 of file QTest.h.

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

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

Reimplemented from QCriterion.

Definition at line 1081 of file QTest.cc.

References gather_cfg::cout, dqm::impl::MonitorElement::getEntries(), 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(), SiStripPI::mean, MonitorElementData::TH1D, MonitorElementData::TH1F, and MonitorElementData::TH1S.

1081  {
1082  if (!me)
1083  return -1;
1084  if (!me->getRootObject())
1085  return -1;
1086  TH1* h = nullptr;
1087 
1088  if (verbose_ > 1)
1089  std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me->getFullname() << "\n";
1090 
1091  if (minEntries_ != 0 && me->getEntries() < minEntries_)
1092  return -1;
1093 
1094  if (me->kind() == MonitorElement::Kind::TH1F) {
1095  h = me->getTH1F(); //access Test histo
1096  } else if (me->kind() == MonitorElement::Kind::TH1S) {
1097  h = me->getTH1S(); //access Test histo
1098  } else if (me->kind() == MonitorElement::Kind::TH1D) {
1099  h = me->getTH1D(); //access Test histo
1100  } else {
1101  if (verbose_ > 0)
1102  std::cout << "QTest:MeanWithinExpected"
1103  << " ME " << me->getFullname() << " does not contain TH1F/TH1S/TH1D, exiting\n";
1104  return -1;
1105  }
1106 
1107  if (useRange_) {
1108  double mean = h->GetMean();
1109  if (mean <= xmax_ && mean >= xmin_)
1110  return 1;
1111  else
1112  return 0;
1113  } else if (useSigma_) {
1114  if (sigma_ != 0.) {
1115  double chi = (h->GetMean() - expMean_) / sigma_;
1116  return TMath::Prob(chi * chi, 1);
1117  } else {
1118  if (verbose_ > 0)
1119  std::cout << "QTest:MeanWithinExpected"
1120  << " Error, sigma_ is zero, exiting\n";
1121  return 0;
1122  }
1123  } else if (useRMS_) {
1124  if (h->GetRMS() != 0.) {
1125  double chi = (h->GetMean() - expMean_) / h->GetRMS();
1126  return TMath::Prob(chi * chi, 1);
1127  } else {
1128  if (verbose_ > 0)
1129  std::cout << "QTest:MeanWithinExpected"
1130  << " Error, RMS is zero, exiting\n";
1131  return 0;
1132  }
1133  } else {
1134  if (verbose_ > 0)
1135  std::cout << "QTest:MeanWithinExpected"
1136  << " Error, neither Range, nor Sigma, nor RMS, exiting\n";
1137  return -1;
1138  }
1139 }
double xmin_
Definition: QTest.h:418
int verbose_
Definition: QTest.h:110
virtual TH1F * getTH1F() const
Kind kind() const
Get the type of the monitor element.
virtual TH1S * getTH1S() const
static std::string getAlgoName()
Definition: QTest.h:404
virtual double getEntries() const
get # of entries
double sigma_
Definition: QTest.h:416
virtual TH1D * getTH1D() const
double expMean_
Definition: QTest.h:417
std::string getFullname() const
get full name of ME including Pathname
tuple cout
Definition: gather_cfg.py:144
unsigned minEntries_
Definition: QTest.h:138
TObject * getRootObject() const override
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void MeanWithinExpected::setExpectedMean ( double  mean)
inline

Definition at line 407 of file QTest.h.

References expMean_, and SiStripPI::mean.

void MeanWithinExpected::useRange ( double  xmin,
double  xmax 
)

Definition at line 1141 of file QTest.cc.

References gather_cfg::cout, hlt_dqm_clientPB-live_cfg::xmax, and hlt_dqm_clientPB-live_cfg::xmin.

1141  {
1142  useRange_ = true;
1143  useSigma_ = useRMS_ = false;
1144  xmin_ = xmin;
1145  xmax_ = xmax;
1146  if (xmin_ > xmax_)
1147  if (verbose_ > 0)
1148  std::cout << "QTest:MeanWithinExpected"
1149  << " Illogical range: (" << xmin_ << ", " << xmax_ << "\n";
1150 }
double xmin_
Definition: QTest.h:418
int verbose_
Definition: QTest.h:110
double xmax_
Definition: QTest.h:418
tuple cout
Definition: gather_cfg.py:144
void MeanWithinExpected::useRMS ( )

Definition at line 1161 of file QTest.cc.

1161  {
1162  useRMS_ = true;
1163  useSigma_ = useRange_ = false;
1164 }
void MeanWithinExpected::useSigma ( double  expectedSigma)

Definition at line 1151 of file QTest.cc.

References gather_cfg::cout.

1151  {
1152  useSigma_ = true;
1153  useRMS_ = useRange_ = false;
1154  sigma_ = expectedSigma;
1155  if (sigma_ == 0)
1156  if (verbose_ > 0)
1157  std::cout << "QTest:MeanWithinExpected"
1158  << " Expected sigma = " << sigma_ << "\n";
1159 }
int verbose_
Definition: QTest.h:110
double sigma_
Definition: QTest.h:416
tuple cout
Definition: gather_cfg.py:144

Member Data Documentation

double MeanWithinExpected::expMean_
protected

Definition at line 417 of file QTest.h.

Referenced by setExpectedMean().

double MeanWithinExpected::sigma_
protected

Definition at line 416 of file QTest.h.

bool MeanWithinExpected::useRange_
protected

Definition at line 415 of file QTest.h.

bool MeanWithinExpected::useRMS_
protected

Definition at line 413 of file QTest.h.

bool MeanWithinExpected::useSigma_
protected

Definition at line 414 of file QTest.h.

double MeanWithinExpected::xmax_
protected

Definition at line 418 of file QTest.h.

double MeanWithinExpected::xmin_
protected

Definition at line 418 of file QTest.h.