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
00044 class QCriterion
00045 {
00047
00048 public:
00049
00051 int getStatus(void) const { return status_; }
00053 std::string getMessage(void) const { return message_; }
00055 std::string getName(void) const { return qtname_; }
00057 std::string algoName(void) const { return algoName_; }
00059 void setWarningProb(float prob) { warningProb_ = prob; }
00060 void setErrorProb(float prob) { errorProb_ = prob; }
00063 virtual std::vector<DQMChannel> getBadChannels(void) const
00064 { return std::vector<DQMChannel>(); }
00065
00066 protected:
00067 QCriterion(std::string qtname) { qtname_ = qtname; init(); }
00069 void init(void);
00070
00071 virtual ~QCriterion(void) {}
00072
00073 virtual float runTest(const MonitorElement *me);
00075 void setAlgoName(std::string name) { algoName_ = name; }
00076
00077 float runTest(const MonitorElement *me, QReport &qr, DQMNet::QValue &qv) {
00078 assert(qr.qcriterion_ == this);
00079 assert(qv.qtname == qtname_);
00080
00081 prob_ = runTest(me);
00082
00083 if (prob_ < errorProb_) status_ = dqm::qstatus::ERROR;
00084 else if (prob_ < warningProb_) status_ = dqm::qstatus::WARNING;
00085 else status_ = dqm::qstatus::STATUS_OK;
00086
00087 setMessage();
00088
00089 if (verbose_==2) std::cout << " Message = " << message_ << std::endl;
00090 if (verbose_==2) std::cout << " Name = " << qtname_ <<
00091 " / Algorithm = " << algoName_ <<
00092 " / Status = " << status_ <<
00093 " / Prob = " << prob_ << std::endl;
00094
00095 qv.code = status_;
00096 qv.message = message_;
00097 qv.qtname = qtname_;
00098 qv.algorithm = algoName_;
00099 qv.qtresult = prob_;
00100 qr.badChannels_ = getBadChannels();
00101
00102 return prob_;
00103 }
00104
00106 virtual void setMessage(void) = 0;
00107
00108 std::string qtname_;
00109 std::string algoName_;
00110 float prob_;
00111 int status_;
00112 std::string message_;
00113 float warningProb_, errorProb_;
00114 void setVerbose(int verbose) { verbose_ = verbose; }
00115 int verbose_;
00116
00117 private:
00119 static const float WARNING_PROB_THRESHOLD;
00120 static const float ERROR_PROB_THRESHOLD;
00121
00123 friend class DQMStore;
00125 friend class MonitorElement;
00126 };
00127
00131
00132 class SimpleTest : public QCriterion
00133 {
00134 public:
00135 SimpleTest(const std::string &name, bool keepBadChannels = false) : QCriterion(name),
00136 minEntries_ (0),
00137 keepBadChannels_ (keepBadChannels)
00138 {}
00139
00141 void setMinimumEntries(unsigned n) { minEntries_ = n; }
00143 virtual std::vector<DQMChannel> getBadChannels(void) const
00144 {
00145 return keepBadChannels_ ? badChannels_ : QCriterion::getBadChannels();
00146 }
00147
00148 protected:
00149
00151 virtual void setMessage(void)
00152 {
00153 message_.clear();
00154 }
00155
00156 unsigned minEntries_;
00157 std::vector<DQMChannel> badChannels_;
00158 bool keepBadChannels_;
00159 };
00160
00161
00162
00163
00164
00165
00166
00167
00168 class Comp2RefEqualH : public SimpleTest
00169 {
00170 public:
00171 Comp2RefEqualH(const std::string &name) : SimpleTest(name,true)
00172 {
00173 setAlgoName( getAlgoName() );
00174 }
00175 static std::string getAlgoName(void) { return "Comp2RefEqualH"; }
00176 float runTest(const MonitorElement*me);
00177 };
00178
00179
00180
00181 class Comp2RefChi2 : public SimpleTest
00182 {
00183 public:
00184 Comp2RefChi2(const std::string &name) :SimpleTest(name)
00185 {
00186 setAlgoName(getAlgoName());
00187 }
00188 static std::string getAlgoName(void) { return "Comp2RefChi2"; }
00189 float runTest(const MonitorElement*me);
00190
00191 protected:
00192
00193 void setMessage(void)
00194 {
00195 std::ostringstream message;
00196 message << "chi2/Ndof = " << chi2_ << "/" << Ndof_
00197 << ", minimum needed statistics = " << minEntries_
00198 << " warning threshold = " << this->warningProb_
00199 << " error threshold = " << this->errorProb_;
00200 message_ = message.str();
00201 }
00202
00203
00204 int Ndof_; double chi2_;
00205 };
00206
00207
00209 class Comp2RefKolmogorov : public SimpleTest
00210 {
00211 public:
00212 Comp2RefKolmogorov(const std::string &name) : SimpleTest(name)
00213 {
00214 setAlgoName(getAlgoName());
00215 }
00216 static std::string getAlgoName(void) { return "Comp2RefKolmogorov"; }
00217
00218 float runTest(const MonitorElement *me);
00219 };
00220
00221
00222
00223 class ContentsXRange : public SimpleTest
00224 {
00225 public:
00226 ContentsXRange(const std::string &name) : SimpleTest(name)
00227 {
00228 rangeInitialized_ = false;
00229 setAlgoName(getAlgoName());
00230 }
00231 static std::string getAlgoName(void) { return "ContentsXRange"; }
00232 float runTest(const MonitorElement *me) ;
00233
00235 virtual void setAllowedXRange(double xmin, double xmax)
00236 {
00237 xmin_ = xmin; xmax_ = xmax;
00238 rangeInitialized_ = true;
00239 }
00240
00241 protected:
00242 double xmin_;double xmax_;
00243 bool rangeInitialized_;
00244 };
00245
00246
00247
00248 class ContentsYRange : public SimpleTest
00249 {
00250 public:
00251 ContentsYRange(const std::string &name) : SimpleTest(name,true)
00252 {
00253 rangeInitialized_ = false;
00254 setAlgoName(getAlgoName());
00255 }
00256 static std::string getAlgoName(void) { return "ContentsYRange"; }
00257 float runTest(const MonitorElement *me);
00258
00259 void setUseEmptyBins(unsigned int useEmptyBins) { useEmptyBins_ = useEmptyBins; }
00260 virtual void setAllowedYRange(double ymin, double ymax)
00261 {
00262 ymin_ = ymin; ymax_ = ymax;
00263 rangeInitialized_ = true;
00264 }
00265
00266 protected:
00267 double ymin_; double ymax_;
00268 bool rangeInitialized_;
00269 unsigned int useEmptyBins_;
00270
00271 };
00272
00273
00275 class DeadChannel : public SimpleTest
00276 {
00277 public:
00278 DeadChannel(const std::string &name) : SimpleTest(name,true)
00279 {
00280 rangeInitialized_ = false;
00281 setAlgoName(getAlgoName());
00282 }
00283 static std::string getAlgoName(void) { return "DeadChannel"; }
00284 float runTest(const MonitorElement *me);
00285
00287 void setThreshold(double ymin)
00288 {
00289 ymin_ = ymin;
00290 rangeInitialized_ = true;
00291 }
00292
00293 protected:
00294 double ymin_;
00295 bool rangeInitialized_;
00296 };
00297
00298
00299
00301 class NoisyChannel : public SimpleTest
00302 {
00303 public:
00304 NoisyChannel(const std::string &name) : SimpleTest(name,true)
00305 {
00306 rangeInitialized_ = false;
00307 numNeighbors_ = 1;
00308 setAlgoName(getAlgoName());
00309 }
00310 static std::string getAlgoName(void) { return "NoisyChannel"; }
00311 float runTest(const MonitorElement*me);
00312
00320 void setNumNeighbors(unsigned n) { if (n > 0) numNeighbors_ = n; }
00321
00326 void setTolerance(float percentage)
00327 {
00328 if (percentage >=0)
00329 {
00330 tolerance_ = percentage;
00331 rangeInitialized_ = true;
00332 }
00333 }
00334
00335 protected:
00338 double getAverage(int bin, const TH1 *h) const;
00339
00340 float tolerance_;
00341 unsigned numNeighbors_;
00342
00343 bool rangeInitialized_;
00344 };
00345
00346
00347
00348 class ContentsWithinExpected : public SimpleTest
00349 {
00350 public:
00351 ContentsWithinExpected(const std::string &name) : SimpleTest(name,true)
00352 {
00353 checkMean_ = checkRMS_ = false;
00354 minMean_ = maxMean_ = minRMS_ = maxRMS_ = 0.0;
00355 checkMeanTolerance_ = false;
00356 toleranceMean_ = -1.0;
00357 setAlgoName(getAlgoName());
00358 }
00359 static std::string getAlgoName(void) { return "ContentsWithinExpected"; }
00360 float runTest(const MonitorElement *me);
00361
00362 void setUseEmptyBins(unsigned int useEmptyBins) {
00363 useEmptyBins_ = useEmptyBins;
00364 }
00365 void setMeanRange(double xmin, double xmax);
00366 void setRMSRange(double xmin, double xmax);
00367
00369 void setMeanTolerance(float fracTolerance)
00370 {
00371 if (fracTolerance >= 0.0)
00372 {
00373 toleranceMean_ = fracTolerance;
00374 checkMeanTolerance_ = true;
00375 }
00376 }
00377
00378 protected:
00379 bool checkMean_;
00380 bool checkRMS_;
00381 bool checkMeanTolerance_;
00382 float toleranceMean_;
00383 float minMean_, maxMean_;
00384 float minRMS_, maxRMS_;
00385 unsigned int useEmptyBins_;
00386
00387 };
00388
00389
00391 class MeanWithinExpected : public SimpleTest
00392 {
00393 public:
00394 MeanWithinExpected(const std::string &name) : SimpleTest(name)
00395 {
00396 setAlgoName(getAlgoName());
00397 }
00398 static std::string getAlgoName(void) { return "MeanWithinExpected"; }
00399 float runTest(const MonitorElement*me);
00400
00401 void setExpectedMean(double mean) { expMean_ = mean; }
00402 void useRange(double xmin, double xmax);
00403 void useSigma(double expectedSigma);
00404 void useRMS(void) ;
00405
00406 protected:
00407 bool useRMS_;
00408 bool useSigma_;
00409 bool useRange_;
00410 double sigma_;
00411 double expMean_;
00412 double xmin_, xmax_;
00413
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 #if 0 // FIXME: need to know what parameters to set before runTest!
00480 class FlatOccupancy1d : public SimpleTest
00481 {
00482 public:
00483 FlatOccupancy1d(const std::string &name) : SimpleTest(name)
00484 {
00485 Nbins = 0;
00486 FailedBins[0] = 0;
00487 FailedBins[1] = 0;
00488 setAlgoName(getAlgoName());
00489 }
00490
00491 ~FlatOccupancy1d(void)
00492 {
00493 delete [] FailedBins[0];
00494 delete [] FailedBins[1];
00495 }
00496
00497 static std::string getAlgoName(void) { return "RuleFlatOccupancy1d"; }
00498
00499 void set_ExclusionMask(double *mask) { ExclusionMask = mask; }
00500 void set_epsilon_min(double epsilon) { epsilon_min = epsilon; }
00501 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00502 void set_S_fail(double S) { S_fail = S; }
00503 void set_S_pass(double S) { S_pass = S; }
00504 double get_FailedBins(void) { return *FailedBins[2]; }
00505 int get_result() { return result; }
00506
00507 float runTest(const MonitorElement*me);
00508
00509 protected:
00510 double *ExclusionMask;
00511 double epsilon_min, epsilon_max;
00512 double S_fail, S_pass;
00513 double *FailedBins[2];
00514 int Nbins;
00515 int result;
00516 };
00517 #endif
00518
00519
00520 class FixedFlatOccupancy1d : public SimpleTest
00521 {
00522 public:
00523 FixedFlatOccupancy1d(const std::string &name) : SimpleTest(name)
00524 {
00525 Nbins = 0;
00526 FailedBins[0] = 0;
00527 FailedBins[1] = 0;
00528 setAlgoName(getAlgoName());
00529 }
00530
00531 ~FixedFlatOccupancy1d(void)
00532 {
00533 if( Nbins > 0 )
00534 {
00535 delete [] FailedBins[0];
00536 delete [] FailedBins[1];
00537 }
00538 }
00539
00540 static std::string getAlgoName(void) { return "RuleFixedFlatOccupancy1d"; }
00541
00542 void set_Occupancy(double level) { b = level; }
00543 void set_ExclusionMask(double *mask) { ExclusionMask = mask; }
00544 void set_epsilon_min(double epsilon) { epsilon_min = epsilon; }
00545 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00546 void set_S_fail(double S) { S_fail = S; }
00547 void set_S_pass(double S) { S_pass = S; }
00548 double get_FailedBins(void) { return *FailedBins[2]; }
00549 int get_result() { return result; }
00550
00551 float runTest(const MonitorElement*me);
00552
00553 protected:
00554 double b;
00555 double *ExclusionMask;
00556 double epsilon_min, epsilon_max;
00557 double S_fail, S_pass;
00558 double *FailedBins[2];
00559 int Nbins;
00560 int result;
00561 };
00562
00563
00564 class CSC01 : public SimpleTest
00565 {
00566 public:
00567 CSC01(const std::string &name) : SimpleTest(name)
00568 {
00569 setAlgoName(getAlgoName());
00570 }
00571 static std::string getAlgoName(void) { return "RuleCSC01"; }
00572
00573 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00574 void set_S_fail(double S) { S_fail = S; }
00575 void set_S_pass(double S) { S_pass = S; }
00576 double get_epsilon_obs() { return epsilon_obs; }
00577 double get_S_fail_obs() { return S_fail_obs; }
00578 double get_S_pass_obs() { return S_pass_obs; }
00579 int get_result() { return result; }
00580
00581 float runTest(const MonitorElement*me);
00582
00583 protected:
00584 double epsilon_max;
00585 double S_fail, S_pass;
00586 double epsilon_obs;
00587 double S_fail_obs, S_pass_obs;
00588 int result;
00589 };
00590
00591
00592 class CompareToMedian : public SimpleTest
00593 {
00594 public:
00595
00596 CompareToMedian(const std::string &name) : SimpleTest(name,true){
00597 this->_min = 0.2;
00598 this->_max = 3.0;
00599 this->_emptyBins = 0;
00600 this->_maxMed = 10;
00601 this->_minMed = 0;
00602 this->nBins = 0;
00603 this->_statCut = 0;
00604 reset();
00605 setAlgoName( getAlgoName() );
00606 };
00607
00608 ~CompareToMedian(){};
00609
00610 static std::string getAlgoName(void) { return "CompareToMedian"; }
00611
00612 float runTest(const MonitorElement *me);
00613 void setMin(float min){_min = min;};
00614 void setMax(float max){_max = max;};
00615 void setEmptyBins(int eB){eB > 0 ? _emptyBins = 1 : _emptyBins = 0;};
00616 void setMaxMedian(float max){_maxMed = max;};
00617 void setMinMedian(float min){_minMed = min;};
00618 void setStatCut(float cut){_statCut = (cut > 0) ? cut : 0;};
00619
00620 protected :
00621 void setMessage(void){
00622 std::ostringstream message;
00623 message << "Test " << qtname_ << " (" << algoName_
00624 << "): Entry fraction within range = " << prob_;
00625 message_ = message.str();
00626 }
00627
00628 private :
00629 float _min, _max;
00630 int _emptyBins;
00631 float _maxMed,_minMed;
00632 float _statCut;
00633
00634 int nBinsX, nBinsY;
00635
00636 int nBins;
00637
00638
00639 std::vector<float> binValues;
00640
00641 void reset(){binValues.clear();};
00642
00643 };
00644
00645
00646 #if 0 // FIXME: need to know what parameters to set before runTest!
00647 class AllContentAlongDiagonal : public SimpleTest
00648
00649 public:
00650 AllContentAlongDiagonal(const std::string &name) : SimpleTest(name)
00651 {
00652 setAlgoName(getAlgoName());
00653 }
00654 static std::string getAlgoName(void) { return "RuleAllContentAlongDiagonal"; }
00655
00656 void set_epsilon_max(double epsilon) { epsilon_max = epsilon; }
00657 void set_S_fail(double S) { S_fail = S; }
00658 void set_S_pass(double S) { S_pass = S; }
00659 double get_epsilon_obs() { return epsilon_obs; }
00660 double get_S_fail_obs() { return S_fail_obs; }
00661 double get_S_pass_obs() { return S_pass_obs; }
00662 int get_result() { return result; }
00663
00664
00665
00666 float runTest(const MonitorElement*me);
00667
00668 protected:
00669 double epsilon_max;
00670 double S_fail, S_pass;
00671 double epsilon_obs;
00672 double S_fail_obs, S_pass_obs;
00673 int result;
00674 };
00675 #endif
00676
00677 #endif // DQMSERVICES_CORE_Q_CRITERION_H