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
 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::MeanWithinExpected ( const std::string &  name)
inline

Definition at line 403 of file QTest.h.

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

Member Function Documentation

◆ getAlgoName()

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

Definition at line 404 of file QTest.h.

404 { return "MeanWithinExpected"; }

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

◆ runTest()

float MeanWithinExpected::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 1081 of file QTest.cc.

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 }

References gather_cfg::cout, hlt_dqm_clientPB-live_cfg::me, SiStripPI::mean, MonitorElementData::TH1D, MonitorElementData::TH1F, and MonitorElementData::TH1S.

◆ setExpectedMean()

void MeanWithinExpected::setExpectedMean ( double  mean)
inline

Definition at line 407 of file QTest.h.

407 { expMean_ = mean; }

References expMean_, and SiStripPI::mean.

◆ useRange()

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

Definition at line 1141 of file QTest.cc.

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 }

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

◆ useRMS()

void MeanWithinExpected::useRMS ( )

Definition at line 1161 of file QTest.cc.

1161  {
1162  useRMS_ = true;
1163  useSigma_ = useRange_ = false;
1164 }

◆ useSigma()

void MeanWithinExpected::useSigma ( double  expectedSigma)

Definition at line 1151 of file QTest.cc.

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 }

References gather_cfg::cout.

Member Data Documentation

◆ expMean_

double MeanWithinExpected::expMean_
protected

Definition at line 417 of file QTest.h.

Referenced by setExpectedMean().

◆ sigma_

double MeanWithinExpected::sigma_
protected

Definition at line 416 of file QTest.h.

◆ useRange_

bool MeanWithinExpected::useRange_
protected

Definition at line 415 of file QTest.h.

◆ useRMS_

bool MeanWithinExpected::useRMS_
protected

Definition at line 413 of file QTest.h.

◆ useSigma_

bool MeanWithinExpected::useSigma_
protected

Definition at line 414 of file QTest.h.

◆ xmax_

double MeanWithinExpected::xmax_
protected

Definition at line 418 of file QTest.h.

◆ xmin_

double MeanWithinExpected::xmin_
protected

Definition at line 418 of file QTest.h.

SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
SimpleTest::minEntries_
unsigned minEntries_
Definition: QTest.h:138
MonitorElementData::Kind::TH1S
MonitorElementData::Kind::TH1F
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MeanWithinExpected::getAlgoName
static std::string getAlgoName()
Definition: QTest.h:404
SimpleTest::SimpleTest
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:124
MeanWithinExpected::useRMS_
bool useRMS_
Definition: QTest.h:413
h
MeanWithinExpected::useSigma_
bool useSigma_
Definition: QTest.h:414
QCriterion::verbose_
int verbose_
Definition: QTest.h:110
MeanWithinExpected::useRange_
bool useRange_
Definition: QTest.h:415
QCriterion::setAlgoName
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:96
MonitorElementData::Kind::TH1D
MeanWithinExpected::sigma_
double sigma_
Definition: QTest.h:416
MeanWithinExpected::expMean_
double expMean_
Definition: QTest.h:417
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
MeanWithinExpected::xmax_
double xmax_
Definition: QTest.h:418
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
MeanWithinExpected::xmin_
double xmin_
Definition: QTest.h:418