Comparison to reference using the Kolmogorov algorithm. More...
#include <QTest.h>
Public Member Functions | |
Comp2RefKolmogorov (const std::string &name) | |
float | runTest (const MonitorElement *me) |
Static Public Member Functions | |
static std::string | getAlgoName (void) |
Comparison to reference using the Kolmogorov algorithm.
Comp2RefKolmogorov::Comp2RefKolmogorov | ( | const std::string & | name | ) | [inline] |
Definition at line 212 of file QTest.h.
References getAlgoName(), and QCriterion::setAlgoName().
: SimpleTest(name) { setAlgoName(getAlgoName()); }
static std::string Comp2RefKolmogorov::getAlgoName | ( | void | ) | [inline, static] |
Definition at line 216 of file QTest.h.
Referenced by Comp2RefKolmogorov(), QTestConfigure::EnableComp2RefKolmogorovTest(), QTestConfigure::enableTests(), and QTestParameterNames::QTestParameterNames().
{ return "Comp2RefKolmogorov"; }
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, 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 z.
{ const double difprec = 1e-5; if (!me) return -1; if (!me->getRootObject() || !me->getRefRootObject()) return -1; TH1* h=0; TH1* ref_=0; if (verbose_>1) std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me-> getFullname() << "\n"; //-- TH1F if (me->kind()==MonitorElement::DQM_KIND_TH1F) { h = me->getTH1F(); // access Test histo ref_ = me->getRefTH1F(); //access Ref histo } //-- TH1S else if (me->kind()==MonitorElement::DQM_KIND_TH1S) { h = me->getTH1S(); // access Test histo ref_ = me->getRefTH1S(); //access Ref histo } //-- TH1D else if (me->kind()==MonitorElement::DQM_KIND_TH1D) { h = me->getTH1D(); // access Test histo ref_ = me->getRefTH1D(); //access Ref histo } //-- TProfile else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE) { h = me->getTProfile(); // access Test histo ref_ = me->getRefTProfile(); //access Ref histo } else { if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " ME does not contain TH1F/TH1S/TH1D/TProfile, exiting\n"; return -1; } //-- isInvalid ? - Check consistency in number of channels int ncx1 = h->GetXaxis()->GetNbins(); int ncx2 = ref_->GetXaxis()->GetNbins(); if ( ncx1 != ncx2) { if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " different number of channels! (" << ncx1 << ", " << ncx2 << "), exiting\n"; return -1; } //-- isInvalid ? - Check consistency in channel edges double diff1 = TMath::Abs(h->GetXaxis()->GetXmin() - ref_->GetXaxis()->GetXmin()); double diff2 = TMath::Abs(h->GetXaxis()->GetXmax() - ref_->GetXaxis()->GetXmax()); if (diff1 > difprec || diff2 > difprec) { if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " histograms with different binning, exiting\n"; return -1; } //-- QUALITY TEST itself Bool_t afunc1 = kFALSE; Bool_t afunc2 = kFALSE; double sum1 = 0, sum2 = 0; double ew1, ew2, w1 = 0, w2 = 0; int bin; for (bin=1;bin<=ncx1;bin++) { sum1 += h->GetBinContent(bin); sum2 += ref_->GetBinContent(bin); ew1 = h->GetBinError(bin); ew2 = ref_->GetBinError(bin); w1 += ew1*ew1; w2 += ew2*ew2; } if (sum1 == 0) { if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " Test Histogram: " << h->GetName() << ": integral is zero, exiting\n"; return -1; } if (sum2 == 0) { if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " Ref Histogram: " << ref_->GetName() << ": integral is zero, exiting\n"; return -1; } double tsum1 = sum1; double tsum2 = sum2; tsum1 += h->GetBinContent(0); tsum2 += ref_->GetBinContent(0); tsum1 += h->GetBinContent(ncx1+1); tsum2 += ref_->GetBinContent(ncx1+1); // Check if histograms are weighted. // If number of entries = number of channels, probably histograms were // not filled via Fill(), but via SetBinContent() double ne1 = h->GetEntries(); double ne2 = ref_->GetEntries(); // look at first histogram double difsum1 = (ne1-tsum1)/tsum1; double esum1 = sum1; if (difsum1 > difprec && int(ne1) != ncx1) { if (h->GetSumw2N() == 0) { if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " Weighted events and no Sumw2 for " << h->GetName() << "\n"; } else { esum1 = sum1*sum1/w1; //number of equivalent entries } } // look at second histogram double difsum2 = (ne2-tsum2)/tsum2; double esum2 = sum2; if (difsum2 > difprec && int(ne2) != ncx1) { if (ref_->GetSumw2N() == 0) { if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " Weighted events and no Sumw2 for " << ref_->GetName() << "\n"; } else { esum2 = sum2*sum2/w2; //number of equivalent entries } } double s1 = 1/tsum1; double s2 = 1/tsum2; // Find largest difference for Kolmogorov Test double dfmax =0, rsum1 = 0, rsum2 = 0; // use underflow bin int first = 0; // 1 // use overflow bin int last = ncx1+1; // ncx1 for ( bin=first; bin<=last; bin++) { rsum1 += s1*h->GetBinContent(bin); rsum2 += s2*ref_->GetBinContent(bin); dfmax = TMath::Max(dfmax,TMath::Abs(rsum1-rsum2)); } // Get Kolmogorov probability double z = 0; if (afunc1) z = dfmax*TMath::Sqrt(esum2); else if (afunc2) z = dfmax*TMath::Sqrt(esum1); else z = dfmax*TMath::Sqrt(esum1*esum2/(esum1+esum2)); // This numerical error condition should never occur: if (TMath::Abs(rsum1-1) > 0.002) if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " Numerical problems with histogram " << h->GetName() << "\n"; if (TMath::Abs(rsum2-1) > 0.002) if (verbose_>0) std::cout << "QTest:Comp2RefKolmogorov" << " Numerical problems with histogram " << ref_->GetName() << "\n"; return TMath::KolmogorovProb(z); }