CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  edm::LogWarning("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(),Comp2RefKolmogorov::getAlgoName().c_str()))
54  this->EnableComp2RefKolmogorovTest(testName, params,bei);
55  if(!std::strcmp(testType.c_str(),ContentsWithinExpected::getAlgoName().c_str()))
56  this->EnableContentsWithinExpectedTest(testName, params, bei);
57  if(!std::strcmp(testType.c_str(),CompareToMedian::getAlgoName().c_str()))
58  this->EnableCompareToMedianTest(testName, params, bei);
59  if(!std::strcmp(testType.c_str(),CompareLastFilledBin::getAlgoName().c_str()))
60  this->EnableCompareLastFilledBinTest(testName, params, bei);
61  if(!std::strcmp(testType.c_str(),CheckVariance::getAlgoName().c_str()))
62  this->EnableCheckVarianceTest(testName, params, bei);
63  }
64  return false;
65 }
66 
68  const std::map<std::string, std::string> & params,
69  DQMStore *bei) {
70  QCriterion * qc1;
71  if (! bei->getQCriterion(testName)) {
72  testsConfigured.push_back(testName);
73  qc1 = bei->createQTest(Comp2RefEqualH::getAlgoName(), testName);
74  } else {
75  qc1 = bei->getQCriterion(testName);
76  }
77  Comp2RefEqualH * me_qc1 = (Comp2RefEqualH *) qc1;
78  double warning = atof(findOrDefault(params, "warning", "0"));
79  double error = atof(findOrDefault(params, "error", "0"));
80  me_qc1->setWarningProb(warning);
81  me_qc1->setErrorProb(error);
82 }
83 
85  const std::map<std::string, std::string> & params,
86  DQMStore *bei) {
87  QCriterion * qc1;
88  if (! bei->getQCriterion(testName)) {
89  testsConfigured.push_back(testName);
90  qc1 = bei->createQTest(Comp2RefChi2::getAlgoName(), testName);
91  } else {
92  qc1 = bei->getQCriterion(testName);
93  }
94  Comp2RefChi2 * me_qc1 = (Comp2RefChi2 *) qc1;
95  double warning = atof(findOrDefault(params, "warning", "0"));
96  double error = atof(findOrDefault(params, "error", "0"));
97  me_qc1->setWarningProb(warning);
98  me_qc1->setErrorProb(error);
99 }
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(Comp2RefKolmogorov::getAlgoName(), testName);
109  } else {
110  qc1 = bei->getQCriterion(testName);
111  }
112  Comp2RefKolmogorov * me_qc1 = (Comp2RefKolmogorov *) qc1;
113  double warning = atof(findOrDefault(params, "warning", "0"));
114  double error = atof(findOrDefault(params, "error", "0"));
115  me_qc1->setWarningProb(warning);
116  me_qc1->setErrorProb(error);
117 }
118 
120  const std::map<std::string, std::string> & params,
121  DQMStore *bei) {
122  QCriterion * qc1;
123  if (! bei->getQCriterion(testName)) {
124  testsConfigured.push_back(testName);
125  qc1 = bei->createQTest(ContentsXRange::getAlgoName(),testName);
126  } else {
127  qc1 = bei->getQCriterion(testName);
128  }
129  ContentsXRange * me_qc1 = (ContentsXRange *) qc1;
130  double xmin = atof(findOrDefault(params, "xmin", "0"));
131  double xmax = atof(findOrDefault(params, "xmax", "0"));
132  double warning = atof(findOrDefault(params, "warning", "0"));
133  double error = atof(findOrDefault(params, "error", "0"));
134  me_qc1->setAllowedXRange(xmin, xmax);
135  me_qc1->setWarningProb(warning);
136  me_qc1->setErrorProb(error);
137 }
138 
140  const std::map<std::string, std::string> & params,
141  DQMStore *bei) {
142  QCriterion * qc1;
143  if (! bei->getQCriterion(testName)) {
144  testsConfigured.push_back(testName);
145  qc1 = bei->createQTest(ContentsYRange::getAlgoName(), testName);
146  } else {
147  qc1 = bei->getQCriterion(testName);
148  }
149  ContentsYRange * me_qc1 = (ContentsYRange *) qc1;
150  double ymin = atof(findOrDefault(params, "ymin", "0"));
151  double ymax = atof(findOrDefault(params, "ymax", "0"));
152  double warning = atof(findOrDefault(params, "warning", "0"));
153  double error = atof(findOrDefault(params, "error", "0"));
154  unsigned int useEmptyBins = (unsigned int)atof(findOrDefault(params, "useEmptyBins", "0"));
155  me_qc1->setAllowedYRange(ymin, ymax);
156  me_qc1->setWarningProb(warning);
157  me_qc1->setErrorProb(error);
158  me_qc1->setUseEmptyBins(useEmptyBins);
159 }
160 
162  const std::map<std::string, std::string> & params,
163  DQMStore *bei) {
164  QCriterion * qc1;
165  if (! bei->getQCriterion(testName)) {
166  testsConfigured.push_back(testName);
167  qc1 = bei->createQTest(DeadChannel::getAlgoName(), testName);
168  } else {
169  qc1 = bei->getQCriterion(testName);
170  }
171  DeadChannel * me_qc1 = ( DeadChannel *) qc1;
172  unsigned int threshold =(unsigned int) atof(findOrDefault(params, "threshold", "0"));
173  double warning = atof(findOrDefault(params, "warning", "0"));
174  double error = atof(findOrDefault(params, "error", "0"));
175  me_qc1->setThreshold(threshold);
176  me_qc1->setWarningProb(warning);
177  me_qc1->setErrorProb(error);
178 }
179 
181  const std::map<std::string, std::string> & params,
182  DQMStore *bei) {
183  QCriterion * qc1;
184  if (! bei->getQCriterion(testName)) {
185  testsConfigured.push_back(testName);
186  qc1 = bei->createQTest(NoisyChannel::getAlgoName(), testName);
187  } else {
188  qc1 = bei->getQCriterion(testName);
189  }
190  NoisyChannel * me_qc1 = (NoisyChannel *) qc1;
191  unsigned int neighbors = (unsigned int) atof(findOrDefault(params, "neighbours", "0"));
192  double tolerance = atof(findOrDefault(params, "tolerance", "0"));
193  double warning = atof(findOrDefault(params, "warning", "0"));
194  double error = atof(findOrDefault(params, "error", "0"));
195  me_qc1->setNumNeighbors (neighbors);
196  me_qc1->setTolerance (tolerance);
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(MeanWithinExpected::getAlgoName(), testName);
208  } else {
209  qc1 = bei->getQCriterion(testName);
210  }
211  MeanWithinExpected * me_qc1 = (MeanWithinExpected *) qc1;
212  double warning = atof(findOrDefault(params, "warning", "0"));
213  double error = atof(findOrDefault(params, "error", "0"));
214  double mean = atof(findOrDefault(params, "mean", "0"));
215  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
216  double useRMSVal = atof(findOrDefault(params, "useRMS", "0"));
217  double useSigmaVal = atof(findOrDefault(params, "useSigma", "0"));
218  double useRangeVal = atof(findOrDefault(params, "useRange", "0"));
219  me_qc1->setWarningProb(warning);
220  me_qc1->setErrorProb(error);
221  me_qc1->setExpectedMean(mean);
222 
223  if (minEntries != 0)
224  me_qc1->setMinimumEntries(minEntries);
225 
226  if (useRMSVal && useSigmaVal && useRangeVal)
227  return;
228 
229  if (useRMSVal) {
230  me_qc1->useRMS();
231  return;
232  }
233 
234  if (useSigmaVal) {
235  me_qc1->useSigma(useSigmaVal);
236  return;
237  }
238 
239  if(useRangeVal) {
240  float xmin = atof(findOrDefault(params, "xmin", "0"));
241  float xmax = atof(findOrDefault(params, "xmax", "0"));
242  me_qc1->useRange(xmin,xmax);
243  return;
244  }
245 }
246 
248  const std::map<std::string, std::string> & params,
249  DQMStore *bei) {
250  QCriterion *qc1;
251  if (! bei->getQCriterion(testName)) {
252  testsConfigured.push_back(testName);
253  qc1 = bei->createQTest(CompareToMedian::getAlgoName(), testName);
254  } else {
255  qc1 = bei->getQCriterion(testName);
256  }
257  CompareToMedian* vtm = (CompareToMedian*) qc1;
258  vtm->setMin( (double) atof(findOrDefault(params, "MinRel", "0")));
259  vtm->setMax( (double) atof(findOrDefault(params, "MaxRel", "0")));
260  vtm->setEmptyBins( (int) atoi(findOrDefault(params, "UseEmptyBins", "0")));
261  vtm->setMinMedian( (double) atof(findOrDefault(params, "MinAbs", "0")));
262  vtm->setMaxMedian( (double) atof(findOrDefault(params, "MaxAbs", "0")));
263  vtm->setWarningProb( (double) atof(findOrDefault(params, "warning", "0")));
264  vtm->setErrorProb( (double) atof(findOrDefault(params, "error", "0")));
265  vtm->setStatCut( (double) atof(findOrDefault(params, "StatCut", "0")));
266 }
267 
268 /*
269  void QTestConfigure::EnableMostProbableLandauTest(
270  const std::string &roTEST_NAME,
271  std::map<std::string, std::string> &roMParams,
272  DQMStore *bei) {
273 
274  // Create QTest or Get already assigned one
275  MostProbableLandau *poQTest = 0;
276  if( QCriterion *poQCriteration = bei->getQCriterion( roTEST_NAME)) {
277  // Current already assigned to given ME.
278  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
279  } else {
280  // Test does not exist: create one
281  testsConfigured.push_back( roTEST_NAME);
282  poQCriteration = bei->createQTest( MostProbableLandau::getAlgoName(),
283  roTEST_NAME);
284 
285  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
286  }
287 
288  // Set probabilities thresholds.
289  poQTest->setErrorProb ( atof( roMfindOrDefault(params, "error", "0") );
290  poQTest->setWarningProb ( atof( roMfindOrDefault(params, "warning", "0") );
291  poQTest->setXMin ( atof( roMfindOrDefault(params, "xmin", "0") );
292  poQTest->setXMax ( atof( roMfindOrDefault(params, "xmax", "0") );
293  poQTest->setNormalization( atof( roMfindOrDefault(params, "normalization", "0") );
294  poQTest->setMostProbable ( atof( roMfindOrDefault(params, "mostprobable", "0") );
295  poQTest->setSigma ( atof( roMfindOrDefault(params, "sigma", "0") );
296  }
297 */
299  const std::map<std::string, std::string> & params,
300  DQMStore *bei) {
301  QCriterion * qc1;
302  if (! bei->getQCriterion(testName)) {
303  testsConfigured.push_back(testName);
304  qc1 = bei->createQTest(ContentsWithinExpected::getAlgoName(), testName);
305  } else {
306  qc1 = bei->getQCriterion(testName);
307  }
309  unsigned int useEmptyBins = (unsigned int) atof(findOrDefault(params, "useEmptyBins", "0"));
310  double warning = atof(findOrDefault(params, "warning", "0"));
311  double error = atof(findOrDefault(params, "error", "0"));
312  double minMean = atof(findOrDefault(params, "minMean", "0"));
313  double maxMean = atof(findOrDefault(params, "maxMean", "0"));
314  double minRMS = atof(findOrDefault(params, "minRMS", "0"));
315  double maxRMS = atof(findOrDefault(params, "maxRMS", "0"));
316  double toleranceMean = atof(findOrDefault(params, "toleranceMean", "0"));
317  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
318  me_qc1->setUseEmptyBins(useEmptyBins);
319  me_qc1->setWarningProb(warning);
320  me_qc1->setErrorProb(error);
321 
322  if ( minMean != 0 || maxMean != 0 )
323  me_qc1->setMeanRange(minMean, maxMean);
324 
325  if ( minRMS != 0 || maxRMS != 0 )
326  me_qc1->setRMSRange(minRMS, maxRMS);
327 
328  if ( toleranceMean != 0 )
329  me_qc1->setMeanTolerance(toleranceMean);
330 
331  if ( minEntries != 0 )
332  me_qc1->setMinimumEntries(minEntries);
333 }
334 
336  const std::map<std::string, std::string> & params,
337  DQMStore *bei) {
338  QCriterion * qc1;
339  if (! bei->getQCriterion(testName)) {
340  testsConfigured.push_back(testName);
341  qc1 = bei->createQTest(CompareLastFilledBin::getAlgoName(), testName);
342  } else {
343  qc1 = bei->getQCriterion(testName);
344  }
345  CompareLastFilledBin * me_qc1 = (CompareLastFilledBin *) qc1;
346 
347  double warning = atof(findOrDefault(params, "warning", "0"));
348  double error = atof(findOrDefault(params, "error", "0"));
349  double avVal = atof(findOrDefault(params, "AvVal", "0"));
350  double minVal = atof(findOrDefault(params, "MinVal", "0"));
351  double maxVal = atof(findOrDefault(params, "MaxVal", "0"));
352  me_qc1->setWarningProb(warning);
353  me_qc1->setErrorProb(error);
354  me_qc1->setAverage(avVal);
355  me_qc1->setMin(minVal);
356  me_qc1->setMax(maxVal);
357 }
359  const std::map<std::string, std::string>& params,
360  DQMStore *bei){
361  QCriterion * qc1;
362  if(! bei->getQCriterion(testName) ){
363  testsConfigured.push_back(testName);
364  qc1 = bei->createQTest(CheckVariance::getAlgoName(),testName);
365  }else{
366  qc1 = bei->getQCriterion(testName);
367 
368  }
369  CheckVariance * me_qc1 = (CheckVariance *) qc1;
370 
371  double warning = atof(findOrDefault(params, "warning", "0"));
372  double error = atof(findOrDefault(params, "error", "0"));
373  me_qc1->setWarningProb(warning);
374  me_qc1->setErrorProb(error);
375 }
376 
377 /* void QTestConfigure::EnableContentsWithinExpectedASTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
378 
379 QCriterion * qc1;
380 if(! bei->getQCriterion(testName) ){
381 testsConfigured.push_back(testName);
382 qc1 = bei->createQTest(ContentsWithinExpectedAS::getAlgoName(),testName);
383 }else{
384 qc1 = bei->getQCriterion(testName);
385 }
386 ContentsWithinExpectedAS * me_qc1 = (ContentsWithinExpectedAS *) qc1;
387 
388 double warning=atof(findOrDefault(params, "warning", "0");
389 double error=atof(findOrDefault(params, "error", "0");
390 me_qc1->setWarningProb(warning);
391 me_qc1->setErrorProb(error);
392 
393 double minCont=atof(findOrDefault(params, "minCont", "0");
394 double maxCont=atof(findOrDefault(params, "maxCont", "0");
395 if ( minCont != 0 || maxCont != 0 ) me_qc1->setContentsRange(minCont, maxCont);
396 
397 
398 } */
399 
void setErrorProb(float prob)
Definition: QTest.h:62
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:3235
static std::string getAlgoName(void)
get algorithm name
Definition: QTest.h:722
void setStatCut(float cut)
Definition: QTest.h:620
static std::string getAlgoName(void)
Definition: QTest.h:312
dictionary tests
Definition: utils_v2.py:385
void useRMS(void)
Definition: QTest.cc:1247
test that histogram contents are above Ymin
Definition: QTest.h:277
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:261
void setMin(float min)
Definition: QTest.h:615
static std::string getAlgoName(void)
Definition: QTest.h:361
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:237
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:233
void setRMSRange(double xmin, double xmax)
set expected value for mean
Definition: QTest.cc:1123
void useSigma(double expectedSigma)
Definition: QTest.cc:1236
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:616
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:664
void setNumNeighbors(unsigned n)
Definition: QTest.h:322
static std::string getAlgoName(void)
Definition: QTest.h:285
Algorithm for testing if histogram&#39;s mean value is near expected value.
Definition: QTest.h:393
static std::string getAlgoName(void)
Definition: QTest.h:612
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:303
void setEmptyBins(int eB)
Definition: QTest.h:617
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:218
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:328
const char * findOrDefault(const std::map< std::string, std::string > &, const char *, const char *) const
static std::string getAlgoName(void)
Definition: QTest.h:258
void setMinimumEntries(unsigned n)
set minimum # of entries needed
Definition: QTest.h:143
void setExpectedMean(double mean)
Definition: QTest.h:403
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:364
void setMaxMedian(float max)
Definition: QTest.h:618
void useRange(double xmin, double xmax)
Definition: QTest.cc:1226
static std::string getAlgoName(void)
Definition: QTest.h:177
void setWarningProb(float prob)
set probability limit for warning and error (default: 90% and 50%)
Definition: QTest.h:61
Comparison to reference using the Kolmogorov algorithm.
Definition: QTest.h:211
void setMax(float max)
Definition: QTest.h:665
void setMeanRange(double xmin, double xmax)
set expected value for mean
Definition: QTest.cc:1111
static std::string getAlgoName(void)
Definition: QTest.h:190
void EnableDeadChannelTest(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates ContentsYRangeASROOT test.
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:3246
void setMeanTolerance(float fracTolerance)
set (fractional) tolerance for mean
Definition: QTest.h:371
void setThreshold(double ymin)
set Ymin (inclusive) threshold for &quot;dead&quot; channel (default: 0)
Definition: QTest.h:289
void setAverage(float average)
Definition: QTest.h:663
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:262
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:660
static std::string getAlgoName(void)
Definition: QTest.h:400
void setMinMedian(float min)
Definition: QTest.h:619
void EnableComp2RefChi2Test(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates Comp2RefChi2 test.