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 More...
 
void init ()
 initialize values More...
 
 QCriterion (std::string qtname)
 
float runTest (const MonitorElement *me, QReport &qr, DQMNet::QValue &qv)
 
void setErrorProb (float prob)
 
void setWarningProb (float prob)
 set probability limit for warning and error (default: 90% and 50%) More...
 
virtual ~QCriterion ()=default
 

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...
 
- Static Public Attributes inherited from QCriterion
static const float ERROR_PROB_THRESHOLD = 0.50
 
static const float WARNING_PROB_THRESHOLD = 0.90
 default "probability" values for setting warnings & errors when running tests 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 setAlgoName (std::string name)
 set algorithm name More...
 
void setVerbose (int verbose)
 probability limits for warnings, errors More...
 

Detailed Description

Definition at line 365 of file QTest.h.

Constructor & Destructor Documentation

◆ ContentsWithinExpected()

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

Definition at line 367 of file QTest.h.

References checkMean_, checkMeanTolerance_, checkRMS_, getAlgoName(), maxMean_, maxRMS_, minMean_, minRMS_, QCriterion::setAlgoName(), and toleranceMean_.

367  : SimpleTest(name, true) {
368  checkMean_ = checkRMS_ = false;
369  minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0;
370  checkMeanTolerance_ = false;
371  toleranceMean_ = -1.0;
373  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:96
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:124
bool checkMeanTolerance_
Definition: QTest.h:392
static std::string getAlgoName()
Definition: QTest.h:374

Member Function Documentation

◆ getAlgoName()

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

Definition at line 374 of file QTest.h.

Referenced by ContentsWithinExpected(), and QualityTester::makeQCriterion().

374 { return "ContentsWithinExpected"; }

◆ runTest()

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 863 of file QTest.cc.

References funct::abs(), officialStyle::chan, gather_cfg::cout, h, hlt_dqm_clientPB-live_cfg::me, SiStripPI::mean, SiStripPI::rms, MonitorElementData::TH2D, MonitorElementData::TH2F, MonitorElementData::TH2S, MonitorElementData::TPROFILE, and MonitorElementData::TPROFILE2D.

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

◆ setMeanRange()

void ContentsWithinExpected::setMeanRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1047 of file QTest.cc.

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

1047  {
1048  if (xmax < xmin)
1049  if (verbose_ > 0)
1050  std::cout << "QTest:ContentsWitinExpected"
1051  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1052  minMean_ = xmin;
1053  maxMean_ = xmax;
1054  checkMean_ = true;
1055 }
int verbose_
Definition: QTest.h:110

◆ setMeanTolerance()

void ContentsWithinExpected::setMeanTolerance ( float  fracTolerance)
inline

set (fractional) tolerance for mean

Definition at line 382 of file QTest.h.

References checkMeanTolerance_, and toleranceMean_.

382  {
383  if (fracTolerance >= 0.0) {
384  toleranceMean_ = fracTolerance;
385  checkMeanTolerance_ = true;
386  }
387  }
bool checkMeanTolerance_
Definition: QTest.h:392

◆ setRMSRange()

void ContentsWithinExpected::setRMSRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1058 of file QTest.cc.

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

1058  {
1059  if (xmax < xmin)
1060  if (verbose_ > 0)
1061  std::cout << "QTest:ContentsWitinExpected"
1062  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1063  minRMS_ = xmin;
1064  maxRMS_ = xmax;
1065  checkRMS_ = true;
1066 }
int verbose_
Definition: QTest.h:110

◆ setUseEmptyBins()

void ContentsWithinExpected::setUseEmptyBins ( unsigned int  useEmptyBins)
inline

Definition at line 377 of file QTest.h.

References useEmptyBins_.

377 { useEmptyBins_ = useEmptyBins; }
unsigned int useEmptyBins_
Definition: QTest.h:396

Member Data Documentation

◆ checkMean_

bool ContentsWithinExpected::checkMean_
protected

Definition at line 390 of file QTest.h.

Referenced by ContentsWithinExpected().

◆ checkMeanTolerance_

bool ContentsWithinExpected::checkMeanTolerance_
protected

Definition at line 392 of file QTest.h.

Referenced by ContentsWithinExpected(), and setMeanTolerance().

◆ checkRMS_

bool ContentsWithinExpected::checkRMS_
protected

Definition at line 391 of file QTest.h.

Referenced by ContentsWithinExpected().

◆ maxMean_

float ContentsWithinExpected::maxMean_
protected

Definition at line 394 of file QTest.h.

Referenced by ContentsWithinExpected().

◆ maxRMS_

float ContentsWithinExpected::maxRMS_
protected

Definition at line 395 of file QTest.h.

Referenced by ContentsWithinExpected().

◆ minMean_

float ContentsWithinExpected::minMean_
protected

Definition at line 394 of file QTest.h.

Referenced by ContentsWithinExpected().

◆ minRMS_

float ContentsWithinExpected::minRMS_
protected

Definition at line 395 of file QTest.h.

Referenced by ContentsWithinExpected().

◆ toleranceMean_

float ContentsWithinExpected::toleranceMean_
protected

Definition at line 393 of file QTest.h.

Referenced by ContentsWithinExpected(), and setMeanTolerance().

◆ useEmptyBins_

unsigned int ContentsWithinExpected::useEmptyBins_
protected

Definition at line 396 of file QTest.h.

Referenced by setUseEmptyBins().