CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Comp2Ref2DChi2 Class Reference

#include <QTest.h>

Inheritance diagram for Comp2Ref2DChi2:
SimpleTest QCriterion

Public Member Functions

 Comp2Ref2DChi2 (const std::string &name)
 
float runTest (const MonitorElement *me)
 
- 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 Member Functions

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)
 

Protected Attributes

double chi2_
 
int Ndof_
 
- 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 212 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 215 of file QTest.h.

References QCriterion::setAlgoName().

215  :SimpleTest(name)
216  {
218  }
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:219

Member Function Documentation

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

Definition at line 219 of file QTest.h.

References QCriterion::runTest().

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

219 { return "Comp2Ref2DChi2"; }
float Comp2Ref2DChi2::runTest ( const MonitorElement me)
virtual

Reimplemented from QCriterion.

Definition at line 302 of file QTest.cc.

References gather_cfg::cout, MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, MonitorElement::DQM_KIND_TPROFILE2D, MonitorElement::getEntries(), MonitorElement::getRefRootObject(), MonitorElement::getRefTH2D(), MonitorElement::getRefTH2F(), MonitorElement::getRefTH2S(), MonitorElement::getRefTProfile2D(), MonitorElement::getRootObject(), MonitorElement::getTH2D(), MonitorElement::getTH2F(), MonitorElement::getTH2S(), MonitorElement::getTProfile2D(), and MonitorElement::kind().

303 {
304  if (!me)
305  return -1;
306  if (!me->getRootObject() || !me->getRefRootObject())
307  return -1;
308  if (minEntries_ != 0 && me->getEntries() < minEntries_)
309  return -1;
310 
311  TH2* h=nullptr;
312  TH2* ref_=nullptr;
313 
314  if (verbose_>1)
315  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
316  << me-> getFullname() << "\n";
317  //-- TH2F
319  {
320  h = me->getTH2F(); // access Test histo
321  ref_ = me->getRefTH2F(); //access Ref histo
322  }
323  //-- TH2S
324  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
325  {
326  h = me->getTH2S(); // access Test histo
327  ref_ = me->getRefTH2S(); //access Ref histo
328  }
329  //-- TH2D
330  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
331  {
332  h = me->getTH2D(); // access Test histo
333  ref_ = me->getRefTH2D(); //access Ref histo
334  }
335  //-- TProfile
337  {
338  h = me->getTProfile2D(); // access Test histo
339  ref_ = me->getRefTProfile2D(); //access Ref histo
340  }
341  else
342  {
343  if (verbose_>0)
344  std::cout << "QTest::Comp2Ref2DChi2"
345  << " ME does not contain TH2F/TH2S/TH2D/TProfile2D, exiting\n";
346  return -1;
347  }
348 
349  //-- isInvalid ? - Check consistency in number of channels
350  int ncx1 = h->GetXaxis()->GetNbins();
351  int ncx2 = ref_->GetXaxis()->GetNbins();
352  int ncy1 = h->GetYaxis()->GetNbins();
353  int ncy2 = ref_->GetYaxis()->GetNbins();
354  if ( ( ncx1 != ncx2) || ( ncy1 != ncy2) )
355  {
356  if (verbose_>0)
357  std::cout << "QTest:Comp2Ref2DChi2"
358  << " different number of channels! ("
359  << ncx1 << ", " << ncx2 << "), ("
360  << ncy1 << ", " << ncy2 << "), exiting\n";
361  return -1;
362  }
363 
364  //-- QUALITY TEST itself
365  //reset Results
366  Ndof_ = 0; chi2_ = -1.;
367 
368  //check that the histograms are not empty
369  int i_start = h->GetXaxis()->GetFirst();
370  int i_end = h->GetXaxis()->GetLast();
371  int j_start = h->GetYaxis()->GetFirst();
372  int j_end = h->GetYaxis()->GetLast();
373  if (h->Integral(i_start, i_end, j_start, j_end) == 0)
374  {
375  if (verbose_>0)
376  std::cout << "QTest:Comp2Ref2DChi2"
377  << " Test Histogram " << h->GetName()
378  << " is empty, exiting\n";
379  return -1;
380  }
381  if (ref_->Integral(i_start, i_end, j_start, j_end) == 0)
382  {
383  if (verbose_>0)
384  std::cout << "QTest:Comp2Ref2DChi2"
385  << " Ref Histogram " << ref_->GetName()
386  << " is empty, exiting\n";
387  return -1;
388  }
389 
390  //use the chi2 test for 2D histograms defined in ROOT
391  int igood = 0;
392  double pValue = h->Chi2TestX(ref_, chi2_, Ndof_, igood, "");
393 
394  if (chi2_==-1. && Ndof_==0)
395  return -1;
396 
397  return pValue;
398 }
TH2S * getTH2S(void) const
TProfile2D * getTProfile2D(void) const
int verbose_
Definition: QTest.h:118
TProfile2D * getRefTProfile2D(void) const
TH2D * getTH2D(void) const
double getEntries(void) const
get # of entries
TH2F * getRefTH2F(void) const
double chi2_
Definition: QTest.h:235
Kind kind(void) const
Get the type of the monitor element.
TH2D * getRefTH2D(void) const
TObject * getRootObject(void) const
TH2S * getRefTH2S(void) const
static std::string getAlgoName(void)
Definition: QTest.h:219
unsigned minEntries_
Definition: QTest.h:159
TH2F * getTH2F(void) const
TObject * getRefRootObject(void) const
void Comp2Ref2DChi2::setMessage ( void  )
inlineprotectedvirtual

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 224 of file QTest.h.

References QCriterion::errorProb_, python.rootplot.argparse::message, QCriterion::message_, and QCriterion::warningProb_.

225  {
226  std::ostringstream message;
227  message << "chi2/Ndof = " << chi2_ << "/" << Ndof_
228  << ", minimum needed statistics = " << minEntries_
229  << " warning threshold = " << this->warningProb_
230  << " error threshold = " << this->errorProb_;
231  message_ = message.str();
232  }
float errorProb_
Definition: QTest.h:116
double chi2_
Definition: QTest.h:235
std::string message_
quality test status
Definition: QTest.h:115
unsigned minEntries_
Definition: QTest.h:159
float warningProb_
message attached to test
Definition: QTest.h:116

Member Data Documentation

double Comp2Ref2DChi2::chi2_
protected

Definition at line 235 of file QTest.h.

int Comp2Ref2DChi2::Ndof_
protected

Definition at line 235 of file QTest.h.