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 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 ()
 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...
 
- 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...
 
- 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 705 of file QTest.h.

Constructor & Destructor Documentation

◆ CheckVariance()

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

Definition at line 707 of file QTest.h.

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

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

Member Function Documentation

◆ getAlgoName()

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

get algorithm name

Definition at line 709 of file QTest.h.

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

709 { return "CheckVariance"; }

◆ runTest()

float CheckVariance::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 1357 of file QTest.cc.

References newFWLiteAna::bin, relmon_rootfiles_spy::contents, gather_cfg::cout, h, hlt_dqm_clientPB-live_cfg::me, MonitorElementData::TH1D, MonitorElementData::TH1F, and MonitorElementData::TPROFILE.

1357  {
1358  badChannels_.clear();
1359 
1360  if (!me)
1361  return -1;
1362  if (!me->getRootObject())
1363  return -1;
1364  TH1* h = nullptr;
1365 
1366  if (verbose_ > 1)
1367  std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me->getFullname() << "\n";
1368  // -- TH1F
1369  if (me->kind() == MonitorElement::Kind::TH1F) {
1370  h = me->getTH1F();
1371  }
1372  // -- TH1D
1373  else if (me->kind() == MonitorElement::Kind::TH1D) {
1374  h = me->getTH1D();
1375  } else if (me->kind() == MonitorElement::Kind::TPROFILE) {
1376  h = me->getTProfile(); // access Test histo
1377  } else {
1378  if (verbose_ > 0)
1379  std::cout << "QTest:CheckVariance"
1380  << " ME " << me->getFullname() << " does not contain TH1F/TH1D/TPROFILE, exiting\n";
1381  return -1;
1382  }
1383 
1384  int ncx = h->GetXaxis()->GetNbins();
1385 
1386  double sum = 0;
1387  double sum2 = 0;
1388  for (int bin = 1; bin <= ncx; ++bin) {
1389  double contents = h->GetBinContent(bin);
1390  sum += contents;
1391  }
1392  if (sum == 0)
1393  return -1;
1394  double avg = sum / ncx;
1395 
1396  for (int bin = 1; bin <= ncx; ++bin) {
1397  double contents = h->GetBinContent(bin);
1398  sum2 += (contents - avg) * (contents - avg);
1399  }
1400 
1401  double Variance = TMath::Sqrt(sum2 / ncx);
1402  return Variance;
1403 }
int verbose_
Definition: QTest.h:110
std::vector< DQMChannel > badChannels_
Definition: QTest.h:139
static std::string getAlgoName()
get algorithm name
Definition: QTest.h:709
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4