4 void getX0(TString align_file)
7 gROOT->LoadMacro(
"fitfun.C");
13 TH1D *hPar2 =
new TH1D(
"Par2",
"",500,0., 5.);
14 TH1D *hPar3 =
new TH1D(
"Par3",
"",500,0., 1.);
16 Double_t a[M] = {0., 16., 20., 22., 26., 30., 32.};
21 TFile *fin =
new TFile(align_file.Data());
22 for(
int j=0;j<M;j++) {
24 sprintf(inhis,
"zLocal_%d",j);
25 zLocal2D[j] = (TH2D *)fin->Get(inhis);
26 zLocal2D[j]->RebinY(5);
27 for(
int i=0;i<N;i++) {
29 sprintf(hisname,
"Tray_%d_A_%d",i+1,j);
30 zLocal[i][j] = zLocal2D[j]->ProjectionY(hisname,i+1,i+1);
31 zLocal[i][j]->Sumw2();
35 TF1 *fitfun =
new TF1(
"fitfun",fitfun,-6.,6.,5);
38 double z0[N][M], ze[N][M];
40 gStyle->SetOptStat(101);
41 gStyle->SetOptFit(100);
42 gStyle->SetTextSize(0.06);
43 gStyle->SetTextFont(42);
44 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
50 TPostScript *ps =
new TPostScript(
"fig/xLocalFit.ps",112);
52 for(
int j=0;j<M;j++) {
53 for(
int i=0;i<N;i++) {
56 if(i%12==0) ps->NewPage();
59 double par[5], err[5];
60 fitfun->SetParameters(0., zLocal[i][j]->GetBinContent(50), 0.1, 1., 0.);
61 fitfun->SetLineWidth(2);
62 zLocal[i][j]->Draw(
"e");
63 double entries = zLocal[i][j]->Integral(1,100);
65 fitfun->SetParLimits(0, -3., 3.);
66 fitfun->SetParLimits(2, 2.9, 3.1);
67 fitfun->SetParLimits(3, 0.01, 0.16);
68 zLocal[i][j]->Fit(
"fitfun",
"R");
69 fitfun->GetParameters(&par[0]);
70 err[0] = fitfun->GetParError(0);
80 sprintf(text,
"Z0 = %5.3f #pm %5.3f", par[0], err[0]);
82 TLatex *tex =
new TLatex(-3, par[1]/3., text);
83 tex->SetTextSize(0.07);
94 gStyle->SetOptStat(0);
96 gStyle->SetEndErrorSize(0.01);
98 TF1 *fitangle =
new TF1(
"fitangle",
"[0]*sin(x*3.14159/180.)+[1]",-10.,40.);
100 double z00[N], ze0[N];
101 double z0F[N], zeF[N];
103 for(
int i=0;i<N;i++) {
105 if(i%12==0) ps->NewPage();
116 sprintf(title,
"Tray_%d",i+1);
117 TH1D *h0 =
new TH1D(
"h0",title,1, x1, x2);
120 h0->GetXaxis()->SetNdivisions(208);
121 h0->GetXaxis()->CenterTitle();
122 h0->GetXaxis()->SetTitle(
"Module Angle (deg)");
123 h0->GetXaxis()->SetTitleOffset(1.0);
124 h0->GetXaxis()->SetTitleSize(0.07);
125 h0->GetXaxis()->SetLabelOffset(0.01);
126 h0->GetXaxis()->SetLabelSize(0.045);
127 h0->GetXaxis()->SetLabelFont(42);
128 h0->GetXaxis()->SetTitleFont(42);
129 h0->GetYaxis()->SetNdivisions(210);
130 h0->GetYaxis()->SetTitle(
"zLocal Offset");
131 h0->GetYaxis()->SetTitleOffset(1.0);
132 h0->GetYaxis()->SetTitleSize(0.07);
133 h0->GetYaxis()->SetLabelOffset(0.01);
134 h0->GetYaxis()->SetLabelSize(0.045);
135 h0->GetYaxis()->SetLabelFont(42);
136 h0->GetYaxis()->SetTitleFont(42);
139 TGraphErrors *gr =
new TGraphErrors(M, a, z0[i], 0, ze[i]);
140 gr->SetMarkerStyle(24);
141 gr->SetMarkerSize(1.5);
145 fitangle->SetParameters(-0.5, 0.0);
146 gr->Fit(
"fitangle",
"R");
148 x0[i] = fitangle->GetParameter(0);
149 z0F[i] = fitangle->GetParameter(1);
150 xe[i] = fitangle->GetParError(0);
151 zeF[i] = fitangle->GetParError(1);
158 gStyle->SetOptStat(0);
159 gStyle->SetOptFit(0);
160 gStyle->SetEndErrorSize(0.01);
162 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
163 c1->SetFillColor(10);
164 c1->SetBorderMode(0);
165 c1->SetBorderSize(2);
166 c1->SetLeftMargin(0.14);
167 c1->SetBottomMargin(0.15);
168 c1->SetTopMargin(0.02);
169 c1->SetRightMargin(0.04);
176 TH1D *h0 =
new TH1D(
"h0",
"",1, x1, x2);
179 h0->GetXaxis()->SetNdivisions(208);
180 h0->GetXaxis()->CenterTitle();
181 h0->GetXaxis()->SetTitle(
"Tray #");
182 h0->GetXaxis()->SetTitleOffset(1.0);
183 h0->GetXaxis()->SetTitleSize(0.07);
184 h0->GetXaxis()->SetLabelOffset(0.01);
185 h0->GetXaxis()->SetLabelSize(0.05);
186 h0->GetXaxis()->SetLabelFont(42);
187 h0->GetXaxis()->SetTitleFont(42);
188 h0->GetYaxis()->SetNdivisions(210);
189 h0->GetYaxis()->SetTitle(
"zLocal Offset");
190 h0->GetYaxis()->SetTitleOffset(1.0);
191 h0->GetYaxis()->SetTitleSize(0.07);
192 h0->GetYaxis()->SetLabelOffset(0.01);
193 h0->GetYaxis()->SetLabelSize(0.045);
194 h0->GetYaxis()->SetLabelFont(42);
195 h0->GetYaxis()->SetTitleFont(42);
198 TLine *l1 =
new TLine(x1,y1,x2,y1);
201 TLine *l2 =
new TLine(x1,y2,x2,y2);
204 TLine *l3 =
new TLine(x1,y1,x1,y2);
207 TLine *l4 =
new TLine(x2,y1,x2,y2);
211 TGraphErrors *gr =
new TGraphErrors(N, t, z00, 0, ze0);
212 gr->SetMarkerStyle(20);
213 gr->SetMarkerSize(1.5);
217 TGraphErrors *gr =
new TGraphErrors(N, t, z0F, 0, zeF);
218 gr->SetMarkerStyle(24);
219 gr->SetMarkerSize(1.5);
227 gStyle->SetOptStat(0);
228 gStyle->SetOptFit(0);
229 gStyle->SetEndErrorSize(0.01);
231 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
232 c1->SetFillColor(10);
233 c1->SetBorderMode(0);
234 c1->SetBorderSize(2);
235 c1->SetLeftMargin(0.14);
236 c1->SetBottomMargin(0.15);
237 c1->SetTopMargin(0.02);
238 c1->SetRightMargin(0.04);
245 TH1D *h0 =
new TH1D(
"h0",
"",1, x1, x2);
248 h0->GetXaxis()->SetNdivisions(208);
249 h0->GetXaxis()->CenterTitle();
250 h0->GetXaxis()->SetTitle(
"Tray #");
251 h0->GetXaxis()->SetTitleOffset(1.0);
252 h0->GetXaxis()->SetTitleSize(0.07);
253 h0->GetXaxis()->SetLabelOffset(0.01);
254 h0->GetXaxis()->SetLabelSize(0.05);
255 h0->GetXaxis()->SetLabelFont(42);
256 h0->GetXaxis()->SetTitleFont(42);
257 h0->GetYaxis()->SetNdivisions(210);
258 h0->GetYaxis()->SetTitle(
"xLocal Offset");
259 h0->GetYaxis()->SetTitleOffset(1.0);
260 h0->GetYaxis()->SetTitleSize(0.07);
261 h0->GetYaxis()->SetLabelOffset(0.01);
262 h0->GetYaxis()->SetLabelSize(0.045);
263 h0->GetYaxis()->SetLabelFont(42);
264 h0->GetYaxis()->SetTitleFont(42);
267 TLine *l1 =
new TLine(x1,y1,x2,y1);
270 TLine *l2 =
new TLine(x1,y2,x2,y2);
273 TLine *l3 =
new TLine(x1,y1,x1,y2);
276 TLine *l4 =
new TLine(x2,y1,x2,y2);
280 TGraphErrors *gr =
new TGraphErrors(N, t, x0, 0, xe);
281 gr->SetMarkerStyle(20);
282 gr->SetMarkerSize(1.5);
291 outData.open(
"xOffset.dat");
292 for(
int i=0;i<N;i++) {
293 outData << setw(15) << z00[i] << setw(15) << ze0[i] << setw(15) << x0[i] << setw(15) << xe[i] << endl;
297 TFile *fout =
new TFile(
"xFitPar.root",
"recreate");