27 #include <TGraphErrors.h>
38 std::vector<int>
searchLeadingJets(TNtuple *
T,
float cutPT,
const char *targetV =
"gpt");
42 const char*
path =
"/gpfs/mnt/gpfs04/sphenix/user/ckim/fjets/Ana/results_1121",
43 const char* var =
"e",
44 const char* suffix =
"",
50 const int setPy[] = {8};
51 const int setBeamE[] = {200};
52 const int setR[] = {4, 6};
53 const int setMinPT[] = { 5, 10, 15};
54 const float setEta[] = {1.2, 1.6, 2.0, 2.4, 2.8, 3.2, 3.6};
55 const float setE[] = {20,25,30,35,40,45,50, 60,70,80,90,100,110,120,130,140,150,160, 180,200};
57 const int nsetPy =
sizeof(setPy) /
sizeof(setPy[0]);
58 const int nsetBeamE =
sizeof(setBeamE)/
sizeof(setBeamE[0]);
59 const int nsetR =
sizeof(setR) /
sizeof(setR[0]);
60 const int nsetMinPT =
sizeof(setMinPT)/
sizeof(setMinPT[0]);
61 const int nsetEta =
sizeof(setEta) /
sizeof(setEta[0]) - 1;
62 const int nsetE =
sizeof(setE) /
sizeof(setE[0]) - 1;
67 TH2F *
h2[nsetPy][nsetBeamE][nsetR][nsetEta];
68 TH1F *
h1[nsetPy][nsetBeamE][nsetR][nsetEta][nsetE];
69 for (
int a=0;
a<nsetPy;
a++)
70 for (
int b=0;
b<nsetBeamE;
b++)
71 for (
int c=0;
c<nsetR;
c++)
72 for (
int x=0;
x<nsetEta;
x++)
74 const char* h2Name = Form(
"sanity_py%i_%i_r0%i_eta%i", setPy[
a],setBeamE[
b],setR[
c],
x);
75 h2[
a][
b][
c][
x] =
new TH2F(h2Name,
"", 100,0,b==0?100:200, 60,0,2);
76 for (
int y=0;
y<nsetE;
y++)
78 const char* h1Name = Form(
"h1_%s_py%i_%i_r0%i_eta%i_e%i", var,setPy[a],setBeamE[b],setR[c],
x,
y);
79 h1[
a][
b][
c][
x][
y] =
new TH1F(h1Name,
"", 150,-1.5,1.5);
86 for (
int a=0;
a<nsetPy;
a++)
87 for (
int b=0;
b<nsetBeamE;
b++)
88 for (
int c=0;
c<nsetR;
c++)
89 for (
int d=0; d<nsetMinPT; d++)
92 const char *finName = Form(
"%s/pythia%i_%i_r0%i_pT%i.root",
path,setPy[
a],setBeamE[
b],setR[
c],setMinPT[d]);
93 TFile *
F = TFile::Open(finName);
94 TNtuple *
T = (TNtuple*)F->Get(
"ntp_truthjet");
95 cout <<Form(
"Open %s from %s...", T->GetName(), F->GetName()) <<endl;
103 T->SetBranchAddress(
"event", &event);
104 T->SetBranchAddress(
"geta", &geta);
105 T->SetBranchAddress(
"gphi", &gphi);
106 T->SetBranchAddress(
"ge", &ge);
107 T->SetBranchAddress(
"eta", &eta);
108 T->SetBranchAddress(
"phi", &phi);
109 T->SetBranchAddress(
"e", &e);
112 for (
unsigned int i=0;
i<jetList.size();
i++)
114 T->GetEntry(jetList[
i]);
117 for (
int x=0;
x<nsetEta;
x++) {
if (geta > setEta[
x] && geta < setEta[
x+1]) id_eta =
x; }
118 if (id_eta == -1)
continue;
120 h2[
a][
b][
c][id_eta]->Fill(ge, e/ge);
123 for (
int y=0;
y<nsetE;
y++) {
if (ge > setE[
y] && ge < setE[
y+1]) id_e =
y; }
124 if (id_e == -1)
continue;
126 if (!strcmp(var,
"e")) h1[
a][
b][
c][id_eta][
id_e]->Fill(e/ge);
130 T->ResetBranchAddresses();
137 gStyle->SetOptStat(
"e");
140 TCanvas *c1[nsetPy][nsetBeamE][nsetR];
141 for (
int a=0;
a<nsetPy;
a++)
142 for (
int b=0;
b<nsetBeamE;
b++)
143 for (
int c=0;
c<nsetR;
c++)
145 const char* c1Name = Form(
"sanity_py%i_%i_r0%i", setPy[
a],setBeamE[
b],setR[
c]);
146 c1[
a][
b][
c] =
new TCanvas(c1Name, c1Name, 1280, 800);
147 c1[
a][
b][
c]->Divide(nsetEta/2, 2, 0.015, 0.015, 10);
148 for (
int x=0;
x<nsetEta;
x++)
150 c1[
a][
b][
c]->cd(
x+1)->SetGrid();
151 h2[
a][
b][
c][
x]->SetTitle(Form(
"%2.1f < #eta < %2.1f;True e;Reco e/True e", setEta[
x], setEta[x+1]));
152 h2[
a][
b][
c][
x]->GetYaxis()->SetTitleOffset(1.45);
153 h2[
a][
b][
c][
x]->Draw(
"colz");
155 if (
print) c1[
a][
b][
c]->Print(Form(
"%s%s.png", c1[a][b][c]->GetName(),suffix));
159 TCanvas *
c2 =
new TCanvas(Form(
"resol_%s", var), var, 1280, 800);
160 c2->Divide(nsetEta/2, 2, 0.015, 0.015, 10);
161 TF1 *f1Gaus =
new TF1(
"f1Gaus",
"[0]*TMath::Gaus(x, [1], [2])", -0.2, 0.2);
162 TLegend *leg1 =
new TLegend(0.4, 0.6, 0.9, 0.9);
163 for (
int a=0;
a<nsetPy;
a++)
164 for (
int b=0;
b<nsetBeamE;
b++)
165 for (
int c=0;
c<nsetR;
c++)
166 for (
int x=0;
x<nsetEta;
x++)
168 TGraphErrors *g1 =
new TGraphErrors();
169 g1->SetName(Form(
"g1_%s_py%i_%i_r0%i_eta%i_e%i", var,setPy[
a],setBeamE[
b],setR[
c],
x));
170 g1->SetLineColor(2 * (b+1));
171 g1->SetMarkerColor(2 * (b+1));
172 g1->SetMarkerSize(1.);
173 g1->SetMarkerStyle(20 + 4*c);
175 for (
int y=0;
y<nsetE;
y++)
177 if (h1[a][b][c][
x][
y]->GetEntries() < 50)
179 h1[
a][
b][
c][
x][
y]->Delete();
182 f1Gaus->SetParameters(
183 h1[a][b][c][
x][
y]->GetMaximum(),
184 h1[a][b][c][
x][
y]->GetMean(),
185 h1[a][b][c][
x][
y]->GetRMS()
187 h1[
a][
b][
c][
x][
y]->Fit(
188 f1Gaus->GetName(),
"QR0",
"",
189 h1[
a][
b][
c][
x][
y]->GetMean() - h1[
a][
b][
c][
x][
y]->GetRMS() * 3,
190 h1[
a][
b][
c][
x][
y]->GetMean() + h1[
a][
b][
c][
x][
y]->GetRMS() * 3
192 g1->SetPoint(g1->GetN(), (setE[
y]+setE[
y+1])/2, f1Gaus->GetParameter(2));
193 g1->SetPointError(g1->GetN()-1, 0, f1Gaus->GetParError(2));
196 c2->cd(
x+1)->SetGrid();
197 if (a==0 && b==0 && c==0)
199 const char *yTitle =
"#sigma (Reco e / True e)";
200 const char *gTitle = Form(
"%2.1f < #eta < %2.1f;True e;%s", setEta[
x],setEta[x+1], yTitle);
201 gPad->DrawFrame(20-5, 0.05, 200+5, 0.3, gTitle);
206 leg1->AddEntry(g1, Form(
"PYTHIA%i, #sqrt{s} = %i, R = 0.%i", setPy[a], setBeamE[b], setR[c]),
"p");
209 if (a==(nsetPy-1) && b==(nsetBeamE-1) && c==(nsetR-1) &&
x==0) leg1->Draw(
"same");
211 if (
print) c2->Print(Form(
"%s%s.png", c2->GetName(),suffix));
219 std::vector<int> jetList;
221 float event, gpt, var;
222 T->SetBranchAddress(
"event", &event);
223 if (strcmp(
"gpt", targetV))
225 T->SetBranchAddress(
"gpt", &gpt);
226 cout <<
"Search leading jets by using " <<targetV <<endl;
228 T->SetBranchAddress(targetV, &var);
237 const int allEntries = T->GetEntries();
238 for (
int a=0;
a<allEntries;
a++)
249 float tempPT = (strcmp(
"gpt", targetV))?gpt:var;
250 if (tempPT < cutPT)
continue;
252 if (evtCheck != event ||
a == allEntries)
254 if (high1_n != -1 && high2_n != -1)
256 if (high1_n < high2_n)
258 jetList.push_back(high1_n);
259 jetList.push_back(high2_n);
263 jetList.push_back(high2_n);
264 jetList.push_back(high1_n);
284 else if (var > high2_v)
292 T->ResetBranchAddresses();