8 #include <TGraphAsymmErrors.h>
29 string inputenergy[4] = {
"5GeV",
"8GeV",
"12GeV",
"60GeV"};
30 string runId[4] = {
"1087",
"0422",
"0571",
"0821"};
31 float mean_energy[4] = {5.0,8.0,12.0,60.0};
33 TH2F *h_mAsymmEnergy_pion[4];
34 TH1F *h_mMIPEnergy_pion[4];
37 for(
int i_energy = 0; i_energy < 4; ++i_energy)
39 string inputfile = Form(
"/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_%s.root",runId[i_energy].c_str());
40 File_InPut[i_energy] = TFile::Open(inputfile.c_str());
41 h_mAsymmEnergy_pion[i_energy] = (TH2F*)File_InPut[i_energy]->
Get(
"h_mAsymmEnergy_pion");
42 h_mMIPEnergy_pion[i_energy] = (TH1F*)h_mAsymmEnergy_pion[i_energy]->
ProjectionY()->Clone();
48 TCanvas *c_MIPEnergy =
new TCanvas(
"c_MIPEnergy",
"c_MIPEnergy",1500,500);
49 c_MIPEnergy->Divide(3,1);
50 for(
int i_pad = 0; i_pad < 3; ++i_pad)
52 c_MIPEnergy->cd(i_pad+1);
53 c_MIPEnergy->cd(i_pad+1)->SetLeftMargin(0.15);
54 c_MIPEnergy->cd(i_pad+1)->SetBottomMargin(0.15);
55 c_MIPEnergy->cd(i_pad+1)->SetTicks(1,1);
56 c_MIPEnergy->cd(i_pad+1)->SetGrid(0,0);
57 h_mMIPEnergy_pion[i_pad]->SetTitle(inputenergy[i_pad].c_str());
58 h_mMIPEnergy_pion[i_pad]->GetXaxis()->SetTitle(
"Tower Calibrated Energy (GeV)");
59 h_mMIPEnergy_pion[i_pad]->Draw(
"hE");
60 string FuncName = Form(
"f_gaus_MIP_%d",i_pad);
61 f_gaus_MIP[i_pad] =
new TF1(FuncName.c_str(),
"gaus",0,5);
62 f_gaus_MIP[i_pad]->SetParameter(0,1.0);
63 f_gaus_MIP[i_pad]->SetParameter(1,1.0);
64 f_gaus_MIP[i_pad]->SetParameter(2,0.1);
65 f_gaus_MIP[i_pad]->SetRange(0.4,0.9);
66 h_mMIPEnergy_pion[i_pad]->Fit(f_gaus_MIP[i_pad],
"NQR");
67 f_gaus_MIP[i_pad]->SetLineColor(2);
68 f_gaus_MIP[i_pad]->SetLineStyle(2);
69 f_gaus_MIP[i_pad]->SetLineWidth(2);
70 f_gaus_MIP[i_pad]->Draw(
"l same");
71 MIP_mean[i_pad] = f_gaus_MIP[i_pad]->GetParameter(1);
72 MIP_width[i_pad] = f_gaus_MIP[i_pad]->GetParameter(2);
73 cout <<
"MIP for " << inputenergy[i_pad] <<
" is: " << MIP_mean[i_pad] <<
" +/- " << MIP_width[i_pad] << endl;
77 cout <<
"default MIP for all energy chosen to be " << inputenergy[i_MIP] <<
" is: " << MIP_mean[i_MIP] <<
" +/- " << MIP_width[i_MIP] << endl;
79 ofstream File_OutPut(
"MIPEnergy.txt");
80 File_OutPut <<
"default MIP at " << inputenergy[i_MIP] <<
" is: " << MIP_mean[i_MIP] <<
" +/- " << MIP_width[i_MIP] << endl;
83 c_MIPEnergy->SaveAs(
"../figures/HCAL_ShowerCalib/c_MIPEnergy.eps");
91 float Reco_resolution[4];
92 float err_resolution[4];
93 TCanvas *c_RecoEnergy =
new TCanvas(
"c_RecoEnergy",
"c_RecoEnergy",1500,500);
94 c_RecoEnergy->Divide(3,1);
95 for(
int i_pad = 0; i_pad < 3; ++i_pad)
97 c_RecoEnergy->cd(i_pad+1);
98 c_RecoEnergy->cd(i_pad+1)->SetLeftMargin(0.15);
99 c_RecoEnergy->cd(i_pad+1)->SetBottomMargin(0.15);
100 c_RecoEnergy->cd(i_pad+1)->SetTicks(1,1);
101 c_RecoEnergy->cd(i_pad+1)->SetGrid(0,0);
102 h_mMIPEnergy_pion[i_pad]->Draw(
"hE");
104 string FuncName = Form(
"f_gaus_Reco_%d",i_pad);
105 f_gaus_Reco[i_pad] =
new TF1(FuncName.c_str(),
"gaus",0,100);
106 f_gaus_Reco[i_pad]->SetParameter(0,1.0);
107 f_gaus_Reco[i_pad]->SetParameter(1,mean_energy[i_pad]/3.0);
108 f_gaus_Reco[i_pad]->SetParameter(2,1.0);
109 f_gaus_Reco[i_pad]->SetRange(MIP_mean[i_MIP]+2.0*MIP_width[i_MIP],0.5*mean_energy[i_pad]);
110 h_mMIPEnergy_pion[i_pad]->Fit(f_gaus_Reco[i_pad],
"NQR");
111 f_gaus_Reco[i_pad]->SetLineColor(2);
112 f_gaus_Reco[i_pad]->SetLineStyle(2);
113 f_gaus_Reco[i_pad]->SetLineWidth(2);
114 f_gaus_Reco[i_pad]->Draw(
"l same");
116 Reco_mean[i_pad] = f_gaus_Reco[i_pad]->GetParameter(1);
117 err_mean[i_pad] = f_gaus_Reco[i_pad]->GetParError(1);
118 Reco_width[i_pad] = f_gaus_Reco[i_pad]->GetParameter(2);
119 err_width[i_pad] = f_gaus_Reco[i_pad]->GetParError(2);
120 cout <<
"Reco for " << inputenergy[i_pad] <<
" is: " << Reco_mean[i_pad] <<
" +/- " << Reco_width[i_pad] << endl;
122 Reco_resolution[i_pad] = Reco_width[i_pad]/Reco_mean[i_pad];
123 err_resolution[i_pad] =
ErrDiv(Reco_width[i_pad],Reco_mean[i_pad],err_width[i_pad],err_mean[i_pad]);
126 TGraphAsymmErrors *g_lieanrity =
new TGraphAsymmErrors();
127 TGraphAsymmErrors *g_resolution =
new TGraphAsymmErrors();
128 for(
int i_point = 0; i_point < 3; ++i_point)
130 g_lieanrity->SetPoint(i_point,mean_energy[i_point],Reco_mean[i_point]);
131 g_lieanrity->SetPointError(i_point,0.0,0.0,err_mean[i_point],err_mean[i_point]);
133 g_resolution->SetPoint(i_point,mean_energy[i_point],Reco_resolution[i_point]);
134 g_resolution->SetPointError(i_point,0.0,0.0,err_resolution[i_point],err_resolution[i_point]);
137 TCanvas *c_Linearity =
new TCanvas(
"c_Linearity",
"c_Linearity",10,10,800,800);
139 c_Linearity->cd()->SetLeftMargin(0.15);
140 c_Linearity->cd()->SetBottomMargin(0.15);
141 c_Linearity->cd()->SetTicks(1,1);
142 c_Linearity->cd()->SetGrid(0,0);
144 TH1F *h_play =
new TH1F(
"h_play",
"h_play",100,0.0,100.0);
145 for(
int i_bin = 0; i_bin < 100; ++i_bin)
147 h_play->SetBinContent(i_bin+1,-10.0);
148 h_play->SetBinError(i_bin+1,1.0);
150 h_play->SetTitle(
"");
152 h_play->GetXaxis()->SetTitle(
"input Energy (GeV)");
153 h_play->GetXaxis()->CenterTitle();
154 h_play->GetXaxis()->SetNdivisions(505);
155 h_play->GetXaxis()->SetRangeUser(0.0,20.0);
157 h_play->GetYaxis()->SetTitle(
"Tower Calibrated Energy (GeV)");
158 h_play->GetYaxis()->CenterTitle();
159 h_play->GetYaxis()->SetRangeUser(0.0,10.0);
160 h_play->DrawCopy(
"pE");
162 g_lieanrity->SetMarkerStyle(24);
163 g_lieanrity->SetMarkerColor(2);
164 g_lieanrity->SetMarkerSize(1.2);
165 g_lieanrity->Draw(
"PE same");
167 TF1 *f_pol =
new TF1(
"f_pol",
"pol1",0.0,20.0);
168 f_pol->SetParameter(0,0.0);
169 f_pol->SetParameter(1,1.0);
170 f_pol->SetRange(0.0,20.0);
171 g_lieanrity->Fit(f_pol,
"NR");
172 f_pol->SetLineColor(2);
173 f_pol->SetLineStyle(2);
174 f_pol->SetLineWidth(2);
175 f_pol->Draw(
"l same");
177 TGraphAsymmErrors *g_resolution_old =
new TGraphAsymmErrors();
178 string inputresolution =
"resolution.txt";
179 FILE *fres = fopen(inputresolution.c_str(),
"r");
182 perror(
"Error opening file!");
186 float x,
y, err_x_low, err_x_high, err_y_low, err_y_high;
188 int line_counter = 0;
189 while(fgets(line,1024,fres))
191 sscanf(&line[0],
"%f %f %f %f %f %f", &x, &y, &err_x_low, &err_x_high, &err_y_low, &err_y_high);
193 g_resolution_old->SetPoint(line_counter,x,y);
194 g_resolution_old->SetPointError(line_counter,err_x_low,err_x_high,err_y_low,err_y_high);
198 TCanvas *c_Resolution =
new TCanvas(
"c_Resolution",
"c_Resolution",10,10,800,800);
200 c_Resolution->cd()->SetLeftMargin(0.15);
201 c_Resolution->cd()->SetBottomMargin(0.15);
202 c_Resolution->cd()->SetTicks(1,1);
203 c_Resolution->cd()->SetGrid(0,0);
205 h_play->GetYaxis()->SetTitle(
"#DeltaE/<E>");
206 h_play->GetYaxis()->CenterTitle();
207 h_play->GetYaxis()->SetRangeUser(0.0,0.8);
208 h_play->DrawCopy(
"pE");
210 g_resolution->SetMarkerStyle(20);
211 g_resolution->SetMarkerColor(kGray+2);
212 g_resolution->SetMarkerSize(2.0);
213 g_resolution->Draw(
"pE same");
215 g_resolution_old->SetMarkerStyle(21);
216 g_resolution_old->SetMarkerColor(2);
217 g_resolution_old->SetMarkerSize(1.8);
218 g_resolution_old->Draw(
"pE same");
220 TLegend *leg_res =
new TLegend(0.55,0.6,0.85,0.8);
221 leg_res->SetBorderSize(0);
222 leg_res->SetFillColor(0);
223 leg_res->AddEntry(g_resolution_old,
"#pi- T1044-2017",
"p");
224 leg_res->AddEntry(g_resolution,
"#pi- T1044-2018",
"p");
225 leg_res->Draw(
"same");