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) override
 
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 () override=default
 
- Public Member Functions inherited from SimpleTest
std::vector< DQMChannelgetBadChannels () const override
 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 () const
 get algorithm name More...
 
std::string getMessage () const
 get message attached to test More...
 
std::string getName () const
 get name of quality test More...
 
int getStatus () 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 ()
 

Protected Member Functions

void setMessage () override
 set status & message after test has run More...
 
- Protected Member Functions inherited from QCriterion
void init ()
 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 ()=default
 

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

Constructor & Destructor Documentation

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

Definition at line 721 of file QTest.h.

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

721  : SimpleTest(name,true){
722  this->_min = 0.2;
723  this->_max = 3.0;
724  this->_emptyBins = 0;
725  this->_maxMed = 10;
726  this->_minMed = 0;
727  this->nBins = 0;
728  this->_statCut = 0;
729  reset();
731  };
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:80
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:140
float _statCut
Definition: QTest.h:757
int _emptyBins
Definition: QTest.h:755
static std::string getAlgoName()
Definition: QTest.h:735
float _minMed
Definition: QTest.h:756
float _maxMed
Definition: QTest.h:756
void reset()
Definition: QTest.h:766
float _max
Definition: QTest.h:754
float _min
Definition: QTest.h:754
CompareToMedian::~CompareToMedian ( )
overridedefault

Member Function Documentation

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

Definition at line 735 of file QTest.h.

References QCriterion::runTest().

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

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

Definition at line 766 of file QTest.h.

766 {binValues.clear();};
std::vector< float > binValues
Definition: QTest.h:764
float CompareToMedian::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 1852 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(), h, createfilelist::int, MonitorElement::kind(), pfParticleNetPreprocessParams_cfi::median, pileupCalc::nbins, and reset().

1852  {
1853  int32_t nbins=0, failed=0;
1854  badChannels_.clear();
1855 
1856  if (!me)
1857  return -1;
1858  if (!me->getRootObject())
1859  return -1;
1860  TH1* h=nullptr;
1861 
1862  if (verbose_>1){
1863  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1864  << me-> getFullname() << "\n";
1865  std::cout << "\tMin = " << _min << "; Max = " << _max << "\n";
1866  std::cout << "\tMinMedian = " << _minMed << "; MaxMedian = " << _maxMed << "\n";
1867  std::cout << "\tUseEmptyBins = " << (_emptyBins?"Yes":"No" )<< "\n";
1868  }
1869 
1871  {
1872  h = me->getTProfile2D(); // access Test histo
1873  }
1874  else
1875  {
1876  if (verbose_>0)
1877  std::cout << "QTest:ContentsWithinExpected"
1878  << " ME does not contain TPROFILE2D, exiting\n";
1879  return -1;
1880  }
1881 
1882  nBinsX = h->GetNbinsX();
1883  nBinsY = h->GetNbinsY();
1884  int entries = 0;
1885  float median = 0.0;
1886 
1887  //Median calculated with partially sorted vector
1888  for (int binX = 1; binX <= nBinsX; binX++ ){
1889  reset();
1890  // Fill vector
1891  for (int binY = 1; binY <= nBinsY; binY++){
1892  int bin = h->GetBin(binX, binY);
1893  auto content = (double)h->GetBinContent(bin);
1894  if ( content == 0 && !_emptyBins)
1895  continue;
1896  binValues.push_back(content);
1897  entries = me->getTProfile2D()->GetBinEntries(bin);
1898  }
1899  if (binValues.empty())
1900  continue;
1901  nbins+=binValues.size();
1902 
1903  //calculate median
1904  if(!binValues.empty()){
1905  int medPos = (int)binValues.size()/2;
1906  nth_element(binValues.begin(),binValues.begin()+medPos,binValues.end());
1907  median = *(binValues.begin()+medPos);
1908  }
1909 
1910  // if median == 0, use the absolute cut
1911  if(median == 0){
1912  if (verbose_ > 0){
1913  std::cout << "QTest: Median is 0; the fixed cuts: [" << _minMed << "; " << _maxMed << "] are used\n";
1914  }
1915  for(int binY = 1; binY <= nBinsY; binY++){
1916  int bin = h->GetBin(binX, binY);
1917  auto content = (double)h->GetBinContent(bin);
1918  entries = me->getTProfile2D()->GetBinEntries(bin);
1919  if ( entries == 0 )
1920  continue;
1921  if (content > _maxMed || content < _minMed){
1922  DQMChannel chan(binX,binY, 0, content, h->GetBinError(bin));
1923  badChannels_.push_back(chan);
1924  failed++;
1925  }
1926  }
1927  continue;
1928  }
1929 
1930  //Cut on stat: will mask rings with no enought of statistics
1931  if (median*entries < _statCut )
1932  continue;
1933 
1934  // If median is off the absolute cuts, declare everything bad (if bin has non zero entries)
1935  if(median > _maxMed || median < _minMed){
1936  for(int binY = 1; binY <= nBinsY; binY++){
1937  int bin = h->GetBin(binX, binY);
1938  auto content = (double)h->GetBinContent(bin);
1939  entries = me->getTProfile2D()->GetBinEntries(bin);
1940  if ( entries == 0 )
1941  continue;
1942  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1943  badChannels_.push_back(chan);
1944  failed++;
1945  }
1946  continue;
1947  }
1948 
1949  // Test itself
1950  float minCut = median*_min;
1951  float maxCut = median*_max;
1952  for(int binY = 1; binY <= nBinsY; binY++){
1953  int bin = h->GetBin(binX, binY);
1954  auto content = (double)h->GetBinContent(bin);
1955  entries = me->getTProfile2D()->GetBinEntries(bin);
1956  if ( entries == 0 )
1957  continue;
1958  if (content > maxCut || content < minCut){
1959  DQMChannel chan(binX,binY, 0, content/median, h->GetBinError(bin));
1960  badChannels_.push_back(chan);
1961  failed++;
1962  }
1963  }
1964  }
1965 
1966  if (nbins==0){
1967  if (verbose_ > 0)
1968  std::cout << "QTest:CompareToMedian: Histogram is empty" << std::endl;
1969  return 1.;
1970  }
1971  return 1 - (float)failed/nbins;
1972 }
TProfile2D * getTProfile2D() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int verbose_
Definition: QTest.h:120
float _statCut
Definition: QTest.h:757
TObject * getRootObject() const
int _emptyBins
Definition: QTest.h:755
static std::string getAlgoName()
Definition: QTest.h:735
float _minMed
Definition: QTest.h:756
float _maxMed
Definition: QTest.h:756
void reset()
Definition: QTest.h:766
bin
set the eta bin as selection string.
std::vector< float > binValues
Definition: QTest.h:764
std::vector< DQMChannel > badChannels_
Definition: QTest.h:162
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:754
Kind kind() const
Get the type of the monitor element.
float _min
Definition: QTest.h:754
void CompareToMedian::setEmptyBins ( int  eB)
inline

Definition at line 740 of file QTest.h.

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Definition at line 739 of file QTest.h.

References SiStripPI::max.

Referenced by QTestConfigure::EnableCompareToMedianTest().

void CompareToMedian::setMaxMedian ( float  max)
inline

Definition at line 741 of file QTest.h.

References SiStripPI::max.

Referenced by QTestConfigure::EnableCompareToMedianTest().

void CompareToMedian::setMessage ( )
inlineoverrideprotectedvirtual

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 746 of file QTest.h.

References QCriterion::algoName_, QCriterion::message_, QCriterion::prob_, and QCriterion::qtname_.

746  {
747  std::ostringstream message;
748  message << "Test " << qtname_ << " (" << algoName_
749  << "): Entry fraction within range = " << prob_;
750  message_ = message.str();
751  }
std::string algoName_
name of quality test
Definition: QTest.h:114
std::string qtname_
Definition: QTest.h:113
float prob_
name of algorithm
Definition: QTest.h:115
std::string message_
quality test status
Definition: QTest.h:117
void CompareToMedian::setMin ( float  min)
inline

Definition at line 738 of file QTest.h.

References min().

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Definition at line 742 of file QTest.h.

References min().

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Definition at line 743 of file QTest.h.

Referenced by QTestConfigure::EnableCompareToMedianTest().

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

Member Data Documentation

int CompareToMedian::_emptyBins
private

Definition at line 755 of file QTest.h.

float CompareToMedian::_max
private

Definition at line 754 of file QTest.h.

Referenced by generateEDF.LumiInfoCont::max().

float CompareToMedian::_maxMed
private

Definition at line 756 of file QTest.h.

float CompareToMedian::_min
private

Definition at line 754 of file QTest.h.

Referenced by generateEDF.LumiInfoCont::min().

float CompareToMedian::_minMed
private

Definition at line 756 of file QTest.h.

float CompareToMedian::_statCut
private

Definition at line 757 of file QTest.h.

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

Definition at line 764 of file QTest.h.

int CompareToMedian::nBins
private

Definition at line 761 of file QTest.h.

int CompareToMedian::nBinsX
private

Definition at line 759 of file QTest.h.

int CompareToMedian::nBinsY
private

Definition at line 759 of file QTest.h.