CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQMOffline/Muon/src/MuonTestSummary.cc

Go to the documentation of this file.
00001 
00002 /*
00003  *  See header file for a description of this class.
00004  *
00005  *  $Date: 2010/02/25 19:57:02 $
00006  *  $Revision: 1.32 $
00007  *  \author G. Mila - INFN Torino
00008  */
00009 
00010 
00011 #include <DQMOffline/Muon/src/MuonTestSummary.h>
00012 
00013 // Framework
00014 #include <FWCore/Framework/interface/Event.h>
00015 #include <FWCore/Framework/interface/EventSetup.h>
00016 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00017 
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019 #include "DQMServices/Core/interface/MonitorElement.h"
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021 #include "FWCore/Framework/interface/Run.h"
00022 
00023 #include "DQMOffline/Muon/test/langauFit.C"
00024 #include <string>
00025 
00026 using namespace edm;
00027 using namespace std;
00028 
00029 
00030 MuonTestSummary::MuonTestSummary(const edm::ParameterSet& ps){
00031 
00032   dbe = Service<DQMStore>().operator->();
00033 
00034   // parameter initialization for kinematics test
00035   etaExpected = ps.getParameter<double>("etaExpected");
00036   phiExpected = ps.getParameter<double>("phiExpected");
00037   chi2Fraction = ps.getParameter<double>("chi2Fraction");
00038   chi2Spread = ps.getParameter<double>("chi2Spread");
00039   resEtaSpread_tkGlb = ps.getParameter<double>("resEtaSpread_tkGlb");
00040   resEtaSpread_glbSta = ps.getParameter<double>("resEtaSpread_glbSta");
00041   resPhiSpread_tkGlb = ps.getParameter<double>("resPhiSpread_tkGlb");
00042   resPhiSpread_glbSta = ps.getParameter<double>("resPhiSpread_glbSta");
00043   resOneOvPSpread_tkGlb = ps.getParameter<double>("resOneOvPSpread_tkGlb");
00044   resOneOvPSpread_glbSta = ps.getParameter<double>("resOneOvPSpread_glbSta");
00045   pullEtaSpread = ps.getParameter<double>("pullEtaSpread");
00046   pullPhiSpread = ps.getParameter<double>("pullPhiSpread");
00047   pullOneOvPSpread = ps.getParameter<double>("pullOneOvPSpread");
00048   resChargeLimit_tkGlb = ps.getParameter<double>("resChargeLimit_tkGlb");
00049   resChargeLimit_glbSta = ps.getParameter<double>("resChargeLimit_glbSta");
00050   resChargeLimit_tkSta = ps.getParameter<double>("resChargeLimit_tkSta");
00051   numMatchedExpected_min = ps.getParameter<double>("numMatchedExpected_min");
00052   numMatchedExpected_max = ps.getParameter<double>("numMatchedExpected_max");
00053   matchesFractionDt_min = ps.getParameter<double>("matchesFractionDt_min");
00054   matchesFractionDt_max = ps.getParameter<double>("matchesFractionDt_max");
00055   matchesFractionCsc_min = ps.getParameter<double>("matchesFractionCsc_min");
00056   matchesFractionCsc_max = ps.getParameter<double>("matchesFractionCsc_max");
00057   resSegmTrack_rms_min = ps.getParameter<double>("resSegmTrack_rms_min");
00058   resSegmTrack_rms_max = ps.getParameter<double>("resSegmTrack_rms_max");
00059   resSegmTrack_mean_min = ps.getParameter<double>("resSegmTrack_mean_min");
00060   resSegmTrack_mean_max = ps.getParameter<double>("resSegmTrack_mean_max");
00061   expPeakEcalS9_min = ps.getParameter<double>("expPeakEcalS9_min");        
00062   expPeakEcalS9_max = ps.getParameter<double>("expPeakEcalS9_max");        
00063   expPeakHadS9_min = ps.getParameter<double>("expPeakHadS9_min");        
00064   expPeakHadS9_max = ps.getParameter<double>("expPeakHadS9_max");        
00065   expMultiplicityGlb_max = ps.getParameter<double>("expMultiplicityGlb_max");
00066   expMultiplicityTk_max = ps.getParameter<double>("expMultiplicityTk_max");
00067   expMultiplicitySta_max = ps.getParameter<double>("expMultiplicitySta_max");
00068   expMultiplicityGlb_min = ps.getParameter<double>("expMultiplicityGlb_min");
00069   expMultiplicityTk_min = ps.getParameter<double>("expMultiplicityTk_min");
00070   expMultiplicitySta_min = ps.getParameter<double>("expMultiplicitySta_min");
00071 
00072 }
00073 
00074 MuonTestSummary::~MuonTestSummary(){}
00075 
00076 void MuonTestSummary::beginJob(void){
00077 
00078   metname = "muonTestSummary";
00079   LogTrace(metname)<<"[MuonTestSummary] beginJob: Histo booking";
00080 
00081   // book the summary histos
00082   dbe->setCurrentFolder("Muons/TestSummary"); 
00083 
00084   // kinematics test report
00085   kinematicsSummaryMap = dbe->book2D("kinematicsSummaryMap","Kinematics test summary",5,1,6,3,1,4);
00086   kinematicsSummaryMap->setAxisTitle("track monitored",1);
00087   kinematicsSummaryMap->setBinLabel(1,"GLB",1);
00088   kinematicsSummaryMap->setBinLabel(2,"TKfromGLB",1);
00089   kinematicsSummaryMap->setBinLabel(3,"STAfromGLB",1);
00090   kinematicsSummaryMap->setBinLabel(4,"TK",1);
00091   kinematicsSummaryMap->setBinLabel(5,"STA",1);
00092   kinematicsSummaryMap->setAxisTitle("parameter tested",2);
00093   kinematicsSummaryMap->setBinLabel(1,"#chi^{2}",2);
00094   kinematicsSummaryMap->setBinLabel(2,"#eta",2);
00095   kinematicsSummaryMap->setBinLabel(3,"#phi",2);
00096    
00097   //chi2 kinematics quality test report
00098   chi2TestSummaryMap = dbe->book2D("chi2TestSummaryMap","#chi2 quality test summary",5,1,6,5,1,6);
00099   chi2TestSummaryMap->setAxisTitle("track monitored",1);
00100   chi2TestSummaryMap->setBinLabel(1,"GLB",1);
00101   chi2TestSummaryMap->setBinLabel(2,"TKfromGLB",1);
00102   chi2TestSummaryMap->setBinLabel(3,"STAfromGLB",1);
00103   chi2TestSummaryMap->setBinLabel(4,"TK",1);
00104   chi2TestSummaryMap->setBinLabel(5,"STA",1);
00105   chi2TestSummaryMap->setAxisTitle("parameter tested",2);
00106   chi2TestSummaryMap->setBinLabel(1,"#chi^{2}",2);
00107   chi2TestSummaryMap->setBinLabel(2,"#eta",2);
00108   chi2TestSummaryMap->setBinLabel(3,"#phi",2);
00109   chi2TestSummaryMap->setBinLabel(4,"#pt",2);
00110   chi2TestSummaryMap->setBinLabel(5,"#q",2);
00111 
00112 //Kolmogorov  kinematics quality test report
00113   KolmogorovTestSummaryMap = dbe->book2D("KolmogorovTestSummaryMap","Kolmogorov quality test summary",5,1,6,5,1,6);
00114   KolmogorovTestSummaryMap->setAxisTitle("track monitored",1);
00115   KolmogorovTestSummaryMap->setBinLabel(1,"GLB",1);
00116   KolmogorovTestSummaryMap->setBinLabel(2,"TKfromGLB",1);
00117   KolmogorovTestSummaryMap->setBinLabel(3,"STAfromGLB",1);
00118   KolmogorovTestSummaryMap->setBinLabel(4,"TK",1);
00119   KolmogorovTestSummaryMap->setBinLabel(5,"STA",1);
00120   KolmogorovTestSummaryMap->setAxisTitle("parameter tested",2);
00121   KolmogorovTestSummaryMap->setBinLabel(1,"#chi^{2}",2);
00122   KolmogorovTestSummaryMap->setBinLabel(2,"#eta",2);
00123   KolmogorovTestSummaryMap->setBinLabel(3,"#phi",2);
00124   KolmogorovTestSummaryMap->setBinLabel(4,"#pt",2);
00125   KolmogorovTestSummaryMap->setBinLabel(5,"#q",2);
00126 
00127 
00128   // residuals test report
00129   residualsSummaryMap = dbe->book2D("residualsSummaryMap","Residuals test summary",4,1,5,4,1,5);
00130   residualsSummaryMap->setAxisTitle("residuals",1);
00131   residualsSummaryMap->setBinLabel(1,"TK-GLB",1);
00132   residualsSummaryMap->setBinLabel(2,"GLB-STA",1);
00133   residualsSummaryMap->setBinLabel(3,"TK-STA",1);
00134   residualsSummaryMap->setBinLabel(4,"TK-STA Pull",1);
00135   residualsSummaryMap->setAxisTitle("parameter tested",2);
00136   residualsSummaryMap->setBinLabel(1,"#eta",2);
00137   residualsSummaryMap->setBinLabel(2,"#phi",2);
00138   residualsSummaryMap->setBinLabel(3,"1/p",2);
00139   residualsSummaryMap->setBinLabel(4,"q",2);
00140 
00141   // muonId test report
00142   muonIdSummaryMap = dbe->book2D("muonIdSummaryMap","muonId test summary",4,1,5, 5,1,6);
00143   muonIdSummaryMap->setAxisTitle("muons",1);
00144   muonIdSummaryMap->setBinLabel(1,"GLB DT",1);
00145   muonIdSummaryMap->setBinLabel(2,"GLB CSC",1);
00146   muonIdSummaryMap->setBinLabel(3,"TK DT",1);
00147   muonIdSummaryMap->setBinLabel(4,"TK CSC",1);
00148   muonIdSummaryMap->setAxisTitle("tests",2);
00149   muonIdSummaryMap->setBinLabel(1,"#assSeg",2);
00150   muonIdSummaryMap->setBinLabel(2,"x mean",2);
00151   muonIdSummaryMap->setBinLabel(3,"x rms",2);
00152   muonIdSummaryMap->setBinLabel(4,"y mean",2);
00153   muonIdSummaryMap->setBinLabel(5,"y rms",2);
00154 
00155   // energy test report
00156   energySummaryMap = dbe->book2D("energySummaryMap","Energy deposits test summary",3,1,4,3,1,4);
00157   energySummaryMap->setAxisTitle("muons",1);
00158   energySummaryMap->setBinLabel(1,"GLB",1);
00159   energySummaryMap->setBinLabel(2,"TK",1);
00160   energySummaryMap->setBinLabel(3,"STA",1);
00161   energySummaryMap->setAxisTitle("calorimeter tested",2);
00162   energySummaryMap->setBinLabel(1,"ECAL",2);
00163   energySummaryMap->setBinLabel(2,"HAD",2);
00164   energySummaryMap->setBinLabel(3,"H0",2);
00165 
00166   // multiplicity tests report
00167   multiplicitySummaryMap = dbe->book1D("multiplicitySummaryMap","muon multiplicity test summary",3,1,4);
00168   multiplicitySummaryMap->setAxisTitle("muon");
00169   multiplicitySummaryMap->setBinLabel(1,"GLB");
00170   multiplicitySummaryMap->setBinLabel(2,"TK");
00171   multiplicitySummaryMap->setBinLabel(3,"STA");
00172 
00173   
00174   // summary test report
00175   dbe->setCurrentFolder("Muons/EventInfo"); 
00176   summaryReport = dbe->bookFloat("reportSummary");
00177 
00178   summaryReportMap = dbe->book2D("reportSummaryMap","Muon Report Summary Map",3,1,4,7,1,8);
00179   summaryReportMap->setAxisTitle("muons",1);
00180   summaryReportMap->setBinLabel(1,"GLB",1);
00181   summaryReportMap->setBinLabel(2,"TK",1);
00182   summaryReportMap->setBinLabel(3,"STA",1);
00183   summaryReportMap->setAxisTitle("test",2);
00184   summaryReportMap->setBinLabel(1,"#chi^{2}/Df",2);
00185   summaryReportMap->setBinLabel(2,"#eta",2);
00186   summaryReportMap->setBinLabel(3,"#phi",2);
00187   summaryReportMap->setBinLabel(4,"residuals",2);
00188   summaryReportMap->setBinLabel(5,"muonId",2);
00189   summaryReportMap->setBinLabel(6,"energyDeposits",2);
00190   summaryReportMap->setBinLabel(7,"multiplicity",2);
00191 
00192   dbe->setCurrentFolder("Muons/EventInfo/reportSummaryContents");
00193   theSummaryContents.push_back(dbe->bookFloat("kinematics_GLB"));
00194   theSummaryContents.push_back(dbe->bookFloat("muonId_GLB"));
00195   theSummaryContents.push_back(dbe->bookFloat("residuals_GLB"));
00196   theSummaryContents.push_back(dbe->bookFloat("GLB"));
00197   theSummaryContents.push_back(dbe->bookFloat("kinematics_TK"));
00198   theSummaryContents.push_back(dbe->bookFloat("muonId_TK"));
00199   theSummaryContents.push_back(dbe->bookFloat("residuals_TK"));
00200   theSummaryContents.push_back(dbe->bookFloat("TK"));
00201   theSummaryContents.push_back(dbe->bookFloat("kinematics_STA"));
00202   theSummaryContents.push_back(dbe->bookFloat("residuals_STA"));
00203   theSummaryContents.push_back(dbe->bookFloat("STA"));
00204   theSummaryContents.push_back(dbe->bookFloat("energyDeposits"));
00205   theSummaryContents.push_back(dbe->bookFloat("multiplicity"));
00206 
00207   // certification report
00208   dbe->setCurrentFolder("Muons/EventInfo"); 
00209   summaryCertification = dbe->bookFloat("CertificationSummary");
00210   summaryCertification->Fill(-1);
00211 
00212   summaryCertificationMap = dbe->book2D("CertificationSummaryMap","Muon Certification Summary Map",9,1,10,7,1,8);
00213   summaryCertificationMap->setAxisTitle("muons",1);
00214   summaryCertificationMap->setBinLabel(1,"GLB_Tot",1);
00215   summaryCertificationMap->setBinLabel(2,"TK_Tot",1);
00216   summaryCertificationMap->setBinLabel(3,"STA_tot",1);
00217   summaryCertificationMap->setBinLabel(4,"GLB_B",1);
00218   summaryCertificationMap->setBinLabel(5,"TK_B",1);
00219   summaryCertificationMap->setBinLabel(6,"STA_B",1);
00220   summaryCertificationMap->setBinLabel(7,"GLB_EC",1);
00221   summaryCertificationMap->setBinLabel(8,"TK_EC",1);
00222   summaryCertificationMap->setBinLabel(9,"STA_EC",1);
00223   summaryCertificationMap->setAxisTitle("test",2);
00224   summaryCertificationMap->setBinLabel(1,"#chi^{2}/Df",2);
00225   summaryCertificationMap->setBinLabel(2,"#eta",2);
00226   summaryCertificationMap->setBinLabel(3,"#phi",2);
00227   summaryCertificationMap->setBinLabel(4,"residuals",2);
00228   summaryCertificationMap->setBinLabel(5,"muonId",2);
00229   summaryCertificationMap->setBinLabel(6,"energyDeposits",2);
00230   summaryCertificationMap->setBinLabel(7,"multiplicity",2);
00231 
00232   dbe->setCurrentFolder("Muons/EventInfo/CertificationContents");
00233   theCertificationContents.push_back(dbe->bookFloat("GLB_Tot"));
00234   theCertificationContents.push_back(dbe->bookFloat("STA_Tot"));
00235   theCertificationContents.push_back(dbe->bookFloat("TK_Tot"));
00236   theCertificationContents.push_back(dbe->bookFloat("GLB_B"));
00237   theCertificationContents.push_back(dbe->bookFloat("STA_B"));
00238   theCertificationContents.push_back(dbe->bookFloat("TK_B"));
00239   theCertificationContents.push_back(dbe->bookFloat("GLB_EC"));
00240   theCertificationContents.push_back(dbe->bookFloat("STA_EC"));
00241   theCertificationContents.push_back(dbe->bookFloat("TK_EC"));
00242 
00243 
00244   for (unsigned int icert=0;icert <theCertificationContents.size();icert++){
00245     theCertificationContents[icert]->Fill(-1);
00246   }
00247 }
00248 
00249 
00250 void MuonTestSummary::beginRun(Run const& run, EventSetup const& eSetup) {
00251 
00252   LogTrace(metname)<<"[MuonTestSummary]: beginRun";
00253 
00254   // initialisation of histo bins
00255   for(int xBin=1; xBin<=5; xBin++){
00256     for(int yBin=1; yBin<=3; yBin++){
00257       kinematicsSummaryMap->Fill(xBin,yBin,1);
00258     }
00259     for(int yBin=1; yBin<=5; yBin++){
00260       chi2TestSummaryMap->Fill(xBin,yBin,1); 
00261       KolmogorovTestSummaryMap->Fill(xBin,yBin,1);
00262     }
00263   }
00264   for(int xBin=1; xBin<=residualsSummaryMap->getNbinsX(); xBin++){
00265     for(int yBin=1; yBin<=residualsSummaryMap->getNbinsY(); yBin++){
00266       residualsSummaryMap->Fill(xBin,yBin,1);
00267     }
00268   }
00269   residualsSummaryMap->setBinContent(4, 4, 1); //not used for now
00270 
00271   for(int xBin=1; xBin<=muonIdSummaryMap->getNbinsX(); xBin++){
00272     for(int yBin=1; yBin<=muonIdSummaryMap->getNbinsY(); yBin++){
00273       muonIdSummaryMap->Fill(xBin,yBin,1);
00274     }
00275   }
00276   for(int xBin=1; xBin<=3; xBin++){
00277     for(int yBin=1; yBin<=3; yBin++){
00278       energySummaryMap->Fill(xBin,yBin,1);
00279     }
00280   }
00281   for(int xBin=1; xBin<=3; xBin++){
00282     multiplicitySummaryMap->Fill(xBin,1);
00283   }
00284   for(int xBin=1; xBin<=3; xBin++){
00285     for(int yBin=1; yBin<=7; yBin++){
00286       summaryReportMap->Fill(xBin,yBin,1);
00287     }
00288   }
00289   for(int xBin=1; xBin<=9; xBin++){
00290     for(int yBin=1; yBin<=7; yBin++){
00291       summaryCertificationMap->Fill(xBin,yBin,1);
00292     }
00293   }
00294 }
00295 
00296 void MuonTestSummary::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00297   //  LogTrace(metname)<<"[MuonTestSummary]: beginLuminosityBlock";
00298 }
00299 
00300 void MuonTestSummary::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00301 
00302   //  LogTrace(metname)<<"[MuonTestSummary]: endLuminosityBlock, performing the DQM LS client operation";
00303 
00304 }
00305 
00306 void MuonTestSummary::endRun(Run const& run, EventSetup const& eSetup) {
00307 
00308   LogTrace(metname)<<"[MuonTestSummary]: endRun, performing the DQM end of run client operation";
00309 
00310   // fill the kinematics report summary
00311   doKinematicsTests("GlbMuon_Glb_", 1);
00312   doKinematicsTests("GlbMuon_Tk_", 2);
00313   doKinematicsTests("GlbMuon_Sta_",3);
00314   doKinematicsTests("TkMuon_", 4);
00315   doKinematicsTests("StaMuon_", 5);
00316 
00317   // fill the residuals report summary
00318   doResidualsTests("TkGlb", "eta", 1);
00319   doResidualsTests("GlbSta", "eta", 2);
00320   doResidualsTests("TkSta", "eta", 3);
00321   doResidualsTests("TkGlb", "phi", 1);
00322   doResidualsTests("GlbSta", "phi", 2);
00323   doResidualsTests("TkSta", "phi", 3);
00324   doResidualsTests("TkGlb", "oneOverp", 1);
00325   doResidualsTests("GlbSta", "oneOverp", 2);
00326   doResidualsTests("TkSta", "oneOverp", 3);
00327   doResidualsTests("GlbMuon", "qComparison", -1);
00328 
00329   // fill the muonID report summary
00330   doMuonIDTests();
00331 
00332   // fill the energy report summary
00333   doEnergyTests("ecalS9PointingMuDepositedEnergy_","Glb_muons", 1);
00334   doEnergyTests("hadS9PointingMuDepositedEnergy_", "Glb_muons", 1);
00335   doEnergyTests("hoS9PointingMuDepositedEnergy_", "Glb_muons", 1);
00336   doEnergyTests("ecalS9PointingMuDepositedEnergy_", "Tk_muons", 2);
00337   doEnergyTests("hadS9PointingMuDepositedEnergy_", "Tk_muons", 2);
00338   doEnergyTests("hoS9PointingMuDepositedEnergy_", "Tk_muons", 2);
00339   doEnergyTests("ecalS9PointingMuDepositedEnergy_", "Sta_muons", 3);
00340   doEnergyTests("hadS9PointingMuDepositedEnergy_", "Sta_muons", 3);
00341   doEnergyTests("hoS9PointingMuDepositedEnergy_", "Sta_muons", 3);
00342 
00343   // fill the multiplicity test summary
00344   doMultiplicityTests();
00345   
00346   // fill the final report summary
00347   /*
00348   summaryReportMap->setBinContent(1,1,double(kinematicsSummaryMap->getBinContent(1,1)+kinematicsSummaryMap->getBinContent(2,1)+kinematicsSummaryMap->getBinContent(3,1))/3.0);
00349   summaryReportMap->setBinContent(2,1,kinematicsSummaryMap->getBinContent(4,1));
00350   summaryReportMap->setBinContent(3,1,kinematicsSummaryMap->getBinContent(5,1));
00351   summaryReportMap->setBinContent(1,2,double(kinematicsSummaryMap->getBinContent(1,2)+kinematicsSummaryMap->getBinContent(2,2)+kinematicsSummaryMap->getBinContent(3,2))/3.0);
00352   summaryReportMap->setBinContent(2,2,kinematicsSummaryMap->getBinContent(4,2));
00353   summaryReportMap->setBinContent(3,2,kinematicsSummaryMap->getBinContent(5,2));
00354   summaryReportMap->setBinContent(1,3,double(kinematicsSummaryMap->getBinContent(1,3)+kinematicsSummaryMap->getBinContent(2,3)+kinematicsSummaryMap->getBinContent(3,3))/3.0);
00355   summaryReportMap->setBinContent(2,3,kinematicsSummaryMap->getBinContent(4,3));
00356   summaryReportMap->setBinContent(3,3,kinematicsSummaryMap->getBinContent(5,3));
00357   */  
00358   //Changed to KolmogorovQuality test--------------------------
00359   summaryReportMap->setBinContent(1,1,double(KolmogorovTestSummaryMap->getBinContent(1,1)+KolmogorovTestSummaryMap->getBinContent(2,1)+KolmogorovTestSummaryMap->getBinContent(3,1))/3.0);
00360   summaryReportMap->setBinContent(2,1,KolmogorovTestSummaryMap->getBinContent(4,1));
00361   summaryReportMap->setBinContent(3,1,KolmogorovTestSummaryMap->getBinContent(5,1));
00362   summaryReportMap->setBinContent(1,2,double(KolmogorovTestSummaryMap->getBinContent(1,2)+KolmogorovTestSummaryMap->getBinContent(2,2)+KolmogorovTestSummaryMap->getBinContent(3,2))/3.0);
00363   summaryReportMap->setBinContent(2,2,KolmogorovTestSummaryMap->getBinContent(4,2));
00364   summaryReportMap->setBinContent(3,2,KolmogorovTestSummaryMap->getBinContent(5,2));
00365   summaryReportMap->setBinContent(1,3,double(KolmogorovTestSummaryMap->getBinContent(1,3)+KolmogorovTestSummaryMap->getBinContent(2,3)+KolmogorovTestSummaryMap->getBinContent(3,3))/3.0);
00366   summaryReportMap->setBinContent(2,3,KolmogorovTestSummaryMap->getBinContent(4,3));
00367   summaryReportMap->setBinContent(3,3,KolmogorovTestSummaryMap->getBinContent(5,3));
00368 
00369 
00370 
00371   //-- modified GH
00372   double residualsSummary = 0;
00373   //put the TRK-STA resid & pulls in the first bin ("GLB")
00374   //then the GLB-TRK and GLB-STA residuals in the 2nd and 3rd
00375   for(int i=3; i<=residualsSummaryMap->getNbinsX(); i++)
00376     for (int j=1; j<=residualsSummaryMap->getNbinsY(); j++) 
00377       residualsSummary += residualsSummaryMap->getBinContent(i,j);
00378   residualsSummary /=2*residualsSummaryMap->getNbinsY();
00379   summaryReportMap->setBinContent(1,4, residualsSummary);
00380 
00381   residualsSummary=0;
00382   for(int i=1; i<=1; i++)
00383     for (int j=1; j<=residualsSummaryMap->getNbinsY(); j++) 
00384       residualsSummary += residualsSummaryMap->getBinContent(i,j);
00385   residualsSummary /=1*residualsSummaryMap->getNbinsY();
00386   summaryReportMap->setBinContent(2,4,residualsSummary);
00387   
00388   residualsSummary=0;
00389   for(int i=2; i<=2; i++)
00390     for (int j=1; j<=residualsSummaryMap->getNbinsY(); j++) 
00391       residualsSummary += residualsSummaryMap->getBinContent(i,j);
00392   residualsSummary /=1*residualsSummaryMap->getNbinsY(); 
00393   summaryReportMap->setBinContent(3,4,residualsSummary);
00394   
00395   //--
00396 
00397 
00398 
00399   //-- modified GH
00400   float idtest=0;
00401   for(int i=1; i<=2; i++)
00402     for(int j=1; j<=5; j++) {
00403       if(j==3 || j==5) continue; //ignore pull widths for now
00404       idtest+=muonIdSummaryMap->getBinContent(i,j);
00405     }
00406   //  idtest/=10.;
00407    idtest/=6.;
00408   summaryReportMap->setBinContent(1,5, idtest);
00409   idtest=0;
00410   for(int i=3; i<=4; i++)
00411     for(int j=1; j<=5; j++) {
00412       if(j==3 || j==5) continue; //ignore pull widths for now
00413       idtest+=muonIdSummaryMap->getBinContent(i,j);
00414     }
00415   //  idtest/=10.;
00416   idtest/=6.;
00417   summaryReportMap->setBinContent(2,5,idtest);
00418   summaryReportMap->setBinContent(3,5,-1.0/6.0);
00419   //--
00420 
00421 
00422 
00423   //summaryReportMap->setBinContent(1,6,double(energySummaryMap->getBinContent(1,1)+energySummaryMap->getBinContent(1,2)+energySummaryMap->getBinContent(1,3))/3.0);
00424   //summaryReportMap->setBinContent(2,6,double(energySummaryMap->getBinContent(2,1)+energySummaryMap->getBinContent(2,2)+energySummaryMap->getBinContent(2,3))/3.0);
00425   //summaryReportMap->setBinContent(3,6,double(energySummaryMap->getBinContent(3,1)+energySummaryMap->getBinContent(3,2)+energySummaryMap->getBinContent(3,3))/3.0);
00426   summaryReportMap->setBinContent(1,6,double(energySummaryMap->getBinContent(1,1)+energySummaryMap->getBinContent(1,2))/2.0);
00427   summaryReportMap->setBinContent(2,6,double(energySummaryMap->getBinContent(2,1)+energySummaryMap->getBinContent(2,2))/2.0);
00428   summaryReportMap->setBinContent(3,6,double(energySummaryMap->getBinContent(3,1)+energySummaryMap->getBinContent(3,2))/2.0);
00429   summaryReportMap->setBinContent(1,7,multiplicitySummaryMap->getBinContent(1));
00430   summaryReportMap->setBinContent(2,7,multiplicitySummaryMap->getBinContent(2));
00431   summaryReportMap->setBinContent(3,7,multiplicitySummaryMap->getBinContent(3));
00432 
00433 
00434   double kinematics_GLB = double(summaryReportMap->getBinContent(1,1)+summaryReportMap->getBinContent(1,2)+summaryReportMap->getBinContent(1,3))/3.0;
00435   theSummaryContents[0]->Fill(kinematics_GLB);
00436   double muonId_GLB = double(summaryReportMap->getBinContent(1,5));
00437   theSummaryContents[1]->Fill(muonId_GLB);
00438   double residuals_GLB = double(summaryReportMap->getBinContent(1,4));
00439   theSummaryContents[2]->Fill(residuals_GLB);
00440   double GLB = (kinematics_GLB+muonId_GLB+residuals_GLB)/3.0;
00441   theSummaryContents[3]->Fill(GLB);
00442 
00443   double kinematics_TK = double(summaryReportMap->getBinContent(2,1)+summaryReportMap->getBinContent(2,2)+summaryReportMap->getBinContent(2,3))/3.0;
00444   theSummaryContents[4]->Fill(kinematics_TK);
00445   double muonId_TK = double(summaryReportMap->getBinContent(2,5));
00446   theSummaryContents[5]->Fill(muonId_TK);
00447   double residuals_TK = double(summaryReportMap->getBinContent(2,4));
00448   theSummaryContents[6]->Fill(residuals_TK);
00449   double TK = double(kinematics_TK+muonId_TK+residuals_TK)/3.0;
00450   theSummaryContents[7]->Fill(TK);
00451 
00452   double kinematics_STA = double(summaryReportMap->getBinContent(3,1)+summaryReportMap->getBinContent(3,2)+summaryReportMap->getBinContent(3,3))/3.0;
00453   theSummaryContents[8]->Fill(kinematics_STA);
00454   double residuals_STA = double(summaryReportMap->getBinContent(3,4));
00455   theSummaryContents[9]->Fill(residuals_STA);
00456   double STA = double(kinematics_STA+residuals_STA)/2.0;
00457   theSummaryContents[10]->Fill(STA);
00458   double energyDeposits = double(summaryReportMap->getBinContent(1,6)+summaryReportMap->getBinContent(2,6)+summaryReportMap->getBinContent(3,6))/3.0;
00459   theSummaryContents[11]->Fill(energyDeposits);
00460   double multiplicity = double(summaryReportMap->getBinContent(1,7)+summaryReportMap->getBinContent(2,7)+summaryReportMap->getBinContent(3,7))/3.0;
00461   theSummaryContents[12]->Fill(multiplicity);
00462 
00463   summaryReport->Fill((GLB+TK+STA+energyDeposits+multiplicity)/5.0);
00464 
00465 
00466   //global barrel:
00467   float muonIDsummary=0;
00468   //  for(int i=2; i<=5; i++) 
00469   //     muonIDsummary += muonIdSummaryMap->getBinContent(2, i);
00470   //  summaryCertificationMap->setBinContent(4, 5, muonIDsummary/4.);
00471   //for now, just report the mean:
00472   muonIDsummary += muonIdSummaryMap->getBinContent(1, 2);
00473   muonIDsummary += muonIdSummaryMap->getBinContent(1, 4);
00474   summaryCertificationMap->setBinContent(4, 5, muonIDsummary/2.);
00475   
00476   //global EC:
00477   muonIDsummary=0;
00478   //  for(int i=2; i<=5; i++)
00479   //  muonIDsummary += muonIdSummaryMap->getBinContent(2, i);
00480   // summaryCertificationMap->setBinContent(7, 5, muonIDsummary/4.);
00481   muonIDsummary += muonIdSummaryMap->getBinContent(2, 2);
00482   muonIDsummary += muonIdSummaryMap->getBinContent(2, 4);
00483   summaryCertificationMap->setBinContent(7, 5, muonIDsummary/2.);
00484   
00485   //tracker barrel:
00486   muonIDsummary=0;
00487   //  for(int i=2; i<=5; i++)
00488   //    muonIDsummary += muonIdSummaryMap->getBinContent(3, i);
00489   //  summaryCertificationMap->setBinContent(5, 5, muonIDsummary/4.);
00490   muonIDsummary += muonIdSummaryMap->getBinContent(3, 2);
00491   muonIDsummary += muonIdSummaryMap->getBinContent(3, 4);
00492   summaryCertificationMap->setBinContent(5, 5, muonIDsummary/2.);
00493     
00494   //tracker EC:
00495    muonIDsummary=0;
00496    //  for(int i=2; i<=5; i++)
00497    //    muonIDsummary += muonIdSummaryMap->getBinContent(4, i);
00498    //  summaryCertificationMap->setBinContent(8, 5, muonIDsummary/4.);
00499   muonIDsummary += muonIdSummaryMap->getBinContent(4, 2);
00500   muonIDsummary += muonIdSummaryMap->getBinContent(4, 4);
00501   summaryCertificationMap->setBinContent(8, 5, muonIDsummary/2.);
00502     
00503 
00504   double muonId_GLB_B = double(summaryCertificationMap->getBinContent(4,5));
00505   theCertificationContents[3]->Fill(muonId_GLB_B);
00506   double muonId_GLB_EC = double(summaryCertificationMap->getBinContent(7,5));
00507   theCertificationContents[6]->Fill(muonId_GLB_EC);
00508 
00509   double muonId_TK_B = double(summaryCertificationMap->getBinContent(5,5));
00510   theCertificationContents[5]->Fill(muonId_TK_B);
00511   double muonId_TK_EC = double(summaryCertificationMap->getBinContent(8,5));
00512   theCertificationContents[8]->Fill(muonId_TK_EC);
00513 
00514 
00515 
00516 
00517 
00518 
00519 
00520 }
00521 
00522 
00523 void MuonTestSummary::doKinematicsTests(string muonType, int bin){
00524   
00525 
00526   // chi2 test
00527   string path = "Muons/MuonRecoAnalyzer/" + muonType + "chi2OverDf";
00528   MonitorElement * chi2Histo = dbe->get(path);
00529 
00530   if(chi2Histo){
00531     TH1F * chi2Histo_root = chi2Histo->getTH1F();
00532     if(chi2Histo_root->GetEntries()>20){
00533 
00534       //Standard QT based on fraction of events below and above a cut
00535       LogTrace(metname)<<"chi2 kin test based on fraction for "<<muonType<<endl;
00536       int maxBin = chi2Histo_root->GetMaximumBin();
00537       if(chi2Histo_root->Integral(maxBin+1,chi2Histo_root->GetNbinsX())!=0){
00538         double fraction = double(chi2Histo_root->Integral(1,maxBin))/double(chi2Histo_root->Integral(maxBin+1,chi2Histo_root->GetNbinsX()));
00539         LogTrace(metname)<<"chi2 fraction for "<<muonType<<" : "<<fraction<< " must be within "<< chi2Fraction-chi2Spread<<","<<chi2Fraction+chi2Spread<<endl;
00540         if(fraction>(chi2Fraction-chi2Spread) && fraction<(chi2Fraction+chi2Spread))
00541           kinematicsSummaryMap->setBinContent(bin,1,1);
00542         else
00543           kinematicsSummaryMap->setBinContent(bin,1,0);
00544       }
00545 
00546       //QT based on comp wrt reference based on chi2
00547       LogTrace(metname)<<"chi2 kin test based on comp wrt reference on terms of chi2 for "<<muonType<<endl;
00548       const QReport * myQReport = chi2Histo->getQReport("Mu_Comp2RefChi2"); //get QReport associated to your ME  
00549       if(myQReport) {
00550         LogTrace(metname) << "Chi2Report exists!!";
00551         float qtresult = myQReport->getQTresult(); // get QT result value
00552         int qtstatus = myQReport->getStatus() ; // get QT status value (see table below)
00553         std::string qtmessage = myQReport->getMessage() ; // get the whole QT result message
00554         LogTrace(metname) << "qtresult " <<qtresult << " qtstatus "<<qtstatus<<endl;
00555         chi2TestSummaryMap->setBinContent(bin,1,qtresult);
00556       }
00557       //QT based on comp wrt reference based on kolmogorov test
00558       LogTrace(metname)<<"chi2 kin test based on comp wrt reference using kolmogorov for "<<muonType<<endl;
00559       const QReport * myQReportKolmo = chi2Histo->getQReport("Mu_Comp2RefKolmogorov");
00560       if(myQReportKolmo) {
00561         LogTrace(metname) << "Chi2Report Kolmogorov exists!!";
00562         float qtresult = myQReportKolmo->getQTresult(); // get QT result value
00563         int qtstatus = myQReportKolmo->getStatus() ; // get QT status value (see table below)
00564         std::string qtmessage = myQReportKolmo->getMessage() ; // get the whole QT result message
00565         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00566         KolmogorovTestSummaryMap->setBinContent(bin,1,qtresult);
00567       }
00568 
00569     }
00570     else{
00571       LogTrace(metname) << "[MuonTestSummary]: Test of Chi2 Kin not performed for "<< muonType << " because # entries < 20 ";
00572     }
00573   }
00574 
00575 
00576 
00577   // pseudorapidity test
00578   path = "Muons/MuonRecoAnalyzer/" + muonType + "eta";
00579   MonitorElement * etaHisto = dbe->get(path);
00580 
00581   if(etaHisto){
00582     TH1F * etaHisto_root = etaHisto->getTH1F();
00583     if (etaHisto_root ->GetEntries()>20){
00584 
00585       //Standard QT based on fraction of events below and above a cut
00586       LogTrace(metname)<<"eta kin test based on fraction for "<<muonType<<endl;
00587       double binSize = (etaHisto_root->GetXaxis()->GetXmax()-etaHisto_root->GetXaxis()->GetXmin())/etaHisto_root->GetNbinsX();
00588       int binZero = int((0-etaHisto_root->GetXaxis()->GetXmin())/binSize);
00589       if(etaHisto_root->Integral(1,binZero-1)!=0 && etaHisto_root->Integral(binZero,etaHisto_root->GetNbinsX())!=0){
00590         double symmetryFactor = 
00591           double(etaHisto_root->Integral(1,binZero-1)) / double(etaHisto_root->Integral(binZero,etaHisto_root->GetNbinsX()));
00592         double errSymmetryFactor =
00593           symmetryFactor*sqrt(1.0/double(etaHisto_root->Integral(1,binZero-1)) + 1.0/double(etaHisto_root->Integral(binZero,etaHisto_root->GetNbinsX())));
00594         LogTrace(metname)<<"eta symmetryFactor for "<<muonType<<" : "<<symmetryFactor<< " (expected :" <<etaExpected <<")"<<endl;
00595         LogTrace(metname)<<"eta errSymmetryFactor for "<<muonType<<" : "<<errSymmetryFactor<<endl;
00596         double tParameter;
00597         if((symmetryFactor-etaExpected)>0) tParameter=double(symmetryFactor-etaExpected)/errSymmetryFactor;
00598         else tParameter=double(-symmetryFactor+etaExpected)/errSymmetryFactor;
00599         LogTrace(metname)<<"eta tParameter for "<<muonType<<" : "<<tParameter<<" (expected < 1.95)" <<endl;
00600         if (tParameter<1.95) //2sigma rejection
00601           kinematicsSummaryMap->setBinContent(bin,2,1);
00602         else
00603           kinematicsSummaryMap->setBinContent(bin,2,0);
00604       }
00605 
00606       //QT based on comp wrt reference based on chi2
00607       LogTrace(metname)<<"eta kin test based on comp wrt reference on terms of chi2 for "<<muonType<<endl;
00608       const QReport * myQReport = etaHisto->getQReport("Mu_Comp2RefChi2"); //get QReport associated to your ME
00609       if(myQReport) {
00610         LogTrace(metname) << "EtaReport exists!!";
00611         float qtresult = myQReport->getQTresult(); // get QT result value
00612         int qtstatus = myQReport->getStatus() ; // get QT status value (see table below)
00613         std::string qtmessage = myQReport->getMessage() ; // get the whole QT result message
00614         LogTrace(metname) << "qtresult " <<qtresult << " qtstatus "<<qtstatus<<endl;
00615         chi2TestSummaryMap->setBinContent(bin,2,qtresult);
00616       }
00617 
00618       //QT based on comp wrt reference based on kolmogorov test
00619       LogTrace(metname)<<"eta kin test based on comp wrt reference using kolmogorov for "<<muonType<<endl;
00620       const QReport * myQReportKolmo = etaHisto->getQReport("Mu_Comp2RefKolmogorov");
00621       if(myQReportKolmo) {
00622         LogTrace(metname) << "EtaReport Kolmogorov exists!!";
00623         float qtresult = myQReportKolmo->getQTresult(); // get QT result value
00624         int qtstatus = myQReportKolmo->getStatus() ; // get QT status value (see table below)
00625         std::string qtmessage = myQReportKolmo->getMessage() ; // get the whole QT result message
00626         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00627         KolmogorovTestSummaryMap->setBinContent(bin,2,qtresult);
00628       }
00629       
00630     }
00631     else{
00632       LogTrace(metname) << "[MuonTestSummary]: Test of Eta Kin not performed for "<< muonType << " because # entries < 20 ";
00633     }
00634   }
00635 
00636 
00637 
00638   // phi test
00639   path = "Muons/MuonRecoAnalyzer/" + muonType + "phi";
00640   MonitorElement * phiHisto = dbe->get(path);
00641 
00642   if(phiHisto ){
00643     TH1F * phiHisto_root = phiHisto->getTH1F();
00644     if(phiHisto_root ->GetEntries()>20){    
00645 
00646       //Standard QT based on fraction of events below and above a cut
00647       LogTrace(metname)<<"phi kin test based on fraction for "<<muonType<<endl;
00648       double binSize = (phiHisto_root->GetXaxis()->GetXmax()-phiHisto_root->GetXaxis()->GetXmin())/phiHisto_root->GetNbinsX();
00649       int binZero = int((0-phiHisto_root->GetXaxis()->GetXmin())/binSize);
00650       if(phiHisto_root->Integral(binZero+1,phiHisto_root->GetNbinsX())!=0 && phiHisto_root->Integral(1,binZero)!=0){
00651         double symmetryFactor = 
00652           double(phiHisto_root->Integral(binZero+1,phiHisto_root->GetNbinsX())) / double(phiHisto_root->Integral(1,binZero));
00653         double errSymmetryFactor = 
00654           symmetryFactor*sqrt(1.0/double(phiHisto_root->Integral(binZero+1,phiHisto_root->GetNbinsX())) + 1.0/double(phiHisto_root->Integral(1,binZero)));
00655         LogTrace(metname)<<"phi symmetryFactor for "<<muonType<<" : "<<symmetryFactor<< "(phi expected :" <<phiExpected <<")"<<endl;
00656         LogTrace(metname)<<"phi errSymmetryFactor for "<<muonType<<" : "<<errSymmetryFactor<<endl;
00657         double tParameter;
00658         if((symmetryFactor-phiExpected)>0) tParameter=double(symmetryFactor-phiExpected)/errSymmetryFactor;
00659         else tParameter=double(-symmetryFactor+phiExpected)/errSymmetryFactor;
00660         LogTrace(metname)<<"phi tParameter for "<<muonType<<" : "<<tParameter<<" (expected < 1.95)" <<endl;
00661       if (tParameter<1.95) //2sigma rejection
00662         kinematicsSummaryMap->setBinContent(bin,3,1);
00663       else
00664         kinematicsSummaryMap->setBinContent(bin,3,0);
00665       }
00666 
00667       //QT based on comp wrt reference based on chi2
00668       LogTrace(metname)<<"phi kin test based on comp wrt reference on terms of chi2 for "<<muonType<<endl;
00669       const QReport * myQReport = phiHisto->getQReport("Mu_Comp2RefChi2"); //get QReport associated to your ME
00670       if(myQReport) {
00671         LogTrace(metname) << "PhiReport exists!!";
00672         float qtresult = myQReport->getQTresult(); // get QT result value
00673         int qtstatus = myQReport->getStatus() ; // get QT status value (see table below)
00674         std::string qtmessage = myQReport->getMessage() ; // get the whole QT result message
00675         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00676         chi2TestSummaryMap->setBinContent(bin,3,qtresult);
00677      }
00678 
00679       //QT based on comp wrt reference based on kolmogorov test
00680       LogTrace(metname)<<"phi kin test based on comp wrt reference using kolmogorov for "<<muonType<<endl;
00681       const QReport * myQReportKolmo = phiHisto->getQReport("Mu_Comp2RefKolmogorov");
00682       if(myQReportKolmo) {
00683         LogTrace(metname) << "PhiReport Kolmogorov exists!!";
00684         float qtresult = myQReportKolmo->getQTresult(); // get QT result value
00685         int qtstatus = myQReportKolmo->getStatus() ; // get QT status value (see table below)
00686         std::string qtmessage = myQReportKolmo->getMessage() ; // get the whole QT result message
00687         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00688         KolmogorovTestSummaryMap->setBinContent(bin,3,qtresult);
00689       }
00690 
00691     }
00692     else{
00693       LogTrace(metname) << "[MuonTestSummary]: Test of Phi Kin not performed for "<< muonType << " because # entries < 20 ";
00694     }
00695   }
00696 
00697   // pt test
00698   path = "Muons/MuonRecoAnalyzer/" + muonType + "pt";
00699   MonitorElement * ptHisto = dbe->get(path);
00700 
00701   if(ptHisto ){
00702     TH1F * ptHisto_root = ptHisto->getTH1F();
00703     if(ptHisto_root ->GetEntries()>20){    
00704 
00705       //QT based on comp wrt reference based on chi2
00706       LogTrace(metname)<<"pt kin test based on comp wrt reference on terms of chi2 for "<<muonType<<endl;
00707       const QReport * myQReport = ptHisto->getQReport("Mu_Comp2RefChi2"); //get QReport associated to your ME
00708       if(myQReport) {
00709         LogTrace(metname) << "PtReport exists!!";
00710         float qtresult = myQReport->getQTresult(); // get QT result value
00711         int qtstatus = myQReport->getStatus() ; // get QT status value (see table below)
00712         std::string qtmessage = myQReport->getMessage() ; // get the whole QT result message
00713         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00714         chi2TestSummaryMap->setBinContent(bin,4,qtresult);
00715      }
00716 
00717       //QT based on comp wrt reference based on kolmogorov test
00718       LogTrace(metname)<<"pt kin test based on comp wrt reference using kolmogorov for "<<muonType<<endl;
00719       const QReport * myQReportKolmo = ptHisto->getQReport("Mu_Comp2RefKolmogorov");
00720       if(myQReportKolmo) {
00721         LogTrace(metname) << "PtReport Kolmogorov exists!!";
00722         float qtresult = myQReportKolmo->getQTresult(); // get QT result value
00723         int qtstatus = myQReportKolmo->getStatus() ; // get QT status value (see table below)
00724         std::string qtmessage = myQReportKolmo->getMessage() ; // get the whole QT result message
00725         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00726         KolmogorovTestSummaryMap->setBinContent(bin,4,qtresult);
00727       }
00728     }
00729     else{
00730       LogTrace(metname) << "[MuonTestSummary]: Test of Pt Kin not performed for "<< muonType << " because # entries < 20 ";
00731     }
00732   }
00733 
00734   // q test
00735   path = "Muons/MuonRecoAnalyzer/" + muonType + "q";
00736   MonitorElement * qHisto = dbe->get(path);
00737 
00738   if(ptHisto ){
00739     TH1F * qHisto_root = qHisto->getTH1F();
00740     if(qHisto_root ->GetEntries()>20){    
00741 
00742       //QT based on comp wrt reference based on chi2
00743       LogTrace(metname)<<"q kin test based on comp wrt reference on terms of chi2 for "<<muonType<<endl;
00744       const QReport * myQReport = qHisto->getQReport("Mu_Comp2RefChi2"); //get QReport associated to your ME
00745       if(myQReport) {
00746         LogTrace(metname) << "qReport exists!!";
00747         float qtresult = myQReport->getQTresult(); // get QT result value
00748         int qtstatus = myQReport->getStatus() ; // get QT status value (see table below)
00749         std::string qtmessage = myQReport->getMessage() ; // get the whole QT result message
00750         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00751         chi2TestSummaryMap->setBinContent(bin,5,qtresult);
00752      }
00753 
00754       //QT based on comp wrt reference based on kolmogorov test
00755       LogTrace(metname)<<"q kin test based on comp wrt reference using kolmogorov for "<<muonType<<endl;
00756       const QReport * myQReportKolmo = qHisto->getQReport("Mu_Comp2RefKolmogorov");
00757       if(myQReportKolmo) {
00758         LogTrace(metname) << "qReport Kolmogorov exists!!";
00759         float qtresult = myQReportKolmo->getQTresult(); // get QT result value
00760         int qtstatus = myQReportKolmo->getStatus() ; // get QT status value (see table below)
00761         std::string qtmessage = myQReportKolmo->getMessage() ; // get the whole QT result message
00762         LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00763         KolmogorovTestSummaryMap->setBinContent(bin,5,qtresult);
00764       }
00765     }
00766     else{
00767       LogTrace(metname) << "[MuonTestSummary]: Test of q Kin not performed for "<< muonType << " because # entries < 20 ";
00768     }
00769   }
00770 
00771 }
00772 
00773 
00774 
00775 
00776 
00777 
00778 
00779     //--GH new
00780 void MuonTestSummary::GaussFit(string type, string parameter, MonitorElement *  Histo, float &mean, float &mean_err, float &sigma, float &sigma_err) {
00781   
00782   // Gaussian Fit
00783   float statMean = Histo->getMean(1);
00784   float statSigma = Histo->getRMS(1);
00785   TH1F * histo_root = Histo->getTH1F();
00786   if(histo_root->GetEntries()>20){
00787     TF1 *gfit = new TF1("Gaussian","gaus",(statMean-(2*statSigma)),(statMean+(2*statSigma)));
00788     try {
00789       histo_root->Fit(gfit, "Q0");
00790     } catch (...) {
00791       edm::LogError (metname)<< "[MuonTestSummary]: Exception when fitting Res_"<<type<<"_"<<parameter;
00792     }
00793     if(gfit){
00794       mean = gfit->GetParameter(1); 
00795       mean_err = gfit->GetParErrors()[2];
00796       sigma = gfit->GetParameter(2);
00797       sigma_err = gfit->GetParErrors()[2];
00798       LogTrace(metname)<<"Gaussian fit mean: "<<mean<<" +- "<<mean_err<<" for "<<type<<"_"<<parameter<<endl;
00799       LogTrace(metname)<<"Gaussina fit sigma: "<<sigma<<" +- "<<sigma_err<<" for "<<type<<"_"<<parameter<<endl;
00800     }
00801   }
00802   else{
00803     LogTrace(metname) << "[MuonTestSummary]: Test of  Res_"<<type<<"_"<<parameter<< " not performed because # entries < 20 ";
00804     //auto-pass if not enough events.
00805     mean=1;
00806     mean_err=1;
00807     sigma=1;
00808     sigma_err=1;
00809   }
00810 }  
00811 
00812 
00813 
00814 
00815 
00816 
00817 void MuonTestSummary::doResidualsTests(string type, string parameter, int bin){
00818 
00819   // residuals test
00820   if(type!="GlbMuon"){
00821     string path = "Muons/MuonRecoAnalyzer/Res_" + type + "_" + parameter;
00822     MonitorElement * residualsHisto = dbe->get(path);
00823     
00824     float mean = -1;
00825     float mean_err = -1;
00826     float sigma = -1;
00827     float sigma_err = -1;
00828     
00829     if(residualsHisto){
00830       
00831       LogTrace(metname) << "[MuonTestSummary]: Starting Gaussian fit for Test of  Res_"<<type<<"_"<<parameter<< endl;
00832       GaussFit( type, parameter, residualsHisto, mean, mean_err, sigma, sigma_err); 
00833       
00834       if(sigma!=-1 && parameter=="eta" && type=="TkGlb"){
00835         if(sigma-sigma_err<resEtaSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 1, 1);
00836         else residualsSummaryMap->setBinContent(bin, 1, 0);
00837       }
00838       if(sigma!=-1 && parameter=="eta" && (type=="GlbSta" || type=="TkSta")) {
00839         if(sigma-sigma_err<resEtaSpread_glbSta) residualsSummaryMap->setBinContent(bin, 1, 1);
00840         else residualsSummaryMap->setBinContent(bin, 1, 0);
00841       }
00842       if(sigma!=-1 && parameter=="phi" && type=="TkGlb"){
00843         if(sigma-sigma_err<resPhiSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 2, 1);     
00844         else residualsSummaryMap->setBinContent(bin, 2, 0);
00845       }
00846       if(sigma!=-1 && parameter=="phi" && (type=="GlbSta" || type=="TkSta")){ 
00847         if(sigma-sigma_err<resPhiSpread_glbSta) residualsSummaryMap->setBinContent(bin, 2, 1); 
00848         else residualsSummaryMap->setBinContent(bin, 2, 0); 
00849       }
00850       if(sigma!=-1 && parameter=="oneOverp" && type=="TkGlb"){
00851         if(sigma-sigma_err<resOneOvPSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 3, 1);
00852         else residualsSummaryMap->setBinContent(bin, 3, 0);
00853       }
00854       if(sigma!=-1 && parameter=="oneOverp" && (type=="GlbSta" || type=="TkSta")) {
00855         if(sigma-sigma_err<resOneOvPSpread_glbSta) residualsSummaryMap->setBinContent(bin, 3, 1);
00856         else residualsSummaryMap->setBinContent(bin, 3, 0);
00857       }
00858     }
00859 
00860 
00861 
00862     //--GH modified
00863     if(type=="TkSta"){
00864       //look at the pull:
00865       string path = "Muons/MuonRecoAnalyzer/Pull_" + type + "_" + parameter;
00866       MonitorElement * pullHisto = dbe->get(path);
00867       
00868       if(pullHisto){
00869         
00870         LogTrace(metname) << "[MuonTestSummary]: Starting Gaussian fit for Test of  Pull_"<<type<<"_"<<parameter<< endl;
00871         GaussFit( type, parameter, pullHisto, mean, mean_err, sigma, sigma_err); 
00872 
00873         if(sigma!=-1 && parameter=="eta" ){
00874           if(sigma-sigma_err<pullEtaSpread) residualsSummaryMap->setBinContent(4, 1, 1);
00875           else residualsSummaryMap->setBinContent(4, 1, 0);
00876         }
00877         if(sigma!=-1 && parameter=="phi"){
00878           if(sigma-sigma_err<pullPhiSpread) residualsSummaryMap->setBinContent(4, 2, 1);     
00879           else residualsSummaryMap->setBinContent(4, 2, 0);
00880         }
00881         if(sigma!=-1 && parameter=="oneOverp"){
00882           if(sigma-sigma_err<pullOneOvPSpread) residualsSummaryMap->setBinContent(4, 3, 1);
00883           else residualsSummaryMap->setBinContent(4, 3, 0);
00884         }
00885         
00886       }//have pull histo
00887     } //TkSta muons
00888   }
00889 
00890   //this part for Global Muons:
00891   else{
00892     string path = "Muons/MuonRecoAnalyzer/" + type + "_" + parameter;
00893     MonitorElement * residualsHisto = dbe->get(path);
00894     
00895     if(residualsHisto){
00896       LogTrace(metname) << "[MuonTestSummary]: Test of  Charge Comparison "<<type<<"_"<<parameter<< endl;
00897       if((residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4))!=0){
00898         LogTrace(metname)<<"Charge comparison TkGlb: "<<residualsHisto->getBinContent(4)/double(residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4))<<endl;
00899         if(residualsHisto->getBinContent(4)/double(residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4)) < resChargeLimit_tkGlb)
00900           residualsSummaryMap->setBinContent(1, 4, 1);
00901         else
00902           residualsSummaryMap->setBinContent(1, 4, 0);
00903       }
00904       if((residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2))!=0){
00905         LogTrace(metname)<<"charge comparison GlbSta: "<<residualsHisto->getBinContent(2)/double(residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2))<<endl;
00906         if(residualsHisto->getBinContent(2)/double(residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2)) < resChargeLimit_glbSta)
00907           residualsSummaryMap->setBinContent(2, 4, 1);
00908         else
00909           residualsSummaryMap->setBinContent(2, 4, 0);
00910       }
00911       if(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6)!=0){
00912         LogTrace(metname)<<"charge comparison TkSta: "<<residualsHisto->getBinContent(6)/double(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6))<<endl;
00913         if(residualsHisto->getBinContent(6)/double(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6)) < resChargeLimit_tkSta)
00914           residualsSummaryMap->setBinContent(3, 4, 1);
00915         else
00916           residualsSummaryMap->setBinContent(3, 4, 0);
00917       }
00918     }
00919   }
00920   
00921 }
00922 
00923 void MuonTestSummary::doMuonIDTests(){
00924 
00925   vector<string> muType;
00926   muType.push_back("GlobalMuons");
00927   muType.push_back("TrackerMuons");
00928 
00929   for(int i=0; i<=1; i++){
00930 
00931     // num matches test
00932     string path = "Muons/MuonIdDQM/" + muType[i] + "/hNumMatches";
00933     MonitorElement * matchesHisto = dbe->get(path);
00934     
00935     if(matchesHisto){
00936         TH1F * matchesHisto_root = matchesHisto->getTH1F();
00937       if(matchesHisto_root->GetMaximumBin() >= numMatchedExpected_min && matchesHisto_root->GetMaximumBin() <= numMatchedExpected_max)
00938         muonIdSummaryMap->setBinContent(i+1,1,1);
00939       else
00940         muonIdSummaryMap->setBinContent(i+1,1,0);
00941     }
00942     
00943     
00944     // num of 0 associated segments 
00945     double numOneSegm_dt = 0;
00946     int numHistos_dt=0;
00947     int numHistos_csc=0;
00948     MonitorElement * DT1Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT1NumSegments");
00949     if(DT1Histo)
00950       {numHistos_dt++;
00951         if(DT1Histo->getEntries()!=0) numOneSegm_dt+=double(DT1Histo->getBinContent(2))/double(DT1Histo->getEntries());}
00952     MonitorElement * DT2Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT2NumSegments");
00953     if(DT2Histo) 
00954       {numHistos_dt++;
00955         if(DT2Histo->getEntries()!=0) numOneSegm_dt+=double(DT2Histo->getBinContent(2))/double(DT2Histo->getEntries());}
00956     MonitorElement * DT3Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT3NumSegments");
00957     if(DT3Histo) 
00958       {numHistos_dt++;
00959         if(DT3Histo->getEntries()!=0) numOneSegm_dt+=double(DT3Histo->getBinContent(2))/double(DT3Histo->getEntries());}
00960     MonitorElement * DT4Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT4NumSegments"); 
00961     if(DT4Histo) 
00962       {numHistos_dt++;
00963         if(DT4Histo->getEntries()!=0) numOneSegm_dt+=double(DT4Histo->getBinContent(2))/double(DT4Histo->getEntries());}
00964     double fraction_dt=0;
00965     if(numOneSegm_dt!=0){
00966       fraction_dt = numOneSegm_dt/double(numHistos_dt);
00967       LogTrace(metname)<<"fraction_dt: "<<fraction_dt<<" for "<<muType[i]<<endl;
00968     }
00969 
00970     double numOneSegm_csc = 0;
00971     MonitorElement * CSC1Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC1NumSegments");
00972     if(CSC1Histo) 
00973       {numHistos_csc++;
00974         if(CSC1Histo->getEntries()!=0) numOneSegm_csc+=double(CSC1Histo->getBinContent(2))/double(CSC1Histo->getEntries());}
00975     MonitorElement * CSC2Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC2NumSegments");
00976     if(CSC2Histo) 
00977       {numHistos_csc++;
00978         if(CSC2Histo->getEntries()!=0) numOneSegm_csc+=double(CSC2Histo->getBinContent(2))/double(CSC2Histo->getEntries());}
00979     MonitorElement * CSC3Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC3NumSegments");
00980     if(CSC3Histo) 
00981       {numHistos_csc++;
00982         if(CSC3Histo->getEntries()!=0) numOneSegm_csc+=double(CSC3Histo->getBinContent(2))/double(CSC3Histo->getEntries());}
00983     MonitorElement * CSC4Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC4NumSegments");
00984     if(CSC4Histo) 
00985       {numHistos_csc++;
00986         if(CSC4Histo->getEntries()!=0) numOneSegm_csc+=double(CSC4Histo->getBinContent(2))/double(CSC4Histo->getEntries());}
00987     double fraction_csc=0;
00988     if(numOneSegm_csc!=0){
00989       fraction_csc = numOneSegm_csc/double(numHistos_csc);
00990       LogTrace(metname)<<"fraction_csc: "<<fraction_csc<<" for "<<muType[i]<<endl;
00991     }
00992     
00993 
00994 
00995     //--GH modified
00996 
00997     if(fraction_dt>matchesFractionDt_min && fraction_dt<matchesFractionDt_max)
00998       muonIdSummaryMap->setBinContent(2*i+1,1,1);
00999     else
01000       muonIdSummaryMap->setBinContent(2*i+1,1,0);
01001   
01002     if(fraction_csc>matchesFractionCsc_min && fraction_csc<matchesFractionCsc_max)
01003       muonIdSummaryMap->setBinContent(2*i+2,1,1);
01004     else
01005       muonIdSummaryMap->setBinContent(2*i+2,1,0);
01006 
01007     
01008 
01009     //--GH modified
01010     
01011     // residuals test
01012     vector<string> DTXresHistos, DTYresHistos, CSCXresHistos, CSCYresHistos;
01013     DTXresHistos.push_back("hDT1Pullx");
01014     DTXresHistos.push_back("hDT2Pullx");
01015     DTXresHistos.push_back("hDT3Pullx");
01016     DTXresHistos.push_back("hDT4Pullx");
01017 
01018     DTYresHistos.push_back("hDT1Pully");
01019     DTYresHistos.push_back("hDT2Pully");
01020     DTYresHistos.push_back("hDT3Pully");
01021 
01022     CSCXresHistos.push_back("hCSC1Pullx");
01023     CSCXresHistos.push_back("hCSC2Pullx");
01024     CSCXresHistos.push_back("hCSC3Pullx");
01025     CSCXresHistos.push_back("hCSC4Pullx");
01026 
01027     CSCYresHistos.push_back("hCSC1Pully");
01028     CSCYresHistos.push_back("hCSC2Pully");
01029     CSCYresHistos.push_back("hCSC3Pully");
01030     CSCYresHistos.push_back("hCSC4Pully");
01031     
01032     int numPlot_dtX, numPlot_dtY, numPlot_cscX, numPlot_cscY;
01033     double dtSigmaX, dtSigmaY, cscSigmaX, cscSigmaY;
01034     double dtSigmaX_err, dtSigmaY_err, cscSigmaX_err, cscSigmaY_err;
01035     double dtMeanX, dtMeanY, cscMeanX, cscMeanY;
01036     double dtMeanX_err, dtMeanY_err, cscMeanX_err, cscMeanY_err;
01037     MuonTestSummary::ResidualCheck(muType[i], DTXresHistos, numPlot_dtX, dtMeanX, dtMeanX_err, dtSigmaX, dtSigmaX_err);
01038     MuonTestSummary::ResidualCheck(muType[i], DTYresHistos, numPlot_dtY, dtMeanY, dtMeanY_err, dtSigmaY, dtSigmaY_err);
01039     MuonTestSummary::ResidualCheck(muType[i], CSCXresHistos, numPlot_cscX, cscMeanX, cscMeanX_err, cscSigmaX, cscSigmaX_err);
01040     MuonTestSummary::ResidualCheck(muType[i], CSCYresHistos, numPlot_cscY, cscMeanY, cscMeanY_err, cscSigmaY, cscSigmaY_err);
01041 
01042 
01043     LogTrace(metname)<<"DT mean must be between: "<<resSegmTrack_mean_min <<" and "<<resSegmTrack_mean_max<<endl;
01044     LogTrace(metname)<<"DT rms must be between: "<<resSegmTrack_rms_min <<" and "<<resSegmTrack_rms_max<<endl;
01045     LogTrace(metname)<<"DT X residual "<< muType[i]<<" mean: " << dtMeanX<<" +- "<< dtMeanX_err 
01046                      <<", sigma: "<< dtSigmaX <<" +- "<<dtSigmaX_err<< endl;
01047     LogTrace(metname)<<"DT Y residual "<< muType[i]<<" mean: " << dtMeanY<<" +- "<< dtMeanY_err 
01048                      <<", sigma: "<< dtSigmaY <<" +- "<<dtSigmaY_err<< endl;
01049     LogTrace(metname)<<"CSC X residual "<< muType[i]<<" mean: " << cscMeanX<<" +- "<< cscMeanX_err 
01050                      <<", sigma: "<< cscSigmaX <<" +- "<<cscSigmaX_err<< endl;
01051     LogTrace(metname)<<"CSC Y residual "<< muType[i]<<" mean: " << cscMeanY<<" +- "<< cscMeanY_err 
01052                      <<", sigma: "<< cscSigmaY <<" +- "<<cscSigmaY_err<< endl;
01053 
01054 
01055     //require the mean and rms to be within nsig sigma of preferred range;
01056     const int nsig=2;
01057     if(numPlot_dtX > 0 ) {
01058       if( dtMeanX + nsig*dtMeanX_err>resSegmTrack_mean_min && 
01059           dtMeanX - nsig*dtMeanX_err<resSegmTrack_mean_max) 
01060         muonIdSummaryMap->setBinContent(2*i+1,2,1);
01061       else
01062         muonIdSummaryMap->setBinContent(2*i+1,2,0);
01063       
01064       if( dtSigmaX + nsig*dtSigmaX_err>resSegmTrack_rms_min && 
01065           dtSigmaX - nsig*dtSigmaX_err<resSegmTrack_rms_max) 
01066         muonIdSummaryMap->setBinContent(2*i+1,3,1);
01067       else
01068         muonIdSummaryMap->setBinContent(2*i+1,3,0);
01069     }
01070     if(numPlot_dtY > 0 ){
01071       if( dtMeanY + nsig*dtMeanY_err>resSegmTrack_mean_min &&
01072           dtMeanY - nsig*dtMeanY_err<resSegmTrack_mean_max) 
01073         muonIdSummaryMap->setBinContent(2*i+1,4,1);
01074       else
01075         muonIdSummaryMap->setBinContent(2*i+1,4,0);
01076       
01077       if( dtSigmaY + nsig*dtSigmaY_err>resSegmTrack_rms_min && 
01078           dtSigmaY - nsig*dtSigmaX_err<resSegmTrack_rms_max) 
01079         muonIdSummaryMap->setBinContent(2*i+1,5,1);
01080       else
01081         muonIdSummaryMap->setBinContent(2*i+1,5,0);
01082     }
01083 
01084 
01085     if(numPlot_cscX > 0 ) {
01086       if( cscMeanX + nsig*cscMeanX_err>resSegmTrack_mean_min && 
01087           cscMeanX - nsig*cscMeanX_err<resSegmTrack_mean_max) 
01088         muonIdSummaryMap->setBinContent(2*i+2,2,1);
01089       else
01090         muonIdSummaryMap->setBinContent(2*i+2,2,0);
01091       
01092       if( cscSigmaX + nsig*cscSigmaX_err>resSegmTrack_rms_min && 
01093           cscSigmaX - nsig*cscSigmaX_err<resSegmTrack_rms_max) 
01094         muonIdSummaryMap->setBinContent(2*i+2,3,1);
01095       else
01096         muonIdSummaryMap->setBinContent(2*i+2,3,0);
01097     }
01098     if(numPlot_cscY > 0 ){
01099        if( cscMeanY + nsig*cscMeanY_err>resSegmTrack_mean_min &&
01100            cscMeanY - nsig*cscMeanY_err<resSegmTrack_mean_max) 
01101         muonIdSummaryMap->setBinContent(2*i+2,4,1);
01102       else
01103         muonIdSummaryMap->setBinContent(2*i+2,4,0);
01104       
01105      if( cscSigmaY + nsig*cscSigmaY_err>resSegmTrack_rms_min && 
01106          cscSigmaY - nsig*cscSigmaY_err<resSegmTrack_rms_max) 
01107         muonIdSummaryMap->setBinContent(2*i+2,5,1);
01108       else
01109         muonIdSummaryMap->setBinContent(2*i+2,5,0);
01110     }
01111 
01112     //---- end of modification
01113 
01114 
01115   }
01116   
01117 }
01118 
01119 void MuonTestSummary::ResidualCheck(std::string muType, std::vector<std::string> resHistos, int &numPlot, double &Mean, double &Mean_err, double &Sigma, double &Sigma_err){
01120 
01121   numPlot=0;
01122   Mean=0;
01123   Mean_err=0;
01124   Sigma=0;
01125   Sigma_err=0;
01126   for(uint name=0; name<resHistos.size(); name++){   
01127     MonitorElement * resHisto = dbe->get("Muons/MuonIdDQM/" + muType + "/"+resHistos[name]);
01128     
01129     if(resHisto){
01130       TH1F * resHisto_root = resHisto->getTH1F();
01131       if(resHisto_root->GetEntries() < 20) {
01132         LogTrace(metname) << "[MuonTestSummary]: Test of "<< muType<<" for " <<resHistos[name]<< " not performed because # entries < 20 ";
01133         continue;
01134       }
01135 
01136       //we also want to check if the peak is away from zero.
01137       //so, try fitting in 3 sigma around the histogram mean.
01138       //alternatively, could use the maximum bin (less sensitive to 1-sided tails).
01139       //  float mean = resHisto_root->GetMean();
01140       float mean = resHisto_root->GetBinLowEdge(resHisto_root->GetMaximumBin());
01141       TF1 *gfit = new TF1("Gaussian","gaus",mean-3,mean+3);
01142       
01143       
01144       try {
01145         resHisto_root->Fit(gfit, "Q0");
01146       } catch (...) {
01147         edm::LogError (metname)<< "[MuonTestSummary]: Exception when fitting "<<resHistos[name];
01148       }
01149       if(gfit){
01150         double mean = gfit->GetParameter(1); 
01151         double mean_err = gfit->GetParError(1); 
01152         double sigma = gfit->GetParameter(2);
01153         double sigma_err =  gfit->GetParError(2);
01154         LogTrace(metname)<<"meanRes: "<<mean<<" +- "<<mean_err<<" for "<<resHistos[name]<<endl;
01155         LogTrace(metname)<<"sigmaRes: "<<sigma<<" +- "<<sigma_err<<" for "<<resHistos[name]<<endl;
01156         
01157         Mean+=mean;
01158         Mean_err +=mean_err * mean_err;
01159         Sigma+=sigma;
01160         Sigma_err +=sigma_err * sigma_err;
01161         numPlot++;
01162       } //if gfit? why would we not have gfit?
01163       
01164     }//histogram exists...
01165   } // loop over residuals histos
01166 
01167 
01168   if(numPlot==0){ //eg no stats
01169     Mean_err = 1;
01170     Mean=1;
01171     Sigma_err =1;
01172     Sigma = 1; 
01173   }
01174   else{
01175   Mean_err = sqrt(Mean_err);
01176   Mean_err/=numPlot;
01177   Mean/=numPlot;
01178   
01179   Sigma_err = sqrt(Sigma_err);
01180   Sigma_err/=numPlot;
01181   Sigma/=numPlot;
01182   }
01183   return;
01184 
01185 }
01186 
01187 
01188 
01189 
01190 
01191 void MuonTestSummary::doEnergyTests(string histname, string muonType, int binNumber){
01192 
01193   // num matches test
01194   string path = "Muons/MuonEnergyDepositAnalyzer/"+histname+muonType;
01195   MonitorElement * energyHisto = dbe->get(path);
01196   Double_t hPeak=-1, hFWHM=-1;
01197   if(energyHisto){
01198     TH1F * energyHisto_root = energyHisto->getTH1F();
01199     
01200     // Setting fit range and start values
01201     Double_t fitRange[2];
01202     Double_t startValues[4], parlimitslo[4], parlimitshi[4], fitPar[4], fitParErr[4];
01203 
01204     if (energyHisto->getEntries()>20){
01205       if(histname=="ecalS9PointingMuDepositedEnergy_"){
01206         fitRange[0]=0.04;
01207         fitRange[1]=3.0;
01208         
01209         startValues[0]=0.036; startValues[1]=0.193; startValues[2]=110.0; startValues[3]=0.06;
01210         parlimitslo[0]=0.0; parlimitslo[1]=0.; parlimitslo[2]=1.0; parlimitslo[3]=0.;
01211         parlimitshi[0]=0.05; parlimitshi[1]=0.5; parlimitshi[2]=80000.0; parlimitshi[3]=0.1;
01212       
01213         Double_t chisqr;
01214         Int_t    ndf;
01215         TF1 *fit = langaufit(energyHisto_root,fitRange,startValues,parlimitslo,parlimitshi,fitPar,fitParErr,&chisqr,&ndf);
01216         if(fit){
01217           langaupro(fitPar,hPeak,hFWHM);
01218           LogTrace(metname)<<"hPeak from langau fit: "<<hPeak<<" for: "<<histname+muonType<<endl;
01219           LogTrace(metname)<<"hFWHM from langau fit: "<<hFWHM<<" for: "<<histname+muonType<<endl;
01220         }
01221       }
01222 
01223       if(histname=="hadS9PointingMuDepositedEnergy_"){
01224         fitRange[0]=0.0;
01225         fitRange[1]=7.0;
01226 
01227         startValues[0]=2.0; startValues[1]=2.4; startValues[2]=110.0; startValues[3]=4.0;
01228         parlimitslo[0]=0.0; parlimitslo[1]=0.; parlimitslo[2]=1.0; parlimitslo[3]=0.;
01229         parlimitshi[0]=4.0; parlimitshi[1]=4.0; parlimitshi[2]=80000.0; parlimitshi[3]=8.0;
01230         
01231         Double_t chisqr;
01232         Int_t    ndf;
01233         TF1 *fit = langaufit(energyHisto_root,fitRange,startValues,parlimitslo,parlimitshi,fitPar,fitParErr,&chisqr,&ndf);
01234         if(fit){
01235           langaupro(fitPar,hPeak,hFWHM);
01236           LogTrace(metname)<<"hPeak from langau fit: "<<hPeak<<" for: "<<histname+muonType<<endl;
01237           LogTrace(metname)<<"hFWHM from langau fit: "<<hFWHM<<" for: "<<histname+muonType<<endl;
01238         }
01239       }
01240     }
01241     else{
01242       LogTrace(metname) << "[MuonTestSummary]: Test of  Energy for "<< histname+muonType << " not performed because # entries < 20 ";
01243     }
01244   }
01245   
01246   if(histname=="ecalS9PointingMuDepositedEnergy_" && hPeak>expPeakEcalS9_min && hPeak<expPeakEcalS9_max)
01247     energySummaryMap->setBinContent(binNumber,1, 1);
01248   if(histname=="ecalS9PointingMuDepositedEnergy_" && (hPeak!=-1) &&!(hPeak>expPeakEcalS9_min && hPeak<expPeakEcalS9_max))
01249     energySummaryMap->setBinContent(binNumber,1, 0);
01250     
01251   if(histname=="hadS9PointingMuDepositedEnergy_" && hPeak>expPeakHadS9_min && hPeak<expPeakHadS9_max)
01252     energySummaryMap->setBinContent(binNumber,2, 1);
01253   if(histname=="hadS9PointingMuDepositedEnergy_" && (hPeak!=-1) && !(hPeak>expPeakHadS9_min && hPeak<expPeakHadS9_max))
01254     energySummaryMap->setBinContent(binNumber,2, 0);
01255 
01256   //missing test on ho distributions
01257 }
01258 
01259 
01260 void MuonTestSummary::doMultiplicityTests(){
01261 
01262   MonitorElement* multiplicityHisto = dbe->get("Muons/MuonRecoAnalyzer/muReco");
01263   
01264   if(multiplicityHisto){
01265     if(multiplicityHisto->getEntries()>20){
01266       double multiplicity_GLB = double(multiplicityHisto->getBinContent(1)+multiplicityHisto->getBinContent(2))/double(multiplicityHisto->getEntries());
01267       LogTrace(metname)<<"multiplicity_GLB: "<<multiplicity_GLB<< " ExpMultiplicityGlb_min " <<expMultiplicityGlb_min <<" ExpMultiplicityGlb_max " <<expMultiplicityGlb_max<<endl;
01268       double multiplicity_TK = double(multiplicityHisto->getBinContent(3)+multiplicityHisto->getBinContent(4))/double(multiplicityHisto->getEntries());
01269       LogTrace(metname)<<"multiplicity_TK: "<<multiplicity_TK<< " ExpMultiplicityTk_min " <<expMultiplicityTk_min <<" ExpMultiplicityTk_max " <<expMultiplicityTk_max<<endl;
01270       double multiplicity_STA = double(multiplicityHisto->getBinContent(3)+multiplicityHisto->getBinContent(5))/double(multiplicityHisto->getEntries());
01271       LogTrace(metname)<<"multiplicity_STA: "<<multiplicity_STA<< " ExpMultiplicitySta_min " <<expMultiplicitySta_min <<" ExpMultiplicitySta_max " <<expMultiplicitySta_max<<endl;
01272 
01273       if(multiplicity_GLB>expMultiplicityGlb_min && multiplicity_GLB<expMultiplicityGlb_max)
01274         multiplicitySummaryMap->setBinContent(1,1);
01275       else 
01276         multiplicitySummaryMap->setBinContent(1,0);
01277       
01278       if(multiplicity_TK>expMultiplicityTk_min && multiplicity_TK<expMultiplicityTk_max)
01279         multiplicitySummaryMap->setBinContent(2,1);
01280       else 
01281         multiplicitySummaryMap->setBinContent(2,0);
01282       
01283       if(multiplicity_STA>expMultiplicitySta_min && multiplicity_STA<expMultiplicitySta_max)
01284         multiplicitySummaryMap->setBinContent(3,1);
01285       else 
01286         multiplicitySummaryMap->setBinContent(3,0);
01287     }
01288     else{
01289       LogTrace(metname) << "[MuonTestSummary]: Test of  Multiplicity not performed because # entries < 20 ";
01290     }
01291   }
01292 
01293 }