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

Constructor & Destructor Documentation

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

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

Definition at line 609 of file QTest.h.

609 {};

Member Function Documentation

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

Definition at line 642 of file QTest.h.

References binValues.

Referenced by CompareToMedian().

642 {binValues.clear();};
std::vector< float > binValues
Definition: QTest.h:640
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:116
float _statCut
Definition: QTest.h:633
int _emptyBins
Definition: QTest.h:631
static std::string getAlgoName(void)
Definition: QTest.h:611
float _minMed
Definition: QTest.h:632
float _maxMed
Definition: QTest.h:632
Kind kind(void) const
Get the type of the monitor element.
void reset()
Definition: QTest.h:642
std::vector< float > binValues
Definition: QTest.h:640
TObject * getRootObject(void) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< DQMChannel > badChannels_
Definition: QTest.h:158
float _max
Definition: QTest.h:630
tuple cout
Definition: gather_cfg.py:121
float _min
Definition: QTest.h:630
void CompareToMedian::setEmptyBins ( int  eB)
inline

Definition at line 616 of file QTest.h.

References _emptyBins.

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Definition at line 615 of file QTest.h.

References _max, and max().

Referenced by QTestConfigure::EnableCompareToMedianTest().

615 {_max = max;};
const T & max(const T &a, const T &b)
float _max
Definition: QTest.h:630
void CompareToMedian::setMaxMedian ( float  max)
inline

Definition at line 617 of file QTest.h.

References _maxMed, and max().

Referenced by QTestConfigure::EnableCompareToMedianTest().

617 {_maxMed = max;};
const T & max(const T &a, const T &b)
float _maxMed
Definition: QTest.h:632
void CompareToMedian::setMessage ( void  )
inlineprotectedvirtual

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_.

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

Definition at line 614 of file QTest.h.

References _min, and min.

Referenced by QTestConfigure::EnableCompareToMedianTest().

614 {_min = min;};
#define min(a, b)
Definition: mlp_lapack.h:161
float _min
Definition: QTest.h:630
void CompareToMedian::setMinMedian ( float  min)
inline

Definition at line 618 of file QTest.h.

References _minMed, and min.

Referenced by QTestConfigure::EnableCompareToMedianTest().

618 {_minMed = min;};
#define min(a, b)
Definition: mlp_lapack.h:161
float _minMed
Definition: QTest.h:632
void CompareToMedian::setStatCut ( float  cut)
inline

Definition at line 619 of file QTest.h.

References _statCut.

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Member Data Documentation

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(), generateEDF.LumiInfoCont::max(), 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(), generateEDF.LumiInfoCont::min(), 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

Definition at line 640 of file QTest.h.

Referenced by reset().

int CompareToMedian::nBins
private

Definition at line 637 of file QTest.h.

Referenced by CompareToMedian().

int CompareToMedian::nBinsX
private

Definition at line 635 of file QTest.h.

int CompareToMedian::nBinsY
private

Definition at line 635 of file QTest.h.