8 #include <TGraphAsymmErrors.h>
29 string input_5GeV =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_1087.root";
30 TFile *File_5GeV = TFile::Open(input_5GeV.c_str());
31 TH2F *h_mAsymmEnergy_pion_5GeV = (TH2F*)File_5GeV->Get(
"h_mAsymmEnergy_pion_ShowerCalib");
32 TH1F *h_mEnergy_pion_5GeV = (TH1F*)h_mAsymmEnergy_pion_5GeV->ProjectionY()->Clone();
34 string input_8GeV =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_0422.root";
35 TFile *File_8GeV = TFile::Open(input_8GeV.c_str());
36 TH2F *h_mAsymmEnergy_pion_8GeV = (TH2F*)File_8GeV->Get(
"h_mAsymmEnergy_pion_ShowerCalib");
37 TH1F *h_mEnergy_pion_8GeV = (TH1F*)h_mAsymmEnergy_pion_8GeV->ProjectionY()->Clone();
39 string input_12GeV =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_0571.root";
40 TFile *File_12GeV = TFile::Open(input_12GeV.c_str());
41 TH2F *h_mAsymmEnergy_pion_12GeV = (TH2F*)File_12GeV->Get(
"h_mAsymmEnergy_pion_ShowerCalib");
42 TH1F *h_mEnergy_pion_12GeV = (TH1F*)h_mAsymmEnergy_pion_12GeV->ProjectionY()->Clone();
44 string input_60GeV =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_0821.root";
45 TFile *File_60GeV = TFile::Open(input_60GeV.c_str());
46 TH2F *h_mAsymmEnergy_pion_60GeV = (TH2F*)File_60GeV->Get(
"h_mAsymmEnergy_pion_ShowerCalib");
47 TH1F *h_mEnergy_pion_60GeV = (TH1F*)h_mAsymmEnergy_pion_60GeV->ProjectionY()->Clone();
49 TCanvas *c_AsymmEnergy =
new TCanvas(
"c_AsymmEnergy",
"c_AsymmEnergy",1600,400);
50 c_AsymmEnergy->Divide(4,1);
51 for(
int i_pad = 0; i_pad < 4; ++i_pad)
53 c_AsymmEnergy->cd(i_pad+1);
54 c_AsymmEnergy->cd(i_pad+1)->SetLeftMargin(0.15);
55 c_AsymmEnergy->cd(i_pad+1)->SetBottomMargin(0.15);
56 c_AsymmEnergy->cd(i_pad+1)->SetTicks(1,1);
57 c_AsymmEnergy->cd(i_pad+1)->SetGrid(0,0);
60 h_mAsymmEnergy_pion_5GeV->Draw(
"colz");
61 h_mAsymmEnergy_pion_5GeV->ProfileX(
"p_mAsymmEnergy_pion_5GeV",1,-1,
"i");
62 p_mAsymmEnergy_pion_5GeV->SetMarkerStyle(20);
63 p_mAsymmEnergy_pion_5GeV->SetMarkerColor(1);
64 p_mAsymmEnergy_pion_5GeV->SetMarkerSize(1.0);
68 h_mAsymmEnergy_pion_8GeV->Draw(
"colz");
69 h_mAsymmEnergy_pion_8GeV->ProfileX(
"p_mAsymmEnergy_pion_8GeV",1,-1,
"i");
70 p_mAsymmEnergy_pion_8GeV->SetMarkerStyle(20);
71 p_mAsymmEnergy_pion_8GeV->SetMarkerColor(1);
72 p_mAsymmEnergy_pion_8GeV->SetMarkerSize(1.0);
76 h_mAsymmEnergy_pion_12GeV->Draw(
"colz");
77 h_mAsymmEnergy_pion_12GeV->ProfileX(
"p_mAsymmEnergy_pion_12GeV",1,-1,
"i");
78 p_mAsymmEnergy_pion_12GeV->SetMarkerStyle(20);
79 p_mAsymmEnergy_pion_12GeV->SetMarkerColor(1);
80 p_mAsymmEnergy_pion_12GeV->SetMarkerSize(1.0);
84 h_mAsymmEnergy_pion_60GeV->Draw(
"colz");
85 h_mAsymmEnergy_pion_60GeV->ProfileX(
"p_mAsymmEnergy_pion_60GeV",1,-1,
"i");
86 p_mAsymmEnergy_pion_60GeV->SetMarkerStyle(20);
87 p_mAsymmEnergy_pion_60GeV->SetMarkerColor(1);
88 p_mAsymmEnergy_pion_60GeV->SetMarkerSize(1.0);
91 c_AsymmEnergy->SaveAs(
"../figures/HCAL_ShowerCalib/c_AsymmEnergy_ShowerCalib.eps");
93 float mean_energy[4] = {5.0,8.0,12.0,60.0};
98 float val_resolution[4];
99 float err_resolution[4];
101 TCanvas *c_Energy =
new TCanvas(
"c_Energy",
"c_Energy",1600,400);
102 c_Energy->Divide(4,1);
103 for(
int i_pad = 0; i_pad < 4; ++i_pad)
105 c_Energy->cd(i_pad+1);
106 c_Energy->cd(i_pad+1)->SetLeftMargin(0.15);
107 c_Energy->cd(i_pad+1)->SetBottomMargin(0.15);
108 c_Energy->cd(i_pad+1)->SetTicks(1,1);
109 c_Energy->cd(i_pad+1)->SetGrid(0,0);
112 h_mEnergy_pion_5GeV->Draw(
"hE");
113 TF1 *f_gaus_5GeV =
new TF1(
"f_gaus_5GeV",
"gaus",0,100);
114 f_gaus_5GeV->SetParameter(0,1.0);
115 f_gaus_5GeV->SetParameter(1,h_mEnergy_pion_5GeV->GetMean());
116 f_gaus_5GeV->SetParameter(2,1.0);
117 f_gaus_5GeV->SetRange(3.5,10.0);
118 h_mEnergy_pion_5GeV->Fit(f_gaus_5GeV,
"NR");
119 f_gaus_5GeV->SetLineColor(2);
120 f_gaus_5GeV->SetLineStyle(2);
121 f_gaus_5GeV->SetLineWidth(2);
122 f_gaus_5GeV->Draw(
"l same");
123 val_mean[0] = f_gaus_5GeV->GetParameter(1);
124 err_mean[0] = f_gaus_5GeV->GetParError(1);
125 val_sigma[0] = f_gaus_5GeV->GetParameter(2);
126 err_sigma[0] = f_gaus_5GeV->GetParError(2);
127 val_resolution[0] = val_sigma[0]/val_mean[0];
128 err_resolution[0] =
ErrDiv(val_sigma[0],val_mean[0],err_sigma[0],err_mean[0]);
131 h_mEnergy_pion_8GeV->Draw(
"hE");
132 TF1 *f_gaus_8GeV =
new TF1(
"f_gaus_8GeV",
"gaus",0,100);
133 f_gaus_8GeV->SetParameter(0,1.0);
134 f_gaus_8GeV->SetParameter(1,h_mEnergy_pion_8GeV->GetMean());
135 f_gaus_8GeV->SetParameter(2,1.0);
136 f_gaus_8GeV->SetRange(3.0,14.2);
137 h_mEnergy_pion_8GeV->Fit(f_gaus_8GeV,
"NR");
138 f_gaus_8GeV->SetLineColor(2);
139 f_gaus_8GeV->SetLineStyle(2);
140 f_gaus_8GeV->SetLineWidth(2);
141 f_gaus_8GeV->Draw(
"l same");
142 val_mean[1] = f_gaus_8GeV->GetParameter(1);
143 err_mean[1] = f_gaus_8GeV->GetParError(1);
144 val_sigma[1] = f_gaus_8GeV->GetParameter(2);
145 err_sigma[1] = f_gaus_8GeV->GetParError(2);
146 val_resolution[1] = val_sigma[1]/val_mean[1];
147 err_resolution[1] =
ErrDiv(val_sigma[1],val_mean[1],err_sigma[1],err_mean[1]);
150 h_mEnergy_pion_12GeV->Draw(
"hE");
151 TF1 *f_gaus_12GeV =
new TF1(
"f_gaus_12GeV",
"gaus",0,100);
152 f_gaus_12GeV->SetParameter(0,1.0);
153 f_gaus_12GeV->SetParameter(1,h_mEnergy_pion_12GeV->GetMean());
154 f_gaus_12GeV->SetParameter(2,1.0);
155 f_gaus_12GeV->SetRange(5.0,20.0);
156 h_mEnergy_pion_12GeV->Fit(f_gaus_12GeV,
"NR");
157 f_gaus_12GeV->SetLineColor(2);
158 f_gaus_12GeV->SetLineStyle(2);
159 f_gaus_12GeV->SetLineWidth(2);
160 f_gaus_12GeV->Draw(
"l same");
161 val_mean[2] = f_gaus_12GeV->GetParameter(1);
162 err_mean[2] = f_gaus_12GeV->GetParError(1);
163 val_sigma[2] = f_gaus_12GeV->GetParameter(2);
164 err_sigma[2] = f_gaus_12GeV->GetParError(2);
165 val_resolution[2] = val_sigma[2]/val_mean[2];
166 err_resolution[2] =
ErrDiv(val_sigma[2],val_mean[2],err_sigma[2],err_mean[2]);
169 h_mEnergy_pion_60GeV->Draw(
"hE");
170 TF1 *f_gaus_60GeV =
new TF1(
"f_gaus_60GeV",
"gaus",0,100);
171 f_gaus_60GeV->SetParameter(0,1.0);
172 f_gaus_60GeV->SetParameter(1,h_mEnergy_pion_60GeV->GetMean());
173 f_gaus_60GeV->SetParameter(2,1.0);
174 f_gaus_60GeV->SetRange(20.2,80.2);
175 h_mEnergy_pion_60GeV->Fit(f_gaus_60GeV,
"NR");
176 f_gaus_60GeV->SetLineColor(2);
177 f_gaus_60GeV->SetLineStyle(2);
178 f_gaus_60GeV->SetLineWidth(2);
179 f_gaus_60GeV->Draw(
"l same");
180 val_mean[3] = f_gaus_60GeV->GetParameter(1);
181 err_mean[3] = f_gaus_60GeV->GetParError(1);
182 val_sigma[3] = f_gaus_60GeV->GetParameter(2);
183 err_sigma[3] = f_gaus_60GeV->GetParError(2);
184 val_resolution[3] = val_sigma[3]/val_mean[3];
185 err_resolution[3] =
ErrDiv(val_sigma[3],val_mean[3],err_sigma[3],err_mean[3]);
187 c_Energy->SaveAs(
"../figures/HCAL_ShowerCalib/c_Energy_ShowerCalib.eps");
190 TGraphAsymmErrors *g_linearity =
new TGraphAsymmErrors();
191 for(
int i_point = 0; i_point < 4; ++i_point)
193 g_linearity->SetPoint(i_point,mean_energy[i_point],val_mean[i_point]);
194 g_linearity->SetPointError(i_point,0.0,0.0,err_mean[i_point],err_mean[i_point]);
197 TGraphAsymmErrors *g_linearity_old =
new TGraphAsymmErrors();
198 string inputlinearity =
"linearity.txt";
199 FILE *flinear = fopen(inputlinearity.c_str(),
"r");
202 perror(
"Error opening file!");
206 float x,
y, err_x_low, err_x_high, err_y_low, err_y_high;
208 int line_counter = 0;
209 while(fgets(line,1024,flinear))
211 sscanf(&line[0],
"%f %f %f %f %f %f", &x, &y, &err_x_low, &err_x_high, &err_y_low, &err_y_high);
213 g_linearity_old->SetPoint(line_counter,x,y);
214 g_linearity_old->SetPointError(line_counter,err_x_low,err_x_high,err_y_low,err_y_high);
219 TCanvas *c_Linearity =
new TCanvas(
"c_Linearity",
"c_Linearity",10,10,800,800);
221 c_Linearity->cd()->SetLeftMargin(0.15);
222 c_Linearity->cd()->SetBottomMargin(0.15);
223 c_Linearity->cd()->SetTicks(1,1);
224 c_Linearity->cd()->SetGrid(0,0);
226 TH1F *h_play =
new TH1F(
"h_play",
"h_play",100,0.0,100.0);
227 for(
int i_bin = 0; i_bin < 100; ++i_bin)
229 h_play->SetBinContent(i_bin+1,-10.0);
230 h_play->SetBinError(i_bin+1,1.0);
232 h_play->SetTitle(
"");
234 h_play->GetXaxis()->SetTitle(
"input Energy (GeV)");
235 h_play->GetXaxis()->CenterTitle();
236 h_play->GetXaxis()->SetNdivisions(505);
237 h_play->GetXaxis()->SetRangeUser(0.0,80.0);
239 h_play->GetYaxis()->SetTitle(
"Tower Calibrated Energy (GeV)");
240 h_play->GetYaxis()->CenterTitle();
241 h_play->GetYaxis()->SetRangeUser(0.0,80.0);
242 h_play->DrawCopy(
"pE");
244 g_linearity->SetMarkerStyle(20);
245 g_linearity->SetMarkerColor(kGray+2);
246 g_linearity->SetMarkerSize(2.0);
247 g_linearity->Draw(
"pE same");
249 g_linearity_old->SetMarkerStyle(21);
250 g_linearity_old->SetMarkerColor(2);
251 g_linearity_old->SetMarkerSize(1.8);
252 g_linearity_old->Draw(
"pE same");
266 TLine *l_unity =
new TLine(1.0,1.0,79.0,79.0);
267 l_unity->SetLineColor(4);
268 l_unity->SetLineStyle(2);
269 l_unity->SetLineWidth(2);
270 l_unity->Draw(
"l same");
272 TLegend *leg_linear =
new TLegend(0.2,0.6,0.5,0.8);
273 leg_linear->SetBorderSize(0);
274 leg_linear->SetFillColor(0);
275 leg_linear->AddEntry(g_linearity_old,
"#pi- T1044-2017",
"p");
276 leg_linear->AddEntry(g_linearity,
"#pi- T1044-2018",
"p");
277 leg_linear->AddEntry(l_unity,
"unity",
"l");
278 leg_linear->Draw(
"same");
280 c_Linearity->SaveAs(
"../figures/HCAL_ShowerCalib/c_Linearity_ShowerCalib.eps");
285 TGraphAsymmErrors *g_resolution =
new TGraphAsymmErrors();
286 for(
int i_point = 0; i_point < 4; ++i_point)
288 g_resolution->SetPoint(i_point,mean_energy[i_point],val_resolution[i_point]);
289 g_resolution->SetPointError(i_point,0.0,0.0,err_resolution[i_point],err_resolution[i_point]);
292 TGraphAsymmErrors *g_resolution_old =
new TGraphAsymmErrors();
293 string inputresolution =
"resolution.txt";
294 FILE *fres = fopen(inputresolution.c_str(),
"r");
297 perror(
"Error opening file!");
301 float x,
y, err_x_low, err_x_high, err_y_low, err_y_high;
303 int line_counter = 0;
304 while(fgets(line,1024,fres))
306 sscanf(&line[0],
"%f %f %f %f %f %f", &x, &y, &err_x_low, &err_x_high, &err_y_low, &err_y_high);
308 g_resolution_old->SetPoint(line_counter,x,y);
309 g_resolution_old->SetPointError(line_counter,err_x_low,err_x_high,err_y_low,err_y_high);
313 TCanvas *c_Resolution =
new TCanvas(
"c_Resolution",
"c_Resolution",10,10,800,800);
315 c_Resolution->cd()->SetLeftMargin(0.15);
316 c_Resolution->cd()->SetBottomMargin(0.15);
317 c_Resolution->cd()->SetTicks(1,1);
318 c_Resolution->cd()->SetGrid(0,0);
320 h_play->GetYaxis()->SetTitle(
"#DeltaE/<E>");
321 h_play->GetYaxis()->CenterTitle();
322 h_play->GetYaxis()->SetRangeUser(0.0,0.8);
323 h_play->DrawCopy(
"pE");
325 g_resolution->SetMarkerStyle(20);
326 g_resolution->SetMarkerColor(kGray+2);
327 g_resolution->SetMarkerSize(2.0);
328 g_resolution->Draw(
"pE same");
330 g_resolution_old->SetMarkerStyle(21);
331 g_resolution_old->SetMarkerColor(2);
332 g_resolution_old->SetMarkerSize(1.8);
333 g_resolution_old->Draw(
"pE same");
335 TLegend *leg_res =
new TLegend(0.55,0.6,0.85,0.8);
336 leg_res->SetBorderSize(0);
337 leg_res->SetFillColor(0);
338 leg_res->AddEntry(g_resolution_old,
"#pi- T1044-2017",
"p");
339 leg_res->AddEntry(g_resolution,
"#pi- T1044-2018",
"p");
340 leg_res->Draw(
"same");
342 c_Resolution->SaveAs(
"../figures/HCAL_ShowerCalib/c_Resolution_ShowerCalib.eps");
346 outputfile =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/T1044_2018_pion.root";
347 TFile *File_OutPut =
new TFile(outputfile.c_str(),
"RECREATE");
349 g_linearity->SetName(
"g_linearity_2018_pion");
350 g_linearity->Write();
351 g_resolution->SetName(
"g_resolution_2018_pion");
352 g_resolution->Write();
353 File_OutPut->Close();
355 outputfile =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/T1044_2017_pion.root";
356 TFile *File_OutPut_old =
new TFile(outputfile.c_str(),
"RECREATE");
357 File_OutPut_old->cd();
358 g_linearity_old->SetName(
"g_linearity_2017_pion");
359 g_linearity_old->Write();
360 g_resolution_old->SetName(
"g_resolution_2017_pion");
361 g_resolution_old->Write();
362 File_OutPut_old->Close();