CMS 3D CMS Logo

QTestConfigure.cc
Go to the documentation of this file.
1 
11 #include <cstring>
12 #include <cstdlib>
13 
14 
15 const char * QTestConfigure::findOrDefault(const std::map<std::string, std::string> &m,
16  const char * item,
17  const char * default_value) const {
18  std::map<std::string, std::string>::const_iterator iter;
19  if (( iter = m.find(std::string(item))) != m.end()) {
20  return (*iter).second.c_str();
21  }
22  LogDebug("QTestConfigure") << "Warning, using default value for parameter "
23  << item << " with default_value: "
24  << default_value << std::endl;
25  return default_value;
26 }
27 
29  const std::map<std::string, std::map<std::string, std::string> > & tests,
30  DQMStore * bei) {
31  testsConfigured.clear();
32  std::map<std::string, std::map<std::string, std::string> >::const_iterator itr;
33  for (itr = tests.begin(); itr!= tests.end();++itr) {
34  const std::map<std::string, std::string> &params= itr->second;
35 
36  std::string testName = itr->first;
37  std::string testType = params.at("type");
38 
39  if(!std::strcmp(testType.c_str(),ContentsXRange::getAlgoName().c_str()))
40  this->EnableXRangeTest(testName, params,bei);
41  if(!std::strcmp(testType.c_str(),ContentsYRange::getAlgoName().c_str()))
42  this->EnableYRangeTest(testName, params,bei);
43  if(!std::strcmp(testType.c_str(),DeadChannel::getAlgoName().c_str()))
44  this->EnableDeadChannelTest(testName, params,bei);
45  if(!std::strcmp(testType.c_str(),NoisyChannel::getAlgoName().c_str()))
46  this->EnableNoisyChannelTest(testName, params,bei);
47  if(!std::strcmp(testType.c_str(),MeanWithinExpected::getAlgoName().c_str()))
48  this->EnableMeanWithinExpectedTest(testName, params,bei);
49  if(!std::strcmp(testType.c_str(),Comp2RefEqualH::getAlgoName().c_str()))
50  this->EnableComp2RefEqualHTest(testName, params,bei);
51  if(!std::strcmp(testType.c_str(), Comp2RefChi2::getAlgoName().c_str()))
52  this->EnableComp2RefChi2Test(testName, params,bei);
53  if(!std::strcmp(testType.c_str(), Comp2Ref2DChi2::getAlgoName().c_str()))
54  this->EnableComp2Ref2DChi2Test(testName, params,bei);
55  if(!std::strcmp(testType.c_str(),Comp2RefKolmogorov::getAlgoName().c_str()))
56  this->EnableComp2RefKolmogorovTest(testName, params,bei);
57  if(!std::strcmp(testType.c_str(),ContentsWithinExpected::getAlgoName().c_str()))
58  this->EnableContentsWithinExpectedTest(testName, params, bei);
59  if(!std::strcmp(testType.c_str(),CompareToMedian::getAlgoName().c_str()))
60  this->EnableCompareToMedianTest(testName, params, bei);
61  if(!std::strcmp(testType.c_str(),CompareLastFilledBin::getAlgoName().c_str()))
62  this->EnableCompareLastFilledBinTest(testName, params, bei);
63  if(!std::strcmp(testType.c_str(),CheckVariance::getAlgoName().c_str()))
64  this->EnableCheckVarianceTest(testName, params, bei);
65  }
66  return false;
67 }
68 
70  const std::map<std::string, std::string> & params,
71  DQMStore *bei) {
72  QCriterion * qc1;
73  if (! bei->getQCriterion(testName)) {
74  testsConfigured.push_back(testName);
75  qc1 = bei->createQTest(Comp2RefEqualH::getAlgoName(), testName);
76  } else {
77  qc1 = bei->getQCriterion(testName);
78  }
79  Comp2RefEqualH * me_qc1 = (Comp2RefEqualH *) qc1;
80  double warning = atof(findOrDefault(params, "warning", "0"));
81  double error = atof(findOrDefault(params, "error", "0"));
82  me_qc1->setWarningProb(warning);
83  me_qc1->setErrorProb(error);
84 }
85 
87  const std::map<std::string, std::string> & params,
88  DQMStore *bei) {
89  QCriterion * qc1;
90  if (! bei->getQCriterion(testName)) {
91  testsConfigured.push_back(testName);
92  qc1 = bei->createQTest(Comp2RefChi2::getAlgoName(), testName);
93  } else {
94  qc1 = bei->getQCriterion(testName);
95  }
96  Comp2RefChi2 * me_qc1 = (Comp2RefChi2 *) qc1;
97  double warning = atof(findOrDefault(params, "warning", "0"));
98  double error = atof(findOrDefault(params, "error", "0"));
99  me_qc1->setWarningProb(warning);
100  me_qc1->setErrorProb(error);
101 }
102 
104  const std::map<std::string, std::string> & params,
105  DQMStore *bei) {
106  QCriterion * qc1;
107  if (! bei->getQCriterion(testName)) {
108  testsConfigured.push_back(testName);
109  qc1 = bei->createQTest(Comp2Ref2DChi2::getAlgoName(), testName);
110  } else {
111  qc1 = bei->getQCriterion(testName);
112  }
113  Comp2Ref2DChi2 * me_qc1 = (Comp2Ref2DChi2 *) qc1;
114  double warning = atof(findOrDefault(params, "warning", "0"));
115  double error = atof(findOrDefault(params, "error", "0"));
116  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
117  me_qc1->setWarningProb(warning);
118  me_qc1->setErrorProb(error);
119  if ( minEntries != 0 )
120  me_qc1->setMinimumEntries(minEntries);
121 }
122 
124  const std::map<std::string, std::string> & params,
125  DQMStore *bei) {
126  QCriterion * qc1;
127  if (! bei->getQCriterion(testName)) {
128  testsConfigured.push_back(testName);
129  qc1 = bei->createQTest(Comp2RefKolmogorov::getAlgoName(), testName);
130  } else {
131  qc1 = bei->getQCriterion(testName);
132  }
133  Comp2RefKolmogorov * me_qc1 = (Comp2RefKolmogorov *) qc1;
134  double warning = atof(findOrDefault(params, "warning", "0"));
135  double error = atof(findOrDefault(params, "error", "0"));
136  me_qc1->setWarningProb(warning);
137  me_qc1->setErrorProb(error);
138 }
139 
141  const std::map<std::string, std::string> & params,
142  DQMStore *bei) {
143  QCriterion * qc1;
144  if (! bei->getQCriterion(testName)) {
145  testsConfigured.push_back(testName);
146  qc1 = bei->createQTest(ContentsXRange::getAlgoName(),testName);
147  } else {
148  qc1 = bei->getQCriterion(testName);
149  }
150  ContentsXRange * me_qc1 = (ContentsXRange *) qc1;
151  double xmin = atof(findOrDefault(params, "xmin", "0"));
152  double xmax = atof(findOrDefault(params, "xmax", "0"));
153  double warning = atof(findOrDefault(params, "warning", "0"));
154  double error = atof(findOrDefault(params, "error", "0"));
155  me_qc1->setAllowedXRange(xmin, xmax);
156  me_qc1->setWarningProb(warning);
157  me_qc1->setErrorProb(error);
158 }
159 
161  const std::map<std::string, std::string> & params,
162  DQMStore *bei) {
163  QCriterion * qc1;
164  if (! bei->getQCriterion(testName)) {
165  testsConfigured.push_back(testName);
166  qc1 = bei->createQTest(ContentsYRange::getAlgoName(), testName);
167  } else {
168  qc1 = bei->getQCriterion(testName);
169  }
170  ContentsYRange * me_qc1 = (ContentsYRange *) qc1;
171  double ymin = atof(findOrDefault(params, "ymin", "0"));
172  double ymax = atof(findOrDefault(params, "ymax", "0"));
173  double warning = atof(findOrDefault(params, "warning", "0"));
174  double error = atof(findOrDefault(params, "error", "0"));
175  unsigned int useEmptyBins = (unsigned int)atof(findOrDefault(params, "useEmptyBins", "0"));
176  me_qc1->setAllowedYRange(ymin, ymax);
177  me_qc1->setWarningProb(warning);
178  me_qc1->setErrorProb(error);
179  me_qc1->setUseEmptyBins(useEmptyBins);
180 }
181 
183  const std::map<std::string, std::string> & params,
184  DQMStore *bei) {
185  QCriterion * qc1;
186  if (! bei->getQCriterion(testName)) {
187  testsConfigured.push_back(testName);
188  qc1 = bei->createQTest(DeadChannel::getAlgoName(), testName);
189  } else {
190  qc1 = bei->getQCriterion(testName);
191  }
192  DeadChannel * me_qc1 = ( DeadChannel *) qc1;
193  unsigned int threshold =(unsigned int) atof(findOrDefault(params, "threshold", "0"));
194  double warning = atof(findOrDefault(params, "warning", "0"));
195  double error = atof(findOrDefault(params, "error", "0"));
196  me_qc1->setThreshold(threshold);
197  me_qc1->setWarningProb(warning);
198  me_qc1->setErrorProb(error);
199 }
200 
202  const std::map<std::string, std::string> & params,
203  DQMStore *bei) {
204  QCriterion * qc1;
205  if (! bei->getQCriterion(testName)) {
206  testsConfigured.push_back(testName);
207  qc1 = bei->createQTest(NoisyChannel::getAlgoName(), testName);
208  } else {
209  qc1 = bei->getQCriterion(testName);
210  }
211  NoisyChannel * me_qc1 = (NoisyChannel *) qc1;
212  unsigned int neighbors = (unsigned int) atof(findOrDefault(params, "neighbours", "0"));
213  double tolerance = atof(findOrDefault(params, "tolerance", "0"));
214  double warning = atof(findOrDefault(params, "warning", "0"));
215  double error = atof(findOrDefault(params, "error", "0"));
216  me_qc1->setNumNeighbors (neighbors);
217  me_qc1->setTolerance (tolerance);
218  me_qc1->setWarningProb(warning);
219  me_qc1->setErrorProb(error);
220 }
221 
223  const std::map<std::string, std::string> & params,
224  DQMStore *bei) {
225  QCriterion * qc1;
226  if (! bei->getQCriterion(testName)) {
227  testsConfigured.push_back(testName);
228  qc1 = bei->createQTest(MeanWithinExpected::getAlgoName(), testName);
229  } else {
230  qc1 = bei->getQCriterion(testName);
231  }
232  MeanWithinExpected * me_qc1 = (MeanWithinExpected *) qc1;
233  double warning = atof(findOrDefault(params, "warning", "0"));
234  double error = atof(findOrDefault(params, "error", "0"));
235  double mean = atof(findOrDefault(params, "mean", "0"));
236  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
237  double useRMSVal = atof(findOrDefault(params, "useRMS", "0"));
238  double useSigmaVal = atof(findOrDefault(params, "useSigma", "0"));
239  double useRangeVal = atof(findOrDefault(params, "useRange", "0"));
240  me_qc1->setWarningProb(warning);
241  me_qc1->setErrorProb(error);
242  me_qc1->setExpectedMean(mean);
243 
244  if (minEntries != 0)
245  me_qc1->setMinimumEntries(minEntries);
246 
247  if (useRMSVal && useSigmaVal && useRangeVal)
248  return;
249 
250  if (useRMSVal) {
251  me_qc1->useRMS();
252  return;
253  }
254 
255  if (useSigmaVal) {
256  me_qc1->useSigma(useSigmaVal);
257  return;
258  }
259 
260  if(useRangeVal) {
261  float xmin = atof(findOrDefault(params, "xmin", "0"));
262  float xmax = atof(findOrDefault(params, "xmax", "0"));
263  me_qc1->useRange(xmin,xmax);
264  return;
265  }
266 }
267 
269  const std::map<std::string, std::string> & params,
270  DQMStore *bei) {
271  QCriterion *qc1;
272  if (! bei->getQCriterion(testName)) {
273  testsConfigured.push_back(testName);
274  qc1 = bei->createQTest(CompareToMedian::getAlgoName(), testName);
275  } else {
276  qc1 = bei->getQCriterion(testName);
277  }
278  CompareToMedian* vtm = (CompareToMedian*) qc1;
279  vtm->setMin( (double) atof(findOrDefault(params, "MinRel", "0")));
280  vtm->setMax( (double) atof(findOrDefault(params, "MaxRel", "0")));
281  vtm->setEmptyBins( (int) atoi(findOrDefault(params, "UseEmptyBins", "0")));
282  vtm->setMinMedian( (double) atof(findOrDefault(params, "MinAbs", "0")));
283  vtm->setMaxMedian( (double) atof(findOrDefault(params, "MaxAbs", "0")));
284  vtm->setWarningProb( (double) atof(findOrDefault(params, "warning", "0")));
285  vtm->setErrorProb( (double) atof(findOrDefault(params, "error", "0")));
286  vtm->setStatCut( (double) atof(findOrDefault(params, "StatCut", "0")));
287 }
288 
289 /*
290  void QTestConfigure::EnableMostProbableLandauTest(
291  const std::string &roTEST_NAME,
292  std::map<std::string, std::string> &roMParams,
293  DQMStore *bei) {
294 
295  // Create QTest or Get already assigned one
296  MostProbableLandau *poQTest = 0;
297  if( QCriterion *poQCriteration = bei->getQCriterion( roTEST_NAME)) {
298  // Current already assigned to given ME.
299  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
300  } else {
301  // Test does not exist: create one
302  testsConfigured.push_back( roTEST_NAME);
303  poQCriteration = bei->createQTest( MostProbableLandau::getAlgoName(),
304  roTEST_NAME);
305 
306  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
307  }
308 
309  // Set probabilities thresholds.
310  poQTest->setErrorProb ( atof( roMfindOrDefault(params, "error", "0") );
311  poQTest->setWarningProb ( atof( roMfindOrDefault(params, "warning", "0") );
312  poQTest->setXMin ( atof( roMfindOrDefault(params, "xmin", "0") );
313  poQTest->setXMax ( atof( roMfindOrDefault(params, "xmax", "0") );
314  poQTest->setNormalization( atof( roMfindOrDefault(params, "normalization", "0") );
315  poQTest->setMostProbable ( atof( roMfindOrDefault(params, "mostprobable", "0") );
316  poQTest->setSigma ( atof( roMfindOrDefault(params, "sigma", "0") );
317  }
318 */
320  const std::map<std::string, std::string> & params,
321  DQMStore *bei) {
322  QCriterion * qc1;
323  if (! bei->getQCriterion(testName)) {
324  testsConfigured.push_back(testName);
325  qc1 = bei->createQTest(ContentsWithinExpected::getAlgoName(), testName);
326  } else {
327  qc1 = bei->getQCriterion(testName);
328  }
330  unsigned int useEmptyBins = (unsigned int) atof(findOrDefault(params, "useEmptyBins", "0"));
331  double warning = atof(findOrDefault(params, "warning", "0"));
332  double error = atof(findOrDefault(params, "error", "0"));
333  double minMean = atof(findOrDefault(params, "minMean", "0"));
334  double maxMean = atof(findOrDefault(params, "maxMean", "0"));
335  double minRMS = atof(findOrDefault(params, "minRMS", "0"));
336  double maxRMS = atof(findOrDefault(params, "maxRMS", "0"));
337  double toleranceMean = atof(findOrDefault(params, "toleranceMean", "0"));
338  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
339  me_qc1->setUseEmptyBins(useEmptyBins);
340  me_qc1->setWarningProb(warning);
341  me_qc1->setErrorProb(error);
342 
343  if ( minMean != 0 || maxMean != 0 )
344  me_qc1->setMeanRange(minMean, maxMean);
345 
346  if ( minRMS != 0 || maxRMS != 0 )
347  me_qc1->setRMSRange(minRMS, maxRMS);
348 
349  if ( toleranceMean != 0 )
350  me_qc1->setMeanTolerance(toleranceMean);
351 
352  if ( minEntries != 0 )
353  me_qc1->setMinimumEntries(minEntries);
354 }
355 
357  const std::map<std::string, std::string> & params,
358  DQMStore *bei) {
359  QCriterion * qc1;
360  if (! bei->getQCriterion(testName)) {
361  testsConfigured.push_back(testName);
362  qc1 = bei->createQTest(CompareLastFilledBin::getAlgoName(), testName);
363  } else {
364  qc1 = bei->getQCriterion(testName);
365  }
366  CompareLastFilledBin * me_qc1 = (CompareLastFilledBin *) qc1;
367 
368  double warning = atof(findOrDefault(params, "warning", "0"));
369  double error = atof(findOrDefault(params, "error", "0"));
370  double avVal = atof(findOrDefault(params, "AvVal", "0"));
371  double minVal = atof(findOrDefault(params, "MinVal", "0"));
372  double maxVal = atof(findOrDefault(params, "MaxVal", "0"));
373  me_qc1->setWarningProb(warning);
374  me_qc1->setErrorProb(error);
375  me_qc1->setAverage(avVal);
376  me_qc1->setMin(minVal);
377  me_qc1->setMax(maxVal);
378 }
380  const std::map<std::string, std::string>& params,
381  DQMStore *bei){
382  QCriterion * qc1;
383  if(! bei->getQCriterion(testName) ){
384  testsConfigured.push_back(testName);
385  qc1 = bei->createQTest(CheckVariance::getAlgoName(),testName);
386  }else{
387  qc1 = bei->getQCriterion(testName);
388 
389  }
390  CheckVariance * me_qc1 = (CheckVariance *) qc1;
391 
392  double warning = atof(findOrDefault(params, "warning", "0"));
393  double error = atof(findOrDefault(params, "error", "0"));
394  me_qc1->setWarningProb(warning);
395  me_qc1->setErrorProb(error);
396 }
397 
398 /* void QTestConfigure::EnableContentsWithinExpectedASTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
399 
400 QCriterion * qc1;
401 if(! bei->getQCriterion(testName) ){
402 testsConfigured.push_back(testName);
403 qc1 = bei->createQTest(ContentsWithinExpectedAS::getAlgoName(),testName);
404 }else{
405 qc1 = bei->getQCriterion(testName);
406 }
407 ContentsWithinExpectedAS * me_qc1 = (ContentsWithinExpectedAS *) qc1;
408 
409 double warning=atof(findOrDefault(params, "warning", "0");
410 double error=atof(findOrDefault(params, "error", "0");
411 me_qc1->setWarningProb(warning);
412 me_qc1->setErrorProb(error);
413 
414 double minCont=atof(findOrDefault(params, "minCont", "0");
415 double maxCont=atof(findOrDefault(params, "maxCont", "0");
416 if ( minCont != 0 || maxCont != 0 ) me_qc1->setContentsRange(minCont, maxCont);
417 
418 
419 } */
420 
#define LogDebug(id)
void setErrorProb(float prob)
Definition: QTest.h:63
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:3281
static std::string getAlgoName(void)
get algorithm name
Definition: QTest.h:751
void setStatCut(float cut)
Definition: QTest.h:649
static std::string getAlgoName(void)
Definition: QTest.h:341
void useRMS(void)
Definition: QTest.cc:1348
test that histogram contents are above Ymin
Definition: QTest.h:306
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:290
void setMin(float min)
Definition: QTest.h:644
static std::string getAlgoName(void)
Definition: QTest.h:390
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:266
void EnableNoisyChannelTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates NoisyChannelROOT test.
static std::string getAlgoName(void)
Definition: QTest.h:262
void setRMSRange(double xmin, double xmax)
set expected value for mean
Definition: QTest.cc:1224
void useSigma(double expectedSigma)
Definition: QTest.cc:1337
void EnableYRangeTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsXRangeASROOT test.
void setMax(float max)
Definition: QTest.h:645
void EnableComp2Ref2DChi2Test(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates Comp2Ref2DChi2 test.
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:693
void setNumNeighbors(unsigned n)
Definition: QTest.h:351
static std::string getAlgoName(void)
Definition: QTest.h:314
Algorithm for testing if histogram&#39;s mean value is near expected value.
Definition: QTest.h:422
static std::string getAlgoName(void)
Definition: QTest.h:641
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:332
void setEmptyBins(int eB)
Definition: QTest.h:646
void EnableComp2RefEqualHTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates Comp2RefEqualH test.
std::vector< std::string > testsConfigured
static std::string getAlgoName(void)
Definition: QTest.h:247
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.
void setTolerance(float percentage)
Definition: QTest.h:357
const char * findOrDefault(const std::map< std::string, std::string > &, const char *, const char *) const
static std::string getAlgoName(void)
Definition: QTest.h:287
void setMinimumEntries(unsigned n)
set minimum # of entries needed
Definition: QTest.h:144
void setExpectedMean(double mean)
Definition: QTest.h:432
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:393
void setMaxMedian(float max)
Definition: QTest.h:647
void useRange(double xmin, double xmax)
Definition: QTest.cc:1327
static std::string getAlgoName(void)
Definition: QTest.h:178
void setWarningProb(float prob)
set probability limit for warning and error (default: 90% and 50%)
Definition: QTest.h:62
Comparison to reference using the Kolmogorov algorithm.
Definition: QTest.h:240
void setMax(float max)
Definition: QTest.h:694
void setMeanRange(double xmin, double xmax)
set expected value for mean
Definition: QTest.cc:1212
static std::string getAlgoName(void)
Definition: QTest.h:191
void EnableDeadChannelTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsYRangeASROOT test.
static std::string getAlgoName(void)
Definition: QTest.h:219
bool enableTests(const std::map< std::string, std::map< std::string, std::string > > &tests, DQMStore *bei)
Creates and defines quality tests.
void EnableComp2RefKolmogorovTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates EnableComp2RefKolmogorov test.
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:3292
void setMeanTolerance(float fracTolerance)
set (fractional) tolerance for mean
Definition: QTest.h:400
void setThreshold(double ymin)
set Ymin (inclusive) threshold for "dead" channel (default: 0)
Definition: QTest.h:318
void setAverage(float average)
Definition: QTest.h:692
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:291
void EnableCompareLastFilledBinTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates EnableCompareLastFilledBinTest test.
static std::string getAlgoName(void)
Definition: QTest.h:689
static std::string getAlgoName(void)
Definition: QTest.h:429
void setMinMedian(float min)
Definition: QTest.h:648
void EnableComp2RefChi2Test(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates Comp2RefChi2 test.