7 #include <TGraphErrors.h>
23 gStyle->SetOptStat(0);
25 TFile *fin =
new TFile(
"EnergyPosition3.root");
65 int NumX = (Xmax - Xmin)/step;
66 int NumY = (Ymax - Ymin)/step;
68 const int XBins = NumX;
70 const int YBins = NumY;
74 cout <<
"XBins = " << XBins << endl;
75 cout <<
"YBins = " << YBins << endl;
78 double value[XBins][YBins];
80 double finalvalue[XBins][YBins];
82 TH2D *Inter =
new TH2D(
"Inter",
"",XBins,Xmin,Xmax,YBins,Ymin,Ymax);
97 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
101 EnPo->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
102 EnPo->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
104 EnPo->SetTitle(
"Energy vs Horizontal and Vertical Positions Before Interpolation - 0 Degree");
109 c1->SaveAs(
"Before0Degree.png");
111 for(
int i = 0;
i < XBins;
i++)
117 for(
int j = 0;
j < YBins;
j++)
126 value[
i][
j] = EnPo->GetBinContent(
i,
j);
133 for(
int i = backward;
i < XBins - backward;
i++)
136 for(
int j = backward;
j < YBins - backward;
j++)
148 for(
int k = i - backward; k < i + forward +1; k++)
151 for(
int m = j - backward;
m < j+backward+1;
m++)
154 if(value[k][
m] > 0) NumberofValue = NumberofValue + 1;
156 Sum = Sum + value[
k][
m];
162 cout <<
"Number of Value = " << NumberofValue << endl;
164 cout <<
"Sum = " << Sum << endl;
166 if(NumberofValue > 0) finalvalue[
i][
j] = Sum/NumberofValue;
168 cout <<
" i = " << i <<
" j = " << j << endl;
169 cout <<
" Xnow = " << Xnow <<
" YNow = " << Ynow << endl;
171 cout <<
"Final Value is " << finalvalue[
i][
j] << endl;
176 Inter->SetBinContent(Xnow,Ynow,finalvalue[i][j]);
248 Inter->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
249 Inter->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
250 Inter->SetTitle(
"Energy vs Horizontal and Vertical Positions After Interpolation - 0 Degree");
252 TFile *
fout =
new TFile(
"Interpolated2.root",
"RECREATE");
270 double initial = -191;
271 double inteval = -12.5;
273 for(
int i=0;
i < All;
i++)
275 TCanvas *c22 =
new TCanvas(
"c22",
"c22",0,0,800,600);
277 Inter->SetMinimum(3.5);
278 Inter->SetMaximum(9.0);
282 left = initial + inteval *
i - 5;
283 right = initial + inteval * i + 5;
285 TLine *
l1 =
new TLine(left,Ymin,left,Ymax);
290 TLine *
l2 =
new TLine(right,Ymin,right,Ymax);
293 sprintf(Outname,
"Result/VerticalPlot%d.png",i);
297 c22->SaveAs(Outname);
303 for(
int i=0;
i < HAll;
i++)
305 TCanvas *c22 =
new TCanvas(
"c22",
"c22",0,0,800,600);
307 Inter->SetMinimum(3.5);
308 Inter->SetMaximum(9.0);
312 left = initial + inteval *
i - 5;
313 right = initial + inteval * i + 5;
315 TLine *
l1 =
new TLine(Xmin,left,Xmax,left);
320 TLine *
l2 =
new TLine(Xmin,right,Xmax,right);
323 sprintf(Outname,
"Result/HorizontalPlot%d.png",i);
327 c22->SaveAs(Outname);