7 #include <TGraphErrors.h>
9 #include "SaveCanvas.C"
10 #include "SetOKStyle.C"
33 gSystem->Load(
"libg4eval.so");
34 gSystem->Load(
"libqa_modules.so");
35 gSystem->Load(
"libPrototype3.so");
37 gStyle->SetOptStat(0);
79 int XBins = (Xmax - Xmin)/step;
80 int YBins = (Ymax - Ymin)/step;
88 int indexmax = XBins * YBins;
94 sprintf(inputfile,
"His2.root");
97 TFile *fin =
new TFile(inputfile);
98 TH2D *EnPo=
new TH2D(
"EnPo",
"",XBins,Xmin,Xmax,YBins,Ymin,Ymax);
100 TF1 *
f1 =
new TF1(
"f1",
"gaus",6,11);
101 cout <<
"XBins = " << XBins << endl;
102 cout <<
"YBins = " << YBins << endl;
106 for(
int i = 0;
i < XBins;
i++)
111 xhigh = Xmin + step*(i+1);
114 for(
int j = 0;
j < YBins;
j++)
117 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
119 yhigh = Ymin + step*(j+1);
124 binx = Energyhis->GetXaxis()->FindBin(x+0.0001);
125 biny = Energyhis->GetYaxis()->FindBin(y+0.0001);
132 binxhigh = Energyhis->GetXaxis()->FindBin(xhigh-0.0001);
133 binyhigh = Energyhis->GetYaxis()->FindBin(yhigh-0.0001);
136 TH1D *h5=
new TH1D(
"h5",
"",25,4,10);
141 h5 = Energyhis->ProjectionZ(
"h5",binx,binxhigh,biny,binyhigh);
156 average = h5->GetMean();
167 Energy = f1->GetParameter(0);
168 Energy_err = f1->GetParError(0);
169 Center = f1->GetParameter(1);
170 Center_err = f1->GetParError(1);
171 Width = f1->GetParameter(2);
172 Width_err = f1->GetParError(2);
181 if(Center > 11 || Center < 4){
183 cout <<
"Old Center = " << Center << endl;
186 Center = h5->GetMean();
188 cout <<
"New Center = " << Center << endl;
193 if(5.5 < Center < 6.5){
198 sprintf(Name,
"EMCAL -10 Degree Energy Distribution in x = %d mm and y = %d mm ",x,y)
199 h5->GetXaxis()->SetTitle(
"Energy (GeV)");
200 h5->GetYaxis()->SetTitle(
"Counts");
205 sprintf(hisname,
"pngfiles/Plot%d-%d.png",x,y);
213 if(average < 1) Center = 0;
222 if(Method == 0) Center = h5->GetMean();
225 cout <<
"Mean = " << Center << endl;
227 EnPo->SetBinContent(binx,biny,Center);
236 TCanvas *c22 =
new TCanvas(
"c22",
"c22",0,0,800,600);
244 c22->SaveAs(
"EnPo.png");
249 sprintf(Filename,
"EnergyPosition2.root");
252 TFile *
fout =
new TFile(Filename,
"RECREATE");