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
 get test status (see Core/interface/DQMDefinitions.h) 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

- Public Types inherited from QCriterion
typedef dqm::legacy::MonitorElement MonitorElement
 (class should be created by DQMStore class) More...
 
- 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 399 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 401 of file QTest.h.

References QCriterion::setAlgoName().

401  : SimpleTest(name, true) {
402  checkMean_ = checkRMS_ = false;
403  minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0;
404  checkMeanTolerance_ = false;
405  toleranceMean_ = -1.0;
407  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:95
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:158
bool checkMeanTolerance_
Definition: QTest.h:426
static std::string getAlgoName()
Definition: QTest.h:408

Member Function Documentation

static std::string ContentsWithinExpected::getAlgoName ( )
inlinestatic
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 867 of file QTest.cc.

References funct::abs(), officialStyle::chan, gather_cfg::cout, dqm::impl::MonitorElement::getFullname(), dqm::legacy::MonitorElement::getRootObject(), dqm::legacy::MonitorElement::getTH2D(), dqm::legacy::MonitorElement::getTH2F(), dqm::legacy::MonitorElement::getTH2S(), dqm::legacy::MonitorElement::getTProfile(), dqm::legacy::MonitorElement::getTProfile2D(), h, dqm::impl::MonitorElement::kind(), SiStripPI::mean, SiStripPI::rms, MonitorElementData::TH2D, MonitorElementData::TH2F, MonitorElementData::TH2S, MonitorElementData::TPROFILE, and MonitorElementData::TPROFILE2D.

867  {
868  badChannels_.clear();
869  if (!me)
870  return -1;
871  if (!me->getRootObject())
872  return -1;
873  TH1* h = nullptr; //initialize histogram pointer
874 
875  if (verbose_ > 1)
876  std::cout << "QTest:" << getAlgoName() << "::runTest called on " << me->getFullname() << "\n";
877 
878  int ncx;
879  int ncy;
880 
881  if (useEmptyBins_) {
882  //-- TH2
883  if (me->kind() == MonitorElement::Kind::TH2F) {
884  ncx = me->getTH2F()->GetXaxis()->GetNbins();
885  ncy = me->getTH2F()->GetYaxis()->GetNbins();
886  h = me->getTH2F(); // access Test histo
887  }
888  //-- TH2S
889  else if (me->kind() == MonitorElement::Kind::TH2S) {
890  ncx = me->getTH2S()->GetXaxis()->GetNbins();
891  ncy = me->getTH2S()->GetYaxis()->GetNbins();
892  h = me->getTH2S(); // access Test histo
893  }
894  //-- TH2D
895  else if (me->kind() == MonitorElement::Kind::TH2D) {
896  ncx = me->getTH2D()->GetXaxis()->GetNbins();
897  ncy = me->getTH2D()->GetYaxis()->GetNbins();
898  h = me->getTH2D(); // access Test histo
899  }
900  //-- TProfile
901  else if (me->kind() == MonitorElement::Kind::TPROFILE) {
902  ncx = me->getTProfile()->GetXaxis()->GetNbins();
903  ncy = 1;
904  h = me->getTProfile(); // access Test histo
905  }
906  //-- TProfile2D
907  else if (me->kind() == MonitorElement::Kind::TPROFILE2D) {
908  ncx = me->getTProfile2D()->GetXaxis()->GetNbins();
909  ncy = me->getTProfile2D()->GetYaxis()->GetNbins();
910  h = me->getTProfile2D(); // access Test histo
911  } else {
912  if (verbose_ > 0)
913  std::cout << "QTest:ContentsWithinExpected"
914  << " ME does not contain TH2F/TH2S/TH2D/TPROFILE/TPROFILE2D, exiting\n";
915  return -1;
916  }
917 
918  int nsum = 0;
919  double sum = 0.0;
920  double average = 0.0;
921 
922  if (checkMeanTolerance_) { // calculate average value of all bin contents
923 
924  for (int cx = 1; cx <= ncx; ++cx) {
925  for (int cy = 1; cy <= ncy; ++cy) {
926  if (me->kind() == MonitorElement::Kind::TH2F) {
927  sum += h->GetBinContent(h->GetBin(cx, cy));
928  ++nsum;
929  } else if (me->kind() == MonitorElement::Kind::TH2S) {
930  sum += h->GetBinContent(h->GetBin(cx, cy));
931  ++nsum;
932  } else if (me->kind() == MonitorElement::Kind::TH2D) {
933  sum += h->GetBinContent(h->GetBin(cx, cy));
934  ++nsum;
935  } else if (me->kind() == MonitorElement::Kind::TPROFILE) {
936  if (me->getTProfile()->GetBinEntries(h->GetBin(cx)) >= minEntries_ / (ncx)) {
937  sum += h->GetBinContent(h->GetBin(cx));
938  ++nsum;
939  }
940  } else if (me->kind() == MonitorElement::Kind::TPROFILE2D) {
941  if (me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) >= minEntries_ / (ncx * ncy)) {
942  sum += h->GetBinContent(h->GetBin(cx, cy));
943  ++nsum;
944  }
945  }
946  }
947  }
948 
949  if (nsum > 0)
950  average = sum / nsum;
951 
952  } // calculate average value of all bin contents
953 
954  int fail = 0;
955 
956  for (int cx = 1; cx <= ncx; ++cx) {
957  for (int cy = 1; cy <= ncy; ++cy) {
958  bool failMean = false;
959  bool failRMS = false;
960  bool failMeanTolerance = false;
961 
962  if (me->kind() == MonitorElement::Kind::TPROFILE &&
963  me->getTProfile()->GetBinEntries(h->GetBin(cx)) < minEntries_ / (ncx))
964  continue;
965 
966  if (me->kind() == MonitorElement::Kind::TPROFILE2D &&
967  me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) < minEntries_ / (ncx * ncy))
968  continue;
969 
970  if (checkMean_) {
971  double mean = h->GetBinContent(h->GetBin(cx, cy));
972  failMean = (mean < minMean_ || mean > maxMean_);
973  }
974 
975  if (checkRMS_) {
976  double rms = h->GetBinError(h->GetBin(cx, cy));
977  failRMS = (rms < minRMS_ || rms > maxRMS_);
978  }
979 
980  if (checkMeanTolerance_) {
981  double mean = h->GetBinContent(h->GetBin(cx, cy));
982  failMeanTolerance = (std::abs(mean - average) > toleranceMean_ * std::abs(average));
983  }
984 
985  if (failMean || failRMS || failMeanTolerance) {
986  if (me->kind() == MonitorElement::Kind::TH2F) {
987  DQMChannel chan(cx, cy, 0, h->GetBinContent(h->GetBin(cx, cy)), h->GetBinError(h->GetBin(cx, cy)));
988  badChannels_.push_back(chan);
989  } else if (me->kind() == MonitorElement::Kind::TH2S) {
990  DQMChannel chan(cx, cy, 0, h->GetBinContent(h->GetBin(cx, cy)), h->GetBinError(h->GetBin(cx, cy)));
991  badChannels_.push_back(chan);
992  } else if (me->kind() == MonitorElement::Kind::TH2D) {
993  DQMChannel chan(cx, cy, 0, h->GetBinContent(h->GetBin(cx, cy)), h->GetBinError(h->GetBin(cx, cy)));
994  badChannels_.push_back(chan);
995  } else if (me->kind() == MonitorElement::Kind::TPROFILE) {
997  cx, cy, int(me->getTProfile()->GetBinEntries(h->GetBin(cx))), 0, h->GetBinError(h->GetBin(cx)));
998  badChannels_.push_back(chan);
999  } else if (me->kind() == MonitorElement::Kind::TPROFILE2D) {
1000  DQMChannel chan(cx,
1001  cy,
1002  int(me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy))),
1003  h->GetBinContent(h->GetBin(cx, cy)),
1004  h->GetBinError(h->GetBin(cx, cy)));
1005  badChannels_.push_back(chan);
1006  }
1007  ++fail;
1008  }
1009  }
1010  }
1011  return 1. * (ncx * ncy - fail) / (ncx * ncy);
1012  }
1013 
1014  else
1015  {
1016  if (me->kind() == MonitorElement::Kind::TH2F) {
1017  ncx = me->getTH2F()->GetXaxis()->GetNbins();
1018  ncy = me->getTH2F()->GetYaxis()->GetNbins();
1019  h = me->getTH2F(); // access Test histo
1020  } else if (me->kind() == MonitorElement::Kind::TH2S) {
1021  ncx = me->getTH2S()->GetXaxis()->GetNbins();
1022  ncy = me->getTH2S()->GetYaxis()->GetNbins();
1023  h = me->getTH2S(); // access Test histo
1024  } else if (me->kind() == MonitorElement::Kind::TH2D) {
1025  ncx = me->getTH2D()->GetXaxis()->GetNbins();
1026  ncy = me->getTH2D()->GetYaxis()->GetNbins();
1027  h = me->getTH2D(); // access Test histo
1028  } else {
1029  if (verbose_ > 0)
1030  std::cout << "QTest:ContentsWithinExpected AS"
1031  << " ME does not contain TH2F/TH2S/TH2D, exiting\n";
1032  return -1;
1033  }
1034 
1035  // if (!rangeInitialized_) return 0; // all accepted if no initialization
1036  int fail = 0;
1037  for (int cx = 1; cx <= ncx; ++cx) {
1038  for (int cy = 1; cy <= ncy; ++cy) {
1039  bool failure = false;
1040  double Content = h->GetBinContent(h->GetBin(cx, cy));
1041  if (Content)
1042  failure = (Content < minMean_ || Content > maxMean_);
1043  if (failure)
1044  ++fail;
1045  }
1046  }
1047  return 1. * (ncx * ncy - fail) / (ncx * ncy);
1048  }
1049 }
virtual TH2D * getTH2D() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
virtual TH2F * getTH2F() const
int verbose_
Definition: QTest.h:138
Kind kind() const
Get the type of the monitor element.
const std::string getFullname() const
get full name of ME including Pathname
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int useEmptyBins_
Definition: QTest.h:430
virtual TProfile2D * getTProfile2D() const
bool checkMeanTolerance_
Definition: QTest.h:426
virtual TH2S * getTH2S() const
static std::string getAlgoName()
Definition: QTest.h:408
virtual TProfile * getTProfile() const
std::vector< DQMChannel > badChannels_
Definition: QTest.h:173
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
TObject * getRootObject() const override
unsigned minEntries_
Definition: QTest.h:172
void ContentsWithinExpected::setMeanRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1051 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1051  {
1052  if (xmax < xmin)
1053  if (verbose_ > 0)
1054  std::cout << "QTest:ContentsWitinExpected"
1055  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1056  minMean_ = xmin;
1057  maxMean_ = xmax;
1058  checkMean_ = true;
1059 }
int verbose_
Definition: QTest.h:138
void ContentsWithinExpected::setMeanTolerance ( float  fracTolerance)
inline

set (fractional) tolerance for mean

Definition at line 416 of file QTest.h.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

416  {
417  if (fracTolerance >= 0.0) {
418  toleranceMean_ = fracTolerance;
419  checkMeanTolerance_ = true;
420  }
421  }
bool checkMeanTolerance_
Definition: QTest.h:426
void ContentsWithinExpected::setRMSRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1062 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1062  {
1063  if (xmax < xmin)
1064  if (verbose_ > 0)
1065  std::cout << "QTest:ContentsWitinExpected"
1066  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1067  minRMS_ = xmin;
1068  maxRMS_ = xmax;
1069  checkRMS_ = true;
1070 }
int verbose_
Definition: QTest.h:138
void ContentsWithinExpected::setUseEmptyBins ( unsigned int  useEmptyBins)
inline

Member Data Documentation

bool ContentsWithinExpected::checkMean_
protected

Definition at line 424 of file QTest.h.

bool ContentsWithinExpected::checkMeanTolerance_
protected

Definition at line 426 of file QTest.h.

bool ContentsWithinExpected::checkRMS_
protected

Definition at line 425 of file QTest.h.

float ContentsWithinExpected::maxMean_
protected

Definition at line 428 of file QTest.h.

float ContentsWithinExpected::maxRMS_
protected

Definition at line 429 of file QTest.h.

float ContentsWithinExpected::minMean_
protected

Definition at line 428 of file QTest.h.

float ContentsWithinExpected::minRMS_
protected

Definition at line 429 of file QTest.h.

float ContentsWithinExpected::toleranceMean_
protected

Definition at line 427 of file QTest.h.

unsigned int ContentsWithinExpected::useEmptyBins_
protected

Definition at line 430 of file QTest.h.