2 .L $ALICE_ROOT/TPC/fastSimul/testEdgeFit.C+
8 #include "TLinearFitter.h"
16 #include "TTreeStream.h"
17 //#include "TVectorD.h"
20 void testEdge(Int_t ntest){
22 TTreeSRedirector *cstream = new TTreeSRedirector("testEdge.root");
45 for (Int_t it=0; it<ntest;it++){
47 ymc0 = gRandom->Rndm()*1;
48 kx = gRandom->Rndm()*1.;
49 npoints = TMath::Nint(gRandom->Rndm()*50);
50 vecX.ResizeTo(npoints);
51 vecY0.ResizeTo(npoints);
52 vecYC.ResizeTo(npoints);
53 vecYT.ResizeTo(npoints);
55 vecYTa.ResizeTo(npoints);
56 vecYTb.ResizeTo(npoints);
57 vecYEa.ResizeTo(npoints);
58 vecYEb.ResizeTo(npoints);
59 vecU.ResizeTo(npoints);
61 TLinearFitter fitter(2,"pol1");
62 for (Int_t ipoint=npoints-1;ipoint>0;ipoint--){
65 x[0]=(Double_t)(ipoint)*0.2;
66 Double_t y0 = ymc0+Double_t(x[0])*kx;
67 Double_t yc = y0+gRandom->Gaus()*sy;
77 fitter.AddPoint(x,yc,sy);
78 if (fitter.GetNpoints()>4){
80 fitter.GetErrors(vecE);
81 vecYTa[ipoint]=fitter.GetParameter(0);
82 vecYTb[ipoint]=fitter.GetParameter(1);
83 vecYEa[ipoint]=vecE[0];
84 vecYEb[ipoint]=vecE[1];
85 vecU[ipoint]=fitter.GetNpoints();
86 vecYT[ipoint]=fitter.GetParameter(0)+fitter.GetParameter(1)*x[0];
109 TFile f("testEdge.root");
110 TTree * tree = (TTree*)f.Get("Dump");
111 TObjArray arrfdy0,arrfdyT;
112 TH2F *phisdY0 = new TH2F("hisdY0","hisdY0",25,1,3,200,-3,3);
113 TH2F *phisdYT = new TH2F("hisdYT","hisdYT",25,1,3,200,-3,3);
114 tree->Draw("10*(vYT.fElements-vY0.fElements):vY0.fElements>>hisdY0","vU.fElements>20&&kx>0.1","colz");
115 phisdY0->SetDirectory(0);
116 tree->Draw("10*(vYT.fElements-vY0.fElements):vYT.fElements>>hisdYT","vU.fElements>20&&kx>0.1","colz");
117 phisdYT->SetDirectory(0);
119 phisdY0->FitSlicesY(0,0,-1,0,"QNR",&arrfdy0);
120 phisdYT->FitSlicesY(0,0,-1,0,"QNR",&arrfdyT);
122 TH1 *hisdy0 = (TH1*)arrfdy0.At(1);
123 TH1 *hisdyT = (TH1*)arrfdyT.At(1);
124 hisdy0->SetLineColor(1);
125 hisdyT->SetLineColor(2);
126 hisdy0->SetMarkerColor(1);
127 hisdyT->SetMarkerColor(2);
128 hisdy0->SetMarkerStyle(22);
129 hisdyT->SetMarkerStyle(24);
130 hisdyT->SetXTitle("Y (cm)");
131 hisdyT->SetYTitle("Y_{t}-Y_{mc} (mm)");
132 hisdyT->SetMinimum(-hisdyT->GetMaximum());
134 hisdy0->Draw("same");
135 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)");
136 legend->AddEntry(hisdy0,"Y=Y_{mc}");
137 legend->AddEntry(hisdyT,"Y=Y_{t}");
139 gPad->SaveAs("picEdge/dYedgeMC.eps");
140 gPad->SaveAs("picEdge/dYedgeMC.gif");
144 TFile f("testEdge.root");
145 TTree * tree = (TTree*)f.Get("Dump");
146 TObjArray arrfdky0,arrfdkyT;
147 TH2F *phisdKY0 = new TH2F("hisdKY0","hisdKY0",25,1,3,200,-150,150);
148 TH2F *phisdKYT = new TH2F("hisdKYT","hisdKYT",25,1,3,200,-150,150);
149 tree->Draw("1000*(vYTb.fElements-kx):vY0.fElements>>hisdKY0","vU.fElements>20","colz");
150 phisdKY0->SetDirectory(0);
151 tree->Draw("1000*(vYTb.fElements-kx):vYT.fElements>>hisdKYT","vU.fElements>20","colz");
152 phisdKYT->SetDirectory(0);
154 phisdKY0->FitSlicesY(0,0,-1,0,"QNR",&arrfdky0);
155 phisdKYT->FitSlicesY(0,0,-1,0,"QNR",&arrfdkyT);
157 TH1 *hisdky0 = (TH1*)arrfdky0.At(1);
158 TH1 *hisdkyT = (TH1*)arrfdkyT.At(1);
159 hisdky0->SetLineColor(1);
160 hisdkyT->SetLineColor(2);
161 hisdky0->SetMarkerColor(1);
162 hisdkyT->SetMarkerColor(2);
163 hisdky0->SetMarkerStyle(22);
164 hisdkyT->SetMarkerStyle(24);
165 hisdkyT->SetMinimum(-20);
166 hisdkyT->SetMaximum(20);
167 hisdkyT->SetXTitle("Y (cm)");
168 hisdkyT->SetYTitle("k_{yt}-k_{ymc} (mrad)");
170 hisdky0->Draw("same");
171 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)");
172 legend->AddEntry(hisdky0,"Y=Y_{mc}");
173 legend->AddEntry(hisdkyT,"Y=Y_{t}");
175 gPad->SaveAs("picEdge/dKYedgeMC.eps");
176 gPad->SaveAs("picEdge/dKYedgeMC.gif");