CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 349 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 352 of file QTest.h.

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

352  : SimpleTest(name,true)
353  {
354  checkMean_ = checkRMS_ = false;
355  minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0;
356  checkMeanTolerance_ = false;
357  toleranceMean_ = -1.0;
359  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:76
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:136
static std::string getAlgoName(void)
Definition: QTest.h:360
bool checkMeanTolerance_
Definition: QTest.h:382

Member Function Documentation

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

References PDRates::average, 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(), timingPdfMaker::mean, and plotscripts::rms().

873 {
874  badChannels_.clear();
875  if (!me)
876  return -1;
877  if (!me->getRootObject())
878  return -1;
879  TH1* h=0; //initialize histogram pointer
880 
881  if (verbose_>1)
882  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
883  << me-> getFullname() << "\n";
884 
885  int ncx;
886  int ncy;
887 
888  if (useEmptyBins_)
889  {
890  //-- TH2
892  {
893  ncx = me->getTH2F()->GetXaxis()->GetNbins();
894  ncy = me->getTH2F()->GetYaxis()->GetNbins();
895  h = me->getTH2F(); // access Test histo
896  }
897  //-- TH2S
898  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
899  {
900  ncx = me->getTH2S()->GetXaxis()->GetNbins();
901  ncy = me->getTH2S()->GetYaxis()->GetNbins();
902  h = me->getTH2S(); // access Test histo
903  }
904  //-- TH2D
905  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
906  {
907  ncx = me->getTH2D()->GetXaxis()->GetNbins();
908  ncy = me->getTH2D()->GetYaxis()->GetNbins();
909  h = me->getTH2D(); // access Test histo
910  }
911  //-- TProfile
912  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE)
913  {
914  ncx = me->getTProfile()->GetXaxis()->GetNbins();
915  ncy = 1;
916  h = me->getTProfile(); // access Test histo
917  }
918  //-- TProfile2D
920  {
921  ncx = me->getTProfile2D()->GetXaxis()->GetNbins();
922  ncy = me->getTProfile2D()->GetYaxis()->GetNbins();
923  h = me->getTProfile2D(); // access Test histo
924  }
925  else
926  {
927  if (verbose_>0)
928  std::cout << "QTest:ContentsWithinExpected"
929  << " ME does not contain TH2F/TH2S/TH2D/TPROFILE/TPROFILE2D, exiting\n";
930  return -1;
931  }
932 
933  int nsum = 0;
934  double sum = 0.0;
935  double average = 0.0;
936 
938  { // calculate average value of all bin contents
939 
940  for (int cx = 1; cx <= ncx; ++cx)
941  {
942  for (int cy = 1; cy <= ncy; ++cy)
943  {
944  if (me->kind() == MonitorElement::DQM_KIND_TH2F)
945  {
946  sum += h->GetBinContent(h->GetBin(cx, cy));
947  ++nsum;
948  }
949  else if (me->kind() == MonitorElement::DQM_KIND_TH2S)
950  {
951  sum += h->GetBinContent(h->GetBin(cx, cy));
952  ++nsum;
953  }
954  else if (me->kind() == MonitorElement::DQM_KIND_TH2D)
955  {
956  sum += h->GetBinContent(h->GetBin(cx, cy));
957  ++nsum;
958  }
959  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE)
960  {
961  if (me->getTProfile()->GetBinEntries(h->GetBin(cx)) >= minEntries_/(ncx))
962  {
963  sum += h->GetBinContent(h->GetBin(cx));
964  ++nsum;
965  }
966  }
967  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D)
968  {
969  if (me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) >= minEntries_/(ncx*ncy))
970  {
971  sum += h->GetBinContent(h->GetBin(cx, cy));
972  ++nsum;
973  }
974  }
975  }
976  }
977 
978  if (nsum > 0)
979  average = sum/nsum;
980 
981  } // calculate average value of all bin contents
982 
983  int fail = 0;
984 
985  for (int cx = 1; cx <= ncx; ++cx)
986  {
987  for (int cy = 1; cy <= ncy; ++cy)
988  {
989  bool failMean = false;
990  bool failRMS = false;
991  bool failMeanTolerance = false;
992 
993  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE &&
994  me->getTProfile()->GetBinEntries(h->GetBin(cx)) < minEntries_/(ncx))
995  continue;
996 
998  me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy)) < minEntries_/(ncx*ncy))
999  continue;
1000 
1001  if (checkMean_)
1002  {
1003  double mean = h->GetBinContent(h->GetBin(cx, cy));
1004  failMean = (mean < minMean_ || mean > maxMean_);
1005  }
1006 
1007  if (checkRMS_)
1008  {
1009  double rms = h->GetBinError(h->GetBin(cx, cy));
1010  failRMS = (rms < minRMS_ || rms > maxRMS_);
1011  }
1012 
1013  if (checkMeanTolerance_)
1014  {
1015  double mean = h->GetBinContent(h->GetBin(cx, cy));
1016  failMeanTolerance = (TMath::Abs(mean - average) > toleranceMean_*TMath::Abs(average));
1017  }
1018 
1019  if (failMean || failRMS || failMeanTolerance)
1020  {
1021 
1022  if (me->kind() == MonitorElement::DQM_KIND_TH2F)
1023  {
1024  DQMChannel chan(cx, cy, 0,
1025  h->GetBinContent(h->GetBin(cx, cy)),
1026  h->GetBinError(h->GetBin(cx, cy)));
1027  badChannels_.push_back(chan);
1028  }
1029  else if (me->kind() == MonitorElement::DQM_KIND_TH2S)
1030  {
1031  DQMChannel chan(cx, cy, 0,
1032  h->GetBinContent(h->GetBin(cx, cy)),
1033  h->GetBinError(h->GetBin(cx, cy)));
1034  badChannels_.push_back(chan);
1035  }
1036  else if (me->kind() == MonitorElement::DQM_KIND_TH2D)
1037  {
1038  DQMChannel chan(cx, cy, 0,
1039  h->GetBinContent(h->GetBin(cx, cy)),
1040  h->GetBinError(h->GetBin(cx, cy)));
1041  badChannels_.push_back(chan);
1042  }
1043  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE)
1044  {
1045  DQMChannel chan(cx, cy, int(me->getTProfile()->GetBinEntries(h->GetBin(cx))),
1046  0,
1047  h->GetBinError(h->GetBin(cx)));
1048  badChannels_.push_back(chan);
1049  }
1050  else if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D)
1051  {
1052  DQMChannel chan(cx, cy, int(me->getTProfile2D()->GetBinEntries(h->GetBin(cx, cy))),
1053  h->GetBinContent(h->GetBin(cx, cy)),
1054  h->GetBinError(h->GetBin(cx, cy)));
1055  badChannels_.push_back(chan);
1056  }
1057  ++fail;
1058  }
1059  }
1060  }
1061  return 1.*(ncx*ncy - fail)/(ncx*ncy);
1062  }
1063 
1064  else
1065  {
1067  {
1068  ncx = me->getTH2F()->GetXaxis()->GetNbins();
1069  ncy = me->getTH2F()->GetYaxis()->GetNbins();
1070  h = me->getTH2F(); // access Test histo
1071  }
1072  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
1073  {
1074  ncx = me->getTH2S()->GetXaxis()->GetNbins();
1075  ncy = me->getTH2S()->GetYaxis()->GetNbins();
1076  h = me->getTH2S(); // access Test histo
1077  }
1078  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
1079  {
1080  ncx = me->getTH2D()->GetXaxis()->GetNbins();
1081  ncy = me->getTH2D()->GetYaxis()->GetNbins();
1082  h = me->getTH2D(); // access Test histo
1083  }
1084  else
1085  {
1086  if (verbose_>0)
1087  std::cout << "QTest:ContentsWithinExpected AS"
1088  << " ME does not contain TH2F/TH2S/TH2D, exiting\n";
1089  return -1;
1090  }
1091 
1092  // if (!rangeInitialized_) return 0; // all accepted if no initialization
1093  int fail = 0;
1094  for (int cx = 1; cx <= ncx; ++cx)
1095  {
1096  for (int cy = 1; cy <= ncy; ++cy)
1097  {
1098  bool failure = false;
1099  double Content = h->GetBinContent(h->GetBin(cx, cy));
1100  if (Content)
1101  failure = (Content < minMean_ || Content > maxMean_);
1102  if (failure)
1103  ++fail;
1104  }
1105  }
1106  return 1.*(ncx*ncy-fail)/(ncx*ncy);
1107  }
1108 
1109 }
TH2S * getTH2S(void) const
TProfile2D * getTProfile2D(void) const
int verbose_
Definition: QTest.h:116
static std::string getAlgoName(void)
Definition: QTest.h:360
TH2D * getTH2D(void) const
unsigned int useEmptyBins_
Definition: QTest.h:386
Kind kind(void) const
Get the type of the monitor element.
bool checkMeanTolerance_
Definition: QTest.h:382
TObject * getRootObject(void) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< DQMChannel > badChannels_
Definition: QTest.h:158
int average
Definition: PDRates.py:137
TProfile * getTProfile(void) const
tuple cout
Definition: gather_cfg.py:121
unsigned minEntries_
Definition: QTest.h:157
TH2F * getTH2F(void) const
void ContentsWithinExpected::setMeanRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1111 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1112 {
1113  if (xmax < xmin)
1114  if (verbose_>0)
1115  std::cout << "QTest:ContentsWitinExpected"
1116  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1117  minMean_ = xmin;
1118  maxMean_ = xmax;
1119  checkMean_ = true;
1120 }
int verbose_
Definition: QTest.h:116
tuple cout
Definition: gather_cfg.py:121
void ContentsWithinExpected::setMeanTolerance ( float  fracTolerance)
inline

set (fractional) tolerance for mean

Definition at line 370 of file QTest.h.

References checkMeanTolerance_, and toleranceMean_.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

371  {
372  if (fracTolerance >= 0.0)
373  {
374  toleranceMean_ = fracTolerance;
375  checkMeanTolerance_ = true;
376  }
377  }
bool checkMeanTolerance_
Definition: QTest.h:382
void ContentsWithinExpected::setRMSRange ( double  xmin,
double  xmax 
)

set expected value for mean

Definition at line 1123 of file QTest.cc.

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

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

1124 {
1125  if (xmax < xmin)
1126  if (verbose_>0)
1127  std::cout << "QTest:ContentsWitinExpected"
1128  << " Illogical range: (" << xmin << ", " << xmax << "\n";
1129  minRMS_ = xmin;
1130  maxRMS_ = xmax;
1131  checkRMS_ = true;
1132 }
int verbose_
Definition: QTest.h:116
tuple cout
Definition: gather_cfg.py:121
void ContentsWithinExpected::setUseEmptyBins ( unsigned int  useEmptyBins)
inline

Definition at line 363 of file QTest.h.

References useEmptyBins_.

Referenced by QTestConfigure::EnableContentsWithinExpectedTest().

363  {
364  useEmptyBins_ = useEmptyBins;
365  }
unsigned int useEmptyBins_
Definition: QTest.h:386

Member Data Documentation

bool ContentsWithinExpected::checkMean_
protected

Definition at line 380 of file QTest.h.

Referenced by ContentsWithinExpected().

bool ContentsWithinExpected::checkMeanTolerance_
protected

Definition at line 382 of file QTest.h.

Referenced by ContentsWithinExpected(), and setMeanTolerance().

bool ContentsWithinExpected::checkRMS_
protected

Definition at line 381 of file QTest.h.

Referenced by ContentsWithinExpected().

float ContentsWithinExpected::maxMean_
protected

Definition at line 384 of file QTest.h.

Referenced by ContentsWithinExpected().

float ContentsWithinExpected::maxRMS_
protected

Definition at line 385 of file QTest.h.

Referenced by ContentsWithinExpected().

float ContentsWithinExpected::minMean_
protected

Definition at line 384 of file QTest.h.

Referenced by ContentsWithinExpected().

float ContentsWithinExpected::minRMS_
protected

Definition at line 385 of file QTest.h.

Referenced by ContentsWithinExpected().

float ContentsWithinExpected::toleranceMean_
protected

Definition at line 383 of file QTest.h.

Referenced by ContentsWithinExpected(), and setMeanTolerance().

unsigned int ContentsWithinExpected::useEmptyBins_
protected

Definition at line 386 of file QTest.h.

Referenced by setUseEmptyBins().