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

Constructor & Destructor Documentation

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

Definition at line 383 of file QTest.h.

References QCriterion::setAlgoName().

383  : SimpleTest(name,true)
384  {
385  checkMean_ = checkRMS_ = false;
386  minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0;
387  checkMeanTolerance_ = false;
388  toleranceMean_ = -1.0;
390  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:79
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:139
bool checkMeanTolerance_
Definition: QTest.h:413
static std::string getAlgoName()
Definition: QTest.h:391

Member Function Documentation

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

Definition at line 391 of file QTest.h.

References QCriterion::runTest().

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

391 { 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 983 of file QTest.cc.

References 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(), MonitorElement::kind(), SiStripPI::mean, and SiStripPI::rms.

984 {
985  badChannels_.clear();
986  if (!me)
987  return -1;
988  if (!me->getRootObject())
989  return -1;
990  TH1* h=nullptr; //initialize histogram pointer
991 
992  if (verbose_>1)
993  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
994  << me-> getFullname() << "\n";
995 
996  int ncx;
997  int ncy;
998 
999  if (useEmptyBins_)
1000  {
1001  //-- TH2
1003  {
1004  ncx = me->getTH2F()->GetXaxis()->GetNbins();
1005  ncy = me->getTH2F()->GetYaxis()->GetNbins();
1006  h = me->getTH2F(); // access Test histo
1007  }
1008  //-- TH2S
1009  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
1010  {
1011  ncx = me->getTH2S()->GetXaxis()->GetNbins();
1012  ncy = me->getTH2S()->GetYaxis()->GetNbins();
1013  h = me->getTH2S(); // access Test histo
1014  }
1015  //-- TH2D
1016  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
1017  {
1018  ncx = me->getTH2D()->GetXaxis()->GetNbins();
1019  ncy = me->getTH2D()->GetYaxis()->GetNbins();
1020  h = me->getTH2D(); // access Test histo
1021  }
1022  //-- TProfile
1023  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE)
1024  {
1025  ncx = me->getTProfile()->GetXaxis()->GetNbins();
1026  ncy = 1;
1027  h = me->getTProfile(); // access Test histo
1028  }
1029  //-- TProfile2D
1030  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE2D)
1031  {
1032  ncx = me->getTProfile2D()->GetXaxis()->GetNbins();
1033  ncy = me->getTProfile2D()->GetYaxis()->GetNbins();
1034  h = me->getTProfile2D(); // access Test histo
1035  }
1036  else
1037  {
1038  if (verbose_>0)
1039  std::cout << "QTest:ContentsWithinExpected"
1040  << " ME does not contain TH2F/TH2S/TH2D/TPROFILE/TPROFILE2D, exiting\n";
1041  return -1;
1042  }
1043 
1044  int nsum = 0;
1045  double sum = 0.0;
1046  double average = 0.0;
1047 
1048  if (checkMeanTolerance_)
1049  { // calculate average value of all bin contents
1050 
1051  for (int cx = 1; cx <= ncx; ++cx)
1052  {
1053  for (int cy = 1; cy <= ncy; ++cy)
1054  {
1055  if (me->kind() == MonitorElement::DQM_KIND_TH2F)
1056  {
1057  sum += h->GetBinContent(h->GetBin(cx, cy));
1058  ++nsum;
1059  }
1060  else if (me->kind() == MonitorElement::DQM_KIND_TH2S)
1061  {
1062  sum += h->GetBinContent(h->GetBin(cx, cy));
1063  ++nsum;
1064  }
1065  else if (me->kind() == MonitorElement::DQM_KIND_TH2D)
1066  {
1067  sum += h->GetBinContent(h->GetBin(cx, cy));
1068  ++nsum;
1069  }
1070  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE)
1071  {
1072  if (me->getTProfile()->GetBinEntries(h->GetBin(cx)) >= minEntries_/(ncx))
1073  {
1074  sum += h->GetBinContent(h->GetBin(cx));
1075  ++nsum;
1076  }
1077  }
1078  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D)
1079  {
1080  if (me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) >= minEntries_/(ncx*ncy))
1081  {
1082  sum += h->GetBinContent(h->GetBin(cx, cy));
1083  ++nsum;
1084  }
1085  }
1086  }
1087  }
1088 
1089  if (nsum > 0)
1090  average = sum/nsum;
1091 
1092  } // calculate average value of all bin contents
1093 
1094  int fail = 0;
1095 
1096  for (int cx = 1; cx <= ncx; ++cx)
1097  {
1098  for (int cy = 1; cy <= ncy; ++cy)
1099  {
1100  bool failMean = false;
1101  bool failRMS = false;
1102  bool failMeanTolerance = false;
1103 
1104  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE &&
1105  me->getTProfile()->GetBinEntries(h->GetBin(cx)) < minEntries_/(ncx))
1106  continue;
1107 
1108  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D &&
1109  me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) < minEntries_/(ncx*ncy))
1110  continue;
1111 
1112  if (checkMean_)
1113  {
1114  double mean = h->GetBinContent(h->GetBin(cx, cy));
1115  failMean = (mean < minMean_ || mean > maxMean_);
1116  }
1117 
1118  if (checkRMS_)
1119  {
1120  double rms = h->GetBinError(h->GetBin(cx, cy));
1121  failRMS = (rms < minRMS_ || rms > maxRMS_);
1122  }
1123 
1124  if (checkMeanTolerance_)
1125  {
1126  double mean = h->GetBinContent(h->GetBin(cx, cy));
1127  failMeanTolerance = (TMath::Abs(mean - average) > toleranceMean_*TMath::Abs(average));
1128  }
1129 
1130  if (failMean || failRMS || failMeanTolerance)
1131  {
1132 
1133  if (me->kind() == MonitorElement::DQM_KIND_TH2F)
1134  {
1135  DQMChannel chan(cx, cy, 0,
1136  h->GetBinContent(h->GetBin(cx, cy)),
1137  h->GetBinError(h->GetBin(cx, cy)));
1138  badChannels_.push_back(chan);
1139  }
1140  else if (me->kind() == MonitorElement::DQM_KIND_TH2S)
1141  {
1142  DQMChannel chan(cx, cy, 0,
1143  h->GetBinContent(h->GetBin(cx, cy)),
1144  h->GetBinError(h->GetBin(cx, cy)));
1145  badChannels_.push_back(chan);
1146  }
1147  else if (me->kind() == MonitorElement::DQM_KIND_TH2D)
1148  {
1149  DQMChannel chan(cx, cy, 0,
1150  h->GetBinContent(h->GetBin(cx, cy)),
1151  h->GetBinError(h->GetBin(cx, cy)));
1152  badChannels_.push_back(chan);
1153  }
1154  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE)
1155  {
1156  DQMChannel chan(cx, cy, int(me->getTProfile()->GetBinEntries(h->GetBin(cx))),
1157  0,
1158  h->GetBinError(h->GetBin(cx)));
1159  badChannels_.push_back(chan);
1160  }
1161  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D)
1162  {
1163  DQMChannel chan(cx, cy, int(me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy))),
1164  h->GetBinContent(h->GetBin(cx, cy)),
1165  h->GetBinError(h->GetBin(cx, cy)));
1166  badChannels_.push_back(chan);
1167  }
1168  ++fail;
1169  }
1170  }
1171  }
1172  return 1.*(ncx*ncy - fail)/(ncx*ncy);
1173  }
1174 
1175  else
1176  {
1178  {
1179  ncx = me->getTH2F()->GetXaxis()->GetNbins();
1180  ncy = me->getTH2F()->GetYaxis()->GetNbins();
1181  h = me->getTH2F(); // access Test histo
1182  }
1183  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
1184  {
1185  ncx = me->getTH2S()->GetXaxis()->GetNbins();
1186  ncy = me->getTH2S()->GetYaxis()->GetNbins();
1187  h = me->getTH2S(); // access Test histo
1188  }
1189  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
1190  {
1191  ncx = me->getTH2D()->GetXaxis()->GetNbins();
1192  ncy = me->getTH2D()->GetYaxis()->GetNbins();
1193  h = me->getTH2D(); // access Test histo
1194  }
1195  else
1196  {
1197  if (verbose_>0)
1198  std::cout << "QTest:ContentsWithinExpected AS"
1199  << " ME does not contain TH2F/TH2S/TH2D, exiting\n";
1200  return -1;
1201  }
1202 
1203  // if (!rangeInitialized_) return 0; // all accepted if no initialization
1204  int fail = 0;
1205  for (int cx = 1; cx <= ncx; ++cx)
1206  {
1207  for (int cy = 1; cy <= ncy; ++cy)
1208  {
1209  bool failure = false;
1210  double Content = h->GetBinContent(h->GetBin(cx, cy));
1211  if (Content)
1212  failure = (Content < minMean_ || Content > maxMean_);
1213  if (failure)
1214  ++fail;
1215  }
1216  }
1217  return 1.*(ncx*ncy-fail)/(ncx*ncy);
1218  }
1219 
1220 }
TProfile * getTProfile() const
TProfile2D * getTProfile2D() const
TH2S * getTH2S() const
int verbose_
Definition: QTest.h:119
TObject * getRootObject() const
T Abs(T a)
Definition: MathUtil.h:49
TH2D * getTH2D() const
unsigned int useEmptyBins_
Definition: QTest.h:417
bool checkMeanTolerance_
Definition: QTest.h:413
TH2F * getTH2F() const
static std::string getAlgoName()
Definition: QTest.h:391
std::vector< DQMChannel > badChannels_
Definition: QTest.h:161
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:160
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 1222 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1223 {
1224  if (xmax < xmin)
1225  if (verbose_>0)
1226  std::cout << "QTest:ContentsWitinExpected"
1227  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1228  minMean_ = xmin;
1229  maxMean_ = xmax;
1230  checkMean_ = true;
1231 }
int verbose_
Definition: QTest.h:119
void ContentsWithinExpected::setMeanTolerance ( float  fracTolerance)
inline

set (fractional) tolerance for mean

Definition at line 401 of file QTest.h.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

402  {
403  if (fracTolerance >= 0.0)
404  {
405  toleranceMean_ = fracTolerance;
406  checkMeanTolerance_ = true;
407  }
408  }
bool checkMeanTolerance_
Definition: QTest.h:413
void ContentsWithinExpected::setRMSRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1234 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1235 {
1236  if (xmax < xmin)
1237  if (verbose_>0)
1238  std::cout << "QTest:ContentsWitinExpected"
1239  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1240  minRMS_ = xmin;
1241  maxRMS_ = xmax;
1242  checkRMS_ = true;
1243 }
int verbose_
Definition: QTest.h:119
void ContentsWithinExpected::setUseEmptyBins ( unsigned int  useEmptyBins)
inline

Definition at line 394 of file QTest.h.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

394  {
395  useEmptyBins_ = useEmptyBins;
396  }
unsigned int useEmptyBins_
Definition: QTest.h:417

Member Data Documentation

bool ContentsWithinExpected::checkMean_
protected

Definition at line 411 of file QTest.h.

bool ContentsWithinExpected::checkMeanTolerance_
protected

Definition at line 413 of file QTest.h.

bool ContentsWithinExpected::checkRMS_
protected

Definition at line 412 of file QTest.h.

float ContentsWithinExpected::maxMean_
protected

Definition at line 415 of file QTest.h.

float ContentsWithinExpected::maxRMS_
protected

Definition at line 416 of file QTest.h.

float ContentsWithinExpected::minMean_
protected

Definition at line 415 of file QTest.h.

float ContentsWithinExpected::minRMS_
protected

Definition at line 416 of file QTest.h.

float ContentsWithinExpected::toleranceMean_
protected

Definition at line 414 of file QTest.h.

unsigned int ContentsWithinExpected::useEmptyBins_
protected

Definition at line 417 of file QTest.h.