7 #include <TGraphErrors.h>
23 gStyle->SetOptStat(0);
25 TFile *fin =
new TFile(
"EnergyPosition3.root");
64 int NumX = (Xmax - Xmin)/step;
65 int NumY = (Ymax - Ymin)/step;
67 const int XBins = NumX;
69 const int YBins = NumY;
73 cout <<
"XBins = " << XBins << endl;
74 cout <<
"YBins = " << YBins << endl;
77 double value[XBins][YBins];
79 double finalvalue[XBins][YBins];
81 TH2D *Inter =
new TH2D(
"Inter",
"",XBins,Xmin,Xmax,YBins,Ymin,Ymax);
94 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
98 EnPo->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
99 EnPo->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
101 EnPo->SetTitle(
"Energy vs Horizontal and Vertical Positions Before Interpolation - 0 Degree");
106 c1->SaveAs(
"Before0Degree.png");
108 for(
int i = 0;
i < XBins;
i++)
114 for(
int j = 0;
j < YBins;
j++)
123 value[
i][
j] = EnPo->GetBinContent(
i,
j);
131 for(
int i = backward;
i < XBins - backward;
i++)
134 for(
int j = backward;
j < YBins - backward;
j++)
141 for(
int k =
i - backward; k <
i + forward +1; k++)
144 for(
int m =
j - backward;
m <
j+backward+1;
m++)
147 if(value[k][
m] > 0) NumberofValue = NumberofValue + 1;
149 Sum = Sum + value[
k][
m];
155 cout <<
"Number of Value = " << NumberofValue << endl;
157 cout <<
"Sum = " << Sum << endl;
159 if(NumberofValue > 0) finalvalue[
i][
j] = Sum/NumberofValue;
161 cout <<
" i = " <<
i <<
" j = " <<
j << endl;
163 cout <<
"Final Value is " << finalvalue[
i][
j] << endl;
166 Inter->SetBinContent(
i,
j,finalvalue[
i][
j]);
239 Inter->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
240 Inter->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
241 Inter->SetTitle(
"Energy vs Horizontal and Vertical Positions After Interpolation - 0 Degree");
243 TFile *
fout =
new TFile(
"Interpolated2.root",
"RECREATE");
247 TCanvas *c22 =
new TCanvas(
"c22",
"c22",0,0,800,600);
258 TLine *
l1 =
new TLine(Xmin,y1,Xmax,y1);
264 texCol=
new TLatex(Xmin,y1,
"Tower 1");
265 texCol->SetTextAlign(13);
266 texCol->SetTextSize(0.03);
267 texCol->SetTextFont(42);
274 TLine *
l2 =
new TLine(Xmin,y2,Xmax,y2);
280 texCol=
new TLatex(Xmin,y2,
"Tower 2");
281 texCol->SetTextAlign(13);
282 texCol->SetTextSize(0.03);
283 texCol->SetTextFont(42);
289 TLine *l3 =
new TLine(Xmin,y3,Xmax,y3);
295 texCol=
new TLatex(Xmin,y3,
"Tower 3");
296 texCol->SetTextAlign(13);
297 texCol->SetTextSize(0.03);
298 texCol->SetTextFont(42);
306 TLine *l4 =
new TLine(Xmin,y4,Xmax,y4);
312 texCol=
new TLatex(Xmin,y4,
"Tower 4");
313 texCol->SetTextAlign(13);
314 texCol->SetTextSize(0.03);
315 texCol->SetTextFont(42);
321 TLine *l4 =
new TLine(Xmin,y5,Xmax,y5);
328 texCol=
new TLatex(Xmin,y5,
"Tower 5");
329 texCol->SetTextAlign(13);
330 texCol->SetTextSize(0.03);
331 texCol->SetTextFont(42);
338 TLine *l6 =
new TLine(x1,Ymin,x1,Ymax);
344 texCol=
new TLatex(x1,Ymax,
"Tower 1");
345 texCol->SetTextAlign(33);
346 texCol->SetTextSize(0.03);
347 texCol->SetTextFont(42);
354 TLine *l7 =
new TLine(x2,Ymin,x2,Ymax);
360 texCol=
new TLatex(x2,Ymax,
"Tower 2");
361 texCol->SetTextAlign(33);
362 texCol->SetTextSize(0.03);
363 texCol->SetTextFont(42);
369 TLine *l8 =
new TLine(x3,Ymin,x3,Ymax);
375 texCol=
new TLatex(x3,Ymax,
"Tower 3");
376 texCol->SetTextAlign(33);
377 texCol->SetTextSize(0.03);
378 texCol->SetTextFont(42);
384 TLine *l9 =
new TLine(x4,Ymin,x4,Ymax);
390 texCol=
new TLatex(x4,Ymax,
"Tower 4");
391 texCol->SetTextAlign(33);
392 texCol->SetTextSize(0.03);
393 texCol->SetTextFont(42);
400 TLine *l10 =
new TLine(x5,Ymin,x5,Ymax);
401 l10->SetLineWidth(1);
406 texCol=
new TLatex(x5,Ymax,
"Tower 5");
407 texCol->SetTextAlign(33);
408 texCol->SetTextSize(0.03);
409 texCol->SetTextFont(42);
416 c22->SaveAs(
"Interpolation 0 Degree.png");