- Timestamp:
- Aug 23, 2016, 3:57:49 PM (8 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 7b48085, 9327245
- Parents:
- 6563d4d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/Validation.C
r6563d4d r20ca0cd 144 144 Int_t i, j; 145 145 146 TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra Pt", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax)); 147 TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra Pt", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax)); 148 TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra Eta", 12, -3, 3); 149 TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra Eta", 12, -3, 3); 150 151 152 BinLogX(histGenPt); 153 BinLogX(histRecoPt); 146 TH1D *histGenPtcen = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax)); 147 TH1D *histRecoPtcen = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax)); 148 TH1D *histGenPtfwd = new TH1D(name+" gen spectra Eta",name+" gen spectra fwd", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax)); 149 TH1D *histRecoPtfwd = new TH1D(name+" reco spectra Eta",name+" reco spectra fwd", Nbins, TMath::Log10(ptrangemin), TMath::Log10(ptrangemax)); 150 151 152 BinLogX(histGenPtcen); 153 BinLogX(histRecoPtcen); 154 BinLogX(histGenPtfwd); 155 BinLogX(histRecoPtfwd); 154 156 155 157 // Loop over all events … … 201 203 eta = genMomentum.Eta(); 202 204 203 histGenPt->Fill(pt); 204 histGenEta->Fill(eta); 205 206 if(deltaR < 0.3) 205 if (TMath::Abs(eta) < 1.5) 207 206 { 208 histRecoPt->Fill(pt); 209 histRecoEta->Fill(eta); 207 histGenPtcen->Fill(pt); 208 if(deltaR < 0.3) { histRecoPtcen->Fill(pt); } 209 } 210 else if (TMath::Abs(eta) < 2.5) 211 { 212 histGenPtfwd->Fill(pt); 213 if(deltaR < 0.3) { histRecoPtfwd->Fill(pt); } 214 210 215 } 211 216 } … … 216 221 std::pair<TH1D*,TH1D*> histos; 217 222 218 histRecoPt ->Divide(histGenPt);219 histReco Eta->Divide(histGenEta);220 221 histos.first = histRecoPt ;222 histos.second = histReco Eta;223 histRecoPtcen->Divide(histGenPtcen); 224 histRecoPtfwd->Divide(histGenPtfwd); 225 226 histos.first = histRecoPtcen; 227 histos.second = histRecoPtfwd; 223 228 224 229 return histos; … … 355 360 for (bin = 0; bin < Nbins; bin++) 356 361 { 357 if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta > 0.0 && eta< 1.5)362 if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 1.5) 358 363 { 359 364 histos->at(bin).cenResolHist->Fill(jetMomentum.Pt()/bestGenJetMomentum.Pt()); 360 365 } 366 else if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < 2.5) 367 { 368 histos->at(bin).fwdResolHist->Fill(jetMomentum.Pt()/bestGenJetMomentum.Pt()); 369 } 370 361 371 } 362 372 } … … 430 440 if (central == true && histos->at(bin).cenResolHist->GetEntries() > 100) 431 441 { 432 std::cout << " pt : " << (histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0;433 std::cout << " mean : " << histos->at(bin).cenResolHist->GetMean() << " RMS : " << histos->at(bin).cenResolHist->GetRMS();434 std::cout << " entries : " << histos->at(bin).cenResolHist->GetEntries() << std::endl;435 442 std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).cenResolHist); 436 443 if (rms == true) … … 446 453 count++; 447 454 } 448 /*449 else if ( histos->at(bin).cenResolHist->GetEntries() > 10)455 456 else if (central == false && histos->at(bin).fwdResolHist->GetEntries() > 10) 450 457 { 451 histos->at(bin).fwdResolHist->Fit("gaus","","", -2*histos->at(bin).fwdResolHist->GetRMS(), 2*histos->at(bin).fwdResolHist->GetRMS()); 452 TF1 *f = histos->at(bin).fwdResolHist->GetFunction("gaus"); 453 Double_t sig = f->GetParameter(2); 454 Double_t sigErr = f->GetParError(2); 455 gr.SetPoint(bin,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sig); 456 gr.SetPointError(bin,0, sigErr); 458 std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).fwdResolHist); 459 if (rms == true) 460 { 461 gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.second); 462 gr.SetPointError(count,0, sigvalues.second); // to correct 463 } 464 else 465 { 466 gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first); 467 gr.SetPointError(count,0, sigvalues.second); 468 } 469 count++; 457 470 } 458 */471 459 472 } 460 473 return gr; … … 629 642 GetEres<Electron>( &plots_el, branchElectron, branchParticle, elID, treeReader); 630 643 TGraphErrors gr_el = EresGraph(&plots_el, true); 644 TGraphErrors gr_elFwd = EresGraph(&plots_el, false); 631 645 gr_el.SetName("Electron"); 646 gr_elFwd.SetName("ElectronFwd"); 632 647 633 648 // Electron Track Energy Resolution … … 636 651 GetEres<Track>( &plots_eltrack, branchTrack, branchParticle, elID, treeReader); 637 652 TGraphErrors gr_eltrack = EresGraph(&plots_eltrack, true); 653 TGraphErrors gr_eltrackFwd = EresGraph(&plots_eltrack, false); 638 654 gr_eltrack.SetName("ElectronTracks"); 655 gr_eltrackFwd.SetName("ElectronTracksFwd"); 639 656 640 657 // Electron Tower Energy Resolution … … 643 660 GetEres<Tower>( &plots_eltower, branchTower, branchParticle, elID, treeReader); 644 661 TGraphErrors gr_eltower = EresGraph(&plots_eltower, true); 662 TGraphErrors gr_eltowerFwd = EresGraph(&plots_eltower, false); 645 663 gr_eltower.SetName("ElectronTower"); 664 gr_eltrackFwd.SetName("ElectronTracksFwd"); 646 665 647 666 // Canvases … … 666 685 TLegend *leg_el2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax); 667 686 687 gPad->SetLogx(); 668 688 histos_eltrack.second->Draw(); 669 689 addHist(histos_eltrack.second, leg_el2, 2); … … 673 693 addHist(histos_el.second, leg_el2, 1); 674 694 675 DrawAxis(histos_eltrack.second, leg_el2, 1);695 DrawAxis(histos_eltrack.second, leg_el2, 0); 676 696 delete(leg_el2); 677 697 C_el1->cd(0); 678 698 679 699 TString elRes = "electronERes"; 700 TString elResFwd = "electronEResForward"; 680 701 TCanvas *C_el2 = new TCanvas(elRes,elRes, 1000, 500); 702 C_el2->Divide(2); 703 C_el2->cd(1); 681 704 TMultiGraph *mg_el = new TMultiGraph(elRes,elRes); 682 705 TLegend *leg_el = new TLegend(0.52,0.7,0.9,0.9); … … 690 713 691 714 DrawAxis(mg_el, leg_el, 0.1); 715 716 C_el2->cd(2); 717 TMultiGraph *mg_elFwd = new TMultiGraph(elResFwd,elResFwd); 718 TLegend *leg_elFwd = new TLegend(0.52,0.7,0.9,0.9); 719 720 addGraph(mg_elFwd, &gr_eltowerFwd, leg_elFwd, 3); 721 addGraph(mg_elFwd, &gr_eltrackFwd, leg_elFwd, 2); 722 addGraph(mg_elFwd, &gr_elFwd, leg_elFwd, 1); 723 724 mg_elFwd->Draw("ACX"); 725 726 DrawAxis(mg_elFwd, leg_elFwd, 0.1); 727 692 728 693 729 C_el1->SaveAs(elEff+".eps"); … … 716 752 GetEres<Muon>( &plots_mu, branchMuon, branchParticle, muID, treeReader); 717 753 TGraphErrors gr_mu = EresGraph(&plots_mu, true); 754 TGraphErrors gr_muFwd = EresGraph(&plots_mu, false); 718 755 gr_mu.SetName("Muon"); 756 gr_muFwd.SetName("MuonFwd"); 719 757 720 758 // Muon Track Energy Resolution … … 723 761 GetEres<Track>( &plots_mutrack, branchTrack, branchParticle, muID, treeReader); 724 762 TGraphErrors gr_mutrack = EresGraph(&plots_mutrack, true); 725 gr_mutrack.SetName("MuonTracks"); 763 TGraphErrors gr_mutrackFwd = EresGraph(&plots_mutrack, false); 764 gr_mutrackFwd.SetName("MuonTracksFwd"); 726 765 727 766 // Canvas … … 745 784 TLegend *leg_mu2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax); 746 785 786 gPad->SetLogx(); 747 787 histos_mutrack.second->Draw(); 748 788 addHist(histos_mutrack.second, leg_mu2, 2); … … 753 793 754 794 TString muRes = "muonERes"; 795 TString muResFwd = "muonEResFwd"; 796 755 797 TCanvas *C_mu = new TCanvas(muRes,muRes, 1000, 500); 798 C_mu->Divide(2); 799 C_mu->cd(1); 756 800 TMultiGraph *mg_mu = new TMultiGraph(muRes,muRes); 757 801 TLegend *leg_mu = new TLegend(0.52,0.7,0.9,0.9); … … 764 808 765 809 DrawAxis(mg_mu, leg_mu, 0.3); 810 811 C_mu->cd(2); 812 TMultiGraph *mg_muFwd = new TMultiGraph(muResFwd,muResFwd); 813 TLegend *leg_muFwd = new TLegend(0.52,0.7,0.9,0.9); 814 815 addGraph(mg_muFwd, &gr_mutrackFwd, leg_muFwd, 2); 816 addGraph(mg_muFwd, &gr_muFwd, leg_muFwd, 1); 817 818 mg_muFwd->Draw("ACX"); 819 820 DrawAxis(mg_muFwd, leg_muFwd, 0.3); 766 821 767 822 C_mu1->SaveAs(muEff+".eps"); … … 788 843 GetEres<Photon>( &plots_ph, branchPhoton, branchParticle, phID, treeReader); 789 844 TGraphErrors gr_ph = EresGraph(&plots_ph, true); 845 TGraphErrors gr_phFwd = EresGraph(&plots_ph, false); 790 846 gr_ph.SetName("Photon"); 847 gr_phFwd.SetName("PhotonFwd"); 848 791 849 792 850 // Photon Tower Energy Resolution … … 795 853 GetEres<Tower>( &plots_phtower, branchTower, branchParticle, phID, treeReader); 796 854 TGraphErrors gr_phtower = EresGraph(&plots_phtower, true); 855 TGraphErrors gr_phtowerFwd = EresGraph(&plots_phtower, false); 797 856 gr_phtower.SetName("PhotonTower"); 857 gr_phtowerFwd.SetName("PhotonTowerFwd"); 798 858 799 859 // Canvas … … 817 877 TLegend *leg_ph2 = new TLegend(effLegXmin,effLegYmin,effLegXmax,effLegYmax); 818 878 879 gPad->SetLogx(); 819 880 histos_phtower.second->Draw("same"); 820 881 addHist(histos_phtower.second, leg_ph2, 3); … … 827 888 828 889 TString phRes = "phERes"; 890 TString phResFwd = "phEResFwd"; 891 829 892 TCanvas *C_ph = new TCanvas(phRes,phRes, 1000, 500); 893 C_ph->Divide(2); 894 C_ph->cd(1); 830 895 TMultiGraph *mg_ph = new TMultiGraph(phRes,phRes); 831 896 TLegend *leg_ph = new TLegend(0.52,0.7,0.9,0.9); … … 838 903 839 904 DrawAxis(mg_ph, leg_ph, 0.3); 905 906 C_ph->cd(2); 907 TMultiGraph *mg_phFwd = new TMultiGraph(phResFwd,phResFwd); 908 TLegend *leg_phFwd = new TLegend(0.52,0.7,0.9,0.9); 909 910 addGraph(mg_phFwd, &gr_phtowerFwd, leg_phFwd, 3); 911 addGraph(mg_phFwd, &gr_phFwd, leg_phFwd, 1); 912 913 mg_phFwd->Draw("ACX"); 914 915 DrawAxis(mg_phFwd, leg_phFwd, 0.3); 840 916 841 917 C_ph->SaveAs(phRes+".eps"); … … 864 940 GetJetsEres( &plots_pfjets, branchPFJet, branchGenJet, treeReader); 865 941 TGraphErrors gr_pfjets = EresGraph(&plots_pfjets, true); 942 TGraphErrors gr_pfjetsFwd = EresGraph(&plots_pfjets, false); 866 943 gr_pfjets.SetName("pfJet"); 944 gr_pfjetsFwd.SetName("pfJetFwd"); 867 945 868 946 // CaloJets Energy Resolution … … 871 949 GetJetsEres( &plots_calojets, branchCaloJet, branchGenJet, treeReader); 872 950 TGraphErrors gr_calojets = EresGraph(&plots_calojets, true); 951 TGraphErrors gr_calojetsFwd = EresGraph(&plots_calojets, false); 873 952 gr_calojets.SetName("caloJet"); 953 gr_calojetsFwd.SetName("caloJetFwd"); 874 954 875 955 // MET Resolution vs HT … … 881 961 882 962 // Canvas 883 884 963 TString btagEff = "btagEff"; 885 964 TCanvas *C_btag1 = new TCanvas(btagEff,btagEff, 1000, 500); … … 929 1008 930 1009 TString jetRes = "jetERes"; 1010 TString jetResFwd = "jetEResFwd"; 931 1011 TCanvas *C_jet = new TCanvas(jetRes,jetRes, 1000, 500); 1012 C_jet->Divide(2); 1013 1014 C_jet->cd(1); 932 1015 TMultiGraph *mg_jet = new TMultiGraph(jetRes,jetRes); 933 1016 TLegend *leg_jet = new TLegend(0.52,0.7,0.9,0.9); … … 940 1023 941 1024 DrawAxis(mg_jet, leg_jet, 0.25); 1025 1026 C_jet->cd(2); 1027 TMultiGraph *mg_jetFwd = new TMultiGraph(jetResFwd,jetResFwd); 1028 TLegend *leg_jetFwd = new TLegend(0.52,0.7,0.9,0.9); 1029 1030 addGraph(mg_jetFwd, &gr_calojetsFwd, leg_jetFwd, 3); 1031 addGraph(mg_jetFwd, &gr_pfjetsFwd, leg_jetFwd, 1); 1032 1033 mg_jetFwd->Draw("ACX"); 1034 1035 DrawAxis(mg_jetFwd, leg_jetFwd, 0.25); 942 1036 943 1037 C_btag1->SaveAs(btagEff+".eps"); … … 979 1073 plots_eltrack.at(bin).cenResolHist->Write(); 980 1074 plots_eltower.at(bin).cenResolHist->Write(); 1075 plots_el.at(bin).fwdResolHist->Write(); 1076 plots_eltrack.at(bin).fwdResolHist->Write(); 1077 plots_eltower.at(bin).fwdResolHist->Write(); 981 1078 } 982 1079 // gr.Write(); … … 1010 1107 { 1011 1108 plots_pfjets.at(bin).cenResolHist->Write(); 1109 plots_pfjets.at(bin).fwdResolHist->Write(); 1012 1110 plots_calojets.at(bin).cenResolHist->Write(); 1111 plots_calojets.at(bin).fwdResolHist->Write(); 1013 1112 plots_met.at(bin).cenResolHist->Write(); 1014 1113 }
Note:
See TracChangeset
for help on using the changeset viewer.