#include <QTest.h>
Public Member Functions | |
ContentsWithinExpected (const std::string &name) | |
float | runTest (const MonitorElement *me) |
void | setMeanRange (double xmin, double xmax) |
set expected value for mean | |
void | setMeanTolerance (float fracTolerance) |
set (fractional) tolerance for mean | |
void | setRMSRange (double xmin, double xmax) |
set expected value for mean | |
void | setUseEmptyBins (unsigned int useEmptyBins) |
Static Public Member Functions | |
static std::string | getAlgoName (void) |
Protected Attributes | |
bool | checkMean_ |
bool | checkMeanTolerance_ |
bool | checkRMS_ |
float | maxMean_ |
float | maxRMS_ |
float | minMean_ |
float | minRMS_ |
float | toleranceMean_ |
unsigned int | useEmptyBins_ |
ContentsWithinExpected::ContentsWithinExpected | ( | const std::string & | name | ) | [inline] |
Definition at line 351 of file QTest.h.
References checkMean_, checkMeanTolerance_, checkRMS_, getAlgoName(), maxMean_, maxRMS_, minMean_, minRMS_, QCriterion::setAlgoName(), and toleranceMean_.
: SimpleTest(name,true) { checkMean_ = checkRMS_ = false; minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0; checkMeanTolerance_ = false; toleranceMean_ = -1.0; setAlgoName(getAlgoName()); }
static std::string ContentsWithinExpected::getAlgoName | ( | void | ) | [inline, static] |
Definition at line 359 of file QTest.h.
Referenced by ContentsWithinExpected(), QTestConfigure::EnableContentsWithinExpectedTest(), QTestConfigure::enableTests(), and QTestParameterNames::QTestParameterNames().
{ return "ContentsWithinExpected"; }
float ContentsWithinExpected::runTest | ( | const MonitorElement * | me | ) | [virtual] |
end of normal Test
AS quality test !!!
end of AS quality test
Reimplemented from QCriterion.
Definition at line 872 of file QTest.cc.
References PDRates::average, gather_cfg::cout, MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::DQM_KIND_TPROFILE2D, cmsPerfPublish::fail(), MonitorElement::getRootObject(), MonitorElement::getTH2D(), MonitorElement::getTH2F(), MonitorElement::getTH2S(), MonitorElement::getTProfile(), MonitorElement::getTProfile2D(), h, MonitorElement::kind(), plotscripts::mean(), and plotscripts::rms().
{ badChannels_.clear(); if (!me) return -1; if (!me->getRootObject()) return -1; TH1* h=0; //initialize histogram pointer if (verbose_>1) std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me-> getFullname() << "\n"; int ncx; int ncy; if (useEmptyBins_) { //-- TH2 if (me->kind()==MonitorElement::DQM_KIND_TH2F) { ncx = me->getTH2F()->GetXaxis()->GetNbins(); ncy = me->getTH2F()->GetYaxis()->GetNbins(); h = me->getTH2F(); // access Test histo } //-- TH2S else if (me->kind()==MonitorElement::DQM_KIND_TH2S) { ncx = me->getTH2S()->GetXaxis()->GetNbins(); ncy = me->getTH2S()->GetYaxis()->GetNbins(); h = me->getTH2S(); // access Test histo } //-- TH2D else if (me->kind()==MonitorElement::DQM_KIND_TH2D) { ncx = me->getTH2D()->GetXaxis()->GetNbins(); ncy = me->getTH2D()->GetYaxis()->GetNbins(); h = me->getTH2D(); // access Test histo } //-- TProfile else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE) { ncx = me->getTProfile()->GetXaxis()->GetNbins(); ncy = 1; h = me->getTProfile(); // access Test histo } //-- TProfile2D else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE2D) { ncx = me->getTProfile2D()->GetXaxis()->GetNbins(); ncy = me->getTProfile2D()->GetYaxis()->GetNbins(); h = me->getTProfile2D(); // access Test histo } else { if (verbose_>0) std::cout << "QTest:ContentsWithinExpected" << " ME does not contain TH2F/TH2S/TH2D/TPROFILE/TPROFILE2D, exiting\n"; return -1; } int nsum = 0; double sum = 0.0; double average = 0.0; if (checkMeanTolerance_) { // calculate average value of all bin contents for (int cx = 1; cx <= ncx; ++cx) { for (int cy = 1; cy <= ncy; ++cy) { if (me->kind() == MonitorElement::DQM_KIND_TH2F) { sum += h->GetBinContent(h->GetBin(cx, cy)); ++nsum; } else if (me->kind() == MonitorElement::DQM_KIND_TH2S) { sum += h->GetBinContent(h->GetBin(cx, cy)); ++nsum; } else if (me->kind() == MonitorElement::DQM_KIND_TH2D) { sum += h->GetBinContent(h->GetBin(cx, cy)); ++nsum; } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) { if (me->getTProfile()->GetBinEntries(h->GetBin(cx)) >= minEntries_/(ncx)) { sum += h->GetBinContent(h->GetBin(cx)); ++nsum; } } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D) { if (me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) >= minEntries_/(ncx*ncy)) { sum += h->GetBinContent(h->GetBin(cx, cy)); ++nsum; } } } } if (nsum > 0) average = sum/nsum; } // calculate average value of all bin contents int fail = 0; for (int cx = 1; cx <= ncx; ++cx) { for (int cy = 1; cy <= ncy; ++cy) { bool failMean = false; bool failRMS = false; bool failMeanTolerance = false; if (me->kind() == MonitorElement::DQM_KIND_TPROFILE && me->getTProfile()->GetBinEntries(h->GetBin(cx)) < minEntries_/(ncx)) continue; if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D && me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) < minEntries_/(ncx*ncy)) continue; if (checkMean_) { double mean = h->GetBinContent(h->GetBin(cx, cy)); failMean = (mean < minMean_ || mean > maxMean_); } if (checkRMS_) { double rms = h->GetBinError(h->GetBin(cx, cy)); failRMS = (rms < minRMS_ || rms > maxRMS_); } if (checkMeanTolerance_) { double mean = h->GetBinContent(h->GetBin(cx, cy)); failMeanTolerance = (TMath::Abs(mean - average) > toleranceMean_*TMath::Abs(average)); } if (failMean || failRMS || failMeanTolerance) { if (me->kind() == MonitorElement::DQM_KIND_TH2F) { DQMChannel chan(cx, cy, 0, h->GetBinContent(h->GetBin(cx, cy)), h->GetBinError(h->GetBin(cx, cy))); badChannels_.push_back(chan); } else if (me->kind() == MonitorElement::DQM_KIND_TH2S) { DQMChannel chan(cx, cy, 0, h->GetBinContent(h->GetBin(cx, cy)), h->GetBinError(h->GetBin(cx, cy))); badChannels_.push_back(chan); } else if (me->kind() == MonitorElement::DQM_KIND_TH2D) { DQMChannel chan(cx, cy, 0, h->GetBinContent(h->GetBin(cx, cy)), h->GetBinError(h->GetBin(cx, cy))); badChannels_.push_back(chan); } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) { DQMChannel chan(cx, cy, int(me->getTProfile()->GetBinEntries(h->GetBin(cx))), 0, h->GetBinError(h->GetBin(cx))); badChannels_.push_back(chan); } else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D) { DQMChannel chan(cx, cy, int(me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy))), h->GetBinContent(h->GetBin(cx, cy)), h->GetBinError(h->GetBin(cx, cy))); badChannels_.push_back(chan); } ++fail; } } } return 1.*(ncx*ncy - fail)/(ncx*ncy); } else { if (me->kind()==MonitorElement::DQM_KIND_TH2F) { ncx = me->getTH2F()->GetXaxis()->GetNbins(); ncy = me->getTH2F()->GetYaxis()->GetNbins(); h = me->getTH2F(); // access Test histo } else if (me->kind()==MonitorElement::DQM_KIND_TH2S) { ncx = me->getTH2S()->GetXaxis()->GetNbins(); ncy = me->getTH2S()->GetYaxis()->GetNbins(); h = me->getTH2S(); // access Test histo } else if (me->kind()==MonitorElement::DQM_KIND_TH2D) { ncx = me->getTH2D()->GetXaxis()->GetNbins(); ncy = me->getTH2D()->GetYaxis()->GetNbins(); h = me->getTH2D(); // access Test histo } else { if (verbose_>0) std::cout << "QTest:ContentsWithinExpected AS" << " ME does not contain TH2F/TH2S/TH2D, exiting\n"; return -1; } // if (!rangeInitialized_) return 0; // all accepted if no initialization int fail = 0; for (int cx = 1; cx <= ncx; ++cx) { for (int cy = 1; cy <= ncy; ++cy) { bool failure = false; double Content = h->GetBinContent(h->GetBin(cx, cy)); if (Content) failure = (Content < minMean_ || Content > maxMean_); if (failure) ++fail; } } return 1.*(ncx*ncy-fail)/(ncx*ncy); } }
void ContentsWithinExpected::setMeanRange | ( | double | xmin, |
double | xmax | ||
) |
set expected value for mean
Definition at line 1111 of file QTest.cc.
References gather_cfg::cout.
Referenced by QTestConfigure::EnableContentsWithinExpectedTest().
{ if (xmax < xmin) if (verbose_>0) std::cout << "QTest:ContentsWitinExpected" << " Illogical range: (" << xmin << ", " << xmax << "\n"; minMean_ = xmin; maxMean_ = xmax; checkMean_ = true; }
void ContentsWithinExpected::setMeanTolerance | ( | float | fracTolerance | ) | [inline] |
set (fractional) tolerance for mean
Definition at line 369 of file QTest.h.
References checkMeanTolerance_, and toleranceMean_.
Referenced by QTestConfigure::EnableContentsWithinExpectedTest().
{ if (fracTolerance >= 0.0) { toleranceMean_ = fracTolerance; checkMeanTolerance_ = true; } }
void ContentsWithinExpected::setRMSRange | ( | double | xmin, |
double | xmax | ||
) |
set expected value for mean
Definition at line 1123 of file QTest.cc.
References gather_cfg::cout.
Referenced by QTestConfigure::EnableContentsWithinExpectedTest().
void ContentsWithinExpected::setUseEmptyBins | ( | unsigned int | useEmptyBins | ) | [inline] |
Definition at line 362 of file QTest.h.
References useEmptyBins_.
Referenced by QTestConfigure::EnableContentsWithinExpectedTest().
{ useEmptyBins_ = useEmptyBins; }
bool ContentsWithinExpected::checkMean_ [protected] |
Definition at line 379 of file QTest.h.
Referenced by ContentsWithinExpected().
bool ContentsWithinExpected::checkMeanTolerance_ [protected] |
Definition at line 381 of file QTest.h.
Referenced by ContentsWithinExpected(), and setMeanTolerance().
bool ContentsWithinExpected::checkRMS_ [protected] |
Definition at line 380 of file QTest.h.
Referenced by ContentsWithinExpected().
float ContentsWithinExpected::maxMean_ [protected] |
Definition at line 383 of file QTest.h.
Referenced by ContentsWithinExpected().
float ContentsWithinExpected::maxRMS_ [protected] |
Definition at line 384 of file QTest.h.
Referenced by ContentsWithinExpected().
float ContentsWithinExpected::minMean_ [protected] |
Definition at line 383 of file QTest.h.
Referenced by ContentsWithinExpected().
float ContentsWithinExpected::minRMS_ [protected] |
Definition at line 384 of file QTest.h.
Referenced by ContentsWithinExpected().
float ContentsWithinExpected::toleranceMean_ [protected] |
Definition at line 382 of file QTest.h.
Referenced by ContentsWithinExpected(), and setMeanTolerance().
unsigned int ContentsWithinExpected::useEmptyBins_ [protected] |
Definition at line 385 of file QTest.h.
Referenced by setUseEmptyBins().