Go to the documentation of this file.00001 #ifndef DQMSERVICES_CORE_Q_CRITERION_H
00002 # define DQMSERVICES_CORE_Q_CRITERION_H
00003
00004 # include "DQMServices/Core/interface/MonitorElement.h"
00005 # include "TProfile2D.h"
00006 # include "TProfile.h"
00007 # include "TH2F.h"
00008 # include "TH1F.h"
00009 # include <sstream>
00010 # include <string>
00011 # include <map>
00012
00013
00014
00015 class Comp2RefChi2; typedef Comp2RefChi2 Comp2RefChi2ROOT;
00016 class Comp2RefKolmogorov; typedef Comp2RefKolmogorov Comp2RefKolmogorovROOT;
00017 class Comp2RefEqualH; typedef Comp2RefEqualH Comp2RefEqualHROOT;
00018 class ContentsXRange; typedef ContentsXRange ContentsXRangeROOT;
00019 class ContentsYRange; typedef ContentsYRange ContentsYRangeROOT;
00020 class NoisyChannel; typedef NoisyChannel NoisyChannelROOT;
00021 class DeadChannel; typedef DeadChannel DeadChannelROOT;
00022 class ContentsWithinExpected; typedef ContentsWithinExpected ContentsWithinExpectedROOT;
00023 class MeanWithinExpected; typedef MeanWithinExpected MeanWithinExpectedROOT;
00024
00025
00026 class FlatOccupancy1d; typedef FlatOccupancy1d RuleFlatOccupancy1d; typedef FlatOccupancy1d FlatOccupancy1dROOT;
00027 class FixedFlatOccupancy1d; typedef FixedFlatOccupancy1d RuleFixedFlatOccupancy1d; typedef FixedFlatOccupancy1d FixedFlatOccupancy1dROOT;
00028 class CSC01; typedef CSC01 RuleCSC01; typedef CSC01 CSC01ROOT;
00029 class AllContentAlongDiagonal; typedef AllContentAlongDiagonal RuleAllContentAlongDiagonal; typedef AllContentAlongDiagonal AllContentAlongDiagonalROOT;
00030 class CompareToMedian; typedef CompareToMedian CompareToMedianROOT;
00031 class CompareLastFilledBin; typedef CompareLastFilledBin CompareLastFilledBinROOT;
00032
00045 class QCriterion
00046 {
00048
00049 public:
00050
00052 int getStatus(void) const { return status_; }
00054 std::string getMessage(void) const { return message_; }
00056 std::string getName(void) const { return qtname_; }
00058 std::string algoName(void) const { return algoName_; }
00060 void setWarningProb(float prob) { warningProb_ = prob; }
00061 void setErrorProb(float prob) { errorProb_ = prob; }
00064 virtual std::vector<DQMChannel> getBadChannels(void) const
00065 { return std::vector<DQMChannel>(); }
00066
00067 protected:
00068 QCriterion(std::string qtname) { qtname_ = qtname; init(); }
00070 void init(void);
00071
00072 virtual ~QCriterion(void) {}
00073
00074 virtual float runTest(const MonitorElement *me);
00076 void setAlgoName(std::string name) { algoName_ = name; }
00077
00078 float runTest(const MonitorElement *me, QReport &qr, DQMNet::QValue &qv) {
00079 assert(qr.qcriterion_ == this);
00080 assert(qv.qtname == qtname_);
00081
00082 prob_ = runTest(me);
00083
00084 if (prob_ < errorProb_) status_ = dqm::qstatus::ERROR;
00085 else if (prob_ < warningProb_) status_ = dqm::qstatus::WARNING;
00086 else status_ = dqm::qstatus::STATUS_OK;
00087
00088 setMessage();
00089
00090 if (verbose_==2) std::cout << " Message = " << message_ << std::endl;
00091 if (verbose_==2) std::cout << " Name = " << qtname_ <<
00092 " / Algorithm = " << algoName_ <<
00093 " / Status = " << status_ <<
00094 " / Prob = " << prob_ << std::endl;
00095
00096 qv.code = status_;
00097 qv.message = message_;
00098 qv.qtname = qtname_;
00099 qv.algorithm = algoName_;
00100 qv.qtresult = prob_;
00101 qr.badChannels_ = getBadChannels();
00102
00103 return prob_;
00104 }
00105
00107 virtual void setMessage(void) = 0;
00108
00109 std::string qtname_;
00110 std::string algoName_;
00111 float prob_;
00112 int status_;
00113 std::string message_;
00114 float warningProb_, errorProb_;
00115 void setVerbose(int verbose) { verbose_ = verbose; }
00116 int verbose_;
00117
00118 private:
00120 static const float WARNING_PROB_THRESHOLD;
00121 static const float ERROR_PROB_THRESHOLD;
00122
00124 friend class DQMStore;
00126 friend class MonitorElement;
00127 };
00128
00132
00133 class SimpleTest : public QCriterion
00134 {
00135 public:
00136 SimpleTest(const std::string &name, bool keepBadChannels = false) : QCriterion(name),
00137 minEntries_ (0),
00138 keepBadChannels_ (keepBadChannels)
00139 {}
00140
00142 void setMinimumEntries(unsigned n) { minEntries_ = n; }
00144 virtual std::vector<DQMChannel> getBadChannels(void) const
00145 {
00146 return keepBadChannels_ ? badChannels_ : QCriterion::getBadChannels();
00147 }
00148
00149 protected:
00150
00152 virtual void setMessage(void)
00153 {
00154 message_.clear();
00155 }
00156
00157 unsigned minEntries_;
00158 std::vector<DQMChannel> badChannels_;
00159 bool keepBadChannels_;
00160 };
00161
00162
00163
00164
00165
00166
00167
00168
00169 class Comp2RefEqualH : public SimpleTest
00170 {
00171 public:
00172 Comp2RefEqualH(const std::string &name) : SimpleTest(name,true)
00173 {
00174 setAlgoName( getAlgoName() );
00175 }
00176 static std::string getAlgoName(void) { return "Comp2RefEqualH"; }
00177 float runTest(const MonitorElement*me);
00178 };
00179
00180
00181
00182 class Comp2RefChi2 : public SimpleTest
00183 {
00184 public:
00185 Comp2RefChi2(const std::string &name) :SimpleTest(name)
00186 {
00187 setAlgoName(getAlgoName());
00188 }
00189 static std::string getAlgoName(void) { return "Comp2RefChi2"; }
00190 float runTest(const MonitorElement*me);
00191
00192 protected:
00193
00194 void setMessage(void)
00195 {
00196 std::ostringstream message;
00197 message << "chi2/Ndof = " << chi2_ << "/" << Ndof_
00198 << ", minimum needed statistics = " << minEntries_
00199 << " warning threshold = " << this->warningProb_
00200 << " error threshold = " << this->errorProb_;
00201 message_ = message.str();
00202 }
00203
00204
00205 int Ndof_; double chi2_;
00206 };
00207
00208
00210 class Comp2RefKolmogorov : public SimpleTest
00211 {
00212 public:
00213 Comp2RefKolmogorov(const std::string &name) : SimpleTest(name)
00214 {
00215 setAlgoName(getAlgoName());
00216 }
00217 static std::string getAlgoName(void) { return "Comp2RefKolmogorov"; }
00218
00219 float runTest(const MonitorElement *me);
00220 };
00221
00222
00223
00224 class ContentsXRange : public SimpleTest
00225 {
00226 public:
00227 ContentsXRange(const std::string &name) : SimpleTest(name)
00228 {
00229 rangeInitialized_ = false;
00230 setAlgoName(getAlgoName());
00231 }
00232 static std::string getAlgoName(void) { return "ContentsXRange"; }
00233 float runTest(const MonitorElement *me) ;
00234
00236 virtual void setAllowedXRange(double xmin, double xmax)
00237 {
00238 xmin_ = xmin; xmax_ = xmax;
00239 rangeInitialized_ = true;
00240 }
00241
00242 protected:
00243 double xmin_;double xmax_;
00244 bool rangeInitialized_;
00245 };
00246
00247
00248
00249 class ContentsYRange : public SimpleTest
00250 {
00251 public:
00252 ContentsYRange(const std::string &name) : SimpleTest(name,true)
00253 {
00254 rangeInitialized_ = false;
00255 setAlgoName(getAlgoName());
00256 }
00257 static std::string getAlgoName(void) { return "ContentsYRange"; }
00258 float runTest(const MonitorElement *me);
00259
00260 void setUseEmptyBins(unsigned int useEmptyBins) { useEmptyBins_ = useEmptyBins; }
00261 virtual void setAllowedYRange(double ymin, double ymax)
00262 {
00263 ymin_ = ymin; ymax_ = ymax;
00264 rangeInitialized_ = true;
00265 }
00266
00267 protected:
00268 double ymin_; double ymax_;
00269 bool rangeInitialized_;
00270 unsigned int useEmptyBins_;
00271
00272 };
00273
00274
00276 class DeadChannel : public SimpleTest
00277 {
00278 public:
00279 DeadChannel(const std::string &name) : SimpleTest(name,true)
00280 {
00281 rangeInitialized_ = false;
00282 setAlgoName(getAlgoName());
00283 }
00284 static std::string getAlgoName(void) { return "DeadChannel"; }
00285 float runTest(const MonitorElement *me);
00286
00288 void setThreshold(double ymin)
00289 {
00290 ymin_ = ymin;
00291 rangeInitialized_ = true;
00292 }
00293
00294 protected:
00295 double ymin_;
00296 bool rangeInitialized_;
00297 };
00298
00299
00300
00302 class NoisyChannel : public SimpleTest
00303 {
00304 public:
00305 NoisyChannel(const std::string &name) : SimpleTest(name,true)
00306 {
00307 rangeInitialized_ = false;
00308 numNeighbors_ = 1;
00309 setAlgoName(getAlgoName());
00310 }
00311 static std::string getAlgoName(void) { return "NoisyChannel"; }
00312 float runTest(const MonitorElement*me);
00313
00321 void setNumNeighbors(unsigned n) { if (n > 0) numNeighbors_ = n; }
00322
00327 void setTolerance(float percentage)
00328 {
00329 if (percentage >=0)
00330 {
00331 tolerance_ = percentage;
00332 rangeInitialized_ = true;
00333 }
00334 }
00335
00336 protected:
00339 double getAverage(int bin, const TH1 *h) const;
00340
00341 float tolerance_;
00342 unsigned numNeighbors_;
00343
00344 bool rangeInitialized_;
00345 };
00346
00347
00348
00349 class ContentsWithinExpected : public SimpleTest
00350 {
00351 public:
00352 ContentsWithinExpected(const std::string &name) : SimpleTest(name,true)
00353 {
00354 checkMean_ = checkRMS_ = false;
00355 minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0;
00356 checkMeanTolerance_ = false;
00357 toleranceMean_ = -1.0;
00358 setAlgoName(getAlgoName());
00359 }
00360 static std::string getAlgoName(void) { return "ContentsWithinExpected"; }
00361 float runTest(const MonitorElement *me);
00362
00363 void setUseEmptyBins(unsigned int useEmptyBins) {
00364 useEmptyBins_ = useEmptyBins;
00365 }
00366 void setMeanRange(double xmin, double xmax);
00367 void setRMSRange(double xmin, double xmax);
00368
00370 void setMeanTolerance(float fracTolerance)
00371 {
00372 if (fracTolerance >= 0.0)
00373 {
00374 toleranceMean_ = fracTolerance;
00375 checkMeanTolerance_ = true;
00376 }
00377 }
00378
00379 protected:
00380 bool checkMean_;
00381 bool checkRMS_;
00382 bool checkMeanTolerance_;
00383 float toleranceMean_;
00384 float minMean_, maxMean_;
00385 float minRMS_, maxRMS_;
00386 unsigned int useEmptyBins_;
00387
00388 };
00389
00390
00392 class MeanWithinExpected : public SimpleTest
00393 {
00394 public:
00395 MeanWithinExpected(const std::string &name) : SimpleTest(name)
00396 {
00397 setAlgoName(getAlgoName());
00398 }
00399 static std::string getAlgoName(void) { return "MeanWithinExpected"; }
00400 float runTest(const MonitorElement*me);
00401
00402 void setExpectedMean(double mean) { expMean_ = mean; }
00403 void useRange(double xmin, double xmax);
00404 void useSigma(double expectedSigma);
00405 void useRMS(void) ;
00406
00407 protected:
00408 bool useRMS_;
00409 bool useSigma_;
00410 bool useRange_;
00411 double sigma_;
00412 double expMean_;
00413 double xmin_, xmax_;
00414
00415 };
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480 #if 0 // FIXME: need to know what parameters to set before runTest!
00481 class FlatOccupancy1d : public SimpleTest
00482 {
00483 public:
00484 FlatOccupancy1d(const std::string &name) : SimpleTest(name)
00485 {
00486 Nbins = 0;
00487 FailedBins[0] = 0;
00488 FailedBins[1] = 0;
00489 setAlgoName(getAlgoName());
00490 }
00491
00492 ~FlatOccupancy1d(void)
00493 {
00494 delete [] FailedBins[0];
00495 delete [] FailedBins[1];
00496 }
00497
00498 static std::string getAlgoName(void) { return "RuleFlatOccupancy1d"; }
00499
00500 void set_ExclusionMask(double *mask) { ExclusionMask = mask; }
00501 void set_epsilon_min(double epsilon) { epsilon_min = epsilon; }
00502 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00503 void set_S_fail(double S) { S_fail = S; }
00504 void set_S_pass(double S) { S_pass = S; }
00505 double get_FailedBins(void) { return *FailedBins[1]; }
00506 int get_result() { return result; }
00507
00508 float runTest(const MonitorElement*me);
00509
00510 protected:
00511 double *ExclusionMask;
00512 double epsilon_min, epsilon_max;
00513 double S_fail, S_pass;
00514 double *FailedBins[2];
00515 int Nbins;
00516 int result;
00517 };
00518 #endif
00519
00520
00521 class FixedFlatOccupancy1d : public SimpleTest
00522 {
00523 public:
00524 FixedFlatOccupancy1d(const std::string &name) : SimpleTest(name)
00525 {
00526 Nbins = 0;
00527 FailedBins[0] = 0;
00528 FailedBins[1] = 0;
00529 setAlgoName(getAlgoName());
00530 }
00531
00532 ~FixedFlatOccupancy1d(void)
00533 {
00534 if( Nbins > 0 )
00535 {
00536 delete [] FailedBins[0];
00537 delete [] FailedBins[1];
00538 }
00539 }
00540
00541 static std::string getAlgoName(void) { return "RuleFixedFlatOccupancy1d"; }
00542
00543 void set_Occupancy(double level) { b = level; }
00544 void set_ExclusionMask(double *mask) { ExclusionMask = mask; }
00545 void set_epsilon_min(double epsilon) { epsilon_min = epsilon; }
00546 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00547 void set_S_fail(double S) { S_fail = S; }
00548 void set_S_pass(double S) { S_pass = S; }
00549 double get_FailedBins(void) { return *FailedBins[1]; }
00550 int get_result() { return result; }
00551
00552 float runTest(const MonitorElement*me);
00553
00554 protected:
00555 double b;
00556 double *ExclusionMask;
00557 double epsilon_min, epsilon_max;
00558 double S_fail, S_pass;
00559 double *FailedBins[2];
00560 int Nbins;
00561 int result;
00562 };
00563
00564
00565 class CSC01 : public SimpleTest
00566 {
00567 public:
00568 CSC01(const std::string &name) : SimpleTest(name)
00569 {
00570 setAlgoName(getAlgoName());
00571 }
00572 static std::string getAlgoName(void) { return "RuleCSC01"; }
00573
00574 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00575 void set_S_fail(double S) { S_fail = S; }
00576 void set_S_pass(double S) { S_pass = S; }
00577 double get_epsilon_obs() { return epsilon_obs; }
00578 double get_S_fail_obs() { return S_fail_obs; }
00579 double get_S_pass_obs() { return S_pass_obs; }
00580 int get_result() { return result; }
00581
00582 float runTest(const MonitorElement*me);
00583
00584 protected:
00585 double epsilon_max;
00586 double S_fail, S_pass;
00587 double epsilon_obs;
00588 double S_fail_obs, S_pass_obs;
00589 int result;
00590 };
00591
00592
00593 class CompareToMedian : public SimpleTest
00594 {
00595 public:
00596
00597 CompareToMedian(const std::string &name) : SimpleTest(name,true){
00598 this->_min = 0.2;
00599 this->_max = 3.0;
00600 this->_emptyBins = 0;
00601 this->_maxMed = 10;
00602 this->_minMed = 0;
00603 this->nBins = 0;
00604 this->_statCut = 0;
00605 reset();
00606 setAlgoName( getAlgoName() );
00607 };
00608
00609 ~CompareToMedian(){};
00610
00611 static std::string getAlgoName(void) { return "CompareToMedian"; }
00612
00613 float runTest(const MonitorElement *me);
00614 void setMin(float min){_min = min;};
00615 void setMax(float max){_max = max;};
00616 void setEmptyBins(int eB){eB > 0 ? _emptyBins = 1 : _emptyBins = 0;};
00617 void setMaxMedian(float max){_maxMed = max;};
00618 void setMinMedian(float min){_minMed = min;};
00619 void setStatCut(float cut){_statCut = (cut > 0) ? cut : 0;};
00620
00621 protected :
00622 void setMessage(void){
00623 std::ostringstream message;
00624 message << "Test " << qtname_ << " (" << algoName_
00625 << "): Entry fraction within range = " << prob_;
00626 message_ = message.str();
00627 }
00628
00629 private :
00630 float _min, _max;
00631 int _emptyBins;
00632 float _maxMed,_minMed;
00633 float _statCut;
00634
00635 int nBinsX, nBinsY;
00636
00637 int nBins;
00638
00639
00640 std::vector<float> binValues;
00641
00642 void reset(){binValues.clear();};
00643
00644 };
00645
00646 class CompareLastFilledBin : public SimpleTest
00647 {
00648 public:
00649
00650 CompareLastFilledBin(const std::string &name) : SimpleTest(name,true){
00651 this->_min = 0.0;
00652 this->_max = 1.0;
00653 this->_average = 0.0;
00654 setAlgoName( getAlgoName() );
00655 };
00656
00657 ~CompareLastFilledBin(){};
00658
00659 static std::string getAlgoName(void) { return "CompareLastFilledBin"; }
00660
00661 float runTest(const MonitorElement *me);
00662 void setAverage(float average){_average = average;};
00663 void setMin(float min){_min = min;};
00664 void setMax(float max){_max = max;};
00665
00666
00667 protected :
00668 void setMessage(void){
00669 std::ostringstream message;
00670 message << "Test " << qtname_ << " (" << algoName_
00671 << "): Last Bin filled with desired value = " << prob_;
00672 message_ = message.str();
00673 }
00674
00675 private :
00676 float _min, _max;
00677 float _average;
00678 };
00679
00680
00681 #if 0 // FIXME: need to know what parameters to set before runTest!
00682 class AllContentAlongDiagonal : public SimpleTest
00683
00684 public:
00685 AllContentAlongDiagonal(const std::string &name) : SimpleTest(name)
00686 {
00687 setAlgoName(getAlgoName());
00688 }
00689 static std::string getAlgoName(void) { return "RuleAllContentAlongDiagonal"; }
00690
00691 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00692 void set_S_fail(double S) { S_fail = S; }
00693 void set_S_pass(double S) { S_pass = S; }
00694 double get_epsilon_obs() { return epsilon_obs; }
00695 double get_S_fail_obs() { return S_fail_obs; }
00696 double get_S_pass_obs() { return S_pass_obs; }
00697 int get_result() { return result; }
00698
00699
00700
00701 float runTest(const MonitorElement*me);
00702
00703 protected:
00704 double epsilon_max;
00705 double S_fail, S_pass;
00706 double epsilon_obs;
00707 double S_fail_obs, S_pass_obs;
00708 int result;
00709 };
00710 #endif
00711
00712 #endif // DQMSERVICES_CORE_Q_CRITERION_H