CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
CompareToMedian Class Reference

#include <QTest.h>

Inheritance diagram for CompareToMedian:
SimpleTest QCriterion

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

Protected Member Functions

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)
 

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
 

Additional Inherited Members

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

Constructor & Destructor Documentation

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

Definition at line 627 of file QTest.h.

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

627  : SimpleTest(name,true){
628  this->_min = 0.2;
629  this->_max = 3.0;
630  this->_emptyBins = 0;
631  this->_maxMed = 10;
632  this->_minMed = 0;
633  this->nBins = 0;
634  this->_statCut = 0;
635  reset();
637  };
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:78
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:138
float _statCut
Definition: QTest.h:663
int _emptyBins
Definition: QTest.h:661
static std::string getAlgoName(void)
Definition: QTest.h:641
float _minMed
Definition: QTest.h:662
float _maxMed
Definition: QTest.h:662
void reset()
Definition: QTest.h:672
float _max
Definition: QTest.h:660
float _min
Definition: QTest.h:660
CompareToMedian::~CompareToMedian ( )
inline

Definition at line 639 of file QTest.h.

639 {};

Member Function Documentation

static std::string CompareToMedian::getAlgoName ( void  )
inlinestatic

Definition at line 641 of file QTest.h.

References QCriterion::runTest().

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

641 { return "CompareToMedian"; }
void CompareToMedian::reset ( void  )
inlineprivate

Definition at line 672 of file QTest.h.

672 {binValues.clear();};
std::vector< float > binValues
Definition: QTest.h:670
float CompareToMedian::runTest ( const MonitorElement me)
virtual

Reimplemented from QCriterion.

Definition at line 1375 of file QTest.cc.

References stringResolutionProvider_cfi::bin, officialStyle::chan, ws_sso_content_reader::content, gather_cfg::cout, MonitorElement::DQM_KIND_TPROFILE2D, runEdmFileComparison::failed, objects.autophobj::float, MonitorElement::getRootObject(), MonitorElement::getTProfile2D(), createfilelist::int, MonitorElement::kind(), pfDeepBoostedJetPreprocessParams_cfi::median, pileupCalc::nbins, and reset().

1375  {
1376  int32_t nbins=0, failed=0;
1377  badChannels_.clear();
1378 
1379  if (!me)
1380  return -1;
1381  if (!me->getRootObject())
1382  return -1;
1383  TH1* h=nullptr;
1384 
1385  if (verbose_>1){
1386  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1387  << me-> getFullname() << "\n";
1388  std::cout << "\tMin = " << _min << "; Max = " << _max << "\n";
1389  std::cout << "\tMinMedian = " << _minMed << "; MaxMedian = " << _maxMed << "\n";
1390  std::cout << "\tUseEmptyBins = " << (_emptyBins?"Yes":"No" )<< "\n";
1391  }
1392 
1394  {
1395  h = me->getTProfile2D(); // access Test histo
1396  }
1397  else
1398  {
1399  if (verbose_>0)
1400  std::cout << "QTest:ContentsWithinExpected"
1401  << " ME does not contain TPROFILE2D, exiting\n";
1402  return -1;
1403  }
1404 
1405  nBinsX = h->GetNbinsX();
1406  nBinsY = h->GetNbinsY();
1407  int entries = 0;
1408  float median = 0.0;
1409 
1410  //Median calculated with partially sorted vector
1411  for (int binX = 1; binX <= nBinsX; binX++ ){
1412  reset();
1413  // Fill vector
1414  for (int binY = 1; binY <= nBinsY; binY++){
1415  int bin = h->GetBin(binX, binY);
1416  double content = (double)h->GetBinContent(bin);
1417  if ( content == 0 && !_emptyBins)
1418  continue;
1419  binValues.push_back(content);
1420  entries = me->getTProfile2D()->GetBinEntries(bin);
1421  }
1422  if (binValues.empty())
1423  continue;
1424  nbins+=binValues.size();
1425 
1426  //calculate median
1427  if(!binValues.empty()){
1428  int medPos = (int)binValues.size()/2;
1429  nth_element(binValues.begin(),binValues.begin()+medPos,binValues.end());
1430  median = *(binValues.begin()+medPos);
1431  }
1432 
1433  // if median == 0, use the absolute cut
1434  if(median == 0){
1435  if (verbose_ > 0){
1436  std::cout << "QTest: Median is 0; the fixed cuts: [" << _minMed << "; " << _maxMed << "] are used\n";
1437  }
1438  for(int binY = 1; binY <= nBinsY; binY++){
1439  int bin = h->GetBin(binX, binY);
1440  double content = (double)h->GetBinContent(bin);
1441  entries = me->getTProfile2D()->GetBinEntries(bin);
1442  if ( entries == 0 )
1443  continue;
1444  if (content > _maxMed || content < _minMed){
1445  DQMChannel chan(binX,binY, 0, content, h->GetBinError(bin));
1446  badChannels_.push_back(chan);
1447  failed++;
1448  }
1449  }
1450  continue;
1451  }
1452 
1453  //Cut on stat: will mask rings with no enought of statistics
1454  if (median*entries < _statCut )
1455  continue;
1456 
1457  // If median is off the absolute cuts, declare everything bad (if bin has non zero entries)
1458  if(median > _maxMed || median < _minMed){
1459  for(int binY = 1; binY <= nBinsY; binY++){
1460  int bin = h->GetBin(binX, binY);
1461  double content = (double)h->GetBinContent(bin);
1462  entries = me->getTProfile2D()->GetBinEntries(bin);
1463  if ( entries == 0 )
1464  continue;
1465  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1466  badChannels_.push_back(chan);
1467  failed++;
1468  }
1469  continue;
1470  }
1471 
1472  // Test itself
1473  float minCut = median*_min;
1474  float maxCut = median*_max;
1475  for(int binY = 1; binY <= nBinsY; binY++){
1476  int bin = h->GetBin(binX, binY);
1477  double content = (double)h->GetBinContent(bin);
1478  entries = me->getTProfile2D()->GetBinEntries(bin);
1479  if ( entries == 0 )
1480  continue;
1481  if (content > maxCut || content < minCut){
1482  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1483  badChannels_.push_back(chan);
1484  failed++;
1485  }
1486  }
1487  }
1488 
1489  if (nbins==0){
1490  if (verbose_ > 0)
1491  std::cout << "QTest:CompareToMedian: Histogram is empty" << std::endl;
1492  return 1.;
1493  }
1494  return 1 - (float)failed/nbins;
1495 }
TProfile2D * getTProfile2D(void) const
int verbose_
Definition: QTest.h:118
float _statCut
Definition: QTest.h:663
int _emptyBins
Definition: QTest.h:661
static std::string getAlgoName(void)
Definition: QTest.h:641
float _minMed
Definition: QTest.h:662
float _maxMed
Definition: QTest.h:662
Kind kind(void) const
Get the type of the monitor element.
void reset()
Definition: QTest.h:672
bin
set the eta bin as selection string.
std::vector< float > binValues
Definition: QTest.h:670
TObject * getRootObject(void) const
std::vector< DQMChannel > badChannels_
Definition: QTest.h:160
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
float _max
Definition: QTest.h:660
float _min
Definition: QTest.h:660
void CompareToMedian::setEmptyBins ( int  eB)
inline

Definition at line 646 of file QTest.h.

Referenced by QTestConfigure::EnableCompareToMedianTest().

646 {eB > 0 ? _emptyBins = 1 : _emptyBins = 0;};
int _emptyBins
Definition: QTest.h:661
void CompareToMedian::setMax ( float  max)
inline

Definition at line 645 of file QTest.h.

References SiStripPI::max.

Referenced by QTestConfigure::EnableCompareToMedianTest().

void CompareToMedian::setMaxMedian ( float  max)
inline

Definition at line 647 of file QTest.h.

References SiStripPI::max.

Referenced by QTestConfigure::EnableCompareToMedianTest().

void CompareToMedian::setMessage ( void  )
inlineprotectedvirtual

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 652 of file QTest.h.

References QCriterion::algoName_, python.rootplot.argparse::message, QCriterion::message_, QCriterion::prob_, and QCriterion::qtname_.

652  {
653  std::ostringstream message;
654  message << "Test " << qtname_ << " (" << algoName_
655  << "): Entry fraction within range = " << prob_;
656  message_ = message.str();
657  }
std::string algoName_
name of quality test
Definition: QTest.h:112
std::string qtname_
Definition: QTest.h:111
float prob_
name of algorithm
Definition: QTest.h:113
std::string message_
quality test status
Definition: QTest.h:115
void CompareToMedian::setMin ( float  min)
inline

Definition at line 644 of file QTest.h.

References min().

Referenced by QTestConfigure::EnableCompareToMedianTest().

644 {_min = min;};
T min(T a, T b)
Definition: MathUtil.h:58
float _min
Definition: QTest.h:660
void CompareToMedian::setMinMedian ( float  min)
inline

Definition at line 648 of file QTest.h.

References min().

Referenced by QTestConfigure::EnableCompareToMedianTest().

648 {_minMed = min;};
float _minMed
Definition: QTest.h:662
T min(T a, T b)
Definition: MathUtil.h:58
void CompareToMedian::setStatCut ( float  cut)
inline

Definition at line 649 of file QTest.h.

Referenced by QTestConfigure::EnableCompareToMedianTest().

649 {_statCut = (cut > 0) ? cut : 0;};
float _statCut
Definition: QTest.h:663

Member Data Documentation

int CompareToMedian::_emptyBins
private

Definition at line 661 of file QTest.h.

float CompareToMedian::_max
private

Definition at line 660 of file QTest.h.

Referenced by generateEDF.LumiInfoCont::max().

float CompareToMedian::_maxMed
private

Definition at line 662 of file QTest.h.

float CompareToMedian::_min
private

Definition at line 660 of file QTest.h.

Referenced by generateEDF.LumiInfoCont::min().

float CompareToMedian::_minMed
private

Definition at line 662 of file QTest.h.

float CompareToMedian::_statCut
private

Definition at line 663 of file QTest.h.

std::vector<float> CompareToMedian::binValues
private

Definition at line 670 of file QTest.h.

int CompareToMedian::nBins
private

Definition at line 667 of file QTest.h.

int CompareToMedian::nBinsX
private

Definition at line 665 of file QTest.h.

int CompareToMedian::nBinsY
private

Definition at line 665 of file QTest.h.