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) 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 ()
 

Protected Member Functions

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

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

Constructor & Destructor Documentation

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

Definition at line 217 of file QTest.h.

References QCriterion::setAlgoName().

217  :SimpleTest(name)
218  {
220  }
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()
Definition: QTest.h:221

Member Function Documentation

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

Definition at line 221 of file QTest.h.

References QCriterion::runTest().

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

221 { return "Comp2Ref2DChi2"; }
float Comp2Ref2DChi2::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 303 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(), h, and MonitorElement::kind().

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

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 226 of file QTest.h.

References QCriterion::errorProb_, QCriterion::message_, and QCriterion::warningProb_.

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

Member Data Documentation

double Comp2Ref2DChi2::chi2_
protected

Definition at line 237 of file QTest.h.

int Comp2Ref2DChi2::Ndof_
protected

Definition at line 237 of file QTest.h.