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

Constructor & Destructor Documentation

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

Definition at line 396 of file QTest.h.

References QCriterion::setAlgoName().

396  : SimpleTest(name)
397  {
399  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:77
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:137
static std::string getAlgoName(void)
Definition: QTest.h:400

Member Function Documentation

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

Definition at line 400 of file QTest.h.

References QCriterion::runTest().

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

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

Reimplemented from QCriterion.

Definition at line 1147 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.

1148 {
1149  if (!me)
1150  return -1;
1151  if (!me->getRootObject())
1152  return -1;
1153  TH1* h=0;
1154 
1155  if (verbose_>1)
1156  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1157  << me-> getFullname() << "\n";
1158 
1159  if (minEntries_ != 0 && me->getEntries() < minEntries_) return -1;
1160 
1161  if (me->kind()==MonitorElement::DQM_KIND_TH1F)
1162  {
1163  h = me->getTH1F(); //access Test histo
1164  }
1165  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
1166  {
1167  h = me->getTH1S(); //access Test histo
1168  }
1169  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
1170  {
1171  h = me->getTH1D(); //access Test histo
1172  }
1173  else {
1174  if (verbose_>0)
1175  std::cout << "QTest:MeanWithinExpected"
1176  << " ME " << me->getFullname()
1177  << " does not contain TH1F/TH1S/TH1D, exiting\n";
1178  return -1;
1179  }
1180 
1181 
1182  if (useRange_) {
1183  double mean = h->GetMean();
1184  if (mean <= xmax_ && mean >= xmin_)
1185  return 1;
1186  else
1187  return 0;
1188  }
1189  else if (useSigma_)
1190  {
1191  if (sigma_ != 0.)
1192  {
1193  double chi = (h->GetMean() - expMean_)/sigma_;
1194  return TMath::Prob(chi*chi, 1);
1195  }
1196  else
1197  {
1198  if (verbose_>0)
1199  std::cout << "QTest:MeanWithinExpected"
1200  << " Error, sigma_ is zero, exiting\n";
1201  return 0;
1202  }
1203  }
1204  else if (useRMS_)
1205  {
1206  if (h->GetRMS() != 0.)
1207  {
1208  double chi = (h->GetMean() - expMean_)/h->GetRMS();
1209  return TMath::Prob(chi*chi, 1);
1210  }
1211  else
1212  {
1213  if (verbose_>0)
1214  std::cout << "QTest:MeanWithinExpected"
1215  << " Error, RMS is zero, exiting\n";
1216  return 0;
1217  }
1218  }
1219  else {
1220  if (verbose_>0)
1221  std::cout << "QTest:MeanWithinExpected"
1222  << " Error, neither Range, nor Sigma, nor RMS, exiting\n";
1223  return -1; }
1224 }
TH1S * getTH1S(void) const
double xmin_
Definition: QTest.h:414
int verbose_
Definition: QTest.h:117
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:412
TObject * getRootObject(void) const
TH1F * getTH1F(void) const
double expMean_
Definition: QTest.h:413
unsigned minEntries_
Definition: QTest.h:158
static std::string getAlgoName(void)
Definition: QTest.h:400
void MeanWithinExpected::setExpectedMean ( double  mean)
inline
void MeanWithinExpected::useRange ( double  xmin,
double  xmax 
)

Definition at line 1226 of file QTest.cc.

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

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1227 {
1228  useRange_ = true;
1229  useSigma_ = useRMS_ = false;
1230  xmin_ = xmin; xmax_ = xmax;
1231  if (xmin_ > xmax_)
1232  if (verbose_>0)
1233  std::cout << "QTest:MeanWithinExpected"
1234  << " Illogical range: (" << xmin_ << ", " << xmax_ << "\n";
1235 }
double xmin_
Definition: QTest.h:414
int verbose_
Definition: QTest.h:117
double xmax_
Definition: QTest.h:414
void MeanWithinExpected::useRMS ( void  )

Definition at line 1247 of file QTest.cc.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1248 {
1249  useRMS_ = true;
1250  useSigma_ = useRange_ = false;
1251 }
void MeanWithinExpected::useSigma ( double  expectedSigma)

Definition at line 1236 of file QTest.cc.

References gather_cfg::cout.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

1237 {
1238  useSigma_ = true;
1239  useRMS_ = useRange_ = false;
1240  sigma_ = expectedSigma;
1241  if (sigma_ == 0)
1242  if (verbose_>0)
1243  std::cout << "QTest:MeanWithinExpected"
1244  << " Expected sigma = " << sigma_ << "\n";
1245 }
int verbose_
Definition: QTest.h:117
double sigma_
Definition: QTest.h:412

Member Data Documentation

double MeanWithinExpected::expMean_
protected

Definition at line 413 of file QTest.h.

double MeanWithinExpected::sigma_
protected

Definition at line 412 of file QTest.h.

bool MeanWithinExpected::useRange_
protected

Definition at line 411 of file QTest.h.

bool MeanWithinExpected::useRMS_
protected

Definition at line 409 of file QTest.h.

bool MeanWithinExpected::useSigma_
protected

Definition at line 410 of file QTest.h.

double MeanWithinExpected::xmax_
protected

Definition at line 414 of file QTest.h.

double MeanWithinExpected::xmin_
protected

Definition at line 414 of file QTest.h.