CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions
Comp2RefKolmogorov Class Reference

Comparison to reference using the Kolmogorov algorithm. More...

#include <QTest.h>

Inheritance diagram for Comp2RefKolmogorov:
SimpleTest QCriterion

Public Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from SimpleTest
virtual 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 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

Comparison to reference using the Kolmogorov algorithm.

Definition at line 211 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 214 of file QTest.h.

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

214  : SimpleTest(name)
215  {
217  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:77
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:137
static std::string getAlgoName(void)
Definition: QTest.h:218

Member Function Documentation

static std::string Comp2RefKolmogorov::getAlgoName ( void  )
inlinestatic
float Comp2RefKolmogorov::runTest ( const MonitorElement me)
virtual

Reimplemented from QCriterion.

Definition at line 293 of file QTest.cc.

References newFWLiteAna::bin, gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::DQM_KIND_TPROFILE, alignCSCRings::e, first, MonitorElement::getRefRootObject(), MonitorElement::getRefTH1D(), MonitorElement::getRefTH1F(), MonitorElement::getRefTH1S(), MonitorElement::getRefTProfile(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), MonitorElement::getTProfile(), h, MonitorElement::kind(), prof2calltree::last, siStripFEDMonitor_P5_cff::Max, indexGen::s2, w2, and detailsBasic3DVector::z.

294 {
295  const double difprec = 1e-5;
296 
297  if (!me)
298  return -1;
299  if (!me->getRootObject() || !me->getRefRootObject())
300  return -1;
301  TH1* h=0;
302  TH1* ref_=0;
303 
304  if (verbose_>1)
305  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
306  << me-> getFullname() << "\n";
307  //-- TH1F
309  {
310  h = me->getTH1F(); // access Test histo
311  ref_ = me->getRefTH1F(); //access Ref histo
312  }
313  //-- TH1S
314  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
315  {
316  h = me->getTH1S(); // access Test histo
317  ref_ = me->getRefTH1S(); //access Ref histo
318  }
319  //-- TH1D
320  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
321  {
322  h = me->getTH1D(); // access Test histo
323  ref_ = me->getRefTH1D(); //access Ref histo
324  }
325  //-- TProfile
326  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE)
327  {
328  h = me->getTProfile(); // access Test histo
329  ref_ = me->getRefTProfile(); //access Ref histo
330  }
331  else
332  {
333  if (verbose_>0)
334  std::cout << "QTest:Comp2RefKolmogorov"
335  << " ME does not contain TH1F/TH1S/TH1D/TProfile, exiting\n";
336  return -1;
337  }
338 
339  //-- isInvalid ? - Check consistency in number of channels
340  int ncx1 = h->GetXaxis()->GetNbins();
341  int ncx2 = ref_->GetXaxis()->GetNbins();
342  if ( ncx1 != ncx2)
343  {
344  if (verbose_>0)
345  std::cout << "QTest:Comp2RefKolmogorov"
346  << " different number of channels! ("
347  << ncx1 << ", " << ncx2 << "), exiting\n";
348  return -1;
349  }
350  //-- isInvalid ? - Check consistency in channel edges
351  double diff1 = TMath::Abs(h->GetXaxis()->GetXmin() - ref_->GetXaxis()->GetXmin());
352  double diff2 = TMath::Abs(h->GetXaxis()->GetXmax() - ref_->GetXaxis()->GetXmax());
353  if (diff1 > difprec || diff2 > difprec)
354  {
355  if (verbose_>0)
356  std::cout << "QTest:Comp2RefKolmogorov"
357  << " histograms with different binning, exiting\n";
358  return -1;
359  }
360 
361  //-- QUALITY TEST itself
362  Bool_t afunc1 = kFALSE; Bool_t afunc2 = kFALSE;
363  double sum1 = 0, sum2 = 0;
364  double ew1, ew2, w1 = 0, w2 = 0;
365  int bin;
366  for (bin=1;bin<=ncx1;bin++)
367  {
368  sum1 += h->GetBinContent(bin);
369  sum2 += ref_->GetBinContent(bin);
370  ew1 = h->GetBinError(bin);
371  ew2 = ref_->GetBinError(bin);
372  w1 += ew1*ew1;
373  w2 += ew2*ew2;
374  }
375 
376  if (sum1 == 0)
377  {
378  if (verbose_>0)
379  std::cout << "QTest:Comp2RefKolmogorov"
380  << " Test Histogram: " << h->GetName()
381  << ": integral is zero, exiting\n";
382  return -1;
383  }
384  if (sum2 == 0)
385  {
386  if (verbose_>0)
387  std::cout << "QTest:Comp2RefKolmogorov"
388  << " Ref Histogram: " << ref_->GetName()
389  << ": integral is zero, exiting\n";
390  return -1;
391  }
392 
393  double tsum1 = sum1; double tsum2 = sum2;
394  tsum1 += h->GetBinContent(0);
395  tsum2 += ref_->GetBinContent(0);
396  tsum1 += h->GetBinContent(ncx1+1);
397  tsum2 += ref_->GetBinContent(ncx1+1);
398 
399  // Check if histograms are weighted.
400  // If number of entries = number of channels, probably histograms were
401  // not filled via Fill(), but via SetBinContent()
402  double ne1 = h->GetEntries();
403  double ne2 = ref_->GetEntries();
404  // look at first histogram
405  double difsum1 = (ne1-tsum1)/tsum1;
406  double esum1 = sum1;
407  if (difsum1 > difprec && int(ne1) != ncx1)
408  {
409  if (h->GetSumw2N() == 0)
410  {
411  if (verbose_>0)
412  std::cout << "QTest:Comp2RefKolmogorov"
413  << " Weighted events and no Sumw2 for "
414  << h->GetName() << "\n";
415  }
416  else
417  {
418  esum1 = sum1*sum1/w1; //number of equivalent entries
419  }
420  }
421  // look at second histogram
422  double difsum2 = (ne2-tsum2)/tsum2;
423  double esum2 = sum2;
424  if (difsum2 > difprec && int(ne2) != ncx1)
425  {
426  if (ref_->GetSumw2N() == 0)
427  {
428  if (verbose_>0)
429  std::cout << "QTest:Comp2RefKolmogorov"
430  << " Weighted events and no Sumw2 for "
431  << ref_->GetName() << "\n";
432  }
433  else
434  {
435  esum2 = sum2*sum2/w2; //number of equivalent entries
436  }
437  }
438 
439  double s1 = 1/tsum1; double s2 = 1/tsum2;
440  // Find largest difference for Kolmogorov Test
441  double dfmax =0, rsum1 = 0, rsum2 = 0;
442  // use underflow bin
443  int first = 0; // 1
444  // use overflow bin
445  int last = ncx1+1; // ncx1
446  for ( bin=first; bin<=last; bin++)
447  {
448  rsum1 += s1*h->GetBinContent(bin);
449  rsum2 += s2*ref_->GetBinContent(bin);
450  dfmax = TMath::Max(dfmax,TMath::Abs(rsum1-rsum2));
451  }
452 
453  // Get Kolmogorov probability
454  double z = 0;
455  if (afunc1) z = dfmax*TMath::Sqrt(esum2);
456  else if (afunc2) z = dfmax*TMath::Sqrt(esum1);
457  else z = dfmax*TMath::Sqrt(esum1*esum2/(esum1+esum2));
458 
459  // This numerical error condition should never occur:
460  if (TMath::Abs(rsum1-1) > 0.002)
461  if (verbose_>0)
462  std::cout << "QTest:Comp2RefKolmogorov"
463  << " Numerical problems with histogram "
464  << h->GetName() << "\n";
465  if (TMath::Abs(rsum2-1) > 0.002)
466  if (verbose_>0)
467  std::cout << "QTest:Comp2RefKolmogorov"
468  << " Numerical problems with histogram "
469  << ref_->GetName() << "\n";
470 
471  return TMath::KolmogorovProb(z);
472 }
TH1F * getRefTH1F(void) const
TH1S * getTH1S(void) const
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
int verbose_
Definition: QTest.h:117
TH1D * getTH1D(void) const
float float float z
tuple s2
Definition: indexGen.py:106
static std::string getAlgoName(void)
Definition: QTest.h:218
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Kind kind(void) const
Get the type of the monitor element.
bool first
Definition: L1TdeRCT.cc:75
TObject * getRootObject(void) const
TH1F * getTH1F(void) const
TProfile * getRefTProfile(void) const
TProfile * getTProfile(void) const
tuple cout
Definition: gather_cfg.py:121
TObject * getRefRootObject(void) const
TH1S * getRefTH1S(void) const
TH1D * getRefTH1D(void) const