test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 594 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 598 of file QTest.h.

References _emptyBins, _max, _maxMed, _min, _minMed, _statCut, getAlgoName(), nBins, reset(), and QCriterion::setAlgoName().

598  : SimpleTest(name,true){
599  this->_min = 0.2;
600  this->_max = 3.0;
601  this->_emptyBins = 0;
602  this->_maxMed = 10;
603  this->_minMed = 0;
604  this->nBins = 0;
605  this->_statCut = 0;
606  reset();
608  };
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:77
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:137
float _statCut
Definition: QTest.h:634
int _emptyBins
Definition: QTest.h:632
static std::string getAlgoName(void)
Definition: QTest.h:612
float _minMed
Definition: QTest.h:633
float _maxMed
Definition: QTest.h:633
void reset()
Definition: QTest.h:643
float _max
Definition: QTest.h:631
float _min
Definition: QTest.h:631
CompareToMedian::~CompareToMedian ( )
inline

Definition at line 610 of file QTest.h.

610 {};

Member Function Documentation

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

Definition at line 643 of file QTest.h.

References binValues.

Referenced by CompareToMedian().

643 {binValues.clear();};
std::vector< float > binValues
Definition: QTest.h:641
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().

1264  {
1265  int32_t nbins=0, failed=0;
1266  badChannels_.clear();
1267 
1268  if (!me)
1269  return -1;
1270  if (!me->getRootObject())
1271  return -1;
1272  TH1* h=0;
1273 
1274  if (verbose_>1){
1275  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1276  << me-> getFullname() << "\n";
1277  std::cout << "\tMin = " << _min << "; Max = " << _max << "\n";
1278  std::cout << "\tMinMedian = " << _minMed << "; MaxMedian = " << _maxMed << "\n";
1279  std::cout << "\tUseEmptyBins = " << (_emptyBins?"Yes":"No" )<< "\n";
1280  }
1281 
1283  {
1284  h = me->getTProfile2D(); // access Test histo
1285  }
1286  else
1287  {
1288  if (verbose_>0)
1289  std::cout << "QTest:ContentsWithinExpected"
1290  << " ME does not contain TPROFILE2D, exiting\n";
1291  return -1;
1292  }
1293 
1294  nBinsX = h->GetNbinsX();
1295  nBinsY = h->GetNbinsY();
1296  int entries = 0;
1297  float median = 0.0;
1298 
1299  //Median calculated with partially sorted vector
1300  for (int binX = 1; binX <= nBinsX; binX++ ){
1301  reset();
1302  // Fill vector
1303  for (int binY = 1; binY <= nBinsY; binY++){
1304  int bin = h->GetBin(binX, binY);
1305  double content = (double)h->GetBinContent(bin);
1306  if ( content == 0 && !_emptyBins)
1307  continue;
1308  binValues.push_back(content);
1309  entries = me->getTProfile2D()->GetBinEntries(bin);
1310  }
1311  if (binValues.empty())
1312  continue;
1313  nbins+=binValues.size();
1314 
1315  //calculate median
1316  if(binValues.size()>0){
1317  int medPos = (int)binValues.size()/2;
1318  nth_element(binValues.begin(),binValues.begin()+medPos,binValues.end());
1319  median = *(binValues.begin()+medPos);
1320  }
1321 
1322  // if median == 0, use the absolute cut
1323  if(median == 0){
1324  if (verbose_ > 0){
1325  std::cout << "QTest: Median is 0; the fixed cuts: [" << _minMed << "; " << _maxMed << "] are used\n";
1326  }
1327  for(int binY = 1; binY <= nBinsY; binY++){
1328  int bin = h->GetBin(binX, binY);
1329  double content = (double)h->GetBinContent(bin);
1330  entries = me->getTProfile2D()->GetBinEntries(bin);
1331  if ( entries == 0 )
1332  continue;
1333  if (content > _maxMed || content < _minMed){
1334  DQMChannel chan(binX,binY, 0, content, h->GetBinError(bin));
1335  badChannels_.push_back(chan);
1336  failed++;
1337  }
1338  }
1339  continue;
1340  }
1341 
1342  //Cut on stat: will mask rings with no enought of statistics
1343  if (median*entries < _statCut )
1344  continue;
1345 
1346  // If median is off the absolute cuts, declare everything bad (if bin has non zero entries)
1347  if(median > _maxMed || median < _minMed){
1348  for(int binY = 1; binY <= nBinsY; binY++){
1349  int bin = h->GetBin(binX, binY);
1350  double content = (double)h->GetBinContent(bin);
1351  entries = me->getTProfile2D()->GetBinEntries(bin);
1352  if ( entries == 0 )
1353  continue;
1354  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1355  badChannels_.push_back(chan);
1356  failed++;
1357  }
1358  continue;
1359  }
1360 
1361  // Test itself
1362  float minCut = median*_min;
1363  float maxCut = median*_max;
1364  for(int binY = 1; binY <= nBinsY; binY++){
1365  int bin = h->GetBin(binX, binY);
1366  double content = (double)h->GetBinContent(bin);
1367  entries = me->getTProfile2D()->GetBinEntries(bin);
1368  if ( entries == 0 )
1369  continue;
1370  if (content > maxCut || content < minCut){
1371  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1372  badChannels_.push_back(chan);
1373  failed++;
1374  }
1375  }
1376  }
1377 
1378  if (nbins==0){
1379  if (verbose_ > 0)
1380  std::cout << "QTest:CompareToMedian: Histogram is empty" << std::endl;
1381  return 1.;
1382  }
1383  return 1 - (float)failed/nbins;
1384 }
TProfile2D * getTProfile2D(void) const
int verbose_
Definition: QTest.h:117
float _statCut
Definition: QTest.h:634
int _emptyBins
Definition: QTest.h:632
static std::string getAlgoName(void)
Definition: QTest.h:612
float _minMed
Definition: QTest.h:633
float _maxMed
Definition: QTest.h:633
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Kind kind(void) const
Get the type of the monitor element.
void reset()
Definition: QTest.h:643
std::vector< float > binValues
Definition: QTest.h:641
TObject * getRootObject(void) const
std::vector< DQMChannel > badChannels_
Definition: QTest.h:159
float _max
Definition: QTest.h:631
tuple cout
Definition: gather_cfg.py:121
float _min
Definition: QTest.h:631
void CompareToMedian::setEmptyBins ( int  eB)
inline

Definition at line 617 of file QTest.h.

References _emptyBins.

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Definition at line 616 of file QTest.h.

References _max, and bookConverter::max.

Referenced by QTestConfigure::EnableCompareToMedianTest().

616 {_max = max;};
float _max
Definition: QTest.h:631
void CompareToMedian::setMaxMedian ( float  max)
inline

Definition at line 618 of file QTest.h.

References _maxMed, and bookConverter::max.

Referenced by QTestConfigure::EnableCompareToMedianTest().

618 {_maxMed = max;};
float _maxMed
Definition: QTest.h:633
void CompareToMedian::setMessage ( void  )
inlineprotectedvirtual

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 623 of file QTest.h.

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

623  {
624  std::ostringstream message;
625  message << "Test " << qtname_ << " (" << algoName_
626  << "): Entry fraction within range = " << prob_;
627  message_ = message.str();
628  }
std::string algoName_
name of quality test
Definition: QTest.h:111
std::string qtname_
Definition: QTest.h:110
float prob_
name of algorithm
Definition: QTest.h:112
std::string message_
quality test status
Definition: QTest.h:114
void CompareToMedian::setMin ( float  min)
inline

Definition at line 615 of file QTest.h.

References _min, and min().

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Definition at line 619 of file QTest.h.

References _minMed, and min().

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Definition at line 620 of file QTest.h.

References _statCut.

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Member Data Documentation

int CompareToMedian::_emptyBins
private

Definition at line 632 of file QTest.h.

Referenced by CompareToMedian(), and setEmptyBins().

float CompareToMedian::_max
private

Definition at line 631 of file QTest.h.

Referenced by CompareToMedian(), generateEDF.LumiInfoCont::max(), and setMax().

float CompareToMedian::_maxMed
private

Definition at line 633 of file QTest.h.

Referenced by CompareToMedian(), and setMaxMedian().

float CompareToMedian::_min
private

Definition at line 631 of file QTest.h.

Referenced by CompareToMedian(), generateEDF.LumiInfoCont::min(), and setMin().

float CompareToMedian::_minMed
private

Definition at line 633 of file QTest.h.

Referenced by CompareToMedian(), and setMinMedian().

float CompareToMedian::_statCut
private

Definition at line 634 of file QTest.h.

Referenced by CompareToMedian(), and setStatCut().

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

Definition at line 641 of file QTest.h.

Referenced by reset().

int CompareToMedian::nBins
private

Definition at line 638 of file QTest.h.

Referenced by CompareToMedian().

int CompareToMedian::nBinsX
private

Definition at line 636 of file QTest.h.

int CompareToMedian::nBinsY
private

Definition at line 636 of file QTest.h.