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
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 resChargeLimit_tkGlb = ps.getParameter<double>("resChargeLimit_tkGlb");
00046 resChargeLimit_glbSta = ps.getParameter<double>("resChargeLimit_glbSta");
00047 resChargeLimit_tkSta = ps.getParameter<double>("resChargeLimit_tkSta");
00048 numMatchedExpected = ps.getParameter<double>("numMatchedExpected");
00049 expMolteplicityGlb = ps.getParameter<double>("expMolteplicityGlb");
00050 expMolteplicityTk = ps.getParameter<double>("expMolteplicityTk");
00051 expMolteplicitySta = ps.getParameter<double>("expMolteplicitySta");
00052 }
00053
00054 MuonTestSummary::~MuonTestSummary(){}
00055
00056 void MuonTestSummary::beginJob(const edm::EventSetup& context){
00057
00058 metname = "muonTestSummary";
00059 LogTrace(metname)<<"[MuonTestSummary] Histo booking";
00060
00061
00062 dbe->setCurrentFolder("Muons/TestSummary");
00063
00064
00065 kinematicsSummaryMap = dbe->book2D("kinematicsSummaryMap","Kinematics test summary",5,1,6,3,1,4);
00066 kinematicsSummaryMap->setAxisTitle("track monitored",1);
00067 kinematicsSummaryMap->setBinLabel(1,"GLB",1);
00068 kinematicsSummaryMap->setBinLabel(2,"TKfromGLB",1);
00069 kinematicsSummaryMap->setBinLabel(3,"STAfromGLB",1);
00070 kinematicsSummaryMap->setBinLabel(4,"TK",1);
00071 kinematicsSummaryMap->setBinLabel(5,"STA",1);
00072 kinematicsSummaryMap->setAxisTitle("parameter tested",2);
00073 kinematicsSummaryMap->setBinLabel(1,"#chi^{2}",2);
00074 kinematicsSummaryMap->setBinLabel(2,"#eta",2);
00075 kinematicsSummaryMap->setBinLabel(3,"#phi",2);
00076
00077
00078 residualsSummaryMap = dbe->book2D("residualsSummaryMap","Residuals test summary",3,1,4,4,1,5);
00079 residualsSummaryMap->setAxisTitle("residuals",1);
00080 residualsSummaryMap->setBinLabel(1,"TK-GLB",1);
00081 residualsSummaryMap->setBinLabel(2,"GLB-STA",1);
00082 residualsSummaryMap->setBinLabel(3,"TK-STA",1);
00083 residualsSummaryMap->setAxisTitle("parameter tested",2);
00084 residualsSummaryMap->setBinLabel(1,"#eta",2);
00085 residualsSummaryMap->setBinLabel(2,"#phi",2);
00086 residualsSummaryMap->setBinLabel(3,"1/p",2);
00087 residualsSummaryMap->setBinLabel(4,"q",2);
00088
00089
00090 muonIdSummaryMap = dbe->book1D("muonIdSummaryMap","muonId test summary",3,1,4);
00091 muonIdSummaryMap->setAxisTitle("test");
00092 muonIdSummaryMap->setBinLabel(1,"#matchCh");
00093 muonIdSummaryMap->setBinLabel(2,"#assSegm");
00094 muonIdSummaryMap->setBinLabel(3,"resTrackSegm");
00095
00096
00097 energySummaryMap = dbe->book2D("energySummaryMap","Energy deposits test summary",3,1,4,3,1,4);
00098 energySummaryMap->setAxisTitle("muons",1);
00099 energySummaryMap->setBinLabel(1,"GLB",1);
00100 energySummaryMap->setBinLabel(2,"TK",1);
00101 energySummaryMap->setBinLabel(3,"STA",1);
00102 energySummaryMap->setAxisTitle("calorimeter tested",2);
00103 energySummaryMap->setBinLabel(1,"ECAL",2);
00104 energySummaryMap->setBinLabel(2,"HAD",2);
00105 energySummaryMap->setBinLabel(3,"H0",2);
00106
00107
00108 molteplicitySummaryMap = dbe->book1D("molteplicitySummaryMap","muon molteplicity test summary",3,1,4);
00109 molteplicitySummaryMap->setAxisTitle("muon");
00110 molteplicitySummaryMap->setBinLabel(1,"GLB");
00111 molteplicitySummaryMap->setBinLabel(2,"TK");
00112 molteplicitySummaryMap->setBinLabel(3,"STA");
00113
00114
00115
00116 dbe->setCurrentFolder("Muons/EventInfo");
00117 summaryReport = dbe->bookFloat("reportSummary");
00118
00119 summaryReportMap = dbe->book2D("reportSummaryMap","Muon Report Summary Map",3,1,4,7,1,8);
00120 summaryReportMap->setAxisTitle("muons",1);
00121 summaryReportMap->setBinLabel(1,"GLB",1);
00122 summaryReportMap->setBinLabel(2,"TK",1);
00123 summaryReportMap->setBinLabel(3,"STA",1);
00124 summaryReportMap->setAxisTitle("test",2);
00125 summaryReportMap->setBinLabel(1,"#chi^{2}/Df",2);
00126 summaryReportMap->setBinLabel(2,"#eta",2);
00127 summaryReportMap->setBinLabel(3,"#phi",2);
00128 summaryReportMap->setBinLabel(4,"residuals",2);
00129 summaryReportMap->setBinLabel(5,"muonId",2);
00130 summaryReportMap->setBinLabel(6,"energyDeposits",2);
00131 summaryReportMap->setBinLabel(7,"molteplicity",2);
00132
00133 dbe->setCurrentFolder("Muons/EventInfo/reportSummaryContents");
00134 theSummaryContents.push_back(dbe->bookFloat("kinematics_GLB"));
00135 theSummaryContents.push_back(dbe->bookFloat("residuals_GLB"));
00136 theSummaryContents.push_back(dbe->bookFloat("kinematics_TK"));
00137 theSummaryContents.push_back(dbe->bookFloat("muonId_TK"));
00138 theSummaryContents.push_back(dbe->bookFloat("GLB"));
00139 theSummaryContents.push_back(dbe->bookFloat("TK"));
00140 theSummaryContents.push_back(dbe->bookFloat("STA"));
00141 theSummaryContents.push_back(dbe->bookFloat("energyDeposits"));
00142 theSummaryContents.push_back(dbe->bookFloat("molteciplicity"));
00143
00144 }
00145
00146
00147 void MuonTestSummary::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00148
00149
00150 for(int xBin=1; xBin<=5; xBin++){
00151 for(int yBin=1; yBin<=3; yBin++){
00152 kinematicsSummaryMap->Fill(xBin,yBin,0);
00153 }
00154 }
00155 for(int xBin=1; xBin<=3; xBin++){
00156 for(int yBin=1; yBin<=2; yBin++){
00157 residualsSummaryMap->Fill(xBin,yBin,0);
00158 }
00159 }
00160 for(int xBin=1; xBin<=3; xBin++){
00161 muonIdSummaryMap->Fill(xBin,0);
00162 }
00163 for(int xBin=1; xBin<=3; xBin++){
00164 for(int yBin=1; yBin<=3; yBin++){
00165 energySummaryMap->Fill(xBin,yBin,0);
00166 }
00167 }
00168 for(int xBin=1; xBin<=3; xBin++){
00169 molteplicitySummaryMap->Fill(xBin,0);
00170 }
00171 for(int xBin=1; xBin<=3; xBin++){
00172 for(int yBin=1; yBin<=7; yBin++){
00173 summaryReportMap->Fill(xBin,yBin,0);
00174 }
00175 }
00176 }
00177
00178
00179
00180 void MuonTestSummary::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00181
00182
00183 doKinematicsTests("GlbMuon_Glb_", 1);
00184 doKinematicsTests("GlbMuon_Tk_", 2);
00185 doKinematicsTests("GlbMuon_Sta_",3);
00186 doKinematicsTests("TkMuon_", 4);
00187 doKinematicsTests("StaMuon_", 5);
00188
00189
00190 doResidualsTests("TkGlb", "eta", 1);
00191 doResidualsTests("GlbSta", "eta", 2);
00192 doResidualsTests("TkSta", "eta", 3);
00193 doResidualsTests("TkGlb", "phi", 1);
00194 doResidualsTests("GlbSta", "phi", 2);
00195 doResidualsTests("TkSta", "phi", 3);
00196 doResidualsTests("TkGlb", "oneOverp", 1);
00197 doResidualsTests("GlbSta", "oneOverp", 2);
00198 doResidualsTests("TkSta", "oneOverp", 3);
00199 doResidualsTests("GlbMuon", "qComparison", -1);
00200
00201
00202 doMuonIDTests();
00203
00204
00205 doEnergyTests("ecalS9PointingMuDepositedEnergy_","Glb_muons", 1);
00206 doEnergyTests("hadS9PointingMuDepositedEnergy_", "Glb_muons", 1);
00207 doEnergyTests("hoS9PointingMuDepositedEnergy_", "Glb_muons", 1);
00208 doEnergyTests("ecalS9PointingMuDepositedEnergy_", "Tk_muons", 2);
00209 doEnergyTests("hadS9PointingMuDepositedEnergy_", "Tk_muons", 2);
00210 doEnergyTests("hoS9PointingMuDepositedEnergy_", "Tk_muons", 2);
00211 doEnergyTests("ecalS9PointingMuDepositedEnergy_", "Sta_muons", 3);
00212 doEnergyTests("hadS9PointingMuDepositedEnergy_", "Sta_muons", 3);
00213 doEnergyTests("hoS9PointingMuDepositedEnergy_", "Sta_muons", 3);
00214
00215
00216 doMolteplicityTests();
00217
00218
00219 summaryReportMap->setBinContent(1,1,double(kinematicsSummaryMap->getBinContent(1,1)+kinematicsSummaryMap->getBinContent(2,1)+kinematicsSummaryMap->getBinContent(3,1))/3.0);
00220 summaryReportMap->setBinContent(2,1,kinematicsSummaryMap->getBinContent(4,1));
00221 summaryReportMap->setBinContent(3,1,kinematicsSummaryMap->getBinContent(5,1));
00222 summaryReportMap->setBinContent(1,2,double(kinematicsSummaryMap->getBinContent(1,2)+kinematicsSummaryMap->getBinContent(2,2)+kinematicsSummaryMap->getBinContent(3,2))/3.0);
00223 summaryReportMap->setBinContent(2,2,kinematicsSummaryMap->getBinContent(4,2));
00224 summaryReportMap->setBinContent(3,2,kinematicsSummaryMap->getBinContent(5,2));
00225 summaryReportMap->setBinContent(1,3,double(kinematicsSummaryMap->getBinContent(1,3)+kinematicsSummaryMap->getBinContent(2,3)+kinematicsSummaryMap->getBinContent(3,3))/3.0);
00226 summaryReportMap->setBinContent(2,3,kinematicsSummaryMap->getBinContent(4,3));
00227 summaryReportMap->setBinContent(3,3,kinematicsSummaryMap->getBinContent(5,3));
00228 summaryReportMap->setBinContent(1,4,double(residualsSummaryMap->getBinContent(1,1)+residualsSummaryMap->getBinContent(1,2)+residualsSummaryMap->getBinContent(1,3)+residualsSummaryMap->getBinContent(1,4)+residualsSummaryMap->getBinContent(2,1)+residualsSummaryMap->getBinContent(2,2)+residualsSummaryMap->getBinContent(2,3)+residualsSummaryMap->getBinContent(2,4)+residualsSummaryMap->getBinContent(3,1)+residualsSummaryMap->getBinContent(3,2)+residualsSummaryMap->getBinContent(3,3)+residualsSummaryMap->getBinContent(3,4))/12);
00229 summaryReportMap->setBinContent(2,4,-1.0/6.0);
00230 summaryReportMap->setBinContent(3,4,-1.0/6.0);
00231 summaryReportMap->setBinContent(1,5,-1.0/6.0);
00232 summaryReportMap->setBinContent(2,5,double(muonIdSummaryMap->getBinContent(1)+muonIdSummaryMap->getBinContent(2)+muonIdSummaryMap->getBinContent(3))/3.0);
00233 summaryReportMap->setBinContent(3,5,-1.0/6.0);
00234 summaryReportMap->setBinContent(1,6,double(energySummaryMap->getBinContent(1,1)+energySummaryMap->getBinContent(1,2)+energySummaryMap->getBinContent(1,3))/3.0);
00235 summaryReportMap->setBinContent(2,6,double(energySummaryMap->getBinContent(2,1)+energySummaryMap->getBinContent(2,2)+energySummaryMap->getBinContent(2,3))/3.0);
00236 summaryReportMap->setBinContent(3,6,double(energySummaryMap->getBinContent(3,1)+energySummaryMap->getBinContent(3,2)+energySummaryMap->getBinContent(3,3))/3.0);
00237 summaryReportMap->setBinContent(1,7,molteplicitySummaryMap->getBinContent(1));
00238 summaryReportMap->setBinContent(2,7,molteplicitySummaryMap->getBinContent(2));
00239 summaryReportMap->setBinContent(3,7,molteplicitySummaryMap->getBinContent(3));
00240
00241 double kinematics_GLB = double(summaryReportMap->getBinContent(1,1)+summaryReportMap->getBinContent(1,2)+summaryReportMap->getBinContent(1,3))/3.0;
00242 theSummaryContents[0]->Fill(kinematics_GLB);
00243 double residuals_GLB = summaryReportMap->getBinContent(1,4);
00244 theSummaryContents[1]->Fill(residuals_GLB);
00245 double kinematics_TK = double(summaryReportMap->getBinContent(2,1)+summaryReportMap->getBinContent(2,2)+summaryReportMap->getBinContent(2,3))/3.0;
00246 theSummaryContents[2]->Fill(kinematics_TK);
00247 double muonId_TK = summaryReportMap->getBinContent(2,5);
00248 theSummaryContents[3]->Fill(muonId_TK);
00249 double GLB = (kinematics_GLB+residuals_GLB)/2.0;
00250 theSummaryContents[4]->Fill(GLB);
00251 double TK = double(kinematics_TK+muonId_TK)/2.0;
00252 theSummaryContents[5]->Fill(TK);
00253 double STA = double(summaryReportMap->getBinContent(3,1)+summaryReportMap->getBinContent(3,2)+summaryReportMap->getBinContent(3,3))/3.0;
00254 theSummaryContents[6]->Fill(STA);
00255 double energyDeposits = double(summaryReportMap->getBinContent(1,6)+summaryReportMap->getBinContent(2,6)+summaryReportMap->getBinContent(3,6))/3.0;
00256 theSummaryContents[7]->Fill(energyDeposits);
00257 double molteplicity = double(summaryReportMap->getBinContent(1,7)+summaryReportMap->getBinContent(2,7)+summaryReportMap->getBinContent(3,7))/3.0;
00258 theSummaryContents[8]->Fill(molteplicity);
00259
00260 summaryReport->Fill((GLB+TK*STA+energyDeposits+molteplicity)/5.0);
00261
00262 }
00263
00264
00265 void MuonTestSummary::doKinematicsTests(string muonType, int bin){
00266
00267
00268
00269 string path = "Muons/MuonRecoAnalyzer/" + muonType + "chi2OverDf";
00270 MonitorElement * chi2Histo = dbe->get(path);
00271
00272 if(chi2Histo){
00273
00274 TH1F * chi2Histo_root = chi2Histo->getTH1F();
00275 int maxBin = chi2Histo_root->GetMaximumBin();
00276 if(chi2Histo_root->Integral(maxBin+1,chi2Histo_root->GetNbinsX())!=0){
00277 double fraction = double(chi2Histo_root->Integral(1,maxBin))/double(chi2Histo_root->Integral(maxBin+1,chi2Histo_root->GetNbinsX()));
00278 LogTrace(metname)<<"chi2 fraction for "<<muonType<<" : "<<fraction<<endl;
00279 if(fraction>(chi2Fraction-chi2Spread) && fraction<(chi2Fraction+chi2Spread))
00280 kinematicsSummaryMap->setBinContent(bin,1,1);
00281 else
00282 kinematicsSummaryMap->setBinContent(bin,1,0);
00283 }
00284 }
00285
00286
00287
00288
00289 path = "Muons/MuonRecoAnalyzer/" + muonType + "eta";
00290 MonitorElement * etaHisto = dbe->get(path);
00291
00292 if(etaHisto){
00293
00294 TH1F * etaHisto_root = etaHisto->getTH1F();
00295 double binSize = (etaHisto_root->GetXaxis()->GetXmax()-etaHisto_root->GetXaxis()->GetXmin())/etaHisto_root->GetNbinsX();
00296 int binZero = int((0-etaHisto_root->GetXaxis()->GetXmin())/binSize);
00297 if(etaHisto_root->Integral(1,binZero-1)!=0 && etaHisto_root->Integral(binZero,etaHisto_root->GetNbinsX())!=0){
00298 double symmetryFactor =
00299 double(etaHisto_root->Integral(1,binZero-1)) / double(etaHisto_root->Integral(binZero,etaHisto_root->GetNbinsX()));
00300 double errSymmetryFactor =
00301 symmetryFactor*sqrt(1.0/double(etaHisto_root->Integral(1,binZero-1)) + 1.0/double(etaHisto_root->Integral(binZero,etaHisto_root->GetNbinsX())));
00302 LogTrace(metname)<<"eta symmetryFactor for "<<muonType<<" : "<<symmetryFactor<<endl;
00303 LogTrace(metname)<<"eta errSymmetryFactor for "<<muonType<<" : "<<errSymmetryFactor<<endl;
00304 double tParameter;
00305 if((symmetryFactor-etaExpected)>0) tParameter=double(symmetryFactor-etaExpected)/errSymmetryFactor;
00306 else tParameter=double(-symmetryFactor+etaExpected)/errSymmetryFactor;
00307 if (tParameter<1.95)
00308 kinematicsSummaryMap->setBinContent(bin,2,1);
00309 else
00310 kinematicsSummaryMap->setBinContent(bin,2,0);
00311 }
00312 }
00313
00314
00315
00316 path = "Muons/MuonRecoAnalyzer/" + muonType + "phi";
00317 MonitorElement * phiHisto = dbe->get(path);
00318
00319 if(phiHisto){
00320
00321 TH1F * phiHisto_root = phiHisto->getTH1F();
00322 double binSize = (phiHisto_root->GetXaxis()->GetXmax()-phiHisto_root->GetXaxis()->GetXmin())/phiHisto_root->GetNbinsX();
00323 int binZero = int((0-phiHisto_root->GetXaxis()->GetXmin())/binSize);
00324 if(phiHisto_root->Integral(binZero+1,phiHisto_root->GetNbinsX())!=0 && phiHisto_root->Integral(1,binZero)!=0){
00325 double symmetryFactor =
00326 double(phiHisto_root->Integral(binZero+1,phiHisto_root->GetNbinsX())) / double(phiHisto_root->Integral(1,binZero));
00327 double errSymmetryFactor =
00328 symmetryFactor*sqrt(1.0/double(phiHisto_root->Integral(binZero+1,phiHisto_root->GetNbinsX())) + 1.0/double(phiHisto_root->Integral(1,binZero)));
00329 LogTrace(metname)<<"phi symmetryFactor for "<<muonType<<" : "<<symmetryFactor<<endl;
00330 LogTrace(metname)<<"phi errSymmetryFactor for "<<muonType<<" : "<<errSymmetryFactor<<endl;
00331 double tParameter;
00332 if((symmetryFactor-phiExpected)>0) tParameter=double(symmetryFactor-phiExpected)/errSymmetryFactor;
00333 else tParameter=double(-symmetryFactor+phiExpected)/errSymmetryFactor;
00334 if (tParameter<1.95)
00335 kinematicsSummaryMap->setBinContent(bin,3,1);
00336 else
00337 kinematicsSummaryMap->setBinContent(bin,3,0);
00338 }
00339 }
00340
00341 }
00342
00343
00344
00345
00346 void MuonTestSummary::doResidualsTests(string type, string parameter, int bin){
00347
00348
00349 if(type!="GlbMuon"){
00350 string path = "Muons/MuonRecoAnalyzer/Res_" + type + "_" + parameter;
00351 MonitorElement * residualsHisto = dbe->get(path);
00352
00353 if(residualsHisto){
00354
00355
00356 float statMean = residualsHisto->getMean(1);
00357 float statSigma = residualsHisto->getRMS(1);
00358 Double_t mean = -1;
00359 Double_t sigma = -1;
00360 Double_t errSigma = -1;
00361 TH1F * histo_root = residualsHisto->getTH1F();
00362 if(histo_root->GetEntries()>20){
00363 TF1 *gfit = new TF1("Gaussian","gaus",(statMean-(2*statSigma)),(statMean+(2*statSigma)));
00364 try {
00365 histo_root->Fit(gfit, "Q0");
00366 } catch (...) {
00367 edm::LogError (metname)<< "[MuonTestSummary]: Exception when fitting Res_"<<type<<"_"<<parameter;
00368 }
00369 if(gfit){
00370 mean = gfit->GetParameter(1);
00371 sigma = gfit->GetParameter(2);
00372 errSigma = gfit->GetParErrors()[2];
00373 LogTrace(metname)<<"mean: "<<mean<<"for Res_"<<type<<"_"<<parameter<<endl;
00374 LogTrace(metname)<<"sigma: "<<sigma<<"for Res_"<<type<<"_"<<parameter<<endl;
00375 LogTrace(metname)<<"errSigma: "<<errSigma<<"for Res_"<<type<<"_"<<parameter<<endl;
00376 }
00377 }
00378 else{
00379 LogTrace(metname) << "[MuonTestSummary]: Test of Res_"<<type<<"_"<<parameter<< " not performed because # entries < 20 ";
00380 }
00381
00382 if(sigma!=-1 && parameter=="eta" && type=="TkGlb"){
00383 if(sigma-errSigma<resEtaSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 1, 1);
00384 else residualsSummaryMap->setBinContent(bin, 1, 0);
00385 }
00386 if(sigma!=-1 && parameter=="eta" && (type=="GlbSta" || type=="TkSta")) {
00387 if(sigma-errSigma<resEtaSpread_glbSta) residualsSummaryMap->setBinContent(bin, 1, 1);
00388 else residualsSummaryMap->setBinContent(bin, 1, 0);
00389 }
00390 if(sigma!=-1 && parameter=="phi" && type=="TkGlb"){
00391 if(sigma-errSigma<resPhiSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 2, 1);
00392 else residualsSummaryMap->setBinContent(bin, 2, 0);
00393 }
00394 if(sigma!=-1 && parameter=="phi" && (type=="GlbSta" || type=="TkSta")){
00395 if(sigma-errSigma<resPhiSpread_glbSta) residualsSummaryMap->setBinContent(bin, 2, 1);
00396 else residualsSummaryMap->setBinContent(bin, 2, 0);
00397 }
00398 if(sigma!=-1 && parameter=="oneOverp" && type=="TkGlb"){
00399 if(sigma-errSigma<resOneOvPSpread_tkGlb) residualsSummaryMap->setBinContent(bin, 3, 1);
00400 else residualsSummaryMap->setBinContent(bin, 3, 0);
00401 }
00402 if(sigma!=-1 && parameter=="oneOverp" && (type=="GlbSta" || type=="TkSta")) {
00403 if(sigma-errSigma<resOneOvPSpread_glbSta) residualsSummaryMap->setBinContent(bin, 3, 1);
00404 else residualsSummaryMap->setBinContent(bin, 3, 0);
00405 }
00406 }
00407 }
00408 else{
00409 string path = "Muons/MuonRecoAnalyzer/" + type + "_" + parameter;
00410 MonitorElement * residualsHisto = dbe->get(path);
00411
00412 if(residualsHisto){
00413 if((residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4))!=0){
00414 LogTrace(metname)<<"charge comparison TkGlb: "<<residualsHisto->getBinContent(4)/double(residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4))<<endl;
00415 if(residualsHisto->getBinContent(4)/double(residualsHisto->getBinContent(3)+residualsHisto->getBinContent(4)) < resChargeLimit_tkGlb)
00416 residualsSummaryMap->setBinContent(1, 4, 1);
00417 else
00418 residualsSummaryMap->setBinContent(1, 4, 0);
00419 }
00420 if((residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2))!=0){
00421 LogTrace(metname)<<"charge comparison GlbSta: "<<residualsHisto->getBinContent(2)/double(residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2))<<endl;
00422 if(residualsHisto->getBinContent(2)/double(residualsHisto->getBinContent(1)+residualsHisto->getBinContent(2)) < resChargeLimit_glbSta)
00423 residualsSummaryMap->setBinContent(2, 4, 1);
00424 else
00425 residualsSummaryMap->setBinContent(2, 4, 0);
00426 }
00427 if(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6)!=0){
00428 LogTrace(metname)<<"charge comparison TkSta: "<<residualsHisto->getBinContent(6)/double(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6))<<endl;
00429 if(residualsHisto->getBinContent(6)/double(residualsHisto->getBinContent(5)+residualsHisto->getBinContent(6)) < resChargeLimit_tkSta)
00430 residualsSummaryMap->setBinContent(3, 4, 1);
00431 else
00432 residualsSummaryMap->setBinContent(3, 4, 0);
00433 }
00434 }
00435 }
00436
00437 }
00438
00439 void MuonTestSummary::doMuonIDTests(){
00440
00441
00442 string path = "Muons/MuonIdDQM/TrackerMuons/hNumMatches";
00443 MonitorElement * matchesHisto = dbe->get(path);
00444
00445 if(matchesHisto){
00446 TH1F * matchesHisto_root = matchesHisto->getTH1F();
00447 if(matchesHisto_root->GetMaximumBin() == numMatchedExpected || matchesHisto_root->GetMaximumBin() == numMatchedExpected+1)
00448 muonIdSummaryMap->setBinContent(1,1);
00449 else
00450 muonIdSummaryMap->setBinContent(1,0);
00451 }
00452
00453
00454
00455 double numOneSegm_dt = 0;
00456 MonitorElement * DT1Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hDT1NumSegments");
00457 if(DT1Histo) numOneSegm_dt+=DT1Histo->getBinContent(2);
00458 MonitorElement * DT2Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hDT2NumSegments");
00459 if(DT2Histo) numOneSegm_dt+=DT2Histo->getBinContent(2);
00460 MonitorElement * DT3Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hDT3NumSegments");
00461 if(DT3Histo) numOneSegm_dt+=DT3Histo->getBinContent(2);
00462 MonitorElement * DT4Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hDT4NumSegments");
00463 if(DT4Histo) numOneSegm_dt+=DT4Histo->getBinContent(2);
00464 LogTrace(metname)<<"numOneSegm_dt: "<<numOneSegm_dt<<endl;
00465 double fraction_dt=0;
00466 if(numOneSegm_dt!=0){
00467 fraction_dt = double(DT1Histo->getEntries())/numOneSegm_dt;
00468 LogTrace(metname)<<"fraction_dt: "<<fraction_dt<<endl;
00469 }
00470
00471 double numOneSegm_csc = 0;
00472 MonitorElement * CSC1Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hCSC1NumSegments");
00473 if(CSC1Histo) numOneSegm_csc+=CSC1Histo->getBinContent(2);
00474 MonitorElement * CSC2Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hCSC2NumSegments");
00475 if(CSC2Histo) numOneSegm_csc+=CSC2Histo->getBinContent(2);
00476 MonitorElement * CSC3Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hCSC3NumSegments");
00477 if(CSC3Histo) numOneSegm_csc+=CSC3Histo->getBinContent(2);
00478 MonitorElement * CSC4Histo = dbe->get("Muons/MuonIdDQM/TrackerMuons/hCSC4NumSegments");
00479 if(CSC4Histo) numOneSegm_csc+=CSC4Histo->getBinContent(2);
00480 LogTrace(metname)<<"numOneSegm_csc: "<<numOneSegm_csc<<endl;
00481 double fraction_csc=0;
00482 if(numOneSegm_csc!=0){
00483 fraction_csc = double(CSC1Histo->getEntries())/numOneSegm_csc;
00484 LogTrace(metname)<<"fraction_csc: "<<fraction_csc<<endl;
00485 }
00486
00487 if((fraction_dt>0.7 && fraction_dt<0.8) && (fraction_csc>0.57 && fraction_csc<0.67))
00488 muonIdSummaryMap->setBinContent(2,1);
00489 else{
00490 if((fraction_dt>0.7 && fraction_dt<0.8) || (fraction_csc>0.57 && fraction_csc<0.67))
00491 muonIdSummaryMap->setBinContent(2,1.0/2.0);
00492 else
00493 muonIdSummaryMap->setBinContent(2,0);
00494 }
00495
00496
00497 vector<string> resHistos;
00498 resHistos.push_back("hDT1Pullx");
00499 resHistos.push_back("hDT2Pullx");
00500 resHistos.push_back("hDT3Pullx");
00501 resHistos.push_back("hDT4Pullx");
00502 resHistos.push_back("hDT1Pully");
00503 resHistos.push_back("hDT2Pully");
00504 resHistos.push_back("hDT3Pully");
00505 resHistos.push_back("hCSC1Pullx");
00506 resHistos.push_back("hCSC2Pullx");
00507 resHistos.push_back("hCSC3Pullx");
00508 resHistos.push_back("hCSC4Pullx");
00509 resHistos.push_back("hCSC1Pully");
00510 resHistos.push_back("hCSC2Pully");
00511 resHistos.push_back("hCSC3Pully");
00512 resHistos.push_back("hCSC4Pully");
00513
00514 double dtSigma=0;
00515 double cscSigma=0;
00516 int numPlot_dt=0;
00517 int numPlot_csc=0;
00518 for(int name=0; name<=14; name++){
00519 MonitorElement * resHisto = dbe->get("Muons/MuonIdDQM/TrackerMuons/"+resHistos[name]);
00520 if(resHisto){
00521
00522 TH1F * resHisto_root = resHisto->getTH1F();
00523 if(resHisto_root->GetEntries()>20){
00524 TF1 *gfit = new TF1("Gaussian","gaus",-2,2);
00525 try {
00526 resHisto_root->Fit(gfit, "Q0");
00527 } catch (...) {
00528 edm::LogError (metname)<< "[MuonTestSummary]: Exception when fitting "<<resHistos[name];
00529 }
00530 if(gfit){
00531 double mean = gfit->GetParameter(1);
00532 double sigma = gfit->GetParameter(2);
00533 LogTrace(metname)<<"meanRes: "<<mean<<" for "<<resHistos[name]<<endl;
00534 LogTrace(metname)<<"sigmaRes: "<<sigma<<" for "<<resHistos[name]<<endl;
00535 if(name<=6) {
00536 dtSigma+=sigma;
00537 numPlot_dt++;
00538 }
00539 else {
00540 cscSigma+=sigma;
00541 numPlot_csc++;
00542 }
00543 }
00544 }
00545 else{
00546 LogTrace(metname) << "[MuonTestSummary]: Test of "<<resHistos[name]<< " not performed because # entries < 20 ";
00547 }
00548
00549 }
00550 }
00551
00552 LogTrace(metname)<<"meanDtSigma: "<<dtSigma/double(numPlot_dt)<<endl;
00553 LogTrace(metname)<<"meanCscSigma: "<<cscSigma/double(numPlot_csc)<<endl;
00554 if(numPlot_dt!=0 && numPlot_csc!=0){
00555 if(((dtSigma/double(numPlot_dt))>0.95 && (dtSigma/double(numPlot_dt))<1.05)
00556 && ((cscSigma/double(numPlot_csc))>0.95 && (cscSigma/double(numPlot_csc))<1.05))
00557 muonIdSummaryMap->setBinContent(3,1);
00558 else{
00559 if(((dtSigma/double(numPlot_dt))>0.95 && (dtSigma/double(numPlot_dt))<1.05)
00560 || ((cscSigma/double(numPlot_csc))>0.95 && (cscSigma/double(numPlot_csc))<1.05))
00561 muonIdSummaryMap->setBinContent(3,1.0/2.0);
00562 else
00563 muonIdSummaryMap->setBinContent(3,0);
00564 }
00565 }
00566 if(numPlot_dt!=0 && numPlot_csc!=0){
00567 if((dtSigma/double(numPlot_dt))>0.95 && (dtSigma/double(numPlot_dt))<1.05)
00568 muonIdSummaryMap->setBinContent(3,1.0/2.0);
00569 else
00570 muonIdSummaryMap->setBinContent(3,0);
00571 }
00572 if(numPlot_dt==0 && numPlot_csc!=0){
00573 if((cscSigma/double(numPlot_csc))>0.95 && (cscSigma/double(numPlot_csc))<1.05)
00574 muonIdSummaryMap->setBinContent(3,1.0/2.0);
00575 else
00576 muonIdSummaryMap->setBinContent(3,0);
00577 }
00578
00579 }
00580
00581
00582 void MuonTestSummary::doEnergyTests(string histname, string muonType, int binNumber){
00583
00584
00585 string path = "Muons/MuonEnergyDepositAnalyzer/"+histname+muonType;
00586 MonitorElement * energyHisto = dbe->get(path);
00587 Double_t hPeak=-1, hFWHM=-1;
00588 if(energyHisto){
00589 TH1F * energyHisto_root = energyHisto->getTH1F();
00590
00591
00592 Double_t fitRange[2];
00593 Double_t startValues[4], parlimitslo[4], parlimitshi[4], fitPar[4], fitParErr[4];
00594 fitRange[0]=0.0;
00595 fitRange[1]=3.0;
00596
00597 startValues[0]=0.036; startValues[1]=0.193; startValues[2]=110.0; startValues[3]=0.06;
00598 parlimitslo[0]=0.0; parlimitslo[1]=0.; parlimitslo[2]=1.0; parlimitslo[3]=0.;
00599 parlimitshi[0]=0.05; parlimitshi[1]=0.5; parlimitshi[2]=80000.0; parlimitshi[3]=0.1;
00600
00601 Double_t chisqr;
00602 Int_t ndf;
00603 TF1 *fit = langaufit(energyHisto_root,fitRange,startValues,parlimitslo,parlimitshi,fitPar,fitParErr,&chisqr,&ndf);
00604 if(fit){
00605 langaupro(fitPar,hPeak,hFWHM);
00606 LogTrace(metname)<<"hPeak from langau fit: "<<hPeak<<" for: "<<histname+muonType<<endl;
00607 LogTrace(metname)<<"hFWHM from langau fit: "<<hFWHM<<" for: "<<histname+muonType<<endl;
00608 }
00609 }
00610
00611 if(histname=="ecalS9PointingMuDepositedEnergy_" && hPeak>0.2 && hPeak<0.3)
00612 energySummaryMap->setBinContent(binNumber,1, 1);
00613 if(histname=="ecalS9PointingMuDepositedEnergy_" && !(hPeak>0.2 && hPeak<0.3))
00614 energySummaryMap->setBinContent(binNumber,1, 0);
00615
00616 if(histname=="hadS9PointingMuDepositedEnergy_" && hPeak>2 && hPeak<3.5)
00617 energySummaryMap->setBinContent(binNumber,2, 1);
00618 if(histname=="hadS9PointingMuDepositedEnergy_" && !(hPeak>2 && hPeak<3.5))
00619 energySummaryMap->setBinContent(binNumber,2, 0);
00620
00621 if(histname=="hoS9PointingMuDepositedEnergy_" && hPeak>2 && hPeak<3.5)
00622 energySummaryMap->setBinContent(binNumber,3, 1);
00623 if(histname=="hoS9PointingMuDepositedEnergy_" && !(hPeak>2 && hPeak<3.5))
00624 energySummaryMap->setBinContent(binNumber,3, 0);
00625
00626 }
00627
00628
00629 void MuonTestSummary::doMolteplicityTests(){
00630
00631 MonitorElement* molteplicityHisto = dbe->get("Muons/MuonRecoAnalyzer/muReco");
00632
00633 double molteplicity_GLB = double(molteplicityHisto->getBinContent(1)+molteplicityHisto->getBinContent(2))/double(molteplicityHisto->getEntries());
00634 LogTrace(metname)<<"molteplicity_GLB: "<<molteplicity_GLB<<endl;
00635 double molteplicity_TK = double(molteplicityHisto->getBinContent(3)+molteplicityHisto->getBinContent(4))/double(molteplicityHisto->getEntries());
00636 LogTrace(metname)<<"molteplicity_TK: "<<molteplicity_TK<<endl;
00637 double molteplicity_STA = double(molteplicityHisto->getBinContent(3)+molteplicityHisto->getBinContent(5))/double(molteplicityHisto->getEntries());
00638 LogTrace(metname)<<"molteplicity_STA: "<<molteplicity_STA<<endl;
00639
00640 if(molteplicity_GLB<expMolteplicityGlb+0.06 && molteplicity_GLB>expMolteplicityGlb-0.06)
00641 molteplicitySummaryMap->setBinContent(1,1);
00642 else
00643 molteplicitySummaryMap->setBinContent(1,0);
00644
00645 if(molteplicity_TK<expMolteplicityTk+0.02 && molteplicity_TK>expMolteplicityTk-0.02)
00646 molteplicitySummaryMap->setBinContent(2,1);
00647 else
00648 molteplicitySummaryMap->setBinContent(2,0);
00649
00650 if(molteplicity_STA<expMolteplicitySta+0.1 && molteplicity_STA>expMolteplicitySta-0.1)
00651 molteplicitySummaryMap->setBinContent(3,1);
00652 else
00653 molteplicitySummaryMap->setBinContent(3,0);
00654
00655 }