00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <DQMOffline/Muon/src/MuonTestSummary.h>
00012
00013
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
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
00082 dbe->setCurrentFolder("Muons/TestSummary");
00083
00084
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
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
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
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
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
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
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
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
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
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);
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
00298 }
00299
00300 void MuonTestSummary::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00301
00302
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
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
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
00330 doMuonIDTests();
00331
00332
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
00344 doMultiplicityTests();
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
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
00372 double residualsSummary = 0;
00373
00374
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
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;
00404 idtest+=muonIdSummaryMap->getBinContent(i,j);
00405 }
00406
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;
00413 idtest+=muonIdSummaryMap->getBinContent(i,j);
00414 }
00415
00416 idtest/=6.;
00417 summaryReportMap->setBinContent(2,5,idtest);
00418 summaryReportMap->setBinContent(3,5,-1.0/6.0);
00419
00420
00421
00422
00423
00424
00425
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
00467 float muonIDsummary=0;
00468
00469
00470
00471
00472 muonIDsummary += muonIdSummaryMap->getBinContent(1, 2);
00473 muonIDsummary += muonIdSummaryMap->getBinContent(1, 4);
00474 summaryCertificationMap->setBinContent(4, 5, muonIDsummary/2.);
00475
00476
00477 muonIDsummary=0;
00478
00479
00480
00481 muonIDsummary += muonIdSummaryMap->getBinContent(2, 2);
00482 muonIDsummary += muonIdSummaryMap->getBinContent(2, 4);
00483 summaryCertificationMap->setBinContent(7, 5, muonIDsummary/2.);
00484
00485
00486 muonIDsummary=0;
00487
00488
00489
00490 muonIDsummary += muonIdSummaryMap->getBinContent(3, 2);
00491 muonIDsummary += muonIdSummaryMap->getBinContent(3, 4);
00492 summaryCertificationMap->setBinContent(5, 5, muonIDsummary/2.);
00493
00494
00495 muonIDsummary=0;
00496
00497
00498
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
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
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
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");
00549 if(myQReport) {
00550 LogTrace(metname) << "Chi2Report exists!!";
00551 float qtresult = myQReport->getQTresult();
00552 int qtstatus = myQReport->getStatus() ;
00553 std::string qtmessage = myQReport->getMessage() ;
00554 LogTrace(metname) << "qtresult " <<qtresult << " qtstatus "<<qtstatus<<endl;
00555 chi2TestSummaryMap->setBinContent(bin,1,qtresult);
00556 }
00557
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();
00563 int qtstatus = myQReportKolmo->getStatus() ;
00564 std::string qtmessage = myQReportKolmo->getMessage() ;
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
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
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)
00601 kinematicsSummaryMap->setBinContent(bin,2,1);
00602 else
00603 kinematicsSummaryMap->setBinContent(bin,2,0);
00604 }
00605
00606
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");
00609 if(myQReport) {
00610 LogTrace(metname) << "EtaReport exists!!";
00611 float qtresult = myQReport->getQTresult();
00612 int qtstatus = myQReport->getStatus() ;
00613 std::string qtmessage = myQReport->getMessage() ;
00614 LogTrace(metname) << "qtresult " <<qtresult << " qtstatus "<<qtstatus<<endl;
00615 chi2TestSummaryMap->setBinContent(bin,2,qtresult);
00616 }
00617
00618
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();
00624 int qtstatus = myQReportKolmo->getStatus() ;
00625 std::string qtmessage = myQReportKolmo->getMessage() ;
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
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
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)
00662 kinematicsSummaryMap->setBinContent(bin,3,1);
00663 else
00664 kinematicsSummaryMap->setBinContent(bin,3,0);
00665 }
00666
00667
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");
00670 if(myQReport) {
00671 LogTrace(metname) << "PhiReport exists!!";
00672 float qtresult = myQReport->getQTresult();
00673 int qtstatus = myQReport->getStatus() ;
00674 std::string qtmessage = myQReport->getMessage() ;
00675 LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00676 chi2TestSummaryMap->setBinContent(bin,3,qtresult);
00677 }
00678
00679
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();
00685 int qtstatus = myQReportKolmo->getStatus() ;
00686 std::string qtmessage = myQReportKolmo->getMessage() ;
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
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
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");
00708 if(myQReport) {
00709 LogTrace(metname) << "PtReport exists!!";
00710 float qtresult = myQReport->getQTresult();
00711 int qtstatus = myQReport->getStatus() ;
00712 std::string qtmessage = myQReport->getMessage() ;
00713 LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00714 chi2TestSummaryMap->setBinContent(bin,4,qtresult);
00715 }
00716
00717
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();
00723 int qtstatus = myQReportKolmo->getStatus() ;
00724 std::string qtmessage = myQReportKolmo->getMessage() ;
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
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
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");
00745 if(myQReport) {
00746 LogTrace(metname) << "qReport exists!!";
00747 float qtresult = myQReport->getQTresult();
00748 int qtstatus = myQReport->getStatus() ;
00749 std::string qtmessage = myQReport->getMessage() ;
00750 LogTrace(metname) << "qtresult " <<qtresult<< " qtstatus "<<qtstatus<<endl;
00751 chi2TestSummaryMap->setBinContent(bin,5,qtresult);
00752 }
00753
00754
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();
00760 int qtstatus = myQReportKolmo->getStatus() ;
00761 std::string qtmessage = myQReportKolmo->getMessage() ;
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
00780 void MuonTestSummary::GaussFit(string type, string parameter, MonitorElement * Histo, float &mean, float &mean_err, float &sigma, float &sigma_err) {
00781
00782
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 (cms::Exception& iException) {
00791 edm::LogError (metname)<< "[MuonTestSummary]: Exception when fitting Res_"<<type<<"_"<<parameter;
00792 mean=1;
00793 mean_err=1;
00794 sigma=1;
00795 sigma_err=1;
00796 return;
00797 }
00798 if(gfit){
00799 mean = gfit->GetParameter(1);
00800 mean_err = gfit->GetParErrors()[2];
00801 sigma = gfit->GetParameter(2);
00802 sigma_err = gfit->GetParErrors()[2];
00803 LogTrace(metname)<<"Gaussian fit mean: "<<mean<<" +- "<<mean_err<<" for "<<type<<"_"<<parameter<<endl;
00804 LogTrace(metname)<<"Gaussina fit sigma: "<<sigma<<" +- "<<sigma_err<<" for "<<type<<"_"<<parameter<<endl;
00805 }
00806 }
00807 else{
00808 LogTrace(metname) << "[MuonTestSummary]: Test of Res_"<<type<<"_"<<parameter<< " not performed because # entries < 20 ";
00809
00810 mean=1;
00811 mean_err=1;
00812 sigma=1;
00813 sigma_err=1;
00814 }
00815 }
00816
00817
00818
00819
00820
00821
00822 void MuonTestSummary::doResidualsTests(string type, string parameter, int bin){
00823
00824
00825 if(type!="GlbMuon"){
00826 string path = "Muons/MuonRecoAnalyzer/Res_" + type + "_" + parameter;
00827 MonitorElement * residualsHisto = dbe->get(path);
00828
00829 float mean = -1;
00830 float mean_err = -1;
00831 float sigma = -1;
00832 float sigma_err = -1;
00833
00834 if(residualsHisto){
00835
00836 LogTrace(metname) << "[MuonTestSummary]: Starting Gaussian fit for Test of Res_"<<type<<"_"<<parameter<< endl;
00837 GaussFit( type, parameter, residualsHisto, mean, mean_err, sigma, sigma_err);
00838
00839 if(sigma!=-1 && parameter=="eta" && type=="TkGlb"){
00840 if(sigma-sigma_err<resEtaSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 1, 1);
00841 else residualsSummaryMap->setBinContent(bin, 1, 0);
00842 }
00843 if(sigma!=-1 && parameter=="eta" && (type=="GlbSta" || type=="TkSta")) {
00844 if(sigma-sigma_err<resEtaSpread_glbSta) residualsSummaryMap->setBinContent(bin, 1, 1);
00845 else residualsSummaryMap->setBinContent(bin, 1, 0);
00846 }
00847 if(sigma!=-1 && parameter=="phi" && type=="TkGlb"){
00848 if(sigma-sigma_err<resPhiSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 2, 1);
00849 else residualsSummaryMap->setBinContent(bin, 2, 0);
00850 }
00851 if(sigma!=-1 && parameter=="phi" && (type=="GlbSta" || type=="TkSta")){
00852 if(sigma-sigma_err<resPhiSpread_glbSta) residualsSummaryMap->setBinContent(bin, 2, 1);
00853 else residualsSummaryMap->setBinContent(bin, 2, 0);
00854 }
00855 if(sigma!=-1 && parameter=="oneOverp" && type=="TkGlb"){
00856 if(sigma-sigma_err<resOneOvPSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 3, 1);
00857 else residualsSummaryMap->setBinContent(bin, 3, 0);
00858 }
00859 if(sigma!=-1 && parameter=="oneOverp" && (type=="GlbSta" || type=="TkSta")) {
00860 if(sigma-sigma_err<resOneOvPSpread_glbSta) residualsSummaryMap->setBinContent(bin, 3, 1);
00861 else residualsSummaryMap->setBinContent(bin, 3, 0);
00862 }
00863 }
00864
00865
00866
00867
00868 if(type=="TkSta"){
00869
00870 string path = "Muons/MuonRecoAnalyzer/Pull_" + type + "_" + parameter;
00871 MonitorElement * pullHisto = dbe->get(path);
00872
00873 if(pullHisto){
00874
00875 LogTrace(metname) << "[MuonTestSummary]: Starting Gaussian fit for Test of Pull_"<<type<<"_"<<parameter<< endl;
00876 GaussFit( type, parameter, pullHisto, mean, mean_err, sigma, sigma_err);
00877
00878 if(sigma!=-1 && parameter=="eta" ){
00879 if(sigma-sigma_err<pullEtaSpread) residualsSummaryMap->setBinContent(4, 1, 1);
00880 else residualsSummaryMap->setBinContent(4, 1, 0);
00881 }
00882 if(sigma!=-1 && parameter=="phi"){
00883 if(sigma-sigma_err<pullPhiSpread) residualsSummaryMap->setBinContent(4, 2, 1);
00884 else residualsSummaryMap->setBinContent(4, 2, 0);
00885 }
00886 if(sigma!=-1 && parameter=="oneOverp"){
00887 if(sigma-sigma_err<pullOneOvPSpread) residualsSummaryMap->setBinContent(4, 3, 1);
00888 else residualsSummaryMap->setBinContent(4, 3, 0);
00889 }
00890
00891 }
00892 }
00893 }
00894
00895
00896 else{
00897 string path = "Muons/MuonRecoAnalyzer/" + type + "_" + parameter;
00898 MonitorElement * residualsHisto = dbe->get(path);
00899
00900 if(residualsHisto){
00901 LogTrace(metname) << "[MuonTestSummary]: Test of Charge Comparison "<<type<<"_"<<parameter<< endl;
00902 if((residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4))!=0){
00903 LogTrace(metname)<<"Charge comparison TkGlb: "<<residualsHisto->getBinContent(4)/double(residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4))<<endl;
00904 if(residualsHisto->getBinContent(4)/double(residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4)) < resChargeLimit_tkGlb)
00905 residualsSummaryMap->setBinContent(1, 4, 1);
00906 else
00907 residualsSummaryMap->setBinContent(1, 4, 0);
00908 }
00909 if((residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2))!=0){
00910 LogTrace(metname)<<"charge comparison GlbSta: "<<residualsHisto->getBinContent(2)/double(residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2))<<endl;
00911 if(residualsHisto->getBinContent(2)/double(residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2)) < resChargeLimit_glbSta)
00912 residualsSummaryMap->setBinContent(2, 4, 1);
00913 else
00914 residualsSummaryMap->setBinContent(2, 4, 0);
00915 }
00916 if(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6)!=0){
00917 LogTrace(metname)<<"charge comparison TkSta: "<<residualsHisto->getBinContent(6)/double(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6))<<endl;
00918 if(residualsHisto->getBinContent(6)/double(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6)) < resChargeLimit_tkSta)
00919 residualsSummaryMap->setBinContent(3, 4, 1);
00920 else
00921 residualsSummaryMap->setBinContent(3, 4, 0);
00922 }
00923 }
00924 }
00925
00926 }
00927
00928 void MuonTestSummary::doMuonIDTests(){
00929
00930 vector<string> muType;
00931 muType.push_back("GlobalMuons");
00932 muType.push_back("TrackerMuons");
00933
00934 for(int i=0; i<=1; i++){
00935
00936
00937 string path = "Muons/MuonIdDQM/" + muType[i] + "/hNumMatches";
00938 MonitorElement * matchesHisto = dbe->get(path);
00939
00940 if(matchesHisto){
00941 TH1F * matchesHisto_root = matchesHisto->getTH1F();
00942 if(matchesHisto_root->GetMaximumBin() >= numMatchedExpected_min && matchesHisto_root->GetMaximumBin() <= numMatchedExpected_max)
00943 muonIdSummaryMap->setBinContent(i+1,1,1);
00944 else
00945 muonIdSummaryMap->setBinContent(i+1,1,0);
00946 }
00947
00948
00949
00950 double numOneSegm_dt = 0;
00951 int numHistos_dt=0;
00952 int numHistos_csc=0;
00953 MonitorElement * DT1Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT1NumSegments");
00954 if(DT1Histo)
00955 {numHistos_dt++;
00956 if(DT1Histo->getEntries()!=0) numOneSegm_dt+=double(DT1Histo->getBinContent(2))/double(DT1Histo->getEntries());}
00957 MonitorElement * DT2Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT2NumSegments");
00958 if(DT2Histo)
00959 {numHistos_dt++;
00960 if(DT2Histo->getEntries()!=0) numOneSegm_dt+=double(DT2Histo->getBinContent(2))/double(DT2Histo->getEntries());}
00961 MonitorElement * DT3Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT3NumSegments");
00962 if(DT3Histo)
00963 {numHistos_dt++;
00964 if(DT3Histo->getEntries()!=0) numOneSegm_dt+=double(DT3Histo->getBinContent(2))/double(DT3Histo->getEntries());}
00965 MonitorElement * DT4Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hDT4NumSegments");
00966 if(DT4Histo)
00967 {numHistos_dt++;
00968 if(DT4Histo->getEntries()!=0) numOneSegm_dt+=double(DT4Histo->getBinContent(2))/double(DT4Histo->getEntries());}
00969 double fraction_dt=0;
00970 if(numOneSegm_dt!=0){
00971 fraction_dt = numOneSegm_dt/double(numHistos_dt);
00972 LogTrace(metname)<<"fraction_dt: "<<fraction_dt<<" for "<<muType[i]<<endl;
00973 }
00974
00975 double numOneSegm_csc = 0;
00976 MonitorElement * CSC1Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC1NumSegments");
00977 if(CSC1Histo)
00978 {numHistos_csc++;
00979 if(CSC1Histo->getEntries()!=0) numOneSegm_csc+=double(CSC1Histo->getBinContent(2))/double(CSC1Histo->getEntries());}
00980 MonitorElement * CSC2Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC2NumSegments");
00981 if(CSC2Histo)
00982 {numHistos_csc++;
00983 if(CSC2Histo->getEntries()!=0) numOneSegm_csc+=double(CSC2Histo->getBinContent(2))/double(CSC2Histo->getEntries());}
00984 MonitorElement * CSC3Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC3NumSegments");
00985 if(CSC3Histo)
00986 {numHistos_csc++;
00987 if(CSC3Histo->getEntries()!=0) numOneSegm_csc+=double(CSC3Histo->getBinContent(2))/double(CSC3Histo->getEntries());}
00988 MonitorElement * CSC4Histo = dbe->get("Muons/MuonIdDQM/" + muType[i] + "/hCSC4NumSegments");
00989 if(CSC4Histo)
00990 {numHistos_csc++;
00991 if(CSC4Histo->getEntries()!=0) numOneSegm_csc+=double(CSC4Histo->getBinContent(2))/double(CSC4Histo->getEntries());}
00992 double fraction_csc=0;
00993 if(numOneSegm_csc!=0){
00994 fraction_csc = numOneSegm_csc/double(numHistos_csc);
00995 LogTrace(metname)<<"fraction_csc: "<<fraction_csc<<" for "<<muType[i]<<endl;
00996 }
00997
00998
00999
01000
01001
01002 if(fraction_dt>matchesFractionDt_min && fraction_dt<matchesFractionDt_max)
01003 muonIdSummaryMap->setBinContent(2*i+1,1,1);
01004 else
01005 muonIdSummaryMap->setBinContent(2*i+1,1,0);
01006
01007 if(fraction_csc>matchesFractionCsc_min && fraction_csc<matchesFractionCsc_max)
01008 muonIdSummaryMap->setBinContent(2*i+2,1,1);
01009 else
01010 muonIdSummaryMap->setBinContent(2*i+2,1,0);
01011
01012
01013
01014
01015
01016
01017 vector<string> DTXresHistos, DTYresHistos, CSCXresHistos, CSCYresHistos;
01018 DTXresHistos.push_back("hDT1Pullx");
01019 DTXresHistos.push_back("hDT2Pullx");
01020 DTXresHistos.push_back("hDT3Pullx");
01021 DTXresHistos.push_back("hDT4Pullx");
01022
01023 DTYresHistos.push_back("hDT1Pully");
01024 DTYresHistos.push_back("hDT2Pully");
01025 DTYresHistos.push_back("hDT3Pully");
01026
01027 CSCXresHistos.push_back("hCSC1Pullx");
01028 CSCXresHistos.push_back("hCSC2Pullx");
01029 CSCXresHistos.push_back("hCSC3Pullx");
01030 CSCXresHistos.push_back("hCSC4Pullx");
01031
01032 CSCYresHistos.push_back("hCSC1Pully");
01033 CSCYresHistos.push_back("hCSC2Pully");
01034 CSCYresHistos.push_back("hCSC3Pully");
01035 CSCYresHistos.push_back("hCSC4Pully");
01036
01037 int numPlot_dtX, numPlot_dtY, numPlot_cscX, numPlot_cscY;
01038 double dtSigmaX, dtSigmaY, cscSigmaX, cscSigmaY;
01039 double dtSigmaX_err, dtSigmaY_err, cscSigmaX_err, cscSigmaY_err;
01040 double dtMeanX, dtMeanY, cscMeanX, cscMeanY;
01041 double dtMeanX_err, dtMeanY_err, cscMeanX_err, cscMeanY_err;
01042 MuonTestSummary::ResidualCheck(muType[i], DTXresHistos, numPlot_dtX, dtMeanX, dtMeanX_err, dtSigmaX, dtSigmaX_err);
01043 MuonTestSummary::ResidualCheck(muType[i], DTYresHistos, numPlot_dtY, dtMeanY, dtMeanY_err, dtSigmaY, dtSigmaY_err);
01044 MuonTestSummary::ResidualCheck(muType[i], CSCXresHistos, numPlot_cscX, cscMeanX, cscMeanX_err, cscSigmaX, cscSigmaX_err);
01045 MuonTestSummary::ResidualCheck(muType[i], CSCYresHistos, numPlot_cscY, cscMeanY, cscMeanY_err, cscSigmaY, cscSigmaY_err);
01046
01047
01048 LogTrace(metname)<<"DT mean must be between: "<<resSegmTrack_mean_min <<" and "<<resSegmTrack_mean_max<<endl;
01049 LogTrace(metname)<<"DT rms must be between: "<<resSegmTrack_rms_min <<" and "<<resSegmTrack_rms_max<<endl;
01050 LogTrace(metname)<<"DT X residual "<< muType[i]<<" mean: " << dtMeanX<<" +- "<< dtMeanX_err
01051 <<", sigma: "<< dtSigmaX <<" +- "<<dtSigmaX_err<< endl;
01052 LogTrace(metname)<<"DT Y residual "<< muType[i]<<" mean: " << dtMeanY<<" +- "<< dtMeanY_err
01053 <<", sigma: "<< dtSigmaY <<" +- "<<dtSigmaY_err<< endl;
01054 LogTrace(metname)<<"CSC X residual "<< muType[i]<<" mean: " << cscMeanX<<" +- "<< cscMeanX_err
01055 <<", sigma: "<< cscSigmaX <<" +- "<<cscSigmaX_err<< endl;
01056 LogTrace(metname)<<"CSC Y residual "<< muType[i]<<" mean: " << cscMeanY<<" +- "<< cscMeanY_err
01057 <<", sigma: "<< cscSigmaY <<" +- "<<cscSigmaY_err<< endl;
01058
01059
01060
01061 const int nsig=2;
01062 if(numPlot_dtX > 0 ) {
01063 if( dtMeanX + nsig*dtMeanX_err>resSegmTrack_mean_min &&
01064 dtMeanX - nsig*dtMeanX_err<resSegmTrack_mean_max)
01065 muonIdSummaryMap->setBinContent(2*i+1,2,1);
01066 else
01067 muonIdSummaryMap->setBinContent(2*i+1,2,0);
01068
01069 if( dtSigmaX + nsig*dtSigmaX_err>resSegmTrack_rms_min &&
01070 dtSigmaX - nsig*dtSigmaX_err<resSegmTrack_rms_max)
01071 muonIdSummaryMap->setBinContent(2*i+1,3,1);
01072 else
01073 muonIdSummaryMap->setBinContent(2*i+1,3,0);
01074 }
01075 if(numPlot_dtY > 0 ){
01076 if( dtMeanY + nsig*dtMeanY_err>resSegmTrack_mean_min &&
01077 dtMeanY - nsig*dtMeanY_err<resSegmTrack_mean_max)
01078 muonIdSummaryMap->setBinContent(2*i+1,4,1);
01079 else
01080 muonIdSummaryMap->setBinContent(2*i+1,4,0);
01081
01082 if( dtSigmaY + nsig*dtSigmaY_err>resSegmTrack_rms_min &&
01083 dtSigmaY - nsig*dtSigmaX_err<resSegmTrack_rms_max)
01084 muonIdSummaryMap->setBinContent(2*i+1,5,1);
01085 else
01086 muonIdSummaryMap->setBinContent(2*i+1,5,0);
01087 }
01088
01089
01090 if(numPlot_cscX > 0 ) {
01091 if( cscMeanX + nsig*cscMeanX_err>resSegmTrack_mean_min &&
01092 cscMeanX - nsig*cscMeanX_err<resSegmTrack_mean_max)
01093 muonIdSummaryMap->setBinContent(2*i+2,2,1);
01094 else
01095 muonIdSummaryMap->setBinContent(2*i+2,2,0);
01096
01097 if( cscSigmaX + nsig*cscSigmaX_err>resSegmTrack_rms_min &&
01098 cscSigmaX - nsig*cscSigmaX_err<resSegmTrack_rms_max)
01099 muonIdSummaryMap->setBinContent(2*i+2,3,1);
01100 else
01101 muonIdSummaryMap->setBinContent(2*i+2,3,0);
01102 }
01103 if(numPlot_cscY > 0 ){
01104 if( cscMeanY + nsig*cscMeanY_err>resSegmTrack_mean_min &&
01105 cscMeanY - nsig*cscMeanY_err<resSegmTrack_mean_max)
01106 muonIdSummaryMap->setBinContent(2*i+2,4,1);
01107 else
01108 muonIdSummaryMap->setBinContent(2*i+2,4,0);
01109
01110 if( cscSigmaY + nsig*cscSigmaY_err>resSegmTrack_rms_min &&
01111 cscSigmaY - nsig*cscSigmaY_err<resSegmTrack_rms_max)
01112 muonIdSummaryMap->setBinContent(2*i+2,5,1);
01113 else
01114 muonIdSummaryMap->setBinContent(2*i+2,5,0);
01115 }
01116
01117
01118
01119
01120 }
01121
01122 }
01123
01124 void MuonTestSummary::ResidualCheck(std::string muType, const std::vector<std::string>& resHistos, int &numPlot, double &Mean, double &Mean_err, double &Sigma, double &Sigma_err){
01125
01126 numPlot=0;
01127 Mean=0;
01128 Mean_err=0;
01129 Sigma=0;
01130 Sigma_err=0;
01131 for(uint name=0; name<resHistos.size(); name++){
01132 MonitorElement * resHisto = dbe->get("Muons/MuonIdDQM/" + muType + "/"+resHistos[name]);
01133
01134 if(resHisto){
01135 TH1F * resHisto_root = resHisto->getTH1F();
01136 if(resHisto_root->GetEntries() < 20) {
01137 LogTrace(metname) << "[MuonTestSummary]: Test of "<< muType<<" for " <<resHistos[name]<< " not performed because # entries < 20 ";
01138 continue;
01139 }
01140
01141
01142
01143
01144
01145 float mean = resHisto_root->GetBinLowEdge(resHisto_root->GetMaximumBin());
01146 TF1 *gfit = new TF1("Gaussian","gaus",mean-3,mean+3);
01147
01148
01149 try {
01150 resHisto_root->Fit(gfit, "Q0");
01151 } catch (cms::Exception& iException) {
01152 edm::LogError (metname)<< "[MuonTestSummary]: Exception when fitting "<<resHistos[name];
01153 continue;
01154 }
01155 if(gfit){
01156 double mean = gfit->GetParameter(1);
01157 double mean_err = gfit->GetParError(1);
01158 double sigma = gfit->GetParameter(2);
01159 double sigma_err = gfit->GetParError(2);
01160 LogTrace(metname)<<"meanRes: "<<mean<<" +- "<<mean_err<<" for "<<resHistos[name]<<endl;
01161 LogTrace(metname)<<"sigmaRes: "<<sigma<<" +- "<<sigma_err<<" for "<<resHistos[name]<<endl;
01162
01163 Mean+=mean;
01164 Mean_err +=mean_err * mean_err;
01165 Sigma+=sigma;
01166 Sigma_err +=sigma_err * sigma_err;
01167 numPlot++;
01168 }
01169
01170 }
01171 }
01172
01173
01174 if(numPlot==0){
01175 Mean_err = 1;
01176 Mean=1;
01177 Sigma_err =1;
01178 Sigma = 1;
01179 }
01180 else{
01181 Mean_err = sqrt(Mean_err);
01182 Mean_err/=numPlot;
01183 Mean/=numPlot;
01184
01185 Sigma_err = sqrt(Sigma_err);
01186 Sigma_err/=numPlot;
01187 Sigma/=numPlot;
01188 }
01189 return;
01190
01191 }
01192
01193
01194
01195
01196
01197 void MuonTestSummary::doEnergyTests(string histname, string muonType, int binNumber){
01198
01199
01200 string path = "Muons/MuonEnergyDepositAnalyzer/"+histname+muonType;
01201 MonitorElement * energyHisto = dbe->get(path);
01202 Double_t hPeak=-1, hFWHM=-1;
01203 if(energyHisto){
01204 TH1F * energyHisto_root = energyHisto->getTH1F();
01205
01206
01207 Double_t fitRange[2];
01208 Double_t startValues[4], parlimitslo[4], parlimitshi[4], fitPar[4], fitParErr[4];
01209
01210 if (energyHisto->getEntries()>20){
01211 if(histname=="ecalS9PointingMuDepositedEnergy_"){
01212 fitRange[0]=0.04;
01213 fitRange[1]=3.0;
01214
01215 startValues[0]=0.036; startValues[1]=0.193; startValues[2]=110.0; startValues[3]=0.06;
01216 parlimitslo[0]=0.0; parlimitslo[1]=0.; parlimitslo[2]=1.0; parlimitslo[3]=0.;
01217 parlimitshi[0]=0.05; parlimitshi[1]=0.5; parlimitshi[2]=80000.0; parlimitshi[3]=0.1;
01218
01219 Double_t chisqr;
01220 Int_t ndf;
01221 TF1 *fit = langaufit(energyHisto_root,fitRange,startValues,parlimitslo,parlimitshi,fitPar,fitParErr,&chisqr,&ndf);
01222 if(fit){
01223 langaupro(fitPar,hPeak,hFWHM);
01224 LogTrace(metname)<<"hPeak from langau fit: "<<hPeak<<" for: "<<histname+muonType<<endl;
01225 LogTrace(metname)<<"hFWHM from langau fit: "<<hFWHM<<" for: "<<histname+muonType<<endl;
01226 }
01227 }
01228
01229 if(histname=="hadS9PointingMuDepositedEnergy_"){
01230 fitRange[0]=0.0;
01231 fitRange[1]=7.0;
01232
01233 startValues[0]=2.0; startValues[1]=2.4; startValues[2]=110.0; startValues[3]=4.0;
01234 parlimitslo[0]=0.0; parlimitslo[1]=0.; parlimitslo[2]=1.0; parlimitslo[3]=0.;
01235 parlimitshi[0]=4.0; parlimitshi[1]=4.0; parlimitshi[2]=80000.0; parlimitshi[3]=8.0;
01236
01237 Double_t chisqr;
01238 Int_t ndf;
01239 TF1 *fit = langaufit(energyHisto_root,fitRange,startValues,parlimitslo,parlimitshi,fitPar,fitParErr,&chisqr,&ndf);
01240 if(fit){
01241 langaupro(fitPar,hPeak,hFWHM);
01242 LogTrace(metname)<<"hPeak from langau fit: "<<hPeak<<" for: "<<histname+muonType<<endl;
01243 LogTrace(metname)<<"hFWHM from langau fit: "<<hFWHM<<" for: "<<histname+muonType<<endl;
01244 }
01245 }
01246 }
01247 else{
01248 LogTrace(metname) << "[MuonTestSummary]: Test of Energy for "<< histname+muonType << " not performed because # entries < 20 ";
01249 }
01250 }
01251
01252 if(histname=="ecalS9PointingMuDepositedEnergy_" && hPeak>expPeakEcalS9_min && hPeak<expPeakEcalS9_max)
01253 energySummaryMap->setBinContent(binNumber,1, 1);
01254 if(histname=="ecalS9PointingMuDepositedEnergy_" && (hPeak!=-1) &&!(hPeak>expPeakEcalS9_min && hPeak<expPeakEcalS9_max))
01255 energySummaryMap->setBinContent(binNumber,1, 0);
01256
01257 if(histname=="hadS9PointingMuDepositedEnergy_" && hPeak>expPeakHadS9_min && hPeak<expPeakHadS9_max)
01258 energySummaryMap->setBinContent(binNumber,2, 1);
01259 if(histname=="hadS9PointingMuDepositedEnergy_" && (hPeak!=-1) && !(hPeak>expPeakHadS9_min && hPeak<expPeakHadS9_max))
01260 energySummaryMap->setBinContent(binNumber,2, 0);
01261
01262
01263 }
01264
01265
01266 void MuonTestSummary::doMultiplicityTests(){
01267
01268 MonitorElement* multiplicityHisto = dbe->get("Muons/MuonRecoAnalyzer/muReco");
01269
01270 if(multiplicityHisto){
01271 if(multiplicityHisto->getEntries()>20){
01272 double multiplicity_GLB = double(multiplicityHisto->getBinContent(1)+multiplicityHisto->getBinContent(2))/double(multiplicityHisto->getEntries());
01273 LogTrace(metname)<<"multiplicity_GLB: "<<multiplicity_GLB<< " ExpMultiplicityGlb_min " <<expMultiplicityGlb_min <<" ExpMultiplicityGlb_max " <<expMultiplicityGlb_max<<endl;
01274 double multiplicity_TK = double(multiplicityHisto->getBinContent(3)+multiplicityHisto->getBinContent(4))/double(multiplicityHisto->getEntries());
01275 LogTrace(metname)<<"multiplicity_TK: "<<multiplicity_TK<< " ExpMultiplicityTk_min " <<expMultiplicityTk_min <<" ExpMultiplicityTk_max " <<expMultiplicityTk_max<<endl;
01276 double multiplicity_STA = double(multiplicityHisto->getBinContent(3)+multiplicityHisto->getBinContent(5))/double(multiplicityHisto->getEntries());
01277 LogTrace(metname)<<"multiplicity_STA: "<<multiplicity_STA<< " ExpMultiplicitySta_min " <<expMultiplicitySta_min <<" ExpMultiplicitySta_max " <<expMultiplicitySta_max<<endl;
01278
01279 if(multiplicity_GLB>expMultiplicityGlb_min && multiplicity_GLB<expMultiplicityGlb_max)
01280 multiplicitySummaryMap->setBinContent(1,1);
01281 else
01282 multiplicitySummaryMap->setBinContent(1,0);
01283
01284 if(multiplicity_TK>expMultiplicityTk_min && multiplicity_TK<expMultiplicityTk_max)
01285 multiplicitySummaryMap->setBinContent(2,1);
01286 else
01287 multiplicitySummaryMap->setBinContent(2,0);
01288
01289 if(multiplicity_STA>expMultiplicitySta_min && multiplicity_STA<expMultiplicitySta_max)
01290 multiplicitySummaryMap->setBinContent(3,1);
01291 else
01292 multiplicitySummaryMap->setBinContent(3,0);
01293 }
01294 else{
01295 LogTrace(metname) << "[MuonTestSummary]: Test of Multiplicity not performed because # entries < 20 ";
01296 }
01297 }
01298
01299 }