CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions
CheckVariance Class Reference

#include <QTest.h>

Inheritance diagram for CheckVariance:
SimpleTest QCriterion

Public Member Functions

 CheckVariance (const std::string &name)
 
float runTest (const MonitorElement *me) override
 
- 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 (see Core/interface/DQMDefinitions.h) 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 ()
 get algorithm name More...
 

Additional Inherited Members

- Public Types inherited from QCriterion
typedef dqm::legacy::MonitorElement MonitorElement
 (class should be created by DQMStore class) 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 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
 
- 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...
 

Detailed Description

Definition at line 739 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 741 of file QTest.h.

References QCriterion::setAlgoName().

void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:95
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:158
static std::string getAlgoName()
get algorithm name
Definition: QTest.h:743

Member Function Documentation

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

get algorithm name

Definition at line 743 of file QTest.h.

References QCriterion::runTest().

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

743 { return "CheckVariance"; }
float CheckVariance::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 1361 of file QTest.cc.

References newFWLiteAna::bin, relmon_rootfiles_spy::contents, gather_cfg::cout, dqm::impl::MonitorElement::getFullname(), dqm::legacy::MonitorElement::getRootObject(), dqm::legacy::MonitorElement::getTH1D(), dqm::legacy::MonitorElement::getTH1F(), dqm::legacy::MonitorElement::getTProfile(), h, dqm::impl::MonitorElement::kind(), combinedConstraintHelpers::sum2(), MonitorElementData::TH1D, MonitorElementData::TH1F, and MonitorElementData::TPROFILE.

1361  {
1362  badChannels_.clear();
1363 
1364  if (!me)
1365  return -1;
1366  if (!me->getRootObject())
1367  return -1;
1368  TH1* h = nullptr;
1369 
1370  if (verbose_ > 1)
1371  std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me->getFullname() << "\n";
1372  // -- TH1F
1373  if (me->kind() == MonitorElement::Kind::TH1F) {
1374  h = me->getTH1F();
1375  }
1376  // -- TH1D
1377  else if (me->kind() == MonitorElement::Kind::TH1D) {
1378  h = me->getTH1D();
1379  } else if (me->kind() == MonitorElement::Kind::TPROFILE) {
1380  h = me->getTProfile(); // access Test histo
1381  } else {
1382  if (verbose_ > 0)
1383  std::cout << "QTest:CheckVariance"
1384  << " ME " << me->getFullname() << " does not contain TH1F/TH1D/TPROFILE, exiting\n";
1385  return -1;
1386  }
1387 
1388  int ncx = h->GetXaxis()->GetNbins();
1389 
1390  double sum = 0;
1391  double sum2 = 0;
1392  for (int bin = 1; bin <= ncx; ++bin) {
1393  double contents = h->GetBinContent(bin);
1394  sum += contents;
1395  }
1396  if (sum == 0)
1397  return -1;
1398  double avg = sum / ncx;
1399 
1400  for (int bin = 1; bin <= ncx; ++bin) {
1401  double contents = h->GetBinContent(bin);
1402  sum2 += (contents - avg) * (contents - avg);
1403  }
1404 
1405  double Variance = TMath::Sqrt(sum2 / ncx);
1406  return Variance;
1407 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int verbose_
Definition: QTest.h:138
virtual TH1F * getTH1F() const
Kind kind() const
Get the type of the monitor element.
const std::string getFullname() const
get full name of ME including Pathname
virtual TProfile * getTProfile() const
virtual TH1D * getTH1D() const
std::vector< DQMChannel > badChannels_
Definition: QTest.h:173
static std::string getAlgoName()
get algorithm name
Definition: QTest.h:743
TObject * getRootObject() const override