16 #include <TGraphErrors.h>
18 #include <TGraphErrors.h>
19 #include <TMultiGraph.h>
34 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/column3_214x.txt")
36 std::map<int, float> runtoz;
67 TCanvas *c1 =
new TCanvas(
"c1",
"Vertical scan", 640, 480);
69 TLegend *
leg =
new TLegend(0.9122257, 0.6483516, 0.9968652, 0.9010989, NULL,
82 vector<float> v_dx[8];
83 vector<float> v_dy[8];
91 while (sumfile >> rn >> tower >> mpv >> dmpv)
94 cout << index <<
" " << rn <<
" " << runtoz[rn] <<
" " << mpv <<
" "
96 v_x[
index].push_back(runtoz[rn]);
97 v_dx[
index].push_back(0.2);
98 v_y[
index].push_back(mpv);
99 v_dy[
index].push_back(dmpv);
103 TMultiGraph *mg =
new TMultiGraph();
108 for (
int i = 0;
i < 8;
i++)
110 gr[
i] =
new TGraphErrors(v_x[
i].
size(), &v_x[
i][0], &v_y[i][0],
111 &v_dx[i][0], &v_dy[i][0]);
112 gr[
i]->SetMarkerStyle(marker);
113 gr[
i]->SetMarkerSize(0.4);
114 gr[
i]->SetLineColor(col);
115 gr[
i]->SetMarkerColor(col);
117 gr[
i]->GetFunction(
"expo")->SetLineColor(col);
119 vg_src.push_back((TGraphErrors *) gr[i]->Clone());
121 towername =
"Tower ";
123 leg->AddEntry(gr[i], towername,
"LP");
130 TString
title =
"Longitudinal EMCAL scan (";
134 mg->GetXaxis()->SetTitle(
"Vertical table position (mm)");
135 mg->GetYaxis()->SetTitle(
"MPV of 200 GeV p (ADC counts)");
146 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/getMeanRMS_Summary.root")
155 TCanvas *
c2 = (TCanvas *) _file0->Get(
"getMeanRMS_Summary");
162 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
164 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
166 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
168 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
170 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
172 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
174 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
176 (TGraphErrors *) c2->GetListOfPrimitives()->At(i++)->Clone());
180 TGraphErrors * g_final =
new TGraphErrors((
vg_src[0])->GetN());
181 g_final->SetMarkerSize(3);
182 g_final->SetMarkerStyle(kFullCircle);
183 g_final->SetMarkerColor(kBlue + 3);
184 g_final->SetFillColor(kWhite);
185 g_final->SetLineWidth(3);
186 g_final->SetFillStyle(0);
194 TF1 * f_att =
new TF1(
"f_att",
"(exp(-((13.9-x)/[0])))*[1]", 0, 20);
195 f_att->SetParameters(105, 1);
197 f_att->SetLineColor(kBlue + 3);
198 f_att->SetLineWidth(4);
200 const int N_rows = 8;
202 TGraphErrors * g_src =
vg_src[0];
204 for (
int j = 0;
j < (g_src->GetN()); ++
j)
208 (g_final->GetY())[
j] = 0;
209 (g_final->GetEY())[
j] = 0;
210 (g_final->GetEX())[
j] = 0;
211 (g_final->GetX())[
j] = (g_src->GetX())[
j] / 10 - 0.8;
214 for (
int i = 0; i < N_rows; ++
i)
218 TGraphErrors * g_src =
vg_src[
i];
223 g_src->DrawClone(
"ap*");
226 for (
int j = 0;
j < (g_src->GetN()); ++
j)
228 sum += (g_src->GetY())[
j];
230 double average = sum / g_src->GetN();
232 for (
int j = 0;
j < (g_src->GetN()); ++
j)
234 (g_src->GetY())[
j] /= average;
235 (g_src->GetEY())[
j] /= average;
237 (g_final->GetY())[
j] += (g_src->GetY())[
j];
238 (g_final->GetEY())[
j] += (g_src->GetEY())[
j] * (g_src->GetEY())[
j];
242 for (
int j = 0;
j < (g_src->GetN()); ++
j)
244 (g_final->GetY())[
j] /= N_rows;
245 (g_final->GetEY())[
j] = sqrt((g_final->GetEY())[
j]) / N_rows;
249 TCanvas *c1 =
new TCanvas(
"FitVerticalScan",
"FitVerticalScan", 1800, 650);
253 gPad->SetRightMargin(0.99);
254 gPad->SetLeftMargin(0.15);
255 gPad->SetBottomMargin(0.2);
257 TH1 * frame = gPad->DrawFrame(0, .9, 13.9, 1.1);
259 ";Beam position along the length of module (cm);MIP amplitude (A. U.)");
260 frame->GetXaxis()->SetTitleOffset(1);
261 frame->GetXaxis()->SetTitleSize(0.08);
262 frame->GetXaxis()->SetLabelSize(0.08);
263 frame->GetYaxis()->SetTitleOffset(.7);
264 frame->GetYaxis()->SetTitleSize(0.08);
265 frame->GetYaxis()->SetLabelSize(0.08);
266 frame->GetXaxis()->CenterTitle();
270 g_final->Fit(f_att,
"MR");
274 TLegend *
leg =
new TLegend(.15, .7, .8, .9);
275 leg->AddEntry(g_final,
"Data, Averaged over 8 towers",
"ep");
277 Form(
"Fit, C#timesExp[ -(13.9 - x) / L_{eff} ], L_{eff} = %.0f#pm%.0f cm",
278 f_att->GetParameter(0), f_att->GetParError(0)),
"l");
283 latex.SetTextSize(0.08);
284 latex.SetTextAlign(12);
285 latex.DrawLatex(0,0.92,
"#leftarrow Mirror side");
286 latex.SetTextAlign(32);
287 latex.DrawLatex(13.9,0.92,
"Lightguide side #rightarrow");
289 SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);