7 #include <TGraphErrors.h>
23 gStyle->SetOptStat(0);
25 TFile *fin =
new TFile(
"EnergyPosition2.root");
78 int NumX = (Xmax - Xmin)/step;
79 int NumY = (Ymax - Ymin)/step;
81 const int XBins = NumX;
83 const int YBins = NumY;
87 cout <<
"XBins = " << XBins << endl;
88 cout <<
"YBins = " << YBins << endl;
91 double value[XBins][YBins];
93 double finalvalue[XBins][YBins];
95 TH2D *Inter =
new TH2D(
"Inter",
"",XBins,Xmin,Xmax,YBins,Ymin,Ymax);
108 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
112 EnPo->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
113 EnPo->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
115 EnPo->SetTitle(
"Energy vs Horizontal and Vertical Positions Before Interpolation - 0 Degree");
127 c1->SaveAs(
"Before0Degree.png");
129 for(
int i = 0;
i < XBins;
i++)
135 for(
int j = 0;
j < YBins;
j++)
144 value[
i][
j] = EnPo->GetBinContent(
i,
j);
152 for(
int i = backward;
i < XBins - backward;
i++)
155 for(
int j = backward;
j < YBins - backward;
j++)
167 for(
int k = i - backward; k < i + forward +1; k++)
170 for(
int m = j - backward;
m < j+backward+1;
m++)
173 if(value[k][
m] > 0) NumberofValue = NumberofValue + 1;
175 Sum = Sum + value[
k][
m];
181 cout <<
"Number of Value = " << NumberofValue << endl;
183 cout <<
"Sum = " << Sum << endl;
185 if(NumberofValue > 0) finalvalue[
i][
j] = Sum/NumberofValue;
187 cout <<
" i = " << i <<
" j = " << j << endl;
188 cout <<
" Xnow = " << Xnow <<
" YNow = " << Ynow << endl;
190 cout <<
"Final Value is " << finalvalue[
i][
j] << endl;
195 Inter->SetBinContent(Xnow,Ynow,finalvalue[i][j]);
267 Inter->GetXaxis()->SetTitle(
"Horizontal Axis (mm)");
268 Inter->GetYaxis()->SetTitle(
"Vertical Axis (mm)");
269 Inter->SetTitle(
"Energy vs Horizontal and Vertical Positions After Interpolation - 0 Degree");
271 TFile *
fout =
new TFile(
"Interpolated2.root",
"RECREATE");
275 TCanvas *c22 =
new TCanvas(
"c22",
"c22",0,0,800,600);
279 Inter->SetMinimum(4.5);
281 Inter->SetMaximum(9);
290 TLine *
l1 =
new TLine(Xmin,y1,Xmax,y1);
296 texCol=
new TLatex(Xmin,y1,
"Row 6");
297 texCol->SetTextAlign(11);
298 texCol->SetTextSize(0.03);
299 texCol->SetTextFont(42);
306 TLine *
l2 =
new TLine(Xmin,y2,Xmax,y2);
312 texCol=
new TLatex(Xmin,y2,
"Row 5");
313 texCol->SetTextAlign(11);
314 texCol->SetTextSize(0.03);
315 texCol->SetTextFont(42);
321 TLine *l3 =
new TLine(Xmin,y3,Xmax,y3);
327 texCol=
new TLatex(Xmin,y3,
"Row 4");
328 texCol->SetTextAlign(11);
329 texCol->SetTextSize(0.03);
330 texCol->SetTextFont(42);
338 TLine *l4 =
new TLine(Xmin,y4,Xmax,y4);
344 texCol=
new TLatex(Xmin,y4,
"Row 3");
345 texCol->SetTextAlign(11);
346 texCol->SetTextSize(0.03);
347 texCol->SetTextFont(42);
353 TLine *l4 =
new TLine(Xmin,y5,Xmax,y5);
360 texCol=
new TLatex(Xmin,y5,
"Row 2");
361 texCol->SetTextAlign(11);
362 texCol->SetTextSize(0.03);
363 texCol->SetTextFont(42);
369 TLine *l12 =
new TLine(Xmax,Ymax,Xmax,Ymax);
370 l12->SetLineWidth(1);
375 texCol=
new TLatex(Xmin,-215,
"Row 1");
376 texCol->SetTextAlign(11);
377 texCol->SetTextSize(0.03);
378 texCol->SetTextFont(42);
384 TLine *l6 =
new TLine(x1,Ymin,x1,Ymax);
390 texCol=
new TLatex(x1,Ymin,
"Column 6");
391 texCol->SetTextAlign(11);
392 texCol->SetTextSize(0.03);
393 texCol->SetTextFont(42);
400 TLine *l7 =
new TLine(x2,Ymin,x2,Ymax);
406 texCol=
new TLatex(x2,Ymin,
"Column 5");
407 texCol->SetTextAlign(11);
408 texCol->SetTextSize(0.03);
409 texCol->SetTextFont(42);
415 TLine *l8 =
new TLine(x3,Ymin,x3,Ymax);
421 texCol=
new TLatex(x3,Ymin,
"Column 4");
422 texCol->SetTextAlign(11);
423 texCol->SetTextSize(0.03);
424 texCol->SetTextFont(42);
430 TLine *l9 =
new TLine(x4,Ymin,x4,Ymax);
436 texCol=
new TLatex(x4,Ymin,
"Column 3");
437 texCol->SetTextAlign(11);
438 texCol->SetTextSize(0.03);
439 texCol->SetTextFont(42);
446 TLine *l10 =
new TLine(x5,Ymin,x5,Ymax);
447 l10->SetLineWidth(1);
452 texCol=
new TLatex(x5,Ymin,
"Column 2");
453 texCol->SetTextAlign(11);
454 texCol->SetTextSize(0.03);
455 texCol->SetTextFont(42);
460 TLine *l11 =
new TLine(Xmax,Ymin,Xmax,Ymax);
461 l11->SetLineWidth(1);
466 texCol=
new TLatex(x5-8,Ymin,
"Column 1");
467 texCol->SetTextAlign(31);
468 texCol->SetTextSize(0.03);
469 texCol->SetTextFont(42);
476 c22->SaveAs(
"Interpolation 0 Degree Reversed.png");