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

Constructor & Destructor Documentation

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

Definition at line 426 of file QTest.h.

References QCriterion::setAlgoName().

426  : SimpleTest(name)
427  {
429  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:79
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:139
static std::string getAlgoName()
Definition: QTest.h:430

Member Function Documentation

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

Definition at line 430 of file QTest.h.

References QCriterion::runTest().

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

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

Reimplemented from QCriterion.

Definition at line 1258 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(), MonitorElement::kind(), and SiStripPI::mean.

1259 {
1260  if (!me)
1261  return -1;
1262  if (!me->getRootObject())
1263  return -1;
1264  TH1* h=nullptr;
1265 
1266  if (verbose_>1)
1267  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1268  << me-> getFullname() << "\n";
1269 
1270  if (minEntries_ != 0 && me->getEntries() < minEntries_) return -1;
1271 
1272  if (me->kind()==MonitorElement::DQM_KIND_TH1F)
1273  {
1274  h = me->getTH1F(); //access Test histo
1275  }
1276  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
1277  {
1278  h = me->getTH1S(); //access Test histo
1279  }
1280  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
1281  {
1282  h = me->getTH1D(); //access Test histo
1283  }
1284  else {
1285  if (verbose_>0)
1286  std::cout << "QTest:MeanWithinExpected"
1287  << " ME " << me->getFullname()
1288  << " does not contain TH1F/TH1S/TH1D, exiting\n";
1289  return -1;
1290  }
1291 
1292 
1293  if (useRange_) {
1294  double mean = h->GetMean();
1295  if (mean <= xmax_ && mean >= xmin_)
1296  return 1;
1297  else
1298  return 0;
1299  }
1300  else if (useSigma_)
1301  {
1302  if (sigma_ != 0.)
1303  {
1304  double chi = (h->GetMean() - expMean_)/sigma_;
1305  return TMath::Prob(chi*chi, 1);
1306  }
1307  else
1308  {
1309  if (verbose_>0)
1310  std::cout << "QTest:MeanWithinExpected"
1311  << " Error, sigma_ is zero, exiting\n";
1312  return 0;
1313  }
1314  }
1315  else if (useRMS_)
1316  {
1317  if (h->GetRMS() != 0.)
1318  {
1319  double chi = (h->GetMean() - expMean_)/h->GetRMS();
1320  return TMath::Prob(chi*chi, 1);
1321  }
1322  else
1323  {
1324  if (verbose_>0)
1325  std::cout << "QTest:MeanWithinExpected"
1326  << " Error, RMS is zero, exiting\n";
1327  return 0;
1328  }
1329  }
1330  else {
1331  if (verbose_>0)
1332  std::cout << "QTest:MeanWithinExpected"
1333  << " Error, neither Range, nor Sigma, nor RMS, exiting\n";
1334  return -1; }
1335 }
double xmin_
Definition: QTest.h:444
TH1F * getTH1F() const
int verbose_
Definition: QTest.h:119
TObject * getRootObject() const
static std::string getAlgoName()
Definition: QTest.h:430
double sigma_
Definition: QTest.h:442
const std::string getFullname() const
get full name of ME including Pathname
double getEntries() const
get # of entries
double expMean_
Definition: QTest.h:443
TH1D * getTH1D() const
TH1S * getTH1S() const
unsigned minEntries_
Definition: QTest.h:160
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 1337 of file QTest.cc.

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

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1338 {
1339  useRange_ = true;
1340  useSigma_ = useRMS_ = false;
1341  xmin_ = xmin; xmax_ = xmax;
1342  if (xmin_ > xmax_)
1343  if (verbose_>0)
1344  std::cout << "QTest:MeanWithinExpected"
1345  << " Illogical range: (" << xmin_ << ", " << xmax_ << "\n";
1346 }
double xmin_
Definition: QTest.h:444
int verbose_
Definition: QTest.h:119
double xmax_
Definition: QTest.h:444
void MeanWithinExpected::useRMS ( )

Definition at line 1358 of file QTest.cc.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1359 {
1360  useRMS_ = true;
1361  useSigma_ = useRange_ = false;
1362 }
void MeanWithinExpected::useSigma ( double  expectedSigma)

Definition at line 1347 of file QTest.cc.

References gather_cfg::cout.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1348 {
1349  useSigma_ = true;
1350  useRMS_ = useRange_ = false;
1351  sigma_ = expectedSigma;
1352  if (sigma_ == 0)
1353  if (verbose_>0)
1354  std::cout << "QTest:MeanWithinExpected"
1355  << " Expected sigma = " << sigma_ << "\n";
1356 }
int verbose_
Definition: QTest.h:119
double sigma_
Definition: QTest.h:442

Member Data Documentation

double MeanWithinExpected::expMean_
protected

Definition at line 443 of file QTest.h.

double MeanWithinExpected::sigma_
protected

Definition at line 442 of file QTest.h.

bool MeanWithinExpected::useRange_
protected

Definition at line 441 of file QTest.h.

bool MeanWithinExpected::useRMS_
protected

Definition at line 439 of file QTest.h.

bool MeanWithinExpected::useSigma_
protected

Definition at line 440 of file QTest.h.

double MeanWithinExpected::xmax_
protected

Definition at line 444 of file QTest.h.

double MeanWithinExpected::xmin_
protected

Definition at line 444 of file QTest.h.