CMS 3D CMS Logo

QTestConfigure.cc
Go to the documentation of this file.
1 
11 #include <cstring>
12 #include <cstdlib>
13 
14 const char *QTestConfigure::findOrDefault(const std::map<std::string, std::string> &m,
15  const char *item,
16  const char *default_value) const {
17  std::map<std::string, std::string>::const_iterator iter;
18  if ((iter = m.find(std::string(item))) != m.end()) {
19  return (*iter).second.c_str();
20  }
21  LogDebug("QTestConfigure") << "Warning, using default value for parameter " << item
22  << " with default_value: " << default_value << std::endl;
23  return default_value;
24 }
25 
26 bool QTestConfigure::enableTests(const std::map<std::string, std::map<std::string, std::string> > &tests,
27  DQMStore *bei) {
28  testsConfigured.clear();
29  std::map<std::string, std::map<std::string, std::string> >::const_iterator itr;
30  for (itr = tests.begin(); itr != tests.end(); ++itr) {
31  const std::map<std::string, std::string> &params = itr->second;
32 
33  std::string testName = itr->first;
34  std::string testType = params.at("type");
35 
36  if (!std::strcmp(testType.c_str(), ContentsXRange::getAlgoName().c_str()))
37  this->EnableXRangeTest(testName, params, bei);
38  if (!std::strcmp(testType.c_str(), ContentsYRange::getAlgoName().c_str()))
39  this->EnableYRangeTest(testName, params, bei);
40  if (!std::strcmp(testType.c_str(), DeadChannel::getAlgoName().c_str()))
41  this->EnableDeadChannelTest(testName, params, bei);
42  if (!std::strcmp(testType.c_str(), NoisyChannel::getAlgoName().c_str()))
43  this->EnableNoisyChannelTest(testName, params, bei);
44  if (!std::strcmp(testType.c_str(), ContentSigma::getAlgoName().c_str()))
45  this->EnableContentSigmaTest(testName, params, bei);
46  if (!std::strcmp(testType.c_str(), MeanWithinExpected::getAlgoName().c_str()))
47  this->EnableMeanWithinExpectedTest(testName, params, bei);
48  if (!std::strcmp(testType.c_str(), ContentsWithinExpected::getAlgoName().c_str()))
49  this->EnableContentsWithinExpectedTest(testName, params, bei);
50  if (!std::strcmp(testType.c_str(), CompareToMedian::getAlgoName().c_str()))
51  this->EnableCompareToMedianTest(testName, params, bei);
52  if (!std::strcmp(testType.c_str(), CompareLastFilledBin::getAlgoName().c_str()))
53  this->EnableCompareLastFilledBinTest(testName, params, bei);
54  if (!std::strcmp(testType.c_str(), CheckVariance::getAlgoName().c_str()))
55  this->EnableCheckVarianceTest(testName, params, bei);
56  }
57  return false;
58 }
59 
61  const std::map<std::string, std::string> &params,
62  DQMStore *bei) {
63  QCriterion *qc1;
64  if (!bei->getQCriterion(testName)) {
65  testsConfigured.push_back(testName);
66  qc1 = bei->createQTest(ContentsXRange::getAlgoName(), testName);
67  } else {
68  qc1 = bei->getQCriterion(testName);
69  }
70  ContentsXRange *me_qc1 = (ContentsXRange *)qc1;
71  double xmin = atof(findOrDefault(params, "xmin", "0"));
72  double xmax = atof(findOrDefault(params, "xmax", "0"));
73  double warning = atof(findOrDefault(params, "warning", "0"));
74  double error = atof(findOrDefault(params, "error", "0"));
75  me_qc1->setAllowedXRange(xmin, xmax);
76  me_qc1->setWarningProb(warning);
77  me_qc1->setErrorProb(error);
78 }
79 
81  const std::map<std::string, std::string> &params,
82  DQMStore *bei) {
83  QCriterion *qc1;
84  if (!bei->getQCriterion(testName)) {
85  testsConfigured.push_back(testName);
86  qc1 = bei->createQTest(ContentsYRange::getAlgoName(), testName);
87  } else {
88  qc1 = bei->getQCriterion(testName);
89  }
90  ContentsYRange *me_qc1 = (ContentsYRange *)qc1;
91  double ymin = atof(findOrDefault(params, "ymin", "0"));
92  double ymax = atof(findOrDefault(params, "ymax", "0"));
93  double warning = atof(findOrDefault(params, "warning", "0"));
94  double error = atof(findOrDefault(params, "error", "0"));
95  unsigned int useEmptyBins = (unsigned int)atof(findOrDefault(params, "useEmptyBins", "0"));
96  me_qc1->setAllowedYRange(ymin, ymax);
97  me_qc1->setWarningProb(warning);
98  me_qc1->setErrorProb(error);
99  me_qc1->setUseEmptyBins(useEmptyBins);
100 }
101 
103  const std::map<std::string, std::string> &params,
104  DQMStore *bei) {
105  QCriterion *qc1;
106  if (!bei->getQCriterion(testName)) {
107  testsConfigured.push_back(testName);
108  qc1 = bei->createQTest(DeadChannel::getAlgoName(), testName);
109  } else {
110  qc1 = bei->getQCriterion(testName);
111  }
112  DeadChannel *me_qc1 = (DeadChannel *)qc1;
113  unsigned int threshold = (unsigned int)atof(findOrDefault(params, "threshold", "0"));
114  double warning = atof(findOrDefault(params, "warning", "0"));
115  double error = atof(findOrDefault(params, "error", "0"));
116  me_qc1->setThreshold(threshold);
117  me_qc1->setWarningProb(warning);
118  me_qc1->setErrorProb(error);
119 }
120 
122  const std::map<std::string, std::string> &params,
123  DQMStore *bei) {
124  QCriterion *qc1;
125  if (!bei->getQCriterion(testName)) {
126  testsConfigured.push_back(testName);
127  qc1 = bei->createQTest(NoisyChannel::getAlgoName(), testName);
128  } else {
129  qc1 = bei->getQCriterion(testName);
130  }
131  NoisyChannel *me_qc1 = (NoisyChannel *)qc1;
132  unsigned int neighbors = (unsigned int)atof(findOrDefault(params, "neighbours", "0"));
133  double tolerance = atof(findOrDefault(params, "tolerance", "0"));
134  double warning = atof(findOrDefault(params, "warning", "0"));
135  double error = atof(findOrDefault(params, "error", "0"));
136  me_qc1->setNumNeighbors(neighbors);
137  me_qc1->setTolerance(tolerance);
138  me_qc1->setWarningProb(warning);
139  me_qc1->setErrorProb(error);
140 }
141 
142 //================ContentSigma (Emma Yeager and Chad Freer)=====================//
144  const std::map<std::string, std::string> &params,
145  DQMStore *bei) {
146  QCriterion *qc1;
147  if (!bei->getQCriterion(testName)) {
148  testsConfigured.push_back(testName);
149  qc1 = bei->createQTest(ContentSigma::getAlgoName(), testName);
150  } else {
151  qc1 = bei->getQCriterion(testName);
152  }
153  ContentSigma *me_qc1 = (ContentSigma *)qc1;
154  unsigned int Xblocks = (unsigned int)atof(findOrDefault(params, "Xblocks", "0"));
155  unsigned int Yblocks = (unsigned int)atof(findOrDefault(params, "Yblocks", "0"));
156  unsigned int neighborsX = (unsigned int)atof(findOrDefault(params, "neighboursX", "0"));
157  unsigned int neighborsY = (unsigned int)atof(findOrDefault(params, "neighboursY", "0"));
158  double toleranceNoisy = atof(findOrDefault(params, "toleranceNoisy", "0"));
159  double toleranceDead = atof(findOrDefault(params, "toleranceDead", "0"));
160  int noisy = atoi(findOrDefault(params, "noisy", "0"));
161  int dead = atoi(findOrDefault(params, "dead", "0"));
162  unsigned int xMin = (unsigned int)atof(findOrDefault(params, "xMin", "1"));
163  unsigned int xMax = (unsigned int)atof(findOrDefault(params, "xMax", "500"));
164  unsigned int yMin = (unsigned int)atof(findOrDefault(params, "yMin", "1"));
165  unsigned int yMax = (unsigned int)atof(findOrDefault(params, "yMax", "500"));
166  double warning = atof(findOrDefault(params, "warning", "0"));
167  double error = atof(findOrDefault(params, "error", "0"));
168  me_qc1->setNumXblocks(Xblocks);
169  me_qc1->setNumYblocks(Yblocks);
170  me_qc1->setNumNeighborsX(neighborsX);
171  me_qc1->setNumNeighborsY(neighborsY);
172  me_qc1->setToleranceNoisy(toleranceNoisy);
173  me_qc1->setToleranceDead(toleranceDead);
174  me_qc1->setNoisy(noisy);
175  me_qc1->setDead(dead);
176  me_qc1->setXMin(xMin);
177  me_qc1->setXMax(xMax);
178  me_qc1->setYMin(yMin);
179  me_qc1->setYMax(yMax);
180  me_qc1->setWarningProb(warning);
181  me_qc1->setErrorProb(error);
182 }
183 
184 //==========================================================================//
185 
187  const std::map<std::string, std::string> &params,
188  DQMStore *bei) {
189  QCriterion *qc1;
190  if (!bei->getQCriterion(testName)) {
191  testsConfigured.push_back(testName);
192  qc1 = bei->createQTest(MeanWithinExpected::getAlgoName(), testName);
193  } else {
194  qc1 = bei->getQCriterion(testName);
195  }
196  MeanWithinExpected *me_qc1 = (MeanWithinExpected *)qc1;
197  double warning = atof(findOrDefault(params, "warning", "0"));
198  double error = atof(findOrDefault(params, "error", "0"));
199  double mean = atof(findOrDefault(params, "mean", "0"));
200  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
201  double useRMSVal = atof(findOrDefault(params, "useRMS", "0"));
202  double useSigmaVal = atof(findOrDefault(params, "useSigma", "0"));
203  double useRangeVal = atof(findOrDefault(params, "useRange", "0"));
204  me_qc1->setWarningProb(warning);
205  me_qc1->setErrorProb(error);
206  me_qc1->setExpectedMean(mean);
207 
208  if (minEntries != 0)
209  me_qc1->setMinimumEntries(minEntries);
210 
211  if (useRMSVal && useSigmaVal && useRangeVal)
212  return;
213 
214  if (useRMSVal) {
215  me_qc1->useRMS();
216  return;
217  }
218 
219  if (useSigmaVal) {
220  me_qc1->useSigma(useSigmaVal);
221  return;
222  }
223 
224  if (useRangeVal) {
225  float xmin = atof(findOrDefault(params, "xmin", "0"));
226  float xmax = atof(findOrDefault(params, "xmax", "0"));
227  me_qc1->useRange(xmin, xmax);
228  return;
229  }
230 }
231 
233  const std::map<std::string, std::string> &params,
234  DQMStore *bei) {
235  QCriterion *qc1;
236  if (!bei->getQCriterion(testName)) {
237  testsConfigured.push_back(testName);
238  qc1 = bei->createQTest(CompareToMedian::getAlgoName(), testName);
239  } else {
240  qc1 = bei->getQCriterion(testName);
241  }
242  CompareToMedian *vtm = (CompareToMedian *)qc1;
243  vtm->setMin((double)atof(findOrDefault(params, "MinRel", "0")));
244  vtm->setMax((double)atof(findOrDefault(params, "MaxRel", "0")));
245  vtm->setEmptyBins((int)atoi(findOrDefault(params, "UseEmptyBins", "0")));
246  vtm->setMinMedian((double)atof(findOrDefault(params, "MinAbs", "0")));
247  vtm->setMaxMedian((double)atof(findOrDefault(params, "MaxAbs", "0")));
248  vtm->setWarningProb((double)atof(findOrDefault(params, "warning", "0")));
249  vtm->setErrorProb((double)atof(findOrDefault(params, "error", "0")));
250  vtm->setStatCut((double)atof(findOrDefault(params, "StatCut", "0")));
251 }
252 
253 /*
254  void QTestConfigure::EnableMostProbableLandauTest(
255  const std::string &roTEST_NAME,
256  std::map<std::string, std::string> &roMParams,
257  DQMStore *bei) {
258 
259  // Create QTest or Get already assigned one
260  MostProbableLandau *poQTest = 0;
261  if( QCriterion *poQCriteration = bei->getQCriterion( roTEST_NAME)) {
262  // Current already assigned to given ME.
263  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
264  } else {
265  // Test does not exist: create one
266  testsConfigured.push_back( roTEST_NAME);
267  poQCriteration = bei->createQTest( MostProbableLandau::getAlgoName(),
268  roTEST_NAME);
269 
270  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
271  }
272 
273  // Set probabilities thresholds.
274  poQTest->setErrorProb ( atof( roMfindOrDefault(params, "error", "0") );
275  poQTest->setWarningProb ( atof( roMfindOrDefault(params, "warning", "0") );
276  poQTest->setXMin ( atof( roMfindOrDefault(params, "xmin", "0") );
277  poQTest->setXMax ( atof( roMfindOrDefault(params, "xmax", "0") );
278  poQTest->setNormalization( atof( roMfindOrDefault(params, "normalization", "0") );
279  poQTest->setMostProbable ( atof( roMfindOrDefault(params, "mostprobable", "0") );
280  poQTest->setSigma ( atof( roMfindOrDefault(params, "sigma", "0") );
281  }
282 */
284  const std::map<std::string, std::string> &params,
285  DQMStore *bei) {
286  QCriterion *qc1;
287  if (!bei->getQCriterion(testName)) {
288  testsConfigured.push_back(testName);
289  qc1 = bei->createQTest(ContentsWithinExpected::getAlgoName(), testName);
290  } else {
291  qc1 = bei->getQCriterion(testName);
292  }
294  unsigned int useEmptyBins = (unsigned int)atof(findOrDefault(params, "useEmptyBins", "0"));
295  double warning = atof(findOrDefault(params, "warning", "0"));
296  double error = atof(findOrDefault(params, "error", "0"));
297  double minMean = atof(findOrDefault(params, "minMean", "0"));
298  double maxMean = atof(findOrDefault(params, "maxMean", "0"));
299  double minRMS = atof(findOrDefault(params, "minRMS", "0"));
300  double maxRMS = atof(findOrDefault(params, "maxRMS", "0"));
301  double toleranceMean = atof(findOrDefault(params, "toleranceMean", "0"));
302  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
303  me_qc1->setUseEmptyBins(useEmptyBins);
304  me_qc1->setWarningProb(warning);
305  me_qc1->setErrorProb(error);
306 
307  if (minMean != 0 || maxMean != 0)
308  me_qc1->setMeanRange(minMean, maxMean);
309 
310  if (minRMS != 0 || maxRMS != 0)
311  me_qc1->setRMSRange(minRMS, maxRMS);
312 
313  if (toleranceMean != 0)
314  me_qc1->setMeanTolerance(toleranceMean);
315 
316  if (minEntries != 0)
317  me_qc1->setMinimumEntries(minEntries);
318 }
319 
321  const std::map<std::string, std::string> &params,
322  DQMStore *bei) {
323  QCriterion *qc1;
324  if (!bei->getQCriterion(testName)) {
325  testsConfigured.push_back(testName);
326  qc1 = bei->createQTest(CompareLastFilledBin::getAlgoName(), testName);
327  } else {
328  qc1 = bei->getQCriterion(testName);
329  }
331 
332  double warning = atof(findOrDefault(params, "warning", "0"));
333  double error = atof(findOrDefault(params, "error", "0"));
334  double avVal = atof(findOrDefault(params, "AvVal", "0"));
335  double minVal = atof(findOrDefault(params, "MinVal", "0"));
336  double maxVal = atof(findOrDefault(params, "MaxVal", "0"));
337  me_qc1->setWarningProb(warning);
338  me_qc1->setErrorProb(error);
339  me_qc1->setAverage(avVal);
340  me_qc1->setMin(minVal);
341  me_qc1->setMax(maxVal);
342 }
344  const std::map<std::string, std::string> &params,
345  DQMStore *bei) {
346  QCriterion *qc1;
347  if (!bei->getQCriterion(testName)) {
348  testsConfigured.push_back(testName);
349  qc1 = bei->createQTest(CheckVariance::getAlgoName(), testName);
350  } else {
351  qc1 = bei->getQCriterion(testName);
352  }
353  CheckVariance *me_qc1 = (CheckVariance *)qc1;
354 
355  double warning = atof(findOrDefault(params, "warning", "0"));
356  double error = atof(findOrDefault(params, "error", "0"));
357  me_qc1->setWarningProb(warning);
358  me_qc1->setErrorProb(error);
359 }
360 
361 /* void QTestConfigure::EnableContentsWithinExpectedASTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
362 
363 QCriterion * qc1;
364 if(! bei->getQCriterion(testName) ){
365 testsConfigured.push_back(testName);
366 qc1 = bei->createQTest(ContentsWithinExpectedAS::getAlgoName(),testName);
367 }else{
368 qc1 = bei->getQCriterion(testName);
369 }
370 ContentsWithinExpectedAS * me_qc1 = (ContentsWithinExpectedAS *) qc1;
371 
372 double warning=atof(findOrDefault(params, "warning", "0");
373 double error=atof(findOrDefault(params, "error", "0");
374 me_qc1->setWarningProb(warning);
375 me_qc1->setErrorProb(error);
376 
377 double minCont=atof(findOrDefault(params, "minCont", "0");
378 double maxCont=atof(findOrDefault(params, "maxCont", "0");
379 if ( minCont != 0 || maxCont != 0 ) me_qc1->setContentsRange(minCont, maxCont);
380 
381 
382 } */
#define LogDebug(id)
void setErrorProb(float prob)
Definition: QTest.h:78
void setStatCut(float cut)
Definition: QTest.h:649
void EnableContentSigmaTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentSigmaROOT test.
void setDead(bool dead)
Definition: QTest.h:354
test that histogram contents are above Ymin
Definition: QTest.h:232
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:216
void setMin(float min)
Definition: QTest.h:644
void setXMax(unsigned xMax)
Definition: QTest.h:357
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:193
const double tolerance
void EnableNoisyChannelTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates NoisyChannelROOT test.
void setRMSRange(double xmin, double xmax)
set expected value for mean
Definition: QTest.cc:1062
void useSigma(double expectedSigma)
Definition: QTest.cc:1155
void EnableYRangeTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsXRangeASROOT test.
QCriterion * createQTest(std::string const &algoname, std::string const &qtname)
Definition: DQMStore.cc:2822
void setMax(float max)
Definition: QTest.h:645
void EnableCompareToMedianTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsWithinRangeROOT test.
void setMin(float min)
Definition: QTest.h:691
void setNumNeighbors(unsigned n)
Definition: QTest.h:271
Algorithm for testing if histogram&#39;s mean value is near expected value.
Definition: QTest.h:435
void EnableCheckVarianceTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates CheckVariance test.
Check if any channels are noisy compared to neighboring ones.
Definition: QTest.h:254
static std::string getAlgoName()
Definition: QTest.h:641
void setYMax(unsigned yMax)
Definition: QTest.h:359
static std::string getAlgoName()
Definition: QTest.h:438
void setYMin(unsigned yMin)
Definition: QTest.h:358
void setEmptyBins(int eB)
Definition: QTest.h:646
std::vector< std::string > testsConfigured
void EnableXRangeTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsXRangeROOT test.
void EnableMeanWithinExpectedTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates MeanWithinExpectedROOT test.
static std::string getAlgoName()
Definition: QTest.h:189
void setTolerance(float percentage)
Definition: QTest.h:280
const char * findOrDefault(const std::map< std::string, std::string > &, const char *, const char *) const
void setMinimumEntries(unsigned n)
set minimum # of entries needed
Definition: QTest.h:162
void setExpectedMean(double mean)
Definition: QTest.h:441
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:411
void setMaxMedian(float max)
Definition: QTest.h:647
void useRange(double xmin, double xmax)
Definition: QTest.cc:1145
void setNumNeighborsX(unsigned ncx)
Definition: QTest.h:329
void setToleranceNoisy(float factorNoisy)
Definition: QTest.h:341
Check the sigma of each bin against the rest of the chamber by a factor of tolerance/.
Definition: QTest.h:301
static std::string getAlgoName()
Definition: QTest.h:408
QCriterion * getQCriterion(std::string const &qtname) const
Definition: DQMStore.cc:2813
void setNumYblocks(unsigned ncy)
Definition: QTest.h:325
void setWarningProb(float prob)
set probability limit for warning and error (default: 90% and 50%)
Definition: QTest.h:77
static std::string getAlgoName()
Definition: QTest.h:238
void setMax(float max)
Definition: QTest.h:692
void setMeanRange(double xmin, double xmax)
set expected value for mean
Definition: QTest.cc:1051
static std::string getAlgoName()
get algorithm name
Definition: QTest.h:743
void EnableDeadChannelTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsYRangeASROOT test.
void setNoisy(bool noisy)
Definition: QTest.h:353
bool enableTests(const std::map< std::string, std::map< std::string, std::string > > &tests, DQMStore *bei)
Creates and defines quality tests.
void setNumNeighborsY(unsigned ncy)
Definition: QTest.h:333
void setXMin(unsigned xMin)
Definition: QTest.h:356
static std::string getAlgoName()
Definition: QTest.h:311
void setMeanTolerance(float fracTolerance)
set (fractional) tolerance for mean
Definition: QTest.h:416
void setThreshold(double ymin)
set Ymin (inclusive) threshold for "dead" channel (default: 0)
Definition: QTest.h:242
void setNumXblocks(unsigned ncx)
Definition: QTest.h:321
void setAverage(float average)
Definition: QTest.h:690
void setToleranceDead(float factorDead)
Definition: QTest.h:347
void EnableContentsWithinExpectedTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsWithinRangeROOT test.
virtual void setAllowedYRange(double ymin, double ymax)
Definition: QTest.h:217
void EnableCompareLastFilledBinTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates EnableCompareLastFilledBinTest test.
static std::string getAlgoName()
Definition: QTest.h:261
void setMinMedian(float min)
Definition: QTest.h:648
static std::string getAlgoName()
Definition: QTest.h:213
static std::string getAlgoName()
Definition: QTest.h:687