1 /// \file testEdgeFit.C
4 /// .L $ALICE_ROOT/TPC/fastSimul/testEdgeFit.C+
10 #include "TLinearFitter.h"
18 #include "TTreeStream.h"
19 //#include "TVectorD.h"
22 void testEdge(Int_t ntest){
24 TTreeSRedirector *cstream = new TTreeSRedirector("testEdge.root");
47 for (Int_t it=0; it<ntest;it++){
49 ymc0 = gRandom->Rndm()*1;
50 kx = gRandom->Rndm()*1.;
51 npoints = TMath::Nint(gRandom->Rndm()*50);
52 vecX.ResizeTo(npoints);
53 vecY0.ResizeTo(npoints);
54 vecYC.ResizeTo(npoints);
55 vecYT.ResizeTo(npoints);
57 vecYTa.ResizeTo(npoints);
58 vecYTb.ResizeTo(npoints);
59 vecYEa.ResizeTo(npoints);
60 vecYEb.ResizeTo(npoints);
61 vecU.ResizeTo(npoints);
63 TLinearFitter fitter(2,"pol1");
64 for (Int_t ipoint=npoints-1;ipoint>0;ipoint--){
67 x[0]=(Double_t)(ipoint)*0.2;
68 Double_t y0 = ymc0+Double_t(x[0])*kx;
69 Double_t yc = y0+gRandom->Gaus()*sy;
79 fitter.AddPoint(x,yc,sy);
80 if (fitter.GetNpoints()>4){
82 fitter.GetErrors(vecE);
83 vecYTa[ipoint]=fitter.GetParameter(0);
84 vecYTb[ipoint]=fitter.GetParameter(1);
85 vecYEa[ipoint]=vecE[0];
86 vecYEb[ipoint]=vecE[1];
87 vecU[ipoint]=fitter.GetNpoints();
88 vecYT[ipoint]=fitter.GetParameter(0)+fitter.GetParameter(1)*x[0];
111 TFile f("testEdge.root");
112 TTree * tree = (TTree*)f.Get("Dump");
113 TObjArray arrfdy0,arrfdyT;
114 TH2F *phisdY0 = new TH2F("hisdY0","hisdY0",25,1,3,200,-3,3);
115 TH2F *phisdYT = new TH2F("hisdYT","hisdYT",25,1,3,200,-3,3);
116 tree->Draw("10*(vYT.fElements-vY0.fElements):vY0.fElements>>hisdY0","vU.fElements>20&&kx>0.1","colz");
117 phisdY0->SetDirectory(0);
118 tree->Draw("10*(vYT.fElements-vY0.fElements):vYT.fElements>>hisdYT","vU.fElements>20&&kx>0.1","colz");
119 phisdYT->SetDirectory(0);
121 phisdY0->FitSlicesY(0,0,-1,0,"QNR",&arrfdy0);
122 phisdYT->FitSlicesY(0,0,-1,0,"QNR",&arrfdyT);
124 TH1 *hisdy0 = (TH1*)arrfdy0.At(1);
125 TH1 *hisdyT = (TH1*)arrfdyT.At(1);
126 hisdy0->SetLineColor(1);
127 hisdyT->SetLineColor(2);
128 hisdy0->SetMarkerColor(1);
129 hisdyT->SetMarkerColor(2);
130 hisdy0->SetMarkerStyle(22);
131 hisdyT->SetMarkerStyle(24);
132 hisdyT->SetXTitle("Y (cm)");
133 hisdyT->SetYTitle("Y_{t}-Y_{mc} (mm)");
134 hisdyT->SetMinimum(-hisdyT->GetMaximum());
136 hisdy0->Draw("same");
137 TLegend *legend = new TLegend(0.25,0.60,0.85,0.85, "Track residuals close to edge (Edge= 1 cm, #sigma_{cl}=0.25 cm)");
138 legend->AddEntry(hisdy0,"Y=Y_{mc}");
139 legend->AddEntry(hisdyT,"Y=Y_{t}");
141 gPad->SaveAs("picEdge/dYedgeMC.eps");
142 gPad->SaveAs("picEdge/dYedgeMC.gif");
146 TFile f("testEdge.root");
147 TTree * tree = (TTree*)f.Get("Dump");
148 TObjArray arrfdky0,arrfdkyT;
149 TH2F *phisdKY0 = new TH2F("hisdKY0","hisdKY0",25,1,3,200,-150,150);
150 TH2F *phisdKYT = new TH2F("hisdKYT","hisdKYT",25,1,3,200,-150,150);
151 tree->Draw("1000*(vYTb.fElements-kx):vY0.fElements>>hisdKY0","vU.fElements>20","colz");
152 phisdKY0->SetDirectory(0);
153 tree->Draw("1000*(vYTb.fElements-kx):vYT.fElements>>hisdKYT","vU.fElements>20","colz");
154 phisdKYT->SetDirectory(0);
156 phisdKY0->FitSlicesY(0,0,-1,0,"QNR",&arrfdky0);
157 phisdKYT->FitSlicesY(0,0,-1,0,"QNR",&arrfdkyT);
159 TH1 *hisdky0 = (TH1*)arrfdky0.At(1);
160 TH1 *hisdkyT = (TH1*)arrfdkyT.At(1);
161 hisdky0->SetLineColor(1);
162 hisdkyT->SetLineColor(2);
163 hisdky0->SetMarkerColor(1);
164 hisdkyT->SetMarkerColor(2);
165 hisdky0->SetMarkerStyle(22);
166 hisdkyT->SetMarkerStyle(24);
167 hisdkyT->SetMinimum(-20);
168 hisdkyT->SetMaximum(20);
169 hisdkyT->SetXTitle("Y (cm)");
170 hisdkyT->SetYTitle("k_{yt}-k_{ymc} (mrad)");
172 hisdky0->Draw("same");
173 TLegend *legend = new TLegend(0.25,0.60,0.85,0.85, "Track residuals close to edge (Edge= 1 cm, #sigma_{cl}=0.25 cm)");
174 legend->AddEntry(hisdky0,"Y=Y_{mc}");
175 legend->AddEntry(hisdkyT,"Y=Y_{t}");
177 gPad->SaveAs("picEdge/dKYedgeMC.eps");
178 gPad->SaveAs("picEdge/dKYedgeMC.gif");