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 TH1F *h_mEnergy_pion_5GeV = (TH1F*)File_5GeV->Get(
"h_mEnergyOut_pion_ShowerCalib");
33 string input_8GeV =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_0422.root";
34 TFile *File_8GeV = TFile::Open(input_8GeV.c_str());
35 TH1F *h_mEnergy_pion_8GeV = (TH1F*)File_8GeV->Get(
"h_mEnergyOut_pion_ShowerCalib");
37 string input_12GeV =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_0571.root";
38 TFile *File_12GeV = TFile::Open(input_12GeV.c_str());
39 TH1F *h_mEnergy_pion_12GeV = (TH1F*)File_12GeV->Get(
"h_mEnergyOut_pion_ShowerCalib");
41 float mean_energy[4] = {5.0,8.0,12.0,60.0};
46 float val_resolution[4];
47 float err_resolution[4];
49 TCanvas *c_Energy =
new TCanvas(
"c_Energy",
"c_Energy",1500,500);
50 c_Energy->Divide(3,1);
51 for(
int i_pad = 0; i_pad < 3; ++i_pad)
53 c_Energy->cd(i_pad+1);
54 c_Energy->cd(i_pad+1)->SetLeftMargin(0.15);
55 c_Energy->cd(i_pad+1)->SetBottomMargin(0.15);
56 c_Energy->cd(i_pad+1)->SetTicks(1,1);
57 c_Energy->cd(i_pad+1)->SetGrid(0,0);
60 h_mEnergy_pion_5GeV->SetTitle(
"5 GeV");
61 h_mEnergy_pion_5GeV->GetXaxis()->SetTitle(
"Shower Calibrated Energy (GeV)");
62 h_mEnergy_pion_5GeV->Draw(
"hE");
63 TF1 *f_gaus_5GeV =
new TF1(
"f_gaus_5GeV",
"gaus",0,100);
64 f_gaus_5GeV->SetParameter(0,1.0);
65 f_gaus_5GeV->SetParameter(1,h_mEnergy_pion_5GeV->GetMean());
66 f_gaus_5GeV->SetParameter(2,1.0);
67 f_gaus_5GeV->SetRange(3.5,10.0);
68 h_mEnergy_pion_5GeV->Fit(f_gaus_5GeV,
"NR");
69 f_gaus_5GeV->SetLineColor(2);
70 f_gaus_5GeV->SetLineStyle(2);
71 f_gaus_5GeV->SetLineWidth(2);
72 f_gaus_5GeV->Draw(
"l same");
73 val_mean[0] = f_gaus_5GeV->GetParameter(1);
74 err_mean[0] = f_gaus_5GeV->GetParError(1);
75 val_sigma[0] = f_gaus_5GeV->GetParameter(2);
76 err_sigma[0] = f_gaus_5GeV->GetParError(2);
77 val_resolution[0] = val_sigma[0]/val_mean[0];
78 err_resolution[0] =
ErrDiv(val_sigma[0],val_mean[0],err_sigma[0],err_mean[0]);
81 h_mEnergy_pion_8GeV->SetTitle(
"8 GeV");
82 h_mEnergy_pion_8GeV->GetXaxis()->SetTitle(
"Shower Calibrated Energy (GeV)");
83 h_mEnergy_pion_8GeV->Draw(
"hE");
84 TF1 *f_gaus_8GeV =
new TF1(
"f_gaus_8GeV",
"gaus",0,100);
85 f_gaus_8GeV->SetParameter(0,1.0);
86 f_gaus_8GeV->SetParameter(1,h_mEnergy_pion_8GeV->GetMean());
87 f_gaus_8GeV->SetParameter(2,1.0);
88 f_gaus_8GeV->SetRange(3.0,14.2);
89 h_mEnergy_pion_8GeV->Fit(f_gaus_8GeV,
"NR");
90 f_gaus_8GeV->SetLineColor(2);
91 f_gaus_8GeV->SetLineStyle(2);
92 f_gaus_8GeV->SetLineWidth(2);
93 f_gaus_8GeV->Draw(
"l same");
94 val_mean[1] = f_gaus_8GeV->GetParameter(1);
95 err_mean[1] = f_gaus_8GeV->GetParError(1);
96 val_sigma[1] = f_gaus_8GeV->GetParameter(2);
97 err_sigma[1] = f_gaus_8GeV->GetParError(2);
98 val_resolution[1] = val_sigma[1]/val_mean[1];
99 err_resolution[1] =
ErrDiv(val_sigma[1],val_mean[1],err_sigma[1],err_mean[1]);
102 h_mEnergy_pion_12GeV->SetTitle(
"12 GeV");
103 h_mEnergy_pion_12GeV->GetXaxis()->SetTitle(
"Shower Calibrated Energy (GeV)");
104 h_mEnergy_pion_12GeV->Draw(
"hE");
105 TF1 *f_gaus_12GeV =
new TF1(
"f_gaus_12GeV",
"gaus",0,100);
106 f_gaus_12GeV->SetParameter(0,1.0);
107 f_gaus_12GeV->SetParameter(1,h_mEnergy_pion_12GeV->GetMean());
108 f_gaus_12GeV->SetParameter(2,1.0);
109 f_gaus_12GeV->SetRange(5.0,20.0);
110 h_mEnergy_pion_12GeV->Fit(f_gaus_12GeV,
"NR");
111 f_gaus_12GeV->SetLineColor(2);
112 f_gaus_12GeV->SetLineStyle(2);
113 f_gaus_12GeV->SetLineWidth(2);
114 f_gaus_12GeV->Draw(
"l same");
115 val_mean[2] = f_gaus_12GeV->GetParameter(1);
116 err_mean[2] = f_gaus_12GeV->GetParError(1);
117 val_sigma[2] = f_gaus_12GeV->GetParameter(2);
118 err_sigma[2] = f_gaus_12GeV->GetParError(2);
119 val_resolution[2] = val_sigma[2]/val_mean[2];
120 err_resolution[2] =
ErrDiv(val_sigma[2],val_mean[2],err_sigma[2],err_mean[2]);
122 c_Energy->SaveAs(
"../figures/HCAL_ShowerCalib/c_Energy_ShowerCalib_OHCAL.eps");
125 TGraphAsymmErrors *g_linearity =
new TGraphAsymmErrors();
126 for(
int i_point = 0; i_point < 3; ++i_point)
128 g_linearity->SetPoint(i_point,mean_energy[i_point],val_mean[i_point]);
129 g_linearity->SetPointError(i_point,0.0,0.0,err_mean[i_point],err_mean[i_point]);
132 TGraphAsymmErrors *g_linearity_old =
new TGraphAsymmErrors();
133 string inputlinearity =
"linearity.txt";
134 FILE *flinear = fopen(inputlinearity.c_str(),
"r");
137 perror(
"Error opening file!");
141 float x,
y, err_x_low, err_x_high, err_y_low, err_y_high;
143 int line_counter = 0;
144 while(fgets(line,1024,flinear))
146 sscanf(&line[0],
"%f %f %f %f %f %f", &x, &y, &err_x_low, &err_x_high, &err_y_low, &err_y_high);
148 g_linearity_old->SetPoint(line_counter,x,y);
149 g_linearity_old->SetPointError(line_counter,err_x_low,err_x_high,err_y_low,err_y_high);
154 TCanvas *c_Linearity =
new TCanvas(
"c_Linearity",
"c_Linearity",10,10,800,800);
156 c_Linearity->cd()->SetLeftMargin(0.15);
157 c_Linearity->cd()->SetBottomMargin(0.15);
158 c_Linearity->cd()->SetTicks(1,1);
159 c_Linearity->cd()->SetGrid(0,0);
161 TH1F *h_play =
new TH1F(
"h_play",
"h_play",100,0.0,100.0);
162 for(
int i_bin = 0; i_bin < 100; ++i_bin)
164 h_play->SetBinContent(i_bin+1,-10.0);
165 h_play->SetBinError(i_bin+1,1.0);
167 h_play->SetTitle(
"");
169 h_play->GetXaxis()->SetTitle(
"input Energy (GeV)");
170 h_play->GetXaxis()->CenterTitle();
171 h_play->GetXaxis()->SetNdivisions(505);
172 h_play->GetXaxis()->SetRangeUser(0.0,40.0);
174 h_play->GetYaxis()->SetTitle(
"Shower Calibrated Energy (GeV)");
175 h_play->GetYaxis()->CenterTitle();
176 h_play->GetYaxis()->SetRangeUser(0.0,40.0);
177 h_play->DrawCopy(
"pE");
179 g_linearity->SetMarkerStyle(20);
180 g_linearity->SetMarkerColor(kGray+2);
181 g_linearity->SetMarkerSize(2.0);
182 g_linearity->Draw(
"pE same");
184 g_linearity_old->SetMarkerStyle(21);
185 g_linearity_old->SetMarkerColor(2);
186 g_linearity_old->SetMarkerSize(1.8);
187 g_linearity_old->Draw(
"pE same");
201 TLine *l_unity =
new TLine(1.0,1.0,39.0,39.0);
202 l_unity->SetLineColor(4);
203 l_unity->SetLineStyle(2);
204 l_unity->SetLineWidth(2);
205 l_unity->Draw(
"l same");
207 TLegend *leg_linear =
new TLegend(0.2,0.6,0.5,0.8);
208 leg_linear->SetBorderSize(0);
209 leg_linear->SetFillColor(0);
210 leg_linear->AddEntry(g_linearity_old,
"#pi- T1044-2017",
"p");
211 leg_linear->AddEntry(g_linearity,
"#pi- T1044-2018",
"p");
212 leg_linear->AddEntry(l_unity,
"unity",
"l");
213 leg_linear->Draw(
"same");
215 c_Linearity->SaveAs(
"../figures/HCAL_ShowerCalib/c_Linearity_ShowerCalib_OHCAL.eps");
220 TGraphAsymmErrors *g_resolution =
new TGraphAsymmErrors();
221 for(
int i_point = 0; i_point < 3; ++i_point)
223 g_resolution->SetPoint(i_point,mean_energy[i_point],val_resolution[i_point]);
224 g_resolution->SetPointError(i_point,0.0,0.0,err_resolution[i_point],err_resolution[i_point]);
227 TGraphAsymmErrors *g_resolution_old =
new TGraphAsymmErrors();
228 string inputresolution =
"resolution.txt";
229 FILE *fres = fopen(inputresolution.c_str(),
"r");
232 perror(
"Error opening file!");
236 float x,
y, err_x_low, err_x_high, err_y_low, err_y_high;
238 int line_counter = 0;
239 while(fgets(line,1024,fres))
241 sscanf(&line[0],
"%f %f %f %f %f %f", &x, &y, &err_x_low, &err_x_high, &err_y_low, &err_y_high);
243 g_resolution_old->SetPoint(line_counter,x,y);
244 g_resolution_old->SetPointError(line_counter,err_x_low,err_x_high,err_y_low,err_y_high);
248 TCanvas *c_Resolution =
new TCanvas(
"c_Resolution",
"c_Resolution",10,10,800,800);
250 c_Resolution->cd()->SetLeftMargin(0.15);
251 c_Resolution->cd()->SetBottomMargin(0.15);
252 c_Resolution->cd()->SetTicks(1,1);
253 c_Resolution->cd()->SetGrid(0,0);
255 h_play->GetYaxis()->SetTitle(
"#DeltaE/<E>");
256 h_play->GetYaxis()->CenterTitle();
257 h_play->GetYaxis()->SetRangeUser(0.0,0.8);
258 h_play->DrawCopy(
"pE");
260 g_resolution->SetMarkerStyle(20);
261 g_resolution->SetMarkerColor(kGray+2);
262 g_resolution->SetMarkerSize(2.0);
263 g_resolution->Draw(
"pE same");
265 g_resolution_old->SetMarkerStyle(21);
266 g_resolution_old->SetMarkerColor(2);
267 g_resolution_old->SetMarkerSize(1.8);
268 g_resolution_old->Draw(
"pE same");
270 TLegend *leg_res =
new TLegend(0.55,0.6,0.85,0.8);
271 leg_res->SetBorderSize(0);
272 leg_res->SetFillColor(0);
273 leg_res->AddEntry(g_resolution_old,
"#pi- T1044-2017",
"p");
274 leg_res->AddEntry(g_resolution,
"#pi- T1044-2018",
"p");
275 leg_res->Draw(
"same");
277 c_Resolution->SaveAs(
"../figures/HCAL_ShowerCalib/c_Resolution_ShowerCalib_OHCAL.eps");
281 outputfile =
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/T1044_2018_pion_hcalout.root";
282 TFile *File_OutPut =
new TFile(outputfile.c_str(),
"RECREATE");
284 g_linearity->SetName(
"g_linearity_2018_pion_hcalout");
285 g_linearity->Write();
286 g_resolution->SetName(
"g_resolution_2018_pion_hcalout");
287 g_resolution->Write();
288 File_OutPut->Close();