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 
13 #include <cstring>
14 #include <cstdlib>
15 
16 
17 const char * QTestConfigure::findOrDefault(const std::map<std::string, std::string> &m,
18  const char * item,
19  const char * default_value) const {
20  std::map<std::string, std::string>::const_iterator iter;
21  if (( iter = m.find(std::string(item))) != m.end()) {
22  return (*iter).second.c_str();
23  }
24  edm::LogWarning("QTestConfigure") << "Warning, using default value for parameter "
25  << item << " with default_value: "
26  << default_value << std::endl;
27  return default_value;
28 }
29 
31  const std::map<std::string, std::map<std::string, std::string> > & tests,
32  DQMStore * bei) {
33  testsConfigured.clear();
34  std::map<std::string, std::map<std::string, std::string> >::const_iterator itr;
35  for (itr = tests.begin(); itr!= tests.end();++itr) {
36  const std::map<std::string, std::string> &params= itr->second;
37 
38  std::string testName = itr->first;
39  std::string testType = params.at("type");
40 
41  if(!std::strcmp(testType.c_str(),ContentsXRange::getAlgoName().c_str()))
42  this->EnableXRangeTest(testName, params,bei);
43  if(!std::strcmp(testType.c_str(),ContentsYRange::getAlgoName().c_str()))
44  this->EnableYRangeTest(testName, params,bei);
45  if(!std::strcmp(testType.c_str(),DeadChannel::getAlgoName().c_str()))
46  this->EnableDeadChannelTest(testName, params,bei);
47  if(!std::strcmp(testType.c_str(),NoisyChannel::getAlgoName().c_str()))
48  this->EnableNoisyChannelTest(testName, params,bei);
49  if(!std::strcmp(testType.c_str(),MeanWithinExpected::getAlgoName().c_str()))
50  this->EnableMeanWithinExpectedTest(testName, params,bei);
51  if(!std::strcmp(testType.c_str(),Comp2RefEqualH::getAlgoName().c_str()))
52  this->EnableComp2RefEqualHTest(testName, params,bei);
53  if(!std::strcmp(testType.c_str(), Comp2RefChi2::getAlgoName().c_str()))
54  this->EnableComp2RefChi2Test(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 
64  }
65  return false;
66 }
67 
69  const std::map<std::string, std::string> & params,
70  DQMStore *bei) {
71  QCriterion * qc1;
72  if (! bei->getQCriterion(testName)) {
73  testsConfigured.push_back(testName);
74  qc1 = bei->createQTest(Comp2RefEqualH::getAlgoName(), testName);
75  } else {
76  qc1 = bei->getQCriterion(testName);
77  }
78  Comp2RefEqualH * me_qc1 = (Comp2RefEqualH *) qc1;
79  double warning = atof(findOrDefault(params, "warning", "0"));
80  double error = atof(findOrDefault(params, "error", "0"));
81  me_qc1->setWarningProb(warning);
82  me_qc1->setErrorProb(error);
83 }
84 
86  const std::map<std::string, std::string> & params,
87  DQMStore *bei) {
88  QCriterion * qc1;
89  if (! bei->getQCriterion(testName)) {
90  testsConfigured.push_back(testName);
91  qc1 = bei->createQTest(Comp2RefChi2::getAlgoName(), testName);
92  } else {
93  qc1 = bei->getQCriterion(testName);
94  }
95  Comp2RefChi2 * me_qc1 = (Comp2RefChi2 *) qc1;
96  double warning = atof(findOrDefault(params, "warning", "0"));
97  double error = atof(findOrDefault(params, "error", "0"));
98  me_qc1->setWarningProb(warning);
99  me_qc1->setErrorProb(error);
100 }
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(Comp2RefKolmogorov::getAlgoName(), testName);
110  } else {
111  qc1 = bei->getQCriterion(testName);
112  }
113  Comp2RefKolmogorov * me_qc1 = (Comp2RefKolmogorov *) qc1;
114  double warning = atof(findOrDefault(params, "warning", "0"));
115  double error = atof(findOrDefault(params, "error", "0"));
116  me_qc1->setWarningProb(warning);
117  me_qc1->setErrorProb(error);
118 }
119 
121  const std::map<std::string, std::string> & params,
122  DQMStore *bei) {
123  QCriterion * qc1;
124  if (! bei->getQCriterion(testName)) {
125  testsConfigured.push_back(testName);
126  qc1 = bei->createQTest(ContentsXRange::getAlgoName(),testName);
127  } else {
128  qc1 = bei->getQCriterion(testName);
129  }
130  ContentsXRange * me_qc1 = (ContentsXRange *) qc1;
131  double xmin = atof(findOrDefault(params, "xmin", "0"));
132  double xmax = atof(findOrDefault(params, "xmax", "0"));
133  double warning = atof(findOrDefault(params, "warning", "0"));
134  double error = atof(findOrDefault(params, "error", "0"));
135  me_qc1->setAllowedXRange(xmin, xmax);
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(ContentsYRange::getAlgoName(), testName);
147  } else {
148  qc1 = bei->getQCriterion(testName);
149  }
150  ContentsYRange * me_qc1 = (ContentsYRange *) qc1;
151  double ymin = atof(findOrDefault(params, "ymin", "0"));
152  double ymax = atof(findOrDefault(params, "ymax", "0"));
153  double warning = atof(findOrDefault(params, "warning", "0"));
154  double error = atof(findOrDefault(params, "error", "0"));
155  unsigned int useEmptyBins = (unsigned int)atof(findOrDefault(params, "useEmptyBins", "0"));
156  me_qc1->setAllowedYRange(ymin, ymax);
157  me_qc1->setWarningProb(warning);
158  me_qc1->setErrorProb(error);
159  me_qc1->setUseEmptyBins(useEmptyBins);
160 }
161 
163  const std::map<std::string, std::string> & params,
164  DQMStore *bei) {
165  QCriterion * qc1;
166  if (! bei->getQCriterion(testName)) {
167  testsConfigured.push_back(testName);
168  qc1 = bei->createQTest(DeadChannel::getAlgoName(), testName);
169  } else {
170  qc1 = bei->getQCriterion(testName);
171  }
172  DeadChannel * me_qc1 = ( DeadChannel *) qc1;
173  unsigned int threshold =(unsigned int) atof(findOrDefault(params, "threshold", "0"));
174  double warning = atof(findOrDefault(params, "warning", "0"));
175  double error = atof(findOrDefault(params, "error", "0"));
176  me_qc1->setThreshold(threshold);
177  me_qc1->setWarningProb(warning);
178  me_qc1->setErrorProb(error);
179 }
180 
182  const std::map<std::string, std::string> & params,
183  DQMStore *bei) {
184  QCriterion * qc1;
185  if (! bei->getQCriterion(testName)) {
186  testsConfigured.push_back(testName);
187  qc1 = bei->createQTest(NoisyChannel::getAlgoName(), testName);
188  } else {
189  qc1 = bei->getQCriterion(testName);
190  }
191  NoisyChannel * me_qc1 = (NoisyChannel *) qc1;
192  unsigned int neighbors = (unsigned int) atof(findOrDefault(params, "neighbours", "0"));
193  double tolerance = atof(findOrDefault(params, "tolerance", "0"));
194  double warning = atof(findOrDefault(params, "warning", "0"));
195  double error = atof(findOrDefault(params, "error", "0"));
196  me_qc1->setNumNeighbors (neighbors);
197  me_qc1->setTolerance (tolerance);
198  me_qc1->setWarningProb(warning);
199  me_qc1->setErrorProb(error);
200 }
201 
203  const std::map<std::string, std::string> & params,
204  DQMStore *bei) {
205  QCriterion * qc1;
206  if (! bei->getQCriterion(testName)) {
207  testsConfigured.push_back(testName);
208  qc1 = bei->createQTest(MeanWithinExpected::getAlgoName(), testName);
209  } else {
210  qc1 = bei->getQCriterion(testName);
211  }
212  MeanWithinExpected * me_qc1 = (MeanWithinExpected *) qc1;
213  double warning = atof(findOrDefault(params, "warning", "0"));
214  double error = atof(findOrDefault(params, "error", "0"));
215  double mean = atof(findOrDefault(params, "mean", "0"));
216  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
217  double useRMSVal = atof(findOrDefault(params, "useRMS", "0"));
218  double useSigmaVal = atof(findOrDefault(params, "useSigma", "0"));
219  double useRangeVal = atof(findOrDefault(params, "useRange", "0"));
220  me_qc1->setWarningProb(warning);
221  me_qc1->setErrorProb(error);
222  me_qc1->setExpectedMean(mean);
223 
224  if (minEntries != 0)
225  me_qc1->setMinimumEntries(minEntries);
226 
227  if (useRMSVal && useSigmaVal && useRangeVal)
228  return;
229 
230  if (useRMSVal) {
231  me_qc1->useRMS();
232  return;
233  }
234 
235  if (useSigmaVal) {
236  me_qc1->useSigma(useSigmaVal);
237  return;
238  }
239 
240  if(useRangeVal) {
241  float xmin = atof(findOrDefault(params, "xmin", "0"));
242  float xmax = atof(findOrDefault(params, "xmax", "0"));
243  me_qc1->useRange(xmin,xmax);
244  return;
245  }
246 }
247 
249  const std::map<std::string, std::string> & params,
250  DQMStore *bei) {
251  QCriterion *qc1;
252  if (! bei->getQCriterion(testName)) {
253  testsConfigured.push_back(testName);
254  qc1 = bei->createQTest(CompareToMedian::getAlgoName(), testName);
255  } else {
256  qc1 = bei->getQCriterion(testName);
257  }
258  CompareToMedian* vtm = (CompareToMedian*) qc1;
259  vtm->setMin( (double) atof(findOrDefault(params, "MinRel", "0")));
260  vtm->setMax( (double) atof(findOrDefault(params, "MaxRel", "0")));
261  vtm->setEmptyBins( (int) atoi(findOrDefault(params, "UseEmptyBins", "0")));
262  vtm->setMinMedian( (double) atof(findOrDefault(params, "MinAbs", "0")));
263  vtm->setMaxMedian( (double) atof(findOrDefault(params, "MaxAbs", "0")));
264  vtm->setWarningProb( (double) atof(findOrDefault(params, "warning", "0")));
265  vtm->setErrorProb( (double) atof(findOrDefault(params, "error", "0")));
266  vtm->setStatCut( (double) atof(findOrDefault(params, "StatCut", "0")));
267 }
268 
269 /*
270  void QTestConfigure::EnableMostProbableLandauTest(
271  const std::string &roTEST_NAME,
272  std::map<std::string, std::string> &roMParams,
273  DQMStore *bei) {
274 
275  // Create QTest or Get already assigned one
276  MostProbableLandau *poQTest = 0;
277  if( QCriterion *poQCriteration = bei->getQCriterion( roTEST_NAME)) {
278  // Current already assigned to given ME.
279  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
280  } else {
281  // Test does not exist: create one
282  testsConfigured.push_back( roTEST_NAME);
283  poQCriteration = bei->createQTest( MostProbableLandau::getAlgoName(),
284  roTEST_NAME);
285 
286  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
287  }
288 
289  // Set probabilities thresholds.
290  poQTest->setErrorProb ( atof( roMfindOrDefault(params, "error", "0") );
291  poQTest->setWarningProb ( atof( roMfindOrDefault(params, "warning", "0") );
292  poQTest->setXMin ( atof( roMfindOrDefault(params, "xmin", "0") );
293  poQTest->setXMax ( atof( roMfindOrDefault(params, "xmax", "0") );
294  poQTest->setNormalization( atof( roMfindOrDefault(params, "normalization", "0") );
295  poQTest->setMostProbable ( atof( roMfindOrDefault(params, "mostprobable", "0") );
296  poQTest->setSigma ( atof( roMfindOrDefault(params, "sigma", "0") );
297  }
298 */
300  const std::map<std::string, std::string> & params,
301  DQMStore *bei) {
302  QCriterion * qc1;
303  if (! bei->getQCriterion(testName)) {
304  testsConfigured.push_back(testName);
305  qc1 = bei->createQTest(ContentsWithinExpected::getAlgoName(), testName);
306  } else {
307  qc1 = bei->getQCriterion(testName);
308  }
310  unsigned int useEmptyBins = (unsigned int) atof(findOrDefault(params, "useEmptyBins", "0"));
311  double warning = atof(findOrDefault(params, "warning", "0"));
312  double error = atof(findOrDefault(params, "error", "0"));
313  double minMean = atof(findOrDefault(params, "minMean", "0"));
314  double maxMean = atof(findOrDefault(params, "maxMean", "0"));
315  double minRMS = atof(findOrDefault(params, "minRMS", "0"));
316  double maxRMS = atof(findOrDefault(params, "maxRMS", "0"));
317  double toleranceMean = atof(findOrDefault(params, "toleranceMean", "0"));
318  int minEntries = atoi(findOrDefault(params, "minEntries", "0"));
319  me_qc1->setUseEmptyBins(useEmptyBins);
320  me_qc1->setWarningProb(warning);
321  me_qc1->setErrorProb(error);
322 
323  if ( minMean != 0 || maxMean != 0 )
324  me_qc1->setMeanRange(minMean, maxMean);
325 
326  if ( minRMS != 0 || maxRMS != 0 )
327  me_qc1->setRMSRange(minRMS, maxRMS);
328 
329  if ( toleranceMean != 0 )
330  me_qc1->setMeanTolerance(toleranceMean);
331 
332  if ( minEntries != 0 )
333  me_qc1->setMinimumEntries(minEntries);
334 }
335 
337  const std::map<std::string, std::string> & params,
338  DQMStore *bei) {
339  QCriterion * qc1;
340  if (! bei->getQCriterion(testName)) {
341  testsConfigured.push_back(testName);
342  qc1 = bei->createQTest(CompareLastFilledBin::getAlgoName(), testName);
343  } else {
344  qc1 = bei->getQCriterion(testName);
345  }
346  CompareLastFilledBin * me_qc1 = (CompareLastFilledBin *) qc1;
347 
348  double warning = atof(findOrDefault(params, "warning", "0"));
349  double error = atof(findOrDefault(params, "error", "0"));
350  double avVal = atof(findOrDefault(params, "AvVal", "0"));
351  double minVal = atof(findOrDefault(params, "MinVal", "0"));
352  double maxVal = atof(findOrDefault(params, "MaxVal", "0"));
353  me_qc1->setWarningProb(warning);
354  me_qc1->setErrorProb(error);
355  me_qc1->setAverage(avVal);
356  me_qc1->setMin(minVal);
357  me_qc1->setMax(maxVal);
358 }
359 
360 /* void QTestConfigure::EnableContentsWithinExpectedASTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
361 
362 QCriterion * qc1;
363 if(! bei->getQCriterion(testName) ){
364 testsConfigured.push_back(testName);
365 qc1 = bei->createQTest(ContentsWithinExpectedAS::getAlgoName(),testName);
366 }else{
367 qc1 = bei->getQCriterion(testName);
368 }
369 ContentsWithinExpectedAS * me_qc1 = (ContentsWithinExpectedAS *) 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 double minCont=atof(findOrDefault(params, "minCont", "0");
377 double maxCont=atof(findOrDefault(params, "maxCont", "0");
378 if ( minCont != 0 || maxCont != 0 ) me_qc1->setContentsRange(minCont, maxCont);
379 
380 
381 } */
382 
void setErrorProb(float prob)
Definition: QTest.h:61
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:2602
void setStatCut(float cut)
Definition: QTest.h:619
static std::string getAlgoName(void)
Definition: QTest.h:311
dictionary tests
Definition: utils_v2.py:385
void useRMS(void)
Definition: QTest.cc:1247
test that histogram contents are above Ymin
Definition: QTest.h:276
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:260
void setMin(float min)
Definition: QTest.h:614
static std::string getAlgoName(void)
Definition: QTest.h:360
virtual void setAllowedXRange(double xmin, double xmax)
set allowed range in X-axis (default values: histogram&#39;s X-range)
Definition: QTest.h:236
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:232
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:615
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:663
dictionary map
Definition: Association.py:205
void setNumNeighbors(unsigned n)
Definition: QTest.h:321
static std::string getAlgoName(void)
Definition: QTest.h:284
Algorithm for testing if histogram&#39;s mean value is near expected value.
Definition: QTest.h:392
static std::string getAlgoName(void)
Definition: QTest.h:611
Check if any channels are noisy compared to neighboring ones.
Definition: QTest.h:302
void setEmptyBins(int eB)
Definition: QTest.h:616
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:217
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:327
const char * findOrDefault(const std::map< std::string, std::string > &, const char *, const char *) const
static std::string getAlgoName(void)
Definition: QTest.h:257
void setMinimumEntries(unsigned n)
set minimum # of entries needed
Definition: QTest.h:142
void setExpectedMean(double mean)
Definition: QTest.h:402
void setUseEmptyBins(unsigned int useEmptyBins)
Definition: QTest.h:363
void setMaxMedian(float max)
Definition: QTest.h:617
void useRange(double xmin, double xmax)
Definition: QTest.cc:1226
static std::string getAlgoName(void)
Definition: QTest.h:176
void setWarningProb(float prob)
set probability limit for warning and error (default: 90% and 50%)
Definition: QTest.h:60
Comparison to reference using the Kolmogorov algorithm.
Definition: QTest.h:210
void setMax(float max)
Definition: QTest.h:664
void setMeanRange(double xmin, double xmax)
set expected value for mean
Definition: QTest.cc:1111
static std::string getAlgoName(void)
Definition: QTest.h:189
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:2613
void setMeanTolerance(float fracTolerance)
set (fractional) tolerance for mean
Definition: QTest.h:370
void setThreshold(double ymin)
set Ymin (inclusive) threshold for &quot;dead&quot; channel (default: 0)
Definition: QTest.h:288
void setAverage(float average)
Definition: QTest.h:662
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:261
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:659
static std::string getAlgoName(void)
Definition: QTest.h:399
void setMinMedian(float min)
Definition: QTest.h:618
void EnableComp2RefChi2Test(std::string testName, const std::map< std::string, std::string > &params, DQMStore *bei)
Creates Comp2RefChi2 test.