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)
 
void setExpectedMean (double mean)
 
void useRange (double xmin, double xmax)
 
void useRMS (void)
 
void useSigma (double expectedSigma)
 
- Public Member Functions inherited from SimpleTest
virtual std::vector< DQMChannelgetBadChannels (void) const
 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 (void) const
 get algorithm name More...
 
std::string getMessage (void) const
 get message attached to test More...
 
std::string getName (void) const
 get name of quality test More...
 
int getStatus (void) 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 (void)
 

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
virtual void setMessage (void)
 set status & message after test has run More...
 
- Protected Member Functions inherited from QCriterion
void init (void)
 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 (void)
 

Detailed Description

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

Definition at line 422 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 425 of file QTest.h.

References QCriterion::setAlgoName().

425  : SimpleTest(name)
426  {
428  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:78
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:138
static std::string getAlgoName(void)
Definition: QTest.h:429

Member Function Documentation

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

Definition at line 429 of file QTest.h.

References QCriterion::runTest().

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

429 { return "MeanWithinExpected"; }
float MeanWithinExpected::runTest ( const MonitorElement me)
virtual

Reimplemented from QCriterion.

Definition at line 1248 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 RecoTauDiscriminantConfiguration::mean.

1249 {
1250  if (!me)
1251  return -1;
1252  if (!me->getRootObject())
1253  return -1;
1254  TH1* h=0;
1255 
1256  if (verbose_>1)
1257  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1258  << me-> getFullname() << "\n";
1259 
1260  if (minEntries_ != 0 && me->getEntries() < minEntries_) return -1;
1261 
1262  if (me->kind()==MonitorElement::DQM_KIND_TH1F)
1263  {
1264  h = me->getTH1F(); //access Test histo
1265  }
1266  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
1267  {
1268  h = me->getTH1S(); //access Test histo
1269  }
1270  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
1271  {
1272  h = me->getTH1D(); //access Test histo
1273  }
1274  else {
1275  if (verbose_>0)
1276  std::cout << "QTest:MeanWithinExpected"
1277  << " ME " << me->getFullname()
1278  << " does not contain TH1F/TH1S/TH1D, exiting\n";
1279  return -1;
1280  }
1281 
1282 
1283  if (useRange_) {
1284  double mean = h->GetMean();
1285  if (mean <= xmax_ && mean >= xmin_)
1286  return 1;
1287  else
1288  return 0;
1289  }
1290  else if (useSigma_)
1291  {
1292  if (sigma_ != 0.)
1293  {
1294  double chi = (h->GetMean() - expMean_)/sigma_;
1295  return TMath::Prob(chi*chi, 1);
1296  }
1297  else
1298  {
1299  if (verbose_>0)
1300  std::cout << "QTest:MeanWithinExpected"
1301  << " Error, sigma_ is zero, exiting\n";
1302  return 0;
1303  }
1304  }
1305  else if (useRMS_)
1306  {
1307  if (h->GetRMS() != 0.)
1308  {
1309  double chi = (h->GetMean() - expMean_)/h->GetRMS();
1310  return TMath::Prob(chi*chi, 1);
1311  }
1312  else
1313  {
1314  if (verbose_>0)
1315  std::cout << "QTest:MeanWithinExpected"
1316  << " Error, RMS is zero, exiting\n";
1317  return 0;
1318  }
1319  }
1320  else {
1321  if (verbose_>0)
1322  std::cout << "QTest:MeanWithinExpected"
1323  << " Error, neither Range, nor Sigma, nor RMS, exiting\n";
1324  return -1; }
1325 }
TH1S * getTH1S(void) const
double xmin_
Definition: QTest.h:443
int verbose_
Definition: QTest.h:118
TH1D * getTH1D(void) const
double getEntries(void) const
get # of entries
Kind kind(void) const
Get the type of the monitor element.
const std::string getFullname(void) const
get full name of ME including Pathname
double sigma_
Definition: QTest.h:441
TObject * getRootObject(void) const
TH1F * getTH1F(void) const
double expMean_
Definition: QTest.h:442
unsigned minEntries_
Definition: QTest.h:159
static std::string getAlgoName(void)
Definition: QTest.h:429
void MeanWithinExpected::setExpectedMean ( double  mean)
inline
void MeanWithinExpected::useRange ( double  xmin,
double  xmax 
)

Definition at line 1327 of file QTest.cc.

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

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1328 {
1329  useRange_ = true;
1330  useSigma_ = useRMS_ = false;
1331  xmin_ = xmin; xmax_ = xmax;
1332  if (xmin_ > xmax_)
1333  if (verbose_>0)
1334  std::cout << "QTest:MeanWithinExpected"
1335  << " Illogical range: (" << xmin_ << ", " << xmax_ << "\n";
1336 }
double xmin_
Definition: QTest.h:443
int verbose_
Definition: QTest.h:118
double xmax_
Definition: QTest.h:443
void MeanWithinExpected::useRMS ( void  )

Definition at line 1348 of file QTest.cc.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1349 {
1350  useRMS_ = true;
1351  useSigma_ = useRange_ = false;
1352 }
void MeanWithinExpected::useSigma ( double  expectedSigma)

Definition at line 1337 of file QTest.cc.

References gather_cfg::cout.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1338 {
1339  useSigma_ = true;
1340  useRMS_ = useRange_ = false;
1341  sigma_ = expectedSigma;
1342  if (sigma_ == 0)
1343  if (verbose_>0)
1344  std::cout << "QTest:MeanWithinExpected"
1345  << " Expected sigma = " << sigma_ << "\n";
1346 }
int verbose_
Definition: QTest.h:118
double sigma_
Definition: QTest.h:441

Member Data Documentation

double MeanWithinExpected::expMean_
protected

Definition at line 442 of file QTest.h.

double MeanWithinExpected::sigma_
protected

Definition at line 441 of file QTest.h.

bool MeanWithinExpected::useRange_
protected

Definition at line 440 of file QTest.h.

bool MeanWithinExpected::useRMS_
protected

Definition at line 438 of file QTest.h.

bool MeanWithinExpected::useSigma_
protected

Definition at line 439 of file QTest.h.

double MeanWithinExpected::xmax_
protected

Definition at line 443 of file QTest.h.

double MeanWithinExpected::xmin_
protected

Definition at line 443 of file QTest.h.