7 #include <TGraphErrors.h>
23 gStyle->SetOptStat(0);
25 TFile *fin =
new TFile(
"EnergyPosition3.root");
66 int NumX = (Xmax - Xmin)/step;
67 int NumY = (Ymax - Ymin)/step;
69 const int XBins = NumX;
71 const int YBins = NumY;
75 cout <<
"XBins = " << XBins << endl;
76 cout <<
"YBins = " << YBins << endl;
79 double value[XBins][YBins];
81 double finalvalue[XBins][YBins];
83 TH2D *Inter =
new TH2D(
"Inter",
"",XBins,Xmin,Xmax,YBins,Ymin,Ymax);
96 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
100 EnPo->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
101 EnPo->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
103 EnPo->SetTitle(
"Energy vs Horizontal and Vertical Positions Before Interpolation - 0 Degree");
115 c1->SaveAs(
"Before0Degree.png");
117 for(
int i = 0;
i < XBins;
i++)
123 for(
int j = 0;
j < YBins;
j++)
132 value[
i][
j] = EnPo->GetBinContent(
i,
j);
140 for(
int i = backward;
i < XBins - backward;
i++)
143 for(
int j = backward;
j < YBins - backward;
j++)
155 for(
int k = i - backward; k < i + forward +1; k++)
158 for(
int m = j - backward;
m < j+backward+1;
m++)
161 if(value[k][
m] > 0) NumberofValue = NumberofValue + 1;
163 Sum = Sum + value[
k][
m];
169 cout <<
"Number of Value = " << NumberofValue << endl;
171 cout <<
"Sum = " << Sum << endl;
173 if(NumberofValue > 0) finalvalue[
i][
j] = Sum/NumberofValue;
175 cout <<
" i = " << i <<
" j = " << j << endl;
176 cout <<
" Xnow = " << Xnow <<
" YNow = " << Ynow << endl;
178 cout <<
"Final Value is " << finalvalue[
i][
j] << endl;
183 Inter->SetBinContent(Xnow,Ynow,finalvalue[i][j]);
255 Inter->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
256 Inter->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
257 Inter->SetTitle(
"Energy vs Horizontal and Vertical Positions After Interpolation - 0 Degree");
259 TFile *
fout =
new TFile(
"Interpolated2.root",
"RECREATE");
263 TCanvas *c22 =
new TCanvas(
"c22",
"c22",0,0,800,600);
267 Inter->SetMinimum(3.5);
269 Inter->SetMaximum(9);
278 TLine *
l1 =
new TLine(Xmin,y1,Xmax,y1);
284 texCol=
new TLatex(Xmin,y1,
"Row 6");
285 texCol->SetTextAlign(11);
286 texCol->SetTextSize(0.03);
287 texCol->SetTextFont(42);
294 TLine *
l2 =
new TLine(Xmin,y2,Xmax,y2);
300 texCol=
new TLatex(Xmin,y2,
"Row 5");
301 texCol->SetTextAlign(11);
302 texCol->SetTextSize(0.03);
303 texCol->SetTextFont(42);
309 TLine *l3 =
new TLine(Xmin,y3,Xmax,y3);
315 texCol=
new TLatex(Xmin,y3,
"Row 4");
316 texCol->SetTextAlign(11);
317 texCol->SetTextSize(0.03);
318 texCol->SetTextFont(42);
326 TLine *l4 =
new TLine(Xmin,y4,Xmax,y4);
332 texCol=
new TLatex(Xmin,y4,
"Row 3");
333 texCol->SetTextAlign(11);
334 texCol->SetTextSize(0.03);
335 texCol->SetTextFont(42);
341 TLine *l4 =
new TLine(Xmin,y5,Xmax,y5);
348 texCol=
new TLatex(Xmin,y5,
"Row 2");
349 texCol->SetTextAlign(11);
350 texCol->SetTextSize(0.03);
351 texCol->SetTextFont(42);
357 TLine *l12 =
new TLine(Xmax,Ymax,Xmax,Ymax);
358 l12->SetLineWidth(1);
363 texCol=
new TLatex(Xmin,-215,
"Row 1");
364 texCol->SetTextAlign(11);
365 texCol->SetTextSize(0.03);
366 texCol->SetTextFont(42);
372 TLine *l6 =
new TLine(x1,Ymin,x1,Ymax);
378 texCol=
new TLatex(x1,Ymin,
"Column 6");
379 texCol->SetTextAlign(11);
380 texCol->SetTextSize(0.03);
381 texCol->SetTextFont(42);
388 TLine *l7 =
new TLine(x2,Ymin,x2,Ymax);
394 texCol=
new TLatex(x2,Ymin,
"Column 5");
395 texCol->SetTextAlign(11);
396 texCol->SetTextSize(0.03);
397 texCol->SetTextFont(42);
403 TLine *l8 =
new TLine(x3,Ymin,x3,Ymax);
409 texCol=
new TLatex(x3,Ymin,
"Column 4");
410 texCol->SetTextAlign(11);
411 texCol->SetTextSize(0.03);
412 texCol->SetTextFont(42);
418 TLine *l9 =
new TLine(x4,Ymin,x4,Ymax);
424 texCol=
new TLatex(x4,Ymin,
"Column 3");
425 texCol->SetTextAlign(11);
426 texCol->SetTextSize(0.03);
427 texCol->SetTextFont(42);
434 TLine *l10 =
new TLine(x5,Ymin,x5,Ymax);
435 l10->SetLineWidth(1);
440 texCol=
new TLatex(x5,Ymin,
"Column 2");
441 texCol->SetTextAlign(11);
442 texCol->SetTextSize(0.03);
443 texCol->SetTextFont(42);
448 TLine *l11 =
new TLine(Xmax,Ymin,Xmax,Ymax);
449 l11->SetLineWidth(1);
454 texCol=
new TLatex(x5-8,Ymin,
"Column 1");
455 texCol->SetTextAlign(31);
456 texCol->SetTextSize(0.03);
457 texCol->SetTextFont(42);
464 c22->SaveAs(
"Interpolation 0 Degree Reversed.png");