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)
 
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
virtual std::vector< DQMChannelgetBadChannels (void) const
 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 (void) const
 get algorithm name More...
 
std::string getMessage (void) const
 get message attached to test More...
 
std::string getName (void) const
 get name of quality test More...
 
int getStatus (void) 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 (void)
 

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

Detailed Description

Definition at line 379 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 382 of file QTest.h.

References QCriterion::setAlgoName().

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

Member Function Documentation

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

Definition at line 390 of file QTest.h.

References QCriterion::runTest().

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

390 { return "ContentsWithinExpected"; }
float ContentsWithinExpected::runTest ( const MonitorElement me)
virtual

end of normal Test

AS quality test !!!

end of AS quality test

Reimplemented from QCriterion.

Definition at line 973 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(), RecoTauDiscriminantConfiguration::mean, and RecoTauDiscriminantConfiguration::rms.

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

set expected value for mean

Definition at line 1212 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1213 {
1214  if (xmax < xmin)
1215  if (verbose_>0)
1216  std::cout << "QTest:ContentsWitinExpected"
1217  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1218  minMean_ = xmin;
1219  maxMean_ = xmax;
1220  checkMean_ = true;
1221 }
int verbose_
Definition: QTest.h:118
void ContentsWithinExpected::setMeanTolerance ( float  fracTolerance)
inline

set (fractional) tolerance for mean

Definition at line 400 of file QTest.h.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

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

set expected value for mean

Definition at line 1224 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1225 {
1226  if (xmax < xmin)
1227  if (verbose_>0)
1228  std::cout << "QTest:ContentsWitinExpected"
1229  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1230  minRMS_ = xmin;
1231  maxRMS_ = xmax;
1232  checkRMS_ = true;
1233 }
int verbose_
Definition: QTest.h:118
void ContentsWithinExpected::setUseEmptyBins ( unsigned int  useEmptyBins)
inline

Definition at line 393 of file QTest.h.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

393  {
394  useEmptyBins_ = useEmptyBins;
395  }
unsigned int useEmptyBins_
Definition: QTest.h:416

Member Data Documentation

bool ContentsWithinExpected::checkMean_
protected

Definition at line 410 of file QTest.h.

bool ContentsWithinExpected::checkMeanTolerance_
protected

Definition at line 412 of file QTest.h.

bool ContentsWithinExpected::checkRMS_
protected

Definition at line 411 of file QTest.h.

float ContentsWithinExpected::maxMean_
protected

Definition at line 414 of file QTest.h.

float ContentsWithinExpected::maxRMS_
protected

Definition at line 415 of file QTest.h.

float ContentsWithinExpected::minMean_
protected

Definition at line 414 of file QTest.h.

float ContentsWithinExpected::minRMS_
protected

Definition at line 415 of file QTest.h.

float ContentsWithinExpected::toleranceMean_
protected

Definition at line 413 of file QTest.h.

unsigned int ContentsWithinExpected::useEmptyBins_
protected

Definition at line 416 of file QTest.h.