17 #include <TGraphErrors.h>
27 "/gpfs/mnt/gpfs02/sphenix/user/jinhuang/Prototype_2016/Production_0417_CEMC_MIP_set2_v3/",
28 TString cut =
"col1_row2_5x5_Valid_HODO_center_col1_row2")
31 gStyle->SetOptStat(0);
33 TVirtualFitter::SetDefaultFitter(
"Minuit2");
37 { 2, 3, 4, 8, 12, 16 };
39 { 2042, 2040, 2039, 2038, 2067, 2063 };
46 for (
int i = 0;
i <
N; ++
i)
48 const double E = Es[
i];
57 dres[
i] = v[3] / v[0];
59 cout <<
"mean[i] = " << mean[
i] <<
", "
60 <<
"dmean[i] = " << dmean[
i] <<
", "
61 <<
"res[i] = " << res[
i] <<
", "
62 <<
"dres[i] = " << dres[
i] << endl;
65 TGraphErrors * ge_linear =
new TGraphErrors(N, Es, mean, 0, dmean);
66 TGraphErrors * ge_res =
new TGraphErrors(N, Es, res, 0, dres);
68 ge_linear->SetLineColor(kBlue + 3);
69 ge_linear->SetMarkerColor(kBlue + 3);
70 ge_linear->SetLineWidth(2);
71 ge_linear->SetMarkerStyle(kFullCircle);
72 ge_linear->SetMarkerSize(1.5);
74 ge_res->SetLineColor(kBlue + 3);
75 ge_res->SetMarkerColor(kBlue + 3);
76 ge_res->SetLineWidth(2);
77 ge_res->SetMarkerStyle(kFullCircle);
78 ge_res->SetMarkerSize(1.5);
80 TF1 * f_calo_r =
new TF1(
"f_calo_r",
"sqrt([0]*[0]+[1]*[1]/x)/100", 0.5, 25);
81 TF1 * f_calo_l =
new TF1(
"f_calo_l",
"pol2", 0.5, 25);
83 TF1 * f_calo_sim =
new TF1(
"f_calo_sim",
"sqrt([0]*[0]+[1]*[1]/x)/100", 0.5,
85 f_calo_sim->SetParameters(2.4, 11.8);
86 f_calo_sim->SetLineWidth(1);
87 f_calo_sim->SetLineColor(kGreen + 2);
89 TF1 * f_calo_l_sim =
new TF1(
"f_calo_l_sim",
"pol2", 0.5, 25);
90 f_calo_l_sim->SetParameters(-0.03389, 0.9666, -0.0002822);
91 f_calo_l_sim->SetLineWidth(1);
92 f_calo_l_sim->SetLineColor(kGreen + 2);
95 TCanvas *c1 =
new TCanvas(
96 Form(
"DrawPrototype2EMCalTower_Resolution_Run%.0f_", runs[0]) + cut,
97 Form(
"DrawPrototype2EMCalTower_Resolution_Run%.0f_", runs[0]) + cut, 1300,
103 p = (TPad *) c1->cd(idx++);
109 p->DrawFrame(0, 0, 25, 30,
110 Form(
"Linearity;Input energy (GeV);Measured Energy (GeV)",
E));
111 TLine * l =
new TLine(0, 0, 25, 25);
112 l->SetLineColor(kGray);
115 ge_linear->Draw(
"p");
116 ge_linear->Fit(f_calo_l,
"RM0");
117 f_calo_l->Draw(
"same");
118 f_calo_l_sim->Draw(
"same");
120 p = (TPad *) c1->cd(idx++);
126 TH1 * hframe = p->DrawFrame(0, 0, 25, 0.2,
127 Form(
"Resolution;Input energy (GeV);#DeltaE/<E>",
E));
130 ge_res->Fit(f_calo_r,
"RM0");
131 f_calo_r->Draw(
"same");
132 f_calo_sim->Draw(
"same");
135 Form(
"#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}",
136 f_calo_r->GetParameter(0), f_calo_r->GetParameter(1)));
138 SaveCanvas(c1, base + TString(c1->GetName()), kTRUE);
150 "/beam_0000%d-0000_DSTReader.root_DrawPrototype2EMCalTower_EMCDistribution_SUM_Energy_Sum_",
151 run) + cut +
".root";
154 cout <<
"Process " << fname << endl;
155 TFile *
f =
new TFile(fname);
158 TH1 * hEnergySum = (TH1 *) f->GetObjectChecked(
"EnergySum_LG",
"TH1");
161 TH1 *
h = hEnergySum->DrawClone();
163 hEnergySum->Scale(1. / hEnergySum->Integral(1, -1));
167 TF1 * fgaus_g =
new TF1(
"fgaus_LG_g",
"gaus", h->GetMean() - 1 * h->GetRMS(),
168 h->GetMean() + 4 * h->GetRMS());
169 fgaus_g->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
170 h->GetMean() + 2 * h->GetRMS());
171 h->Fit(fgaus_g,
"MR0N");
173 TF1 * fgaus =
new TF1(
"fgaus_LG",
"gaus",
174 fgaus_g->GetParameter(1) - 2 * fgaus_g->GetParameter(2),
175 fgaus_g->GetParameter(1) + 2 * fgaus_g->GetParameter(2));
176 fgaus->SetParameters(fgaus_g->GetParameter(0), fgaus_g->GetParameter(1),
177 fgaus_g->GetParameter(2));
178 fgaus->SetLineColor(kRed);
179 fgaus->SetLineWidth(4);
183 v[0] = fgaus->GetParameter(1);
184 v[1] = fgaus->GetParError(1);
185 v[2] = fgaus->GetParameter(2);
186 v[3] = fgaus->GetParError(2);