#include <QTest.h>
Public Member Functions | |
CompareToMedian (const std::string &name) | |
float | runTest (const MonitorElement *me) |
void | setEmptyBins (int eB) |
void | setMax (float max) |
void | setMaxMedian (float max) |
void | setMin (float min) |
void | setMinMedian (float min) |
void | setStatCut (float cut) |
~CompareToMedian () | |
Static Public Member Functions | |
static std::string | getAlgoName (void) |
Protected Member Functions | |
void | setMessage (void) |
set status & message after test has run | |
Private Member Functions | |
void | reset () |
Private Attributes | |
int | _emptyBins |
float | _max |
float | _maxMed |
float | _min |
float | _minMed |
float | _statCut |
std::vector< float > | binValues |
int | nBins |
int | nBinsX |
int | nBinsY |
CompareToMedian::CompareToMedian | ( | const std::string & | name | ) | [inline] |
Definition at line 597 of file QTest.h.
References _emptyBins, _max, _maxMed, _min, _minMed, _statCut, getAlgoName(), nBins, reset(), and QCriterion::setAlgoName().
: SimpleTest(name,true){ this->_min = 0.2; this->_max = 3.0; this->_emptyBins = 0; this->_maxMed = 10; this->_minMed = 0; this->nBins = 0; this->_statCut = 0; reset(); setAlgoName( getAlgoName() ); };
static std::string CompareToMedian::getAlgoName | ( | void | ) | [inline, static] |
Definition at line 611 of file QTest.h.
Referenced by CompareToMedian(), QTestConfigure::EnableCompareToMedianTest(), QTestConfigure::enableTests(), and QTestParameterNames::QTestParameterNames().
{ return "CompareToMedian"; }
void CompareToMedian::reset | ( | void | ) | [inline, private] |
Definition at line 642 of file QTest.h.
References binValues.
Referenced by CompareToMedian().
{binValues.clear();};
float CompareToMedian::runTest | ( | const MonitorElement * | me | ) | [virtual] |
Reimplemented from QCriterion.
Definition at line 1264 of file QTest.cc.
References newFWLiteAna::bin, ws_sso_content_reader::content, gather_cfg::cout, MonitorElement::DQM_KIND_TPROFILE2D, python::tagInventory::entries, MonitorElement::getRootObject(), MonitorElement::getTProfile2D(), h, MonitorElement::kind(), pileupCalc::nbins, and reset().
{ int32_t nbins=0, failed=0; badChannels_.clear(); if (!me) return -1; if (!me->getRootObject()) return -1; TH1* h=0; if (verbose_>1){ std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me-> getFullname() << "\n"; std::cout << "\tMin = " << _min << "; Max = " << _max << "\n"; std::cout << "\tMinMedian = " << _minMed << "; MaxMedian = " << _maxMed << "\n"; std::cout << "\tUseEmptyBins = " << (_emptyBins?"Yes":"No" )<< "\n"; } if (me->kind()==MonitorElement::DQM_KIND_TPROFILE2D) { h = me->getTProfile2D(); // access Test histo } else { if (verbose_>0) std::cout << "QTest:ContentsWithinExpected" << " ME does not contain TPROFILE2D, exiting\n"; return -1; } nBinsX = h->GetNbinsX(); nBinsY = h->GetNbinsY(); int entries = 0; float median = 0.0; //Median calculated with partially sorted vector for (int binX = 1; binX <= nBinsX; binX++ ){ reset(); // Fill vector for (int binY = 1; binY <= nBinsY; binY++){ int bin = h->GetBin(binX, binY); double content = (double)h->GetBinContent(bin); if ( content == 0 && !_emptyBins) continue; binValues.push_back(content); entries = me->getTProfile2D()->GetBinEntries(bin); } if (binValues.empty()) continue; nbins+=binValues.size(); //calculate median if(binValues.size()>0){ int medPos = (int)binValues.size()/2; nth_element(binValues.begin(),binValues.begin()+medPos,binValues.end()); median = *(binValues.begin()+medPos); } // if median == 0, use the absolute cut if(median == 0){ if (verbose_ > 0){ std::cout << "QTest: Median is 0; the fixed cuts: [" << _minMed << "; " << _maxMed << "] are used\n"; } for(int binY = 1; binY <= nBinsY; binY++){ int bin = h->GetBin(binX, binY); double content = (double)h->GetBinContent(bin); entries = me->getTProfile2D()->GetBinEntries(bin); if ( entries == 0 ) continue; if (content > _maxMed || content < _minMed){ DQMChannel chan(binX,binY, 0, content, h->GetBinError(bin)); badChannels_.push_back(chan); failed++; } } continue; } //Cut on stat: will mask rings with no enought of statistics if (median*entries < _statCut ) continue; // If median is off the absolute cuts, declare everything bad (if bin has non zero entries) if(median > _maxMed || median < _minMed){ for(int binY = 1; binY <= nBinsY; binY++){ int bin = h->GetBin(binX, binY); double content = (double)h->GetBinContent(bin); entries = me->getTProfile2D()->GetBinEntries(bin); if ( entries == 0 ) continue; DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin)); badChannels_.push_back(chan); failed++; } continue; } // Test itself float minCut = median*_min; float maxCut = median*_max; for(int binY = 1; binY <= nBinsY; binY++){ int bin = h->GetBin(binX, binY); double content = (double)h->GetBinContent(bin); entries = me->getTProfile2D()->GetBinEntries(bin); if ( entries == 0 ) continue; if (content > maxCut || content < minCut){ DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin)); badChannels_.push_back(chan); failed++; } } } if (nbins==0){ if (verbose_ > 0) std::cout << "QTest:CompareToMedian: Histogram is empty" << std::endl; return 1.; } return 1 - (float)failed/nbins; }
void CompareToMedian::setEmptyBins | ( | int | eB | ) | [inline] |
Definition at line 616 of file QTest.h.
References _emptyBins.
Referenced by QTestConfigure::EnableCompareToMedianTest().
{eB > 0 ? _emptyBins = 1 : _emptyBins = 0;};
void CompareToMedian::setMax | ( | float | max | ) | [inline] |
void CompareToMedian::setMaxMedian | ( | float | max | ) | [inline] |
void CompareToMedian::setMessage | ( | void | ) | [inline, protected, virtual] |
set status & message after test has run
Reimplemented from SimpleTest.
Definition at line 622 of file QTest.h.
References QCriterion::algoName_, python::rootplot::argparse::message, QCriterion::message_, QCriterion::prob_, and QCriterion::qtname_.
void CompareToMedian::setMin | ( | float | min | ) | [inline] |
void CompareToMedian::setMinMedian | ( | float | min | ) | [inline] |
void CompareToMedian::setStatCut | ( | float | cut | ) | [inline] |
int CompareToMedian::_emptyBins [private] |
Definition at line 631 of file QTest.h.
Referenced by CompareToMedian(), and setEmptyBins().
float CompareToMedian::_max [private] |
Definition at line 630 of file QTest.h.
Referenced by CompareToMedian(), and setMax().
float CompareToMedian::_maxMed [private] |
Definition at line 632 of file QTest.h.
Referenced by CompareToMedian(), and setMaxMedian().
float CompareToMedian::_min [private] |
Definition at line 630 of file QTest.h.
Referenced by CompareToMedian(), and setMin().
float CompareToMedian::_minMed [private] |
Definition at line 632 of file QTest.h.
Referenced by CompareToMedian(), and setMinMedian().
float CompareToMedian::_statCut [private] |
Definition at line 633 of file QTest.h.
Referenced by CompareToMedian(), and setStatCut().
std::vector<float> CompareToMedian::binValues [private] |
int CompareToMedian::nBins [private] |
Definition at line 637 of file QTest.h.
Referenced by CompareToMedian().
int CompareToMedian::nBinsX [private] |
int CompareToMedian::nBinsY [private] |