CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DQMServices/ClientConfig/src/QTestConfigure.cc

Go to the documentation of this file.
00001 
00009 #include "DQMServices/ClientConfig/interface/QTestConfigure.h"
00010 #include "DQMServices/Core/interface/QTest.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include <cstring>
00013 #include <cstdlib>
00014 
00015 bool QTestConfigure::enableTests(std::map<std::string, std::map<std::string, std::string> > tests,DQMStore *bei){
00016         
00017         testsConfigured.clear();
00018         
00019         std::map<std::string, std::map<std::string, std::string> >::iterator itr;
00020         for(itr= tests.begin(); itr!= tests.end();++itr){
00021  
00022                 std::map<std::string, std::string> params= itr->second;
00023                 
00024                 std::string testName = itr->first; 
00025                 std::string testType = params["type"]; 
00026 
00027                 if(!std::strcmp(testType.c_str(),ContentsXRange::getAlgoName().c_str())) this->EnableXRangeTest(testName, params,bei);       
00028                 if(!std::strcmp(testType.c_str(),ContentsYRange::getAlgoName().c_str())) this->EnableYRangeTest(testName, params,bei);       
00029                 if(!std::strcmp(testType.c_str(),DeadChannel::getAlgoName().c_str()))   this->EnableDeadChannelTest(testName, params,bei);       
00030                 if(!std::strcmp(testType.c_str(),NoisyChannel::getAlgoName().c_str()))  this->EnableNoisyChannelTest(testName, params,bei);       
00031                 if(!std::strcmp(testType.c_str(),MeanWithinExpected::getAlgoName().c_str()))  this->EnableMeanWithinExpectedTest(testName, params,bei);     
00032 
00033                 //================================== new qtests in the parser =============================================================//
00034                 if(!std::strcmp(testType.c_str(),Comp2RefEqualH::getAlgoName().c_str())) this->EnableComp2RefEqualHTest(testName, params,bei);
00035                 if(!std::strcmp(testType.c_str(),  Comp2RefChi2::getAlgoName().c_str())) this->EnableComp2RefChi2Test(testName, params,bei); 
00036                 if(!std::strcmp(testType.c_str(),Comp2RefKolmogorov::getAlgoName().c_str())) this->EnableComp2RefKolmogorovTest(testName, params,bei);
00037 
00038   
00039 /*
00040                 if(!std::strcmp(testType.c_str(),MostProbableLandau::getAlgoName().c_str()))  this->EnableMostProbableLandauTest(testName, params, bei);
00041 */
00042 
00043                 if(!std::strcmp(testType.c_str(),ContentsWithinExpected::getAlgoName().c_str())) this->EnableContentsWithinExpectedTest(testName, params, bei);
00044 //              if(!std::strcmp(testType.c_str(),ContentsWithinExpectedAS::getAlgoName().c_str())) this->EnableContentsWithinExpectedASTest(testName, params, bei);
00045 
00046                 if(!std::strcmp(testType.c_str(),CompareToMedian::getAlgoName().c_str())) this->EnableCompareToMedianTest(testName, params, bei);
00047                 if(!std::strcmp(testType.c_str(),CompareLastFilledBin::getAlgoName().c_str())) this->EnableCompareLastFilledBinTest(testName, params, bei);
00048 
00049         }
00050         
00051         return false;   
00052 }
00053 
00054 
00055 
00056 void QTestConfigure::EnableComp2RefEqualHTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00057         QCriterion * qc1;       
00058         if(! bei->getQCriterion(testName) ){
00059                 testsConfigured.push_back(testName);
00060                 qc1 = bei->createQTest(Comp2RefEqualH::getAlgoName(),testName);
00061         }else{
00062                 qc1 = bei->getQCriterion(testName);
00063                 
00064         }       
00065         Comp2RefEqualH * me_qc1 = (Comp2RefEqualH *) qc1;
00066         
00067         double warning=atof(params["warning"].c_str());
00068         double error=atof(params["error"].c_str());
00069         me_qc1->setWarningProb(warning);
00070         me_qc1->setErrorProb(error);
00071 }
00072 
00073 
00074 
00075 void QTestConfigure::EnableComp2RefChi2Test(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00076         QCriterion * qc1;       
00077         if(! bei->getQCriterion(testName) ){
00078                 testsConfigured.push_back(testName);
00079                 qc1 = bei->createQTest(Comp2RefChi2::getAlgoName(),testName);
00080         }else{
00081                 qc1 = bei->getQCriterion(testName);
00082                 
00083         }       
00084         Comp2RefChi2 * me_qc1 = (Comp2RefChi2 *) qc1;
00085         
00086         double warning=atof(params["warning"].c_str());
00087         double error=atof(params["error"].c_str());
00088         me_qc1->setWarningProb(warning);
00089         me_qc1->setErrorProb(error);
00090 }
00091 
00092 
00093 void QTestConfigure::EnableComp2RefKolmogorovTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00094         QCriterion * qc1;       
00095         if(! bei->getQCriterion(testName) ){
00096                 testsConfigured.push_back(testName);
00097                 qc1 = bei->createQTest(Comp2RefKolmogorov::getAlgoName(),testName);
00098         }else{
00099                 qc1 = bei->getQCriterion(testName);
00100                 
00101         }       
00102         Comp2RefKolmogorov * me_qc1 = (Comp2RefKolmogorov *) qc1;
00103         
00104         double warning=atof(params["warning"].c_str());
00105         double error=atof(params["error"].c_str());
00106         me_qc1->setWarningProb(warning);
00107         me_qc1->setErrorProb(error);
00108 }
00109 
00110 void QTestConfigure::EnableXRangeTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00111         QCriterion * qc1;       
00112         if(! bei->getQCriterion(testName) ){
00113                 testsConfigured.push_back(testName);
00114                 qc1 = bei->createQTest(ContentsXRange::getAlgoName(),testName);
00115         }else{
00116                 qc1 = bei->getQCriterion(testName);
00117                 
00118         }       
00119         ContentsXRange * me_qc1 = (ContentsXRange *) qc1;
00120         
00121         double xmin=atof(params["xmin"].c_str());
00122         double xmax=atof(params["xmax"].c_str());
00123         
00124         me_qc1->setAllowedXRange(xmin,xmax);
00125         
00126         double warning=atof(params["warning"].c_str());
00127         double error=atof(params["error"].c_str());
00128         me_qc1->setWarningProb(warning);
00129         me_qc1->setErrorProb(error);
00130 }
00131 
00132 
00133 void QTestConfigure::EnableYRangeTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00134         QCriterion * qc1;       
00135         if(! bei->getQCriterion(testName) ){
00136                 testsConfigured.push_back(testName);
00137                 qc1 = bei->createQTest(ContentsYRange::getAlgoName(),testName);
00138         }else{
00139                 qc1 = bei->getQCriterion(testName);     
00140         }       
00141         ContentsYRange * me_qc1 = (ContentsYRange *) qc1;
00142         
00143         double ymin=atof(params["ymin"].c_str());
00144         double ymax=atof(params["ymax"].c_str());
00145         me_qc1->setAllowedYRange(ymin,ymax);
00146 
00147         //do a Normal test or AS ?
00148         unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());   
00149         me_qc1->setUseEmptyBins(useEmptyBins);
00150 
00151         double warning=atof(params["warning"].c_str());
00152         double error=atof(params["error"].c_str());
00153         me_qc1->setWarningProb(warning);
00154         me_qc1->setErrorProb(error);
00155 }
00156 
00157 void QTestConfigure::EnableDeadChannelTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00158         QCriterion * qc1;
00159         if(! bei->getQCriterion(testName) ){
00160                 testsConfigured.push_back(testName);
00161                 qc1 = bei->createQTest(DeadChannel::getAlgoName(),testName);
00162         }else{
00163                 qc1 = bei->getQCriterion(testName);     
00164         
00165         }       
00166         DeadChannel * me_qc1 = ( DeadChannel *) qc1;
00167         
00168         unsigned int threshold=(unsigned int)atof(params["threshold"].c_str());
00169         me_qc1->setThreshold(threshold);
00170       
00171         // Include/Exclude empty bins ?
00172         //unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());
00173         //me_qc1->setUseEmptyBins(useEmptyBins);
00174         
00175         double warning=atof(params["warning"].c_str());
00176         double error=atof(params["error"].c_str());
00177         me_qc1->setWarningProb(warning);
00178         me_qc1->setErrorProb(error);
00179 }
00180 
00181 void QTestConfigure::EnableNoisyChannelTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00182 
00183         QCriterion * qc1;
00184         if(! bei->getQCriterion(testName) ){
00185                 testsConfigured.push_back(testName);
00186                 qc1 = bei->createQTest(NoisyChannel::getAlgoName(),testName);
00187         }else{
00188                 qc1 = bei->getQCriterion(testName);                     
00189         }
00190         NoisyChannel * me_qc1 = ( NoisyChannel *) qc1;
00191         
00192         unsigned int neighbors=(unsigned int)atof(params["neighbours"].c_str());
00193         double tolerance=atof(params["tolerance"].c_str());
00194         me_qc1->setNumNeighbors (neighbors);
00195         me_qc1->setTolerance (tolerance);
00196         
00197         double warning=atof(params["warning"].c_str());
00198         double error=atof(params["error"].c_str());
00199         me_qc1->setWarningProb(warning);
00200         me_qc1->setErrorProb(error);
00201 }
00202 
00203 void QTestConfigure::EnableMeanWithinExpectedTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00204         
00205         QCriterion * qc1;
00206         if(! bei->getQCriterion(testName) ){
00207                 testsConfigured.push_back(testName);
00208                 qc1 = bei->createQTest(MeanWithinExpected::getAlgoName(),testName);
00209         }else{
00210                 qc1 = bei->getQCriterion(testName);                             
00211         }
00212         MeanWithinExpected * me_qc1 = (MeanWithinExpected *) qc1;
00213         
00214         double warning=atof(params["warning"].c_str());
00215         double error=atof(params["error"].c_str());
00216         me_qc1->setWarningProb(warning);
00217         me_qc1->setErrorProb(error);
00218 
00219         double mean=atof(params["mean"].c_str());
00220         me_qc1->setExpectedMean(mean);
00221         
00222         int minEntries=atoi(params["minEntries"].c_str());
00223         if ( minEntries != 0 ) me_qc1->setMinimumEntries(minEntries);
00224 
00225         double useRMSVal=atof(params["useRMS"].c_str()); 
00226         double useSigmaVal=atof(params["useSigma"].c_str()); 
00227         double useRangeVal=atof(params["useRange"].c_str());
00228         if( useRMSVal&&useSigmaVal&&useRangeVal){
00229                 return;
00230         }
00231         
00232         if(useRMSVal) {
00233                 me_qc1->useRMS();
00234                 return;
00235         }
00236         if(useSigmaVal) {
00237                 me_qc1->useSigma(useSigmaVal);
00238                 return;
00239         }       
00240         if(useRangeVal) {
00241                 float xmin=atof(params["xmin"].c_str());
00242                 float xmax=atof(params["xmax"].c_str());
00243                 me_qc1->useRange(xmin,xmax);
00244                 return;
00245         }       
00246         
00247         
00248 }
00249 
00250 void QTestConfigure::EnableCompareToMedianTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei)
00251 {
00252   QCriterion *qc1;
00253   if(! bei->getQCriterion(testName)) {
00254     testsConfigured.push_back(testName);
00255     qc1 = bei->createQTest(CompareToMedian::getAlgoName(),testName);
00256   } else {
00257     qc1 = bei->getQCriterion(testName);
00258   }
00259   CompareToMedian* vtm = (CompareToMedian*) qc1;
00260   vtm->setMin((double)atof(params["MinRel"].c_str()));
00261   vtm->setMax((double)atof(params["MaxRel"].c_str()));
00262   vtm->setEmptyBins((int)atoi(params["UseEmptyBins"].c_str()));
00263   vtm->setMinMedian((double)atof(params["MinAbs"].c_str()));
00264   vtm->setMaxMedian((double)atof(params["MaxAbs"].c_str()));
00265   vtm->setWarningProb((double)atof(params["warning"].c_str()));
00266   vtm->setErrorProb((double)atof(params["error"].c_str()));
00267   vtm->setStatCut((double)atof(params["StatCut"].c_str()));
00268 }
00269 
00270 /*
00271 void QTestConfigure::EnableMostProbableLandauTest( 
00272        const std::string                        &roTEST_NAME,
00273        std::map<std::string, std::string> &roMParams,
00274        DQMStore                     *bei) {
00275 
00276   // Create QTest or Get already assigned one
00277   MostProbableLandau *poQTest = 0;
00278   if( QCriterion *poQCriteration = bei->getQCriterion( roTEST_NAME)) {
00279     // Current already assigned to given ME.
00280     poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
00281   } else {
00282     // Test does not exist: create one
00283     testsConfigured.push_back( roTEST_NAME);
00284     poQCriteration = bei->createQTest( MostProbableLandau::getAlgoName(),
00285                                          roTEST_NAME);
00286 
00287     poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
00288   }
00289 
00290   // Set probabilities thresholds.
00291   poQTest->setErrorProb    ( atof( roMParams["error"].c_str()) );
00292   poQTest->setWarningProb  ( atof( roMParams["warning"].c_str()) );
00293   poQTest->setXMin         ( atof( roMParams["xmin"].c_str()) );
00294   poQTest->setXMax         ( atof( roMParams["xmax"].c_str()) );
00295   poQTest->setNormalization( atof( roMParams["normalization"].c_str()) );
00296   poQTest->setMostProbable ( atof( roMParams["mostprobable"].c_str()) );
00297   poQTest->setSigma        ( atof( roMParams["sigma"].c_str()) );
00298 }
00299 */
00300 void QTestConfigure::EnableContentsWithinExpectedTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00301 
00302         QCriterion * qc1;
00303         if(! bei->getQCriterion(testName) ){
00304                 testsConfigured.push_back(testName);
00305                 qc1 = bei->createQTest(ContentsWithinExpected::getAlgoName(),testName);
00306         }else{
00307                 qc1 = bei->getQCriterion(testName);
00308         }
00309         ContentsWithinExpected * me_qc1 = (ContentsWithinExpected *) qc1;
00310 
00311 
00312         //do a Normal test or AS ?
00313         unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());   
00314         me_qc1->setUseEmptyBins(useEmptyBins);
00315 
00316         double warning=atof(params["warning"].c_str());
00317         double error=atof(params["error"].c_str());
00318         me_qc1->setWarningProb(warning);
00319         me_qc1->setErrorProb(error);
00320 
00321         double minMean=atof(params["minMean"].c_str());
00322         double maxMean=atof(params["maxMean"].c_str());
00323         if ( minMean != 0 || maxMean != 0 ) me_qc1->setMeanRange(minMean, maxMean);
00324 
00325         double minRMS=atof(params["minRMS"].c_str());
00326         double maxRMS=atof(params["maxRMS"].c_str());
00327         if ( minRMS != 0 || maxRMS != 0 ) me_qc1->setRMSRange(minRMS, maxRMS);
00328 
00329         double toleranceMean=atof(params["toleranceMean"].c_str());
00330         if ( toleranceMean != 0 ) me_qc1->setMeanTolerance(toleranceMean);
00331 
00332         int minEntries=atoi(params["minEntries"].c_str());
00333         if ( minEntries != 0 ) me_qc1->setMinimumEntries(minEntries);
00334 }
00335 void QTestConfigure::EnableCompareLastFilledBinTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00336 
00337         QCriterion * qc1;
00338         if(! bei->getQCriterion(testName) ){
00339                 testsConfigured.push_back(testName);
00340                 qc1 = bei->createQTest(CompareLastFilledBin::getAlgoName(),testName);
00341         }else{
00342                 qc1 = bei->getQCriterion(testName);
00343         }
00344         CompareLastFilledBin * me_qc1 = (CompareLastFilledBin *) qc1;
00345 
00346         double warning=atof(params["warning"].c_str());
00347         double error=atof(params["error"].c_str());
00348         me_qc1->setWarningProb(warning);
00349         me_qc1->setErrorProb(error);
00350 
00351         double avVal=atof(params["AvVal"].c_str());
00352         me_qc1->setAverage(avVal);
00353 
00354         double minVal=atof(params["MinVal"].c_str());
00355         me_qc1->setMin(minVal);
00356 
00357         double maxVal=atof(params["MaxVal"].c_str());
00358         me_qc1->setMax(maxVal);
00359 }
00360 
00361 /* void QTestConfigure::EnableContentsWithinExpectedASTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00362 
00363         QCriterion * qc1;
00364         if(! bei->getQCriterion(testName) ){
00365                 testsConfigured.push_back(testName);
00366                 qc1 = bei->createQTest(ContentsWithinExpectedAS::getAlgoName(),testName);
00367         }else{
00368                 qc1 = bei->getQCriterion(testName);
00369         }
00370         ContentsWithinExpectedAS * me_qc1 = (ContentsWithinExpectedAS *) qc1;
00371 
00372         double warning=atof(params["warning"].c_str());
00373         double error=atof(params["error"].c_str());
00374         me_qc1->setWarningProb(warning);
00375         me_qc1->setErrorProb(error);
00376 
00377         double minCont=atof(params["minCont"].c_str());
00378         double maxCont=atof(params["maxCont"].c_str());
00379         if ( minCont != 0 || maxCont != 0 ) me_qc1->setContentsRange(minCont, maxCont);
00380 
00381 
00382 } */
00383