4 void getY0(TString align_file)
7 gROOT->LoadMacro(
"fitfun.C");
12 TH1D *hPar2 =
new TH1D(
"Par2",
"",500,0., 5.);
13 TH1D *hPar3 =
new TH1D(
"Par3",
"",500,0., 1.);
15 TFile *fin =
new TFile(align_file.Data());
16 TH2D *yLocal2D = (TH2D *)fin->Get(
"yLocal_all");
19 for(
int i=0;i<N;i++) {
21 sprintf(hisname,
"Tray_%d",i+1);
22 yLocal[i] = yLocal2D->ProjectionY(hisname,i+1,i+1);
26 TF1 *fitfun =
new TF1(
"fitfun",fitfun,-5.,5.,5);
31 gStyle->SetOptStat(101);
32 gStyle->SetOptFit(100);
33 gStyle->SetTextSize(0.06);
34 gStyle->SetTextFont(42);
35 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
41 TPostScript *ps =
new TPostScript(
"fig/yLocalFit.ps",112);
43 for(
int i=0;i<N;i++) {
46 if(i%12==0) ps->NewPage();
49 double par[5], err[5];
50 fitfun->SetParameters(0., yLocal[i]->GetBinContent(50), 0.1, 1., 0.);
51 fitfun->SetLineWidth(2);
53 double entries = yLocal[i]->Integral(1,100);
55 fitfun->SetParLimits(2, 1.55, 1.7);
56 fitfun->SetParLimits(3, 0.1, 0.3);
57 yLocal[i]->Fit(
"fitfun",
"R");
58 fitfun->GetParameters(&par[0]);
59 err[0] = fitfun->GetParError(0);
69 sprintf(text,
"Y0 = %5.3f #pm %5.3f", par[0], err[0]);
71 TLatex *tex =
new TLatex(-3, par[1]/3., text);
72 tex->SetTextSize(0.07);
84 gStyle->SetOptStat(0);
86 gStyle->SetEndErrorSize(0.01);
88 TCanvas *c1 =
new TCanvas(
"c1",
"c1",0,0,800,600);
92 c1->SetLeftMargin(0.14);
93 c1->SetBottomMargin(0.15);
94 c1->SetTopMargin(0.02);
95 c1->SetRightMargin(0.04);
102 TH1D *h0 =
new TH1D(
"h0",
"",1, x1, x2);
105 h0->GetXaxis()->SetNdivisions(208);
106 h0->GetXaxis()->CenterTitle();
107 h0->GetXaxis()->SetTitle(
"Tray #");
108 h0->GetXaxis()->SetTitleOffset(1.0);
109 h0->GetXaxis()->SetTitleSize(0.07);
110 h0->GetXaxis()->SetLabelOffset(0.01);
111 h0->GetXaxis()->SetLabelSize(0.05);
112 h0->GetXaxis()->SetLabelFont(42);
113 h0->GetXaxis()->SetTitleFont(42);
114 h0->GetYaxis()->SetNdivisions(210);
115 h0->GetYaxis()->SetTitle(
"yLocal Offset");
116 h0->GetYaxis()->SetTitleOffset(1.0);
117 h0->GetYaxis()->SetTitleSize(0.07);
118 h0->GetYaxis()->SetLabelOffset(0.01);
119 h0->GetYaxis()->SetLabelSize(0.045);
120 h0->GetYaxis()->SetLabelFont(42);
121 h0->GetYaxis()->SetTitleFont(42);
124 TLine *l1 =
new TLine(x1,y1,x2,y1);
127 TLine *l2 =
new TLine(x1,y2,x2,y2);
130 TLine *l3 =
new TLine(x1,y1,x1,y2);
133 TLine *l4 =
new TLine(x2,y1,x2,y2);
137 TGraphErrors *gr =
new TGraphErrors(N, t, y0, 0, ye);
138 gr->SetMarkerStyle(20);
139 gr->SetMarkerSize(1.5);
148 outData.open(
"yOffset.dat");
149 for(
int i=0;i<N;i++) {
150 outData << setw(15) << y0[i] << setw(15) << ye[i] << endl;
154 TFile *fout =
new TFile(
"yFitPar.root",
"recreate");