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 1365 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(), pileupCalc::nbins, and reset().

1365  {
1366  int32_t nbins=0, failed=0;
1367  badChannels_.clear();
1368 
1369  if (!me)
1370  return -1;
1371  if (!me->getRootObject())
1372  return -1;
1373  TH1* h=0;
1374 
1375  if (verbose_>1){
1376  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1377  << me-> getFullname() << "\n";
1378  std::cout << "\tMin = " << _min << "; Max = " << _max << "\n";
1379  std::cout << "\tMinMedian = " << _minMed << "; MaxMedian = " << _maxMed << "\n";
1380  std::cout << "\tUseEmptyBins = " << (_emptyBins?"Yes":"No" )<< "\n";
1381  }
1382 
1384  {
1385  h = me->getTProfile2D(); // access Test histo
1386  }
1387  else
1388  {
1389  if (verbose_>0)
1390  std::cout << "QTest:ContentsWithinExpected"
1391  << " ME does not contain TPROFILE2D, exiting\n";
1392  return -1;
1393  }
1394 
1395  nBinsX = h->GetNbinsX();
1396  nBinsY = h->GetNbinsY();
1397  int entries = 0;
1398  float median = 0.0;
1399 
1400  //Median calculated with partially sorted vector
1401  for (int binX = 1; binX <= nBinsX; binX++ ){
1402  reset();
1403  // Fill vector
1404  for (int binY = 1; binY <= nBinsY; binY++){
1405  int bin = h->GetBin(binX, binY);
1406  double content = (double)h->GetBinContent(bin);
1407  if ( content == 0 && !_emptyBins)
1408  continue;
1409  binValues.push_back(content);
1410  entries = me->getTProfile2D()->GetBinEntries(bin);
1411  }
1412  if (binValues.empty())
1413  continue;
1414  nbins+=binValues.size();
1415 
1416  //calculate median
1417  if(binValues.size()>0){
1418  int medPos = (int)binValues.size()/2;
1419  nth_element(binValues.begin(),binValues.begin()+medPos,binValues.end());
1420  median = *(binValues.begin()+medPos);
1421  }
1422 
1423  // if median == 0, use the absolute cut
1424  if(median == 0){
1425  if (verbose_ > 0){
1426  std::cout << "QTest: Median is 0; the fixed cuts: [" << _minMed << "; " << _maxMed << "] are used\n";
1427  }
1428  for(int binY = 1; binY <= nBinsY; binY++){
1429  int bin = h->GetBin(binX, binY);
1430  double content = (double)h->GetBinContent(bin);
1431  entries = me->getTProfile2D()->GetBinEntries(bin);
1432  if ( entries == 0 )
1433  continue;
1434  if (content > _maxMed || content < _minMed){
1435  DQMChannel chan(binX,binY, 0, content, h->GetBinError(bin));
1436  badChannels_.push_back(chan);
1437  failed++;
1438  }
1439  }
1440  continue;
1441  }
1442 
1443  //Cut on stat: will mask rings with no enought of statistics
1444  if (median*entries < _statCut )
1445  continue;
1446 
1447  // If median is off the absolute cuts, declare everything bad (if bin has non zero entries)
1448  if(median > _maxMed || median < _minMed){
1449  for(int binY = 1; binY <= nBinsY; binY++){
1450  int bin = h->GetBin(binX, binY);
1451  double content = (double)h->GetBinContent(bin);
1452  entries = me->getTProfile2D()->GetBinEntries(bin);
1453  if ( entries == 0 )
1454  continue;
1455  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1456  badChannels_.push_back(chan);
1457  failed++;
1458  }
1459  continue;
1460  }
1461 
1462  // Test itself
1463  float minCut = median*_min;
1464  float maxCut = median*_max;
1465  for(int binY = 1; binY <= nBinsY; binY++){
1466  int bin = h->GetBin(binX, binY);
1467  double content = (double)h->GetBinContent(bin);
1468  entries = me->getTProfile2D()->GetBinEntries(bin);
1469  if ( entries == 0 )
1470  continue;
1471  if (content > maxCut || content < minCut){
1472  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1473  badChannels_.push_back(chan);
1474  failed++;
1475  }
1476  }
1477  }
1478 
1479  if (nbins==0){
1480  if (verbose_ > 0)
1481  std::cout << "QTest:CompareToMedian: Histogram is empty" << std::endl;
1482  return 1.;
1483  }
1484  return 1 - (float)failed/nbins;
1485 }
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 hpstanc_transforms::max.

Referenced by QTestConfigure::EnableCompareToMedianTest().

void CompareToMedian::setMaxMedian ( float  max)
inline

Definition at line 647 of file QTest.h.

References hpstanc_transforms::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.