Changes in / [8f0b34c:eab6d46] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/Validation.cpp
r8f0b34c reab6d46 343 343 } 344 344 } 345 346 347 template<typename T>348 void GetPtres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, ExRootTreeReader *treeReader)349 {350 Long64_t allEntries = treeReader->GetEntries();351 352 cout << "** Computing pt resolution of " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;353 354 GenParticle *particle;355 T* recoObj;356 357 TLorentzVector recoMomentum, genMomentum, bestGenMomentum;358 359 Float_t deltaR;360 Float_t pt, eta;361 Long64_t entry;362 363 Int_t i, j, bin;364 365 // Loop over all events366 for(entry = 0; entry < allEntries; ++entry)367 {368 // Load selected branches with data from specified event369 treeReader->ReadEntry(entry);370 371 // Loop over all reconstructed jets in event372 for(i = 0; i < branchReco->GetEntriesFast(); ++i)373 {374 recoObj = (T*) branchReco->At(i);375 recoMomentum = recoObj->P4();376 377 deltaR = 999;378 379 // Loop over all hard partons in event380 for(j = 0; j < branchParticle->GetEntriesFast(); ++j)381 {382 particle = (GenParticle*) branchParticle->At(j);383 if (particle->PID == pdgID && particle->Status == 1)384 {385 genMomentum = particle->P4();386 387 // this is simply to avoid warnings from initial state particle388 // having infite rapidity ...389 if(genMomentum.Px() == 0 && genMomentum.Py() == 0) continue;390 391 // take the closest parton candidate392 if(genMomentum.DeltaR(recoMomentum) < deltaR)393 {394 deltaR = genMomentum.DeltaR(recoMomentum);395 bestGenMomentum = genMomentum;396 }397 }398 }399 400 if(deltaR < 0.3)401 {402 pt = bestGenMomentum.Pt();403 eta = TMath::Abs(bestGenMomentum.Eta());404 405 for (bin = 0; bin < Nbins; bin++)406 {407 if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 2.5)408 {409 if (eta < 1.5) {histos->at(bin).cenResolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());}410 else if (eta < 2.5) {histos->at(bin).fwdResolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());}411 }412 }413 }414 }415 }416 }417 418 419 345 void GetJetsEres(std::vector<resolPlot> *histos, TClonesArray *branchJet, TClonesArray *branchGenJet, ExRootTreeReader *treeReader) 420 346 { … … 472 398 if(deltaR < 0.25) 473 399 { 474 pt = genJetMomentum. E();400 pt = genJetMomentum.Pt(); 475 401 eta = TMath::Abs(genJetMomentum.Eta()); 476 402 … … 479 405 if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 1.5) 480 406 { 481 histos->at(bin).cenResolHist->Fill(jetMomentum. E()/bestGenJetMomentum.E());407 histos->at(bin).cenResolHist->Fill(jetMomentum.Pt()/bestGenJetMomentum.Pt()); 482 408 } 483 409 else if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 2.5) 484 410 { 485 histos->at(bin).fwdResolHist->Fill(jetMomentum. E()/bestGenJetMomentum.E());411 histos->at(bin).fwdResolHist->Fill(jetMomentum.Pt()/bestGenJetMomentum.Pt()); 486 412 } 413 487 414 } 488 415 } … … 549 476 TF1 *f1 = new TF1("f1", "gaus", hist->GetMean()-2*hist->GetRMS(), hist->GetMean()+2*hist->GetRMS()); 550 477 hist->Fit("f1","RQ"); 551 552 TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2*f1->GetParameter(2), f1->GetParameter(1) + 2*f1->GetParameter(2)); 553 hist->Fit("f2","RQ"); 554 555 Double_t sig = f2->GetParameter(2); 556 Double_t sigErr = f2->GetParError(2); 557 478 Double_t sig = f1->GetParameter(2); 479 Double_t sigErr = f1->GetParError(2); 558 480 delete f1; 559 delete f2;560 481 return make_pair (sig, sigErr); 561 482 } … … 689 610 } 690 611 691 void DrawAxis(TMultiGraph *mg, TLegend *leg, double max , int type = 0)612 void DrawAxis(TMultiGraph *mg, TLegend *leg, double max) 692 613 { 693 614 mg->SetMinimum(0.); … … 695 616 mg->GetXaxis()->SetLimits(ptrangemin,ptrangemax); 696 617 mg->GetYaxis()->SetTitle("resolution"); 697 if (type == 0) mg->GetXaxis()->SetTitle("E [GeV]"); 698 else mg->GetXaxis()->SetTitle("p_{T} [GeV]"); 618 mg->GetXaxis()->SetTitle("p_{T} [GeV]"); 699 619 mg->GetYaxis()->SetTitleSize(0.07); 700 620 mg->GetXaxis()->SetTitleSize(0.07); … … 721 641 } 722 642 723 void DrawAxis(TH1D *h, TLegend *leg, int type = 0)643 void DrawAxis(TH1D *h, TLegend *leg, int type) 724 644 { 725 645 726 646 h->GetYaxis()->SetRangeUser(0,1.0); 727 if (type == 0) h->GetXaxis()->SetTitle(" E[GeV]");728 else h->GetXaxis()->SetTitle(" p_{T} [GeV]");647 if (type == 0) h->GetXaxis()->SetTitle("p_{T} [GeV]"); 648 else h->GetXaxis()->SetTitle("#eta"); 729 649 h->GetYaxis()->SetTitle("efficiency"); 730 650 h->GetYaxis()->SetTitleSize(0.07); … … 862 782 histos_el.first->Draw("same ]["); 863 783 addHist(histos_el.first, leg_el1, 1); 864 DrawAxis(histos_eltrack.first, leg_el1, 1);784 DrawAxis(histos_eltrack.first, leg_el1, 0); 865 785 866 786 leg_el1->Draw(); … … 877 797 addHist(histos_el.second, leg_el2, 1); 878 798 879 DrawAxis(histos_eltrack.second, leg_el2, 1);799 DrawAxis(histos_eltrack.second, leg_el2, 0); 880 800 leg_el2->Draw(); 881 801 … … 930 850 std::pair <TH1D*,TH1D*> histos_mutrack = GetEff<Track>(branchTrackMuon, branchParticleMuon, "muonTrack", muID, treeReaderMuon); 931 851 932 // Muon PtResolution852 // Muon Energy Resolution 933 853 std::vector<resolPlot> plots_mu; 934 854 HistogramsCollection(&plots_mu, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "muons"); 935 Get Ptres<Muon>(&plots_mu, branchMuon, branchParticleMuon, muID, treeReaderMuon);855 GetEres<Muon>(&plots_mu, branchMuon, branchParticleMuon, muID, treeReaderMuon); 936 856 TGraphErrors gr_mu = EresGraph(&plots_mu, true); 937 857 TGraphErrors gr_muFwd = EresGraph(&plots_mu, false); … … 942 862 std::vector<resolPlot> plots_mutrack; 943 863 HistogramsCollection(&plots_mutrack, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax), "muonsTracks"); 944 Get Ptres<Track>(&plots_mutrack, branchTrackMuon, branchParticleMuon, muID, treeReaderMuon);864 GetEres<Track>(&plots_mutrack, branchTrackMuon, branchParticleMuon, muID, treeReaderMuon); 945 865 TGraphErrors gr_mutrack = EresGraph(&plots_mutrack, true); 946 866 TGraphErrors gr_mutrackFwd = EresGraph(&plots_mutrack, false); … … 964 884 addHist(histos_mu.first, leg_mu1, 1); 965 885 966 DrawAxis(histos_mutrack.first, leg_mu1, 1);886 DrawAxis(histos_mutrack.first, leg_mu1, 0); 967 887 968 888 leg_mu1->Draw(); … … 999 919 leg_mu->Draw(); 1000 920 1001 DrawAxis(mg_mu, leg_mu, 0.3 , 1);921 DrawAxis(mg_mu, leg_mu, 0.3); 1002 922 1003 923 C_mu->cd(2); … … 1013 933 leg_muFwd->Draw(); 1014 934 1015 DrawAxis(mg_muFwd, leg_muFwd, 0.3 , 1);935 DrawAxis(mg_muFwd, leg_muFwd, 0.3); 1016 936 1017 937 C_mu1->Print("delphes_validation.pdf","pdf"); … … 1065 985 addHist(histos_ph.first, leg_ph1, 1); 1066 986 1067 DrawAxis(histos_phtower.first, leg_ph1, 1);987 DrawAxis(histos_phtower.first, leg_ph1, 0); 1068 988 leg_ph1->Draw(); 1069 989 … … 1100 1020 leg_ph->Draw(); 1101 1021 1102 DrawAxis(mg_ph, leg_ph, 0. 1);1022 DrawAxis(mg_ph, leg_ph, 0.3); 1103 1023 1104 1024 C_ph->cd(2); … … 1114 1034 leg_phFwd->Draw(); 1115 1035 1116 DrawAxis(mg_phFwd, leg_phFwd, 0. 1);1036 DrawAxis(mg_phFwd, leg_phFwd, 0.3); 1117 1037 1118 1038 C_ph1->Print("delphes_validation.pdf","pdf"); … … 1171 1091 addHist(histos_btag.first, leg_btag1, 0); 1172 1092 1173 DrawAxis(histos_btag.first, leg_btag1, 1);1093 DrawAxis(histos_btag.first, leg_btag1, 0); 1174 1094 leg_btag1->Draw(); 1175 1095 … … 1183 1103 addHist(histos_btag.second, leg_btag2, 0); 1184 1104 1185 DrawAxis(histos_btag.second, leg_btag2, 1);1105 DrawAxis(histos_btag.second, leg_btag2, 0); 1186 1106 leg_btag2->Draw(); 1187 1107 C_btag1->cd(0); … … 1199 1119 addHist(histos_tautag.first, leg_tautag1, 0); 1200 1120 1201 DrawAxis(histos_tautag.first, leg_tautag1, 1);1121 DrawAxis(histos_tautag.first, leg_tautag1, 0); 1202 1122 leg_tautag1->Draw(); 1203 1123 … … 1211 1131 addHist(histos_tautag.second, leg_tautag2, 0); 1212 1132 1213 DrawAxis(histos_tautag.second, leg_tautag2, 1);1133 DrawAxis(histos_tautag.second, leg_tautag2, 0); 1214 1134 leg_tautag2->Draw(); 1215 1135 C_tautag1->cd(0); … … 1229 1149 addGraph(mg_jet, &gr_pfjets, leg_jet, 1); 1230 1150 1231 mg_jet->Draw("A LX");1151 mg_jet->Draw("ACX"); 1232 1152 leg_jet->Draw(); 1233 1153 1234 DrawAxis(mg_jet, leg_jet, 0. 5);1154 DrawAxis(mg_jet, leg_jet, 0.25); 1235 1155 1236 1156 C_jet->cd(2); 1237 1157 TMultiGraph *mg_jetFwd = new TMultiGraph(jetResFwd,jetResFwd); 1238 1158 TLegend *leg_jetFwd = new TLegend(resLegXmin,resLegYmin,resLegXmax,resLegYmax); 1239 leg_jetFwd->SetHeader("#splitline{jets}{ 1.5 < |#eta| < 2.5}");1159 leg_jetFwd->SetHeader("#splitline{jets}{|#eta| < 1.5}"); 1240 1160 leg_jetFwd->AddEntry("","",""); 1241 1161 … … 1243 1163 addGraph(mg_jetFwd, &gr_pfjetsFwd, leg_jetFwd, 1); 1244 1164 1245 mg_jetFwd->Draw("A LX");1165 mg_jetFwd->Draw("ACX"); 1246 1166 leg_jetFwd->Draw(); 1247 1167 1248 DrawAxis(mg_jetFwd, leg_jetFwd, 0. 5);1168 DrawAxis(mg_jetFwd, leg_jetFwd, 0.25); 1249 1169 1250 1170 TString metRes = "MetRes"; … … 1292 1212 C_el1->Write(); 1293 1213 C_el2->Write(); 1294 1295 for (int bin = 0; bin < Nbins; bin++)1296 {1297 plots_mu.at(bin).cenResolHist->Write();1298 plots_mutrack.at(bin).cenResolHist->Write();1299 plots_mu.at(bin).fwdResolHist->Write();1300 plots_mutrack.at(bin).fwdResolHist->Write();1301 }1302 1214 1303 1215 histos_mu.first->Write();
Note:
See TracChangeset
for help on using the changeset viewer.