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 
12 #include <cstring>
13 #include <cstdlib>
14 
15 bool QTestConfigure::enableTests(std::map<std::string, std::map<std::string, std::string> > tests,DQMStore *bei){
16 
17  testsConfigured.clear();
18 
19  std::map<std::string, std::map<std::string, std::string> >::iterator itr;
20  for(itr= tests.begin(); itr!= tests.end();++itr){
21 
22  std::map<std::string, std::string> params= itr->second;
23 
24  std::string testName = itr->first;
25  std::string testType = params["type"];
26 
27  if(!std::strcmp(testType.c_str(),ContentsXRange::getAlgoName().c_str())) this->EnableXRangeTest(testName, params,bei);
28  if(!std::strcmp(testType.c_str(),ContentsYRange::getAlgoName().c_str())) this->EnableYRangeTest(testName, params,bei);
29  if(!std::strcmp(testType.c_str(),DeadChannel::getAlgoName().c_str())) this->EnableDeadChannelTest(testName, params,bei);
30  if(!std::strcmp(testType.c_str(),NoisyChannel::getAlgoName().c_str())) this->EnableNoisyChannelTest(testName, params,bei);
31  if(!std::strcmp(testType.c_str(),MeanWithinExpected::getAlgoName().c_str())) this->EnableMeanWithinExpectedTest(testName, params,bei);
32 
33  //================================== new qtests in the parser =============================================================//
34  if(!std::strcmp(testType.c_str(),Comp2RefEqualH::getAlgoName().c_str())) this->EnableComp2RefEqualHTest(testName, params,bei);
35  if(!std::strcmp(testType.c_str(), Comp2RefChi2::getAlgoName().c_str())) this->EnableComp2RefChi2Test(testName, params,bei);
36  if(!std::strcmp(testType.c_str(),Comp2RefKolmogorov::getAlgoName().c_str())) this->EnableComp2RefKolmogorovTest(testName, params,bei);
37 
38 
39 /*
40  if(!std::strcmp(testType.c_str(),MostProbableLandau::getAlgoName().c_str())) this->EnableMostProbableLandauTest(testName, params, bei);
41 */
42 
43  if(!std::strcmp(testType.c_str(),ContentsWithinExpected::getAlgoName().c_str())) this->EnableContentsWithinExpectedTest(testName, params, bei);
44 // if(!std::strcmp(testType.c_str(),ContentsWithinExpectedAS::getAlgoName().c_str())) this->EnableContentsWithinExpectedASTest(testName, params, bei);
45 
46  if(!std::strcmp(testType.c_str(),CompareToMedian::getAlgoName().c_str())) this->EnableCompareToMedianTest(testName, params, bei);
47  if(!std::strcmp(testType.c_str(),CompareLastFilledBin::getAlgoName().c_str())) this->EnableCompareLastFilledBinTest(testName, params, bei);
48 
49  }
50 
51  return false;
52 }
53 
54 
55 
56 void QTestConfigure::EnableComp2RefEqualHTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
57  QCriterion * qc1;
58  if(! bei->getQCriterion(testName) ){
59  testsConfigured.push_back(testName);
60  qc1 = bei->createQTest(Comp2RefEqualH::getAlgoName(),testName);
61  }else{
62  qc1 = bei->getQCriterion(testName);
63 
64  }
65  Comp2RefEqualH * me_qc1 = (Comp2RefEqualH *) qc1;
66 
67  double warning=atof(params["warning"].c_str());
68  double error=atof(params["error"].c_str());
69  me_qc1->setWarningProb(warning);
70  me_qc1->setErrorProb(error);
71 }
72 
73 
74 
75 void QTestConfigure::EnableComp2RefChi2Test(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
76  QCriterion * qc1;
77  if(! bei->getQCriterion(testName) ){
78  testsConfigured.push_back(testName);
79  qc1 = bei->createQTest(Comp2RefChi2::getAlgoName(),testName);
80  }else{
81  qc1 = bei->getQCriterion(testName);
82 
83  }
84  Comp2RefChi2 * me_qc1 = (Comp2RefChi2 *) qc1;
85 
86  double warning=atof(params["warning"].c_str());
87  double error=atof(params["error"].c_str());
88  me_qc1->setWarningProb(warning);
89  me_qc1->setErrorProb(error);
90 }
91 
92 
93 void QTestConfigure::EnableComp2RefKolmogorovTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
94  QCriterion * qc1;
95  if(! bei->getQCriterion(testName) ){
96  testsConfigured.push_back(testName);
97  qc1 = bei->createQTest(Comp2RefKolmogorov::getAlgoName(),testName);
98  }else{
99  qc1 = bei->getQCriterion(testName);
100 
101  }
102  Comp2RefKolmogorov * me_qc1 = (Comp2RefKolmogorov *) qc1;
103 
104  double warning=atof(params["warning"].c_str());
105  double error=atof(params["error"].c_str());
106  me_qc1->setWarningProb(warning);
107  me_qc1->setErrorProb(error);
108 }
109 
110 void QTestConfigure::EnableXRangeTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
111  QCriterion * qc1;
112  if(! bei->getQCriterion(testName) ){
113  testsConfigured.push_back(testName);
114  qc1 = bei->createQTest(ContentsXRange::getAlgoName(),testName);
115  }else{
116  qc1 = bei->getQCriterion(testName);
117 
118  }
119  ContentsXRange * me_qc1 = (ContentsXRange *) qc1;
120 
121  double xmin=atof(params["xmin"].c_str());
122  double xmax=atof(params["xmax"].c_str());
123 
124  me_qc1->setAllowedXRange(xmin,xmax);
125 
126  double warning=atof(params["warning"].c_str());
127  double error=atof(params["error"].c_str());
128  me_qc1->setWarningProb(warning);
129  me_qc1->setErrorProb(error);
130 }
131 
132 
133 void QTestConfigure::EnableYRangeTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
134  QCriterion * qc1;
135  if(! bei->getQCriterion(testName) ){
136  testsConfigured.push_back(testName);
137  qc1 = bei->createQTest(ContentsYRange::getAlgoName(),testName);
138  }else{
139  qc1 = bei->getQCriterion(testName);
140  }
141  ContentsYRange * me_qc1 = (ContentsYRange *) qc1;
142 
143  double ymin=atof(params["ymin"].c_str());
144  double ymax=atof(params["ymax"].c_str());
145  me_qc1->setAllowedYRange(ymin,ymax);
146 
147  //do a Normal test or AS ?
148  unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());
149  me_qc1->setUseEmptyBins(useEmptyBins);
150 
151  double warning=atof(params["warning"].c_str());
152  double error=atof(params["error"].c_str());
153  me_qc1->setWarningProb(warning);
154  me_qc1->setErrorProb(error);
155 }
156 
157 void QTestConfigure::EnableDeadChannelTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
158  QCriterion * qc1;
159  if(! bei->getQCriterion(testName) ){
160  testsConfigured.push_back(testName);
161  qc1 = bei->createQTest(DeadChannel::getAlgoName(),testName);
162  }else{
163  qc1 = bei->getQCriterion(testName);
164 
165  }
166  DeadChannel * me_qc1 = ( DeadChannel *) qc1;
167 
168  unsigned int threshold=(unsigned int)atof(params["threshold"].c_str());
169  me_qc1->setThreshold(threshold);
170 
171  // Include/Exclude empty bins ?
172  //unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());
173  //me_qc1->setUseEmptyBins(useEmptyBins);
174 
175  double warning=atof(params["warning"].c_str());
176  double error=atof(params["error"].c_str());
177  me_qc1->setWarningProb(warning);
178  me_qc1->setErrorProb(error);
179 }
180 
181 void QTestConfigure::EnableNoisyChannelTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
182 
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 
192  unsigned int neighbors=(unsigned int)atof(params["neighbours"].c_str());
193  double tolerance=atof(params["tolerance"].c_str());
194  me_qc1->setNumNeighbors (neighbors);
195  me_qc1->setTolerance (tolerance);
196 
197  double warning=atof(params["warning"].c_str());
198  double error=atof(params["error"].c_str());
199  me_qc1->setWarningProb(warning);
200  me_qc1->setErrorProb(error);
201 }
202 
203 void QTestConfigure::EnableMeanWithinExpectedTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
204 
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 
214  double warning=atof(params["warning"].c_str());
215  double error=atof(params["error"].c_str());
216  me_qc1->setWarningProb(warning);
217  me_qc1->setErrorProb(error);
218 
219  double mean=atof(params["mean"].c_str());
220  me_qc1->setExpectedMean(mean);
221 
222  int minEntries=atoi(params["minEntries"].c_str());
223  if ( minEntries != 0 ) me_qc1->setMinimumEntries(minEntries);
224 
225  double useRMSVal=atof(params["useRMS"].c_str());
226  double useSigmaVal=atof(params["useSigma"].c_str());
227  double useRangeVal=atof(params["useRange"].c_str());
228  if( useRMSVal&&useSigmaVal&&useRangeVal){
229  return;
230  }
231 
232  if(useRMSVal) {
233  me_qc1->useRMS();
234  return;
235  }
236  if(useSigmaVal) {
237  me_qc1->useSigma(useSigmaVal);
238  return;
239  }
240  if(useRangeVal) {
241  float xmin=atof(params["xmin"].c_str());
242  float xmax=atof(params["xmax"].c_str());
243  me_qc1->useRange(xmin,xmax);
244  return;
245  }
246 
247 
248 }
249 
250 void QTestConfigure::EnableCompareToMedianTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei)
251 {
252  QCriterion *qc1;
253  if(! bei->getQCriterion(testName)) {
254  testsConfigured.push_back(testName);
255  qc1 = bei->createQTest(CompareToMedian::getAlgoName(),testName);
256  } else {
257  qc1 = bei->getQCriterion(testName);
258  }
259  CompareToMedian* vtm = (CompareToMedian*) qc1;
260  vtm->setMin((double)atof(params["MinRel"].c_str()));
261  vtm->setMax((double)atof(params["MaxRel"].c_str()));
262  vtm->setEmptyBins((int)atoi(params["UseEmptyBins"].c_str()));
263  vtm->setMinMedian((double)atof(params["MinAbs"].c_str()));
264  vtm->setMaxMedian((double)atof(params["MaxAbs"].c_str()));
265  vtm->setWarningProb((double)atof(params["warning"].c_str()));
266  vtm->setErrorProb((double)atof(params["error"].c_str()));
267  vtm->setStatCut((double)atof(params["StatCut"].c_str()));
268 }
269 
270 /*
271 void QTestConfigure::EnableMostProbableLandauTest(
272  const std::string &roTEST_NAME,
273  std::map<std::string, std::string> &roMParams,
274  DQMStore *bei) {
275 
276  // Create QTest or Get already assigned one
277  MostProbableLandau *poQTest = 0;
278  if( QCriterion *poQCriteration = bei->getQCriterion( roTEST_NAME)) {
279  // Current already assigned to given ME.
280  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
281  } else {
282  // Test does not exist: create one
283  testsConfigured.push_back( roTEST_NAME);
284  poQCriteration = bei->createQTest( MostProbableLandau::getAlgoName(),
285  roTEST_NAME);
286 
287  poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
288  }
289 
290  // Set probabilities thresholds.
291  poQTest->setErrorProb ( atof( roMParams["error"].c_str()) );
292  poQTest->setWarningProb ( atof( roMParams["warning"].c_str()) );
293  poQTest->setXMin ( atof( roMParams["xmin"].c_str()) );
294  poQTest->setXMax ( atof( roMParams["xmax"].c_str()) );
295  poQTest->setNormalization( atof( roMParams["normalization"].c_str()) );
296  poQTest->setMostProbable ( atof( roMParams["mostprobable"].c_str()) );
297  poQTest->setSigma ( atof( roMParams["sigma"].c_str()) );
298 }
299 */
300 void QTestConfigure::EnableContentsWithinExpectedTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
301 
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 
311 
312  //do a Normal test or AS ?
313  unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());
314  me_qc1->setUseEmptyBins(useEmptyBins);
315 
316  double warning=atof(params["warning"].c_str());
317  double error=atof(params["error"].c_str());
318  me_qc1->setWarningProb(warning);
319  me_qc1->setErrorProb(error);
320 
321  double minMean=atof(params["minMean"].c_str());
322  double maxMean=atof(params["maxMean"].c_str());
323  if ( minMean != 0 || maxMean != 0 ) me_qc1->setMeanRange(minMean, maxMean);
324 
325  double minRMS=atof(params["minRMS"].c_str());
326  double maxRMS=atof(params["maxRMS"].c_str());
327  if ( minRMS != 0 || maxRMS != 0 ) me_qc1->setRMSRange(minRMS, maxRMS);
328 
329  double toleranceMean=atof(params["toleranceMean"].c_str());
330  if ( toleranceMean != 0 ) me_qc1->setMeanTolerance(toleranceMean);
331 
332  int minEntries=atoi(params["minEntries"].c_str());
333  if ( minEntries != 0 ) me_qc1->setMinimumEntries(minEntries);
334 }
335 void QTestConfigure::EnableCompareLastFilledBinTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
336 
337  QCriterion * qc1;
338  if(! bei->getQCriterion(testName) ){
339  testsConfigured.push_back(testName);
340  qc1 = bei->createQTest(CompareLastFilledBin::getAlgoName(),testName);
341  }else{
342  qc1 = bei->getQCriterion(testName);
343  }
344  CompareLastFilledBin * me_qc1 = (CompareLastFilledBin *) qc1;
345 
346  double warning=atof(params["warning"].c_str());
347  double error=atof(params["error"].c_str());
348  me_qc1->setWarningProb(warning);
349  me_qc1->setErrorProb(error);
350 
351  double avVal=atof(params["AvVal"].c_str());
352  me_qc1->setAverage(avVal);
353 
354  double minVal=atof(params["MinVal"].c_str());
355  me_qc1->setMin(minVal);
356 
357  double maxVal=atof(params["MaxVal"].c_str());
358  me_qc1->setMax(maxVal);
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(params["warning"].c_str());
373  double error=atof(params["error"].c_str());
374  me_qc1->setWarningProb(warning);
375  me_qc1->setErrorProb(error);
376 
377  double minCont=atof(params["minCont"].c_str());
378  double maxCont=atof(params["maxCont"].c_str());
379  if ( minCont != 0 || maxCont != 0 ) me_qc1->setContentsRange(minCont, maxCont);
380 
381 
382 } */
383 
void setErrorProb(float prob)
Definition: QTest.h:61
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:2597
void EnableComp2RefKolmogorovTest(std::string testName, std::map< std::string, std::string >params, DQMStore *bei)
Creates EnableComp2RefKolmogorov test.
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
bool enableTests(std::map< std::string, std::map< std::string, std::string > > tests, DQMStore *bei)
Creates and defines quality tests.
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
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 setMax(float max)
Definition: QTest.h:615
void EnableNoisyChannelTest(std::string testName, std::map< std::string, std::string > params, DQMStore *bei)
Creates NoisyChannelROOT 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 EnableDeadChannelTest(std::string testName, std::map< std::string, std::string > params, DQMStore *bei)
Creates ContentsYRangeASROOT test.
void EnableComp2RefEqualHTest(std::string testName, std::map< std::string, std::string >params, DQMStore *bei)
Creates Comp2RefEqualH test.
void EnableCompareToMedianTest(std::string testName, std::map< std::string, std::string > params, DQMStore *bei)
Creates ContentsWithinRangeROOT test.
void setEmptyBins(int eB)
Definition: QTest.h:616
std::vector< std::string > testsConfigured
static std::string getAlgoName(void)
Definition: QTest.h:217
void setTolerance(float percentage)
Definition: QTest.h:327
static std::string getAlgoName(void)
Definition: QTest.h:257
void setMinimumEntries(unsigned n)
set minimum # of entries needed
Definition: QTest.h:142
void EnableCompareLastFilledBinTest(std::string testName, std::map< std::string, std::string > params, DQMStore *bei)
Creates EnableCompareLastFilledBinTest test.
void EnableComp2RefChi2Test(std::string testName, std::map< std::string, std::string >params, DQMStore *bei)
Creates Comp2RefChi2 test.
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 EnableYRangeTest(std::string testName, std::map< std::string, std::string >params, DQMStore *bei)
Creates ContentsXRangeASROOT test.
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 EnableMeanWithinExpectedTest(std::string testName, std::map< std::string, std::string > params, DQMStore *bei)
Creates MeanWithinExpectedROOT test.
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:2608
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
virtual void setAllowedYRange(double ymin, double ymax)
Definition: QTest.h:261
void EnableXRangeTest(std::string testName, std::map< std::string, std::string >params, DQMStore *bei)
Creates ContentsXRangeROOT test.
static std::string getAlgoName(void)
Definition: QTest.h:659
void EnableContentsWithinExpectedTest(std::string testName, std::map< std::string, std::string > params, DQMStore *bei)
Creates ContentsWithinRangeROOT test.
static std::string getAlgoName(void)
Definition: QTest.h:399
void setMinMedian(float min)
Definition: QTest.h:618