CMS 3D CMS Logo

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

#include <QTest.h>

Inheritance diagram for ContentsWithinExpected:
SimpleTest QCriterion

Public Member Functions

 ContentsWithinExpected (const std::string &name)
 
float runTest (const MonitorElement *me) override
 
void setMeanRange (double xmin, double xmax)
 set expected value for mean More...
 
void setMeanTolerance (float fracTolerance)
 set (fractional) tolerance for mean More...
 
void setRMSRange (double xmin, double xmax)
 set expected value for mean More...
 
void setUseEmptyBins (unsigned int useEmptyBins)
 
- 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 Attributes

bool checkMean_
 
bool checkMeanTolerance_
 
bool checkRMS_
 
float maxMean_
 
float maxRMS_
 
float minMean_
 
float minRMS_
 
float toleranceMean_
 
unsigned int useEmptyBins_
 
- 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...
 

Additional Inherited Members

- Protected Member Functions inherited from SimpleTest
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
 

Detailed Description

Definition at line 473 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 476 of file QTest.h.

References QCriterion::setAlgoName().

476  : SimpleTest(name,true)
477  {
478  checkMean_ = checkRMS_ = false;
479  minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0;
480  checkMeanTolerance_ = false;
481  toleranceMean_ = -1.0;
483  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:80
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:140
bool checkMeanTolerance_
Definition: QTest.h:506
static std::string getAlgoName()
Definition: QTest.h:484

Member Function Documentation

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

Definition at line 484 of file QTest.h.

References QCriterion::runTest().

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

484 { return "ContentsWithinExpected"; }
float ContentsWithinExpected::runTest ( const MonitorElement me)
overridevirtual

end of normal Test

AS quality test !!!

end of AS quality test

Reimplemented from QCriterion.

Definition at line 1460 of file QTest.cc.

References funct::abs(), officialStyle::chan, gather_cfg::cout, MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::DQM_KIND_TPROFILE2D, cmsPerfPublish::fail(), MonitorElement::getRootObject(), MonitorElement::getTH2D(), MonitorElement::getTH2F(), MonitorElement::getTH2S(), MonitorElement::getTProfile(), MonitorElement::getTProfile2D(), h, MonitorElement::kind(), SiStripPI::mean, and SiStripPI::rms.

1461 {
1462  badChannels_.clear();
1463  if (!me)
1464  return -1;
1465  if (!me->getRootObject())
1466  return -1;
1467  TH1* h=nullptr; //initialize histogram pointer
1468 
1469  if (verbose_>1)
1470  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
1471  << me-> getFullname() << "\n";
1472 
1473  int ncx;
1474  int ncy;
1475 
1476  if (useEmptyBins_)
1477  {
1478  //-- TH2
1480  {
1481  ncx = me->getTH2F()->GetXaxis()->GetNbins();
1482  ncy = me->getTH2F()->GetYaxis()->GetNbins();
1483  h = me->getTH2F(); // access Test histo
1484  }
1485  //-- TH2S
1486  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
1487  {
1488  ncx = me->getTH2S()->GetXaxis()->GetNbins();
1489  ncy = me->getTH2S()->GetYaxis()->GetNbins();
1490  h = me->getTH2S(); // access Test histo
1491  }
1492  //-- TH2D
1493  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
1494  {
1495  ncx = me->getTH2D()->GetXaxis()->GetNbins();
1496  ncy = me->getTH2D()->GetYaxis()->GetNbins();
1497  h = me->getTH2D(); // access Test histo
1498  }
1499  //-- TProfile
1500  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE)
1501  {
1502  ncx = me->getTProfile()->GetXaxis()->GetNbins();
1503  ncy = 1;
1504  h = me->getTProfile(); // access Test histo
1505  }
1506  //-- TProfile2D
1507  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE2D)
1508  {
1509  ncx = me->getTProfile2D()->GetXaxis()->GetNbins();
1510  ncy = me->getTProfile2D()->GetYaxis()->GetNbins();
1511  h = me->getTProfile2D(); // access Test histo
1512  }
1513  else
1514  {
1515  if (verbose_>0)
1516  std::cout << "QTest:ContentsWithinExpected"
1517  << " ME does not contain TH2F/TH2S/TH2D/TPROFILE/TPROFILE2D, exiting\n";
1518  return -1;
1519  }
1520 
1521  int nsum = 0;
1522  double sum = 0.0;
1523  double average = 0.0;
1524 
1525  if (checkMeanTolerance_)
1526  { // calculate average value of all bin contents
1527 
1528  for (int cx = 1; cx <= ncx; ++cx)
1529  {
1530  for (int cy = 1; cy <= ncy; ++cy)
1531  {
1532  if (me->kind() == MonitorElement::DQM_KIND_TH2F)
1533  {
1534  sum += h->GetBinContent(h->GetBin(cx, cy));
1535  ++nsum;
1536  }
1537  else if (me->kind() == MonitorElement::DQM_KIND_TH2S)
1538  {
1539  sum += h->GetBinContent(h->GetBin(cx, cy));
1540  ++nsum;
1541  }
1542  else if (me->kind() == MonitorElement::DQM_KIND_TH2D)
1543  {
1544  sum += h->GetBinContent(h->GetBin(cx, cy));
1545  ++nsum;
1546  }
1547  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE)
1548  {
1549  if (me->getTProfile()->GetBinEntries(h->GetBin(cx)) >= minEntries_/(ncx))
1550  {
1551  sum += h->GetBinContent(h->GetBin(cx));
1552  ++nsum;
1553  }
1554  }
1555  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D)
1556  {
1557  if (me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) >= minEntries_/(ncx*ncy))
1558  {
1559  sum += h->GetBinContent(h->GetBin(cx, cy));
1560  ++nsum;
1561  }
1562  }
1563  }
1564  }
1565 
1566  if (nsum > 0)
1567  average = sum/nsum;
1568 
1569  } // calculate average value of all bin contents
1570 
1571  int fail = 0;
1572 
1573  for (int cx = 1; cx <= ncx; ++cx)
1574  {
1575  for (int cy = 1; cy <= ncy; ++cy)
1576  {
1577  bool failMean = false;
1578  bool failRMS = false;
1579  bool failMeanTolerance = false;
1580 
1581  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE &&
1582  me->getTProfile()->GetBinEntries(h->GetBin(cx)) < minEntries_/(ncx))
1583  continue;
1584 
1585  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D &&
1586  me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) < minEntries_/(ncx*ncy))
1587  continue;
1588 
1589  if (checkMean_)
1590  {
1591  double mean = h->GetBinContent(h->GetBin(cx, cy));
1592  failMean = (mean < minMean_ || mean > maxMean_);
1593  }
1594 
1595  if (checkRMS_)
1596  {
1597  double rms = h->GetBinError(h->GetBin(cx, cy));
1598  failRMS = (rms < minRMS_ || rms > maxRMS_);
1599  }
1600 
1601  if (checkMeanTolerance_)
1602  {
1603  double mean = h->GetBinContent(h->GetBin(cx, cy));
1604  failMeanTolerance = (std::abs(mean - average) > toleranceMean_*std::abs(average));
1605  }
1606 
1607  if (failMean || failRMS || failMeanTolerance)
1608  {
1609 
1610  if (me->kind() == MonitorElement::DQM_KIND_TH2F)
1611  {
1612  DQMChannel chan(cx, cy, 0,
1613  h->GetBinContent(h->GetBin(cx, cy)),
1614  h->GetBinError(h->GetBin(cx, cy)));
1615  badChannels_.push_back(chan);
1616  }
1617  else if (me->kind() == MonitorElement::DQM_KIND_TH2S)
1618  {
1619  DQMChannel chan(cx, cy, 0,
1620  h->GetBinContent(h->GetBin(cx, cy)),
1621  h->GetBinError(h->GetBin(cx, cy)));
1622  badChannels_.push_back(chan);
1623  }
1624  else if (me->kind() == MonitorElement::DQM_KIND_TH2D)
1625  {
1626  DQMChannel chan(cx, cy, 0,
1627  h->GetBinContent(h->GetBin(cx, cy)),
1628  h->GetBinError(h->GetBin(cx, cy)));
1629  badChannels_.push_back(chan);
1630  }
1631  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE)
1632  {
1633  DQMChannel chan(cx, cy, int(me->getTProfile()->GetBinEntries(h->GetBin(cx))),
1634  0,
1635  h->GetBinError(h->GetBin(cx)));
1636  badChannels_.push_back(chan);
1637  }
1638  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D)
1639  {
1640  DQMChannel chan(cx, cy, int(me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy))),
1641  h->GetBinContent(h->GetBin(cx, cy)),
1642  h->GetBinError(h->GetBin(cx, cy)));
1643  badChannels_.push_back(chan);
1644  }
1645  ++fail;
1646  }
1647  }
1648  }
1649  return 1.*(ncx*ncy - fail)/(ncx*ncy);
1650  }
1651 
1652  else
1653  {
1655  {
1656  ncx = me->getTH2F()->GetXaxis()->GetNbins();
1657  ncy = me->getTH2F()->GetYaxis()->GetNbins();
1658  h = me->getTH2F(); // access Test histo
1659  }
1660  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
1661  {
1662  ncx = me->getTH2S()->GetXaxis()->GetNbins();
1663  ncy = me->getTH2S()->GetYaxis()->GetNbins();
1664  h = me->getTH2S(); // access Test histo
1665  }
1666  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
1667  {
1668  ncx = me->getTH2D()->GetXaxis()->GetNbins();
1669  ncy = me->getTH2D()->GetYaxis()->GetNbins();
1670  h = me->getTH2D(); // access Test histo
1671  }
1672  else
1673  {
1674  if (verbose_>0)
1675  std::cout << "QTest:ContentsWithinExpected AS"
1676  << " ME does not contain TH2F/TH2S/TH2D, exiting\n";
1677  return -1;
1678  }
1679 
1680  // if (!rangeInitialized_) return 0; // all accepted if no initialization
1681  int fail = 0;
1682  for (int cx = 1; cx <= ncx; ++cx)
1683  {
1684  for (int cy = 1; cy <= ncy; ++cy)
1685  {
1686  bool failure = false;
1687  double Content = h->GetBinContent(h->GetBin(cx, cy));
1688  if (Content)
1689  failure = (Content < minMean_ || Content > maxMean_);
1690  if (failure)
1691  ++fail;
1692  }
1693  }
1694  return 1.*(ncx*ncy-fail)/(ncx*ncy);
1695  }
1696 
1697 }
TProfile * getTProfile() const
TProfile2D * getTProfile2D() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
TH2S * getTH2S() const
int verbose_
Definition: QTest.h:120
TObject * getRootObject() const
TH2D * getTH2D() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int useEmptyBins_
Definition: QTest.h:510
bool checkMeanTolerance_
Definition: QTest.h:506
TH2F * getTH2F() const
static std::string getAlgoName()
Definition: QTest.h:484
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...
unsigned minEntries_
Definition: QTest.h:161
def fail(errstr="")
Kind kind() const
Get the type of the monitor element.
void ContentsWithinExpected::setMeanRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1699 of file QTest.cc.

References gather_cfg::cout, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1700 {
1701  if (xmax < xmin)
1702  if (verbose_>0)
1703  std::cout << "QTest:ContentsWitinExpected"
1704  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1705  minMean_ = xmin;
1706  maxMean_ = xmax;
1707  checkMean_ = true;
1708 }
int verbose_
Definition: QTest.h:120
void ContentsWithinExpected::setMeanTolerance ( float  fracTolerance)
inline

set (fractional) tolerance for mean

Definition at line 494 of file QTest.h.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

495  {
496  if (fracTolerance >= 0.0)
497  {
498  toleranceMean_ = fracTolerance;
499  checkMeanTolerance_ = true;
500  }
501  }
bool checkMeanTolerance_
Definition: QTest.h:506
void ContentsWithinExpected::setRMSRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1711 of file QTest.cc.

References gather_cfg::cout, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1712 {
1713  if (xmax < xmin)
1714  if (verbose_>0)
1715  std::cout << "QTest:ContentsWitinExpected"
1716  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1717  minRMS_ = xmin;
1718  maxRMS_ = xmax;
1719  checkRMS_ = true;
1720 }
int verbose_
Definition: QTest.h:120
void ContentsWithinExpected::setUseEmptyBins ( unsigned int  useEmptyBins)
inline

Definition at line 487 of file QTest.h.

References TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

487  {
488  useEmptyBins_ = useEmptyBins;
489  }
unsigned int useEmptyBins_
Definition: QTest.h:510

Member Data Documentation

bool ContentsWithinExpected::checkMean_
protected

Definition at line 504 of file QTest.h.

bool ContentsWithinExpected::checkMeanTolerance_
protected

Definition at line 506 of file QTest.h.

bool ContentsWithinExpected::checkRMS_
protected

Definition at line 505 of file QTest.h.

float ContentsWithinExpected::maxMean_
protected

Definition at line 508 of file QTest.h.

float ContentsWithinExpected::maxRMS_
protected

Definition at line 509 of file QTest.h.

float ContentsWithinExpected::minMean_
protected

Definition at line 508 of file QTest.h.

float ContentsWithinExpected::minRMS_
protected

Definition at line 509 of file QTest.h.

float ContentsWithinExpected::toleranceMean_
protected

Definition at line 507 of file QTest.h.

unsigned int ContentsWithinExpected::useEmptyBins_
protected

Definition at line 510 of file QTest.h.