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
 (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 ()
 get algorithm name 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
 
- 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 837 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 840 of file QTest.h.

References QCriterion::setAlgoName().

840  : SimpleTest(name)
841  {
843  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:80
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:140
static std::string getAlgoName()
get algorithm name
Definition: QTest.h:845

Member Function Documentation

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

get algorithm name

Definition at line 845 of file QTest.h.

References QCriterion::runTest().

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

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

Reimplemented from QCriterion.

Definition at line 2041 of file QTest.cc.

References stringResolutionProvider_cfi::bin, relmon_rootfiles_spy::contents, gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTProfile(), h, MonitorElement::kind(), and combinedConstraintHelpers::sum2().

2042 {
2043  badChannels_.clear();
2044 
2045  if (!me)
2046  return -1;
2047  if (!me->getRootObject())
2048  return -1;
2049  TH1* h=nullptr;
2050 
2051  if (verbose_>1)
2052  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
2053  << me-> getFullname() << "\n";
2054  // -- TH1F
2055  if (me->kind()==MonitorElement::DQM_KIND_TH1F )
2056  {
2057  h = me->getTH1F();
2058  }
2059  // -- TH1D
2060  else if ( me->kind()==MonitorElement::DQM_KIND_TH1D )
2061  {
2062  h = me->getTH1D();
2063  }
2064  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE)
2065  {
2066  h = me->getTProfile(); // access Test histo
2067  }
2068  else
2069  {
2070  if (verbose_>0) std::cout << "QTest:CheckVariance"
2071  << " ME " << me->getFullname()
2072  << " does not contain TH1F/TH1D/TPROFILE, exiting\n";
2073  return -1;
2074  }
2075 
2076  int ncx = h->GetXaxis()->GetNbins();
2077 
2078  double sum = 0;
2079  double sum2 = 0;
2080  for (int bin = 1; bin <= ncx; ++bin)
2081  {
2082  double contents = h->GetBinContent(bin);
2083  sum += contents;
2084  }
2085  if (sum==0) return -1;
2086  double avg = sum/ncx;
2087 
2088  for (int bin = 1; bin <= ncx; ++bin)
2089  {
2090  double contents = h->GetBinContent(bin);
2091  sum2 += (contents - avg)*(contents - avg);
2092  }
2093 
2094  double Variance = TMath::Sqrt(sum2/ncx);
2095  return Variance;
2096 }
TProfile * getTProfile() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
TH1F * getTH1F() const
int verbose_
Definition: QTest.h:120
TObject * getRootObject() const
bin
set the eta bin as selection string.
const std::string getFullname() const
get full name of ME including Pathname
std::vector< DQMChannel > badChannels_
Definition: QTest.h:162
static std::string getAlgoName()
get algorithm name
Definition: QTest.h:845
TH1D * getTH1D() const
Kind kind() const
Get the type of the monitor element.