7 #include <TGraphErrors.h>
23 gStyle->SetOptStat(0);
25 TFile *fin =
new TFile(
"EnergyPosition2.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 - 10 Degree");
252 TFile *
fout =
new TFile(
"Interpolated2.root",
"RECREATE");
267 double inteval = -12.5;
302 double initial = -77;
304 for(
int i=0;
i < HAll;
i++)
306 TCanvas *c22 =
new TCanvas(
"c22",
"c22",0,0,800,600);
308 Inter->SetMinimum(3.5);
309 Inter->SetMaximum(9.0);
313 left = initial + inteval *
i - 5;
314 right = initial + inteval * i + 5;
321 TLine *
l2 =
new TLine(Xmin,right,Xmax,right);
324 sprintf(Outname,
"Result2/HorizontalPlot%d.png",i);
328 c22->SaveAs(Outname);