CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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 
00048         }
00049         
00050         return false;   
00051 }
00052 
00053 
00054 
00055 void QTestConfigure::EnableComp2RefEqualHTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00056         QCriterion * qc1;       
00057         if(! bei->getQCriterion(testName) ){
00058                 testsConfigured.push_back(testName);
00059                 qc1 = bei->createQTest(Comp2RefEqualH::getAlgoName(),testName);
00060         }else{
00061                 qc1 = bei->getQCriterion(testName);
00062                 
00063         }       
00064         Comp2RefEqualH * me_qc1 = (Comp2RefEqualH *) qc1;
00065         
00066         double warning=atof(params["warning"].c_str());
00067         double error=atof(params["error"].c_str());
00068         me_qc1->setWarningProb(warning);
00069         me_qc1->setErrorProb(error);
00070 }
00071 
00072 
00073 
00074 void QTestConfigure::EnableComp2RefChi2Test(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00075         QCriterion * qc1;       
00076         if(! bei->getQCriterion(testName) ){
00077                 testsConfigured.push_back(testName);
00078                 qc1 = bei->createQTest(Comp2RefChi2::getAlgoName(),testName);
00079         }else{
00080                 qc1 = bei->getQCriterion(testName);
00081                 
00082         }       
00083         Comp2RefChi2 * me_qc1 = (Comp2RefChi2 *) qc1;
00084         
00085         double warning=atof(params["warning"].c_str());
00086         double error=atof(params["error"].c_str());
00087         me_qc1->setWarningProb(warning);
00088         me_qc1->setErrorProb(error);
00089 }
00090 
00091 
00092 void QTestConfigure::EnableComp2RefKolmogorovTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00093         QCriterion * qc1;       
00094         if(! bei->getQCriterion(testName) ){
00095                 testsConfigured.push_back(testName);
00096                 qc1 = bei->createQTest(Comp2RefKolmogorov::getAlgoName(),testName);
00097         }else{
00098                 qc1 = bei->getQCriterion(testName);
00099                 
00100         }       
00101         Comp2RefKolmogorov * me_qc1 = (Comp2RefKolmogorov *) qc1;
00102         
00103         double warning=atof(params["warning"].c_str());
00104         double error=atof(params["error"].c_str());
00105         me_qc1->setWarningProb(warning);
00106         me_qc1->setErrorProb(error);
00107 }
00108 
00109 void QTestConfigure::EnableXRangeTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00110         QCriterion * qc1;       
00111         if(! bei->getQCriterion(testName) ){
00112                 testsConfigured.push_back(testName);
00113                 qc1 = bei->createQTest(ContentsXRange::getAlgoName(),testName);
00114         }else{
00115                 qc1 = bei->getQCriterion(testName);
00116                 
00117         }       
00118         ContentsXRange * me_qc1 = (ContentsXRange *) qc1;
00119         
00120         double xmin=atof(params["xmin"].c_str());
00121         double xmax=atof(params["xmax"].c_str());
00122         
00123         me_qc1->setAllowedXRange(xmin,xmax);
00124         
00125         double warning=atof(params["warning"].c_str());
00126         double error=atof(params["error"].c_str());
00127         me_qc1->setWarningProb(warning);
00128         me_qc1->setErrorProb(error);
00129 }
00130 
00131 
00132 void QTestConfigure::EnableYRangeTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00133         QCriterion * qc1;       
00134         if(! bei->getQCriterion(testName) ){
00135                 testsConfigured.push_back(testName);
00136                 qc1 = bei->createQTest(ContentsYRange::getAlgoName(),testName);
00137         }else{
00138                 qc1 = bei->getQCriterion(testName);     
00139         }       
00140         ContentsYRange * me_qc1 = (ContentsYRange *) qc1;
00141         
00142         double ymin=atof(params["ymin"].c_str());
00143         double ymax=atof(params["ymax"].c_str());
00144         me_qc1->setAllowedYRange(ymin,ymax);
00145 
00146         //do a Normal test or AS ?
00147         unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());   
00148         me_qc1->setUseEmptyBins(useEmptyBins);
00149 
00150         double warning=atof(params["warning"].c_str());
00151         double error=atof(params["error"].c_str());
00152         me_qc1->setWarningProb(warning);
00153         me_qc1->setErrorProb(error);
00154 }
00155 
00156 void QTestConfigure::EnableDeadChannelTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00157         QCriterion * qc1;
00158         if(! bei->getQCriterion(testName) ){
00159                 testsConfigured.push_back(testName);
00160                 qc1 = bei->createQTest(DeadChannel::getAlgoName(),testName);
00161         }else{
00162                 qc1 = bei->getQCriterion(testName);     
00163         
00164         }       
00165         DeadChannel * me_qc1 = ( DeadChannel *) qc1;
00166         
00167         unsigned int threshold=(unsigned int)atof(params["threshold"].c_str());
00168         me_qc1->setThreshold(threshold);
00169       
00170         // Include/Exclude empty bins ?
00171         //unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());
00172         //me_qc1->setUseEmptyBins(useEmptyBins);
00173         
00174         double warning=atof(params["warning"].c_str());
00175         double error=atof(params["error"].c_str());
00176         me_qc1->setWarningProb(warning);
00177         me_qc1->setErrorProb(error);
00178 }
00179 
00180 void QTestConfigure::EnableNoisyChannelTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00181 
00182         QCriterion * qc1;
00183         if(! bei->getQCriterion(testName) ){
00184                 testsConfigured.push_back(testName);
00185                 qc1 = bei->createQTest(NoisyChannel::getAlgoName(),testName);
00186         }else{
00187                 qc1 = bei->getQCriterion(testName);                     
00188         }
00189         NoisyChannel * me_qc1 = ( NoisyChannel *) qc1;
00190         
00191         unsigned int neighbors=(unsigned int)atof(params["neighbours"].c_str());
00192         double tolerance=atof(params["tolerance"].c_str());
00193         me_qc1->setNumNeighbors (neighbors);
00194         me_qc1->setTolerance (tolerance);
00195         
00196         double warning=atof(params["warning"].c_str());
00197         double error=atof(params["error"].c_str());
00198         me_qc1->setWarningProb(warning);
00199         me_qc1->setErrorProb(error);
00200 }
00201 
00202 void QTestConfigure::EnableMeanWithinExpectedTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00203         
00204         QCriterion * qc1;
00205         if(! bei->getQCriterion(testName) ){
00206                 testsConfigured.push_back(testName);
00207                 qc1 = bei->createQTest(MeanWithinExpected::getAlgoName(),testName);
00208         }else{
00209                 qc1 = bei->getQCriterion(testName);                             
00210         }
00211         MeanWithinExpected * me_qc1 = (MeanWithinExpected *) qc1;
00212         
00213         double warning=atof(params["warning"].c_str());
00214         double error=atof(params["error"].c_str());
00215         me_qc1->setWarningProb(warning);
00216         me_qc1->setErrorProb(error);
00217 
00218         double mean=atof(params["mean"].c_str());
00219         me_qc1->setExpectedMean(mean);
00220         
00221         int minEntries=atoi(params["minEntries"].c_str());
00222         if ( minEntries != 0 ) me_qc1->setMinimumEntries(minEntries);
00223 
00224         double useRMSVal=atof(params["useRMS"].c_str()); 
00225         double useSigmaVal=atof(params["useSigma"].c_str()); 
00226         double useRangeVal=atof(params["useRange"].c_str());
00227         if( useRMSVal&&useSigmaVal&&useRangeVal){
00228                 return;
00229         }
00230         
00231         if(useRMSVal) {
00232                 me_qc1->useRMS();
00233                 return;
00234         }
00235         if(useSigmaVal) {
00236                 me_qc1->useSigma(useSigmaVal);
00237                 return;
00238         }       
00239         if(useRangeVal) {
00240                 float xmin=atof(params["xmin"].c_str());
00241                 float xmax=atof(params["xmax"].c_str());
00242                 me_qc1->useRange(xmin,xmax);
00243                 return;
00244         }       
00245         
00246         
00247 }
00248 
00249 void QTestConfigure::EnableCompareToMedianTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei)
00250 {
00251   QCriterion *qc1;
00252   if(! bei->getQCriterion(testName)) {
00253     testsConfigured.push_back(testName);
00254     qc1 = bei->createQTest(CompareToMedian::getAlgoName(),testName);
00255   } else {
00256     qc1 = bei->getQCriterion(testName);
00257   }
00258   CompareToMedian* vtm = (CompareToMedian*) qc1;
00259   vtm->setMin((double)atof(params["MinRel"].c_str()));
00260   vtm->setMax((double)atof(params["MaxRel"].c_str()));
00261   vtm->setEmptyBins((int)atoi(params["UseEmptyBins"].c_str()));
00262   vtm->setMinMedian((double)atof(params["MinAbs"].c_str()));
00263   vtm->setMaxMedian((double)atof(params["MaxAbs"].c_str()));
00264   vtm->setWarningProb((double)atof(params["warning"].c_str()));
00265   vtm->setErrorProb((double)atof(params["error"].c_str()));
00266   vtm->setStatCut((double)atof(params["StatCut"].c_str()));
00267 }
00268 
00269 /*
00270 void QTestConfigure::EnableMostProbableLandauTest( 
00271        const std::string                        &roTEST_NAME,
00272        std::map<std::string, std::string> &roMParams,
00273        DQMStore                     *bei) {
00274 
00275   // Create QTest or Get already assigned one
00276   MostProbableLandau *poQTest = 0;
00277   if( QCriterion *poQCriteration = bei->getQCriterion( roTEST_NAME)) {
00278     // Current already assigned to given ME.
00279     poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
00280   } else {
00281     // Test does not exist: create one
00282     testsConfigured.push_back( roTEST_NAME);
00283     poQCriteration = bei->createQTest( MostProbableLandau::getAlgoName(),
00284                                          roTEST_NAME);
00285 
00286     poQTest = dynamic_cast<MostProbableLandau *>( poQCriteration);
00287   }
00288 
00289   // Set probabilities thresholds.
00290   poQTest->setErrorProb    ( atof( roMParams["error"].c_str()) );
00291   poQTest->setWarningProb  ( atof( roMParams["warning"].c_str()) );
00292   poQTest->setXMin         ( atof( roMParams["xmin"].c_str()) );
00293   poQTest->setXMax         ( atof( roMParams["xmax"].c_str()) );
00294   poQTest->setNormalization( atof( roMParams["normalization"].c_str()) );
00295   poQTest->setMostProbable ( atof( roMParams["mostprobable"].c_str()) );
00296   poQTest->setSigma        ( atof( roMParams["sigma"].c_str()) );
00297 }
00298 */
00299 void QTestConfigure::EnableContentsWithinExpectedTest(std::string testName, std::map<std::string, std::string> params, DQMStore *bei){
00300 
00301         QCriterion * qc1;
00302         if(! bei->getQCriterion(testName) ){
00303                 testsConfigured.push_back(testName);
00304                 qc1 = bei->createQTest(ContentsWithinExpected::getAlgoName(),testName);
00305         }else{
00306                 qc1 = bei->getQCriterion(testName);
00307         }
00308         ContentsWithinExpected * me_qc1 = (ContentsWithinExpected *) qc1;
00309 
00310 
00311         //do a Normal test or AS ?
00312         unsigned int useEmptyBins=(unsigned int)atof(params["useEmptyBins"].c_str());   
00313         me_qc1->setUseEmptyBins(useEmptyBins);
00314 
00315         double warning=atof(params["warning"].c_str());
00316         double error=atof(params["error"].c_str());
00317         me_qc1->setWarningProb(warning);
00318         me_qc1->setErrorProb(error);
00319 
00320         double minMean=atof(params["minMean"].c_str());
00321         double maxMean=atof(params["maxMean"].c_str());
00322         if ( minMean != 0 || maxMean != 0 ) me_qc1->setMeanRange(minMean, maxMean);
00323 
00324         double minRMS=atof(params["minRMS"].c_str());
00325         double maxRMS=atof(params["maxRMS"].c_str());
00326         if ( minRMS != 0 || maxRMS != 0 ) me_qc1->setRMSRange(minRMS, maxRMS);
00327 
00328         double toleranceMean=atof(params["toleranceMean"].c_str());
00329         if ( toleranceMean != 0 ) me_qc1->setMeanTolerance(toleranceMean);
00330 
00331         int minEntries=atoi(params["minEntries"].c_str());
00332         if ( minEntries != 0 ) me_qc1->setMinimumEntries(minEntries);
00333 }
00334 
00335 /* void QTestConfigure::EnableContentsWithinExpectedASTest(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(ContentsWithinExpectedAS::getAlgoName(),testName);
00341         }else{
00342                 qc1 = bei->getQCriterion(testName);
00343         }
00344         ContentsWithinExpectedAS * me_qc1 = (ContentsWithinExpectedAS *) 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 minCont=atof(params["minCont"].c_str());
00352         double maxCont=atof(params["maxCont"].c_str());
00353         if ( minCont != 0 || maxCont != 0 ) me_qc1->setContentsRange(minCont, maxCont);
00354 
00355 
00356 } */
00357