1 #include "sPhenixStyle.h"
2 #include "sPhenixStyle.C"
8 TH1::SetDefaultSumw2();
9 TH2::SetDefaultSumw2();
11 TChain * ct =
new TChain(
"T");
13 ct->Add(
"../macro/output.root");
20 vector<float> *
eta = 0;
21 vector<float> *
phi = 0;
22 vector<float> *
pt = 0;
24 vector<float> *subtracted_et = 0;
25 vector<float> *truthEta = 0;
26 vector<float> *truthPhi = 0;
27 vector<float> *truthPt = 0;
28 vector<float> *truthE = 0;
29 vector<float> *subseedEta = 0;
30 vector<float> *subseedPhi = 0;
31 vector<float> *subseedPt = 0;
32 vector<float> *subseedE = 0;
33 vector<int> *subseedCut = 0;
34 vector<float> *rawseedEta = 0;
35 vector<float> *rawseedPhi = 0;
36 vector<float> *rawseedPt = 0;
37 vector<float> *rawseedE = 0;
38 vector<int> *rawseedCut = 0;
42 ct->SetBranchAddress(
"eta",&eta);
43 ct->SetBranchAddress(
"phi",&phi);
44 ct->SetBranchAddress(
"pt",&pt);
45 ct->SetBranchAddress(
"e",&e);
46 ct->SetBranchAddress(
"subtracted_et",&subtracted_et);
47 ct->SetBranchAddress(
"truthEta",&truthEta);
48 ct->SetBranchAddress(
"truthPhi",&truthPhi);
49 ct->SetBranchAddress(
"truthPt",&truthPt);
50 ct->SetBranchAddress(
"truthE",&truthE);
51 ct->SetBranchAddress(
"cent", ¢);
53 ct->SetBranchAddress(
"rawseedEta", &rawseedEta);
54 ct->SetBranchAddress(
"rawseedPhi", &rawseedPhi);
55 ct->SetBranchAddress(
"rawseedPt", &rawseedPt);
56 ct->SetBranchAddress(
"rawseedE", &rawseedE);
57 ct->SetBranchAddress(
"rawseedCut", &rawseedCut);
58 ct->SetBranchAddress(
"subseedEta", &subseedEta);
59 ct->SetBranchAddress(
"subseedPhi", &subseedPhi);
60 ct->SetBranchAddress(
"subseedPt", &subseedPt);
61 ct->SetBranchAddress(
"subseedE", &subseedE);
62 ct->SetBranchAddress(
"subseedCut", &subseedCut);
64 const Float_t pt_range[] = {10,15,20,25,30,35,40,45,50,60,80};
65 const int pt_N =
sizeof(pt_range)/
sizeof(
float) - 1;
66 const int resp_N = 60;
67 Float_t resp_bins[resp_N+1];
68 for(
int i = 0;
i < resp_N+1;
i++){
69 resp_bins[
i] = 1.2/resp_N *
i;
73 for(
int i = 0;
i < eta_N+1;
i++){
74 eta_bins[
i] = -1.1 + 2.2/eta_N *
i;
78 for(
int i = 0;
i < phi_N+1;
i++){
79 phi_bins[
i] = -TMath::Pi() + 2*TMath::Pi()/phi_N *
i;
81 const int subet_N = 400;
82 Float_t subet_bins[subet_N+1];
83 for(
int i = 0;
i < subet_N+1;
i++){
84 subet_bins[
i] =
i*0.5;
86 const float cent_bins[] = {-1, 0, 10, 30, 50, 80};
87 const int cent_N =
sizeof(cent_bins)/
sizeof(
float) - 1;
89 TH3F *h_MC_Reso_pt =
new TH3F(
"h_MC_Reso",
"" , pt_N, pt_range, resp_N, resp_bins, cent_N, cent_bins);;
90 h_MC_Reso_pt->GetXaxis()->SetTitle(
"p_{T}^{truth} [GeV]");
91 h_MC_Reso_pt->GetYaxis()->SetTitle(
"p_{T}^{reco}/p_{T}^{truth}");
93 TH2F *h_pt_reco =
new TH2F(
"h_pt_reco",
"",subet_N,subet_bins, cent_N, cent_bins);
94 h_pt_reco->GetXaxis()->SetTitle(
"p_{T} [GeV]");
95 TH2F *h_pt_true =
new TH2F(
"h_pt_true",
"",pt_N,pt_range, cent_N, cent_bins);
96 h_pt_true->GetXaxis()->SetTitle(
"p_{T} [GeV]");
97 TH2F *h_pt_true_matched =
new TH2F(
"h_pt_true_matched",
"",subet_N,subet_bins, cent_N, cent_bins);
98 h_pt_true_matched->GetXaxis()->SetTitle(
"p_{T} [GeV]");
99 TH3F *h_eta_phi_reco =
new TH3F(
"h_eta_phi_reco",
"",eta_N, eta_bins, phi_N, phi_bins, cent_N, cent_bins);
100 h_eta_phi_reco->GetXaxis()->SetTitle(
"#eta");
101 h_eta_phi_reco->GetYaxis()->SetTitle(
"#phi");
102 TH3F *h_eta_phi_true =
new TH3F(
"h_eta_phi_true",
"",eta_N, eta_bins, phi_N, phi_bins, cent_N, cent_bins);
103 TH3F *h_subEt_pt =
new TH3F(
"h_subEt_pt",
"",pt_N,pt_range, subet_N, subet_bins, cent_N, cent_bins);
106 TGraphErrors *g_jes[cent_N];
107 TGraphErrors *g_jer[cent_N];
108 for(
int icent = 0; icent < cent_N; icent++){
109 g_jes[icent] =
new TGraphErrors(pt_N);
110 g_jer[icent] =
new TGraphErrors(pt_N);
113 int nentries = ct->GetEntries();
114 for(
int i = 0;
i < nentries;
i++){
117 int njets = truthPt->size();
118 int nrecojets = pt->size();
120 for(
int tj = 0; tj < njets; tj++){
122 h_pt_true->Fill(truthPt->at(tj), cent);
123 h_pt_true->Fill(truthPt->at(tj), -1);
124 h_eta_phi_true->Fill(truthEta->at(tj),truthPhi->at(tj), cent);
125 h_eta_phi_true->Fill(truthEta->at(tj),truthPhi->at(tj), -1);
127 float matchEta, matchPhi, matchPt, matchE, matchsubtracted_et,
dR;
129 for(
int rj = 0; rj < nrecojets; rj++){
130 float dEta = truthEta->at(tj) - eta->at(rj);
131 float dPhi = truthPhi->at(tj) - phi->at(rj);
132 while(dPhi > TMath::Pi()) dPhi -= 2*TMath::Pi();
133 while(dPhi < -TMath::Pi()) dPhi += 2*TMath::Pi();
134 dR = TMath::Sqrt(dEta*dEta + dPhi*dPhi);
136 matchEta = eta->at(rj);
137 matchPhi = phi->at(rj);
138 matchPt = pt->at(rj);
140 matchsubtracted_et = subtracted_et->at(rj);
145 if(dRMax > 0.3)
continue;
146 h_MC_Reso_pt->Fill(truthPt->at(tj),matchPt/truthPt->at(tj), cent);
147 h_pt_true_matched->Fill(truthPt->at(tj), cent);
148 h_eta_phi_reco->Fill(matchEta,matchPhi, cent);
149 h_pt_reco->Fill(matchPt, cent);
150 h_MC_Reso_pt->Fill(truthPt->at(tj),matchPt/truthPt->at(tj), -1);
151 h_pt_true_matched->Fill(truthPt->at(tj), -1);
152 h_eta_phi_reco->Fill(matchEta,matchPhi, -1);
153 h_pt_reco->Fill(matchPt, -1);
154 h_subEt_pt->Fill(matchPt, matchsubtracted_et, cent);
155 h_subEt_pt->Fill(matchPt, matchsubtracted_et, -1);
159 TCanvas *
c =
new TCanvas(
"c",
"c");
161 TLegend *
leg =
new TLegend(.25,.2,.6,.5);
162 leg->SetFillStyle(0);
163 gStyle->SetOptFit(1);
164 for(
int icent = 0; icent < cent_N; ++icent){
165 for (
int i = 0;
i < pt_N; ++
i){
166 TF1 *func =
new TF1(
"func",
"gaus",0,1.2);
167 h_MC_Reso_pt->GetXaxis()->SetRange(
i+1,
i+1);
168 h_MC_Reso_pt->GetZaxis()->SetRange(icent+1,icent+1);
169 TH1F *h_temp = (TH1F*) h_MC_Reso_pt->Project3D(
"y");
170 h_temp->Fit(func,
"",
"",0,1.2);
171 h_temp->Fit(func,
"",
"",func->GetParameter(1)-1.5*func->GetParameter(2),func->GetParameter(1)+1.5*func->GetParameter(2));
172 func->SetLineColor(kRed);
174 leg->AddEntry(
"",Form(
"%2.0f%%-%2.0f%%",h_MC_Reso_pt->GetZaxis()->GetBinLowEdge(icent+1),h_MC_Reso_pt->GetZaxis()->GetBinLowEdge(icent+2)),
"");
175 leg->AddEntry(
"",Form(
"%2.0f < p_T < %2.0f GeV",h_MC_Reso_pt->GetXaxis()->GetBinLowEdge(
i+1),h_MC_Reso_pt->GetXaxis()->GetBinLowEdge(
i+2)),
"");
178 float dsigma = func -> GetParError(2);
179 float denergy = func -> GetParError(1);
183 float djer = dsigma/energy + sigma*denergy/pow(energy,2);
188 g_jes[icent]->SetPoint(
i,0.5*(pt_range[
i]+pt_range[
i+1]),func->GetParameter(1));
189 g_jes[icent]->SetPointError(
i,0.5*(pt_range[
i+1]-pt_range[
i]),func->GetParError(1));
190 g_jer[icent]->SetPoint(i,0.5*(pt_range[i]+pt_range[i+1]),func->GetParameter(2)/func->GetParameter(1));
193 g_jer[icent]->SetPointError(i,0.5*(pt_range[i+1]-pt_range[i]),djer);
200 TFile *f_out =
new TFile(
"hists.root",
"RECREATE");
201 for(
int icent = 0; icent < cent_N; ++icent){
202 g_jes[icent]->Write(Form(
"g_jes_cent%i",icent));
203 g_jer[icent]->Write(Form(
"g_jer_cent%i",icent));
207 h_eta_phi_true->Write();
208 h_pt_true_matched->Write();
209 h_eta_phi_reco->Write();