]>
Commit | Line | Data |
---|---|---|
b48af428 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
61231d74 | 18 | Revision 1.10.2.1 2001/10/24 07:26:04 hristov |
19 | All the changes from the head are merged with the release | |
20 | ||
11091b43 | 21 | Revision 1.14 2001/10/24 07:19:57 hristov |
22 | Some pointer correctly initialised in one of the constructors | |
23 | ||
a49bb2c8 | 24 | Revision 1.13 2001/10/21 19:17:12 hristov |
25 | Several pointers were set to zero in the default constructors to avoid memory management problems | |
26 | ||
55cd883f | 27 | Revision 1.12 2001/10/19 21:32:35 nilsen |
28 | Minor changes to remove compliation warning on gcc 2.92.2 compiler, and | |
29 | cleanded up a little bit of code. | |
30 | ||
b48af428 | 31 | */ |
32 | // The purpose of this class is to permorm the ITS tracking. The | |
33 | // constructor has the task to inizialize some private members. The method | |
34 | // DoTracking is written to be called by a macro. It gets the event number, | |
35 | // the minimum and maximum order number of TPC tracks that are to be tracked | |
36 | // trough the ITS, and the file where the recpoints are registered. The | |
37 | // method Recursivetracking is a recursive function that performs the | |
38 | // tracking trough the ITS The method Intersection found the layer, ladder | |
39 | // and detector whre the intersection take place and caluclate the | |
40 | // cohordinates of this intersection. It returns an integer that is 0 if the | |
41 | // intersection has been found successfully. The two mwthods Kalmanfilter | |
42 | // and kalmanfiltervert operate the kalmanfilter without and with the vertex | |
43 | // imposition respectively. The authors thank Mariana Bondila to have help | |
44 | // them to resolve some problems. July-2000 | |
04b80329 | 45 | |
46 | #include <fstream.h> | |
13888096 | 47 | #include <TMath.h> |
13888096 | 48 | #include <TBranch.h> |
49 | #include <TVector.h> | |
13888096 | 50 | #include <TFile.h> |
51 | #include <TTree.h> | |
cbcfa38d | 52 | #include <TStopwatch.h> |
53 | ||
13888096 | 54 | #include "TParticle.h" |
55 | #include "AliRun.h" | |
56 | #include "AliITS.h" | |
04b80329 | 57 | #include "AliITSsegmentationSSD.h" |
13888096 | 58 | #include "AliITSgeomSPD.h" |
59 | #include "AliITSgeomSDD.h" | |
60 | #include "AliITSgeomSSD.h" | |
61 | #include "AliITSgeom.h" | |
13888096 | 62 | #include "AliITSRecPoint.h" |
04b80329 | 63 | #include "stdlib.h" |
13888096 | 64 | #include "AliKalmanTrack.h" |
65 | #include "AliMagF.h" | |
04b80329 | 66 | #include "AliITSTrackV1.h" |
67 | #include "AliITSIOTrack.h" | |
68 | #include "AliITSRad.h" | |
13888096 | 69 | #include "../TPC/AliTPCtracker.h" |
13888096 | 70 | #include "AliITSTrackerV1.h" |
0983ac5b | 71 | #include "AliITSVertex.h" |
13888096 | 72 | |
13888096 | 73 | ClassImp(AliITSTrackerV1) |
55cd883f | 74 | //______________________________________________________________________ |
75 | AliITSTrackerV1::AliITSTrackerV1() { | |
76 | //Default constructor | |
77 | fITS = 0; | |
78 | fresult = 0; | |
79 | frecPoints = 0; | |
80 | fvettid = 0; | |
81 | frl = 0; | |
82 | fzmin = 0; | |
83 | fzmax = 0; | |
84 | fphimin = 0; | |
85 | fphimax = 0; | |
86 | fphidet = 0; | |
87 | } | |
b48af428 | 88 | //______________________________________________________________________ |
04b80329 | 89 | AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Bool_t flag) { |
b48af428 | 90 | //Origin A. Badala' and G.S. Pappalardo: |
91 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
92 | // Class constructor. It does some initializations. | |
93 | ||
a49bb2c8 | 94 | //PH Initialisation taken from the default constructor |
b48af428 | 95 | fITS = IITTSS; |
a49bb2c8 | 96 | fresult = 0; |
97 | frecPoints = 0; | |
98 | fvettid = 0; | |
99 | frl = 0; | |
100 | fzmin = 0; | |
101 | fzmax = 0; | |
102 | fphimin = 0; | |
103 | fphimax = 0; | |
104 | fphidet = 0; | |
105 | ||
b48af428 | 106 | fPtref = 0.; |
107 | fChi2max =0.; | |
108 | fflagvert =flag; | |
109 | Int_t imax = 200,jmax = 450; | |
110 | frl = new AliITSRad(imax,jmax); | |
111 | ||
112 | ////////// gets information on geometry ///////////////////////////// | |
113 | AliITSgeom *g1 = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom(); | |
114 | // Why not AliITS *g1 = fITS->GetITSgeom(); // ?? BSN | |
115 | Int_t ll=1, dd=1; | |
116 | TVector det(9); | |
117 | ||
118 | //cout<<" nlad ed ndet \n"; | |
119 | Int_t ia; | |
120 | for(ia=0; ia<6; ia++) { | |
121 | fNlad[ia]=g1->GetNladders(ia+1); | |
122 | fNdet[ia]=g1->GetNdetectors(ia+1); | |
123 | //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n"; | |
124 | } // end for ia | |
125 | //getchar(); | |
126 | ||
127 | //cout<<" raggio medio = "; | |
128 | Int_t ib; | |
129 | for(ib=0; ib<6; ib++) { | |
130 | g1->GetCenterThetaPhi(ib+1,ll,dd,det); | |
131 | Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1)); | |
132 | g1->GetCenterThetaPhi(ib+1,ll,dd+1,det); | |
133 | Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1)); | |
134 | fAvrad[ib]=(r1+r2)/2.; | |
135 | //cout<<fAvrad[ib]<<" "; | |
136 | } // end for ib | |
137 | //cout<<"\n"; getchar(); | |
138 | ||
139 | fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx(); | |
140 | fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz(); | |
141 | ||
142 | fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx(); | |
143 | fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz(); | |
144 | ||
145 | fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx(); | |
146 | fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz(); | |
147 | ||
148 | fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx(); | |
149 | fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz(); | |
150 | ||
151 | fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx(); | |
152 | fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz(); | |
153 | ||
154 | fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx(); | |
155 | fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz(); | |
156 | //cout<<" Detx Detz\n"; | |
157 | //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<< | |
158 | // fDetz[la]<<endl; | |
159 | //getchar(); | |
160 | // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax // | |
161 | Double_t epsz=1.2; | |
162 | Double_t epszdrift=0.05; | |
163 | ||
164 | fzmin = new Double_t*[6]; fzmax = new Double_t*[6]; | |
165 | Int_t im1, im2, im2max; | |
166 | for(im1=0; im1<6; im1++) { | |
167 | im2max=fNdet[im1]; | |
168 | fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max]; | |
169 | } // end for im1 | |
170 | ||
171 | for(im1=0; im1<6; im1++) { | |
172 | im2max=fNdet[im1]; | |
173 | for(im2=0; im2<im2max; im2++) { | |
174 | g1->GetCenterThetaPhi(im1+1,1,im2+1,det); | |
175 | if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1]; | |
176 | else | |
177 | fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz; | |
178 | if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1]; | |
179 | else | |
cbcfa38d | 180 | fzmax[im1][im2]=det(2)+fDetz[im1]*epsz; |
b48af428 | 181 | if(im1==2 || im1==3) { |
182 | fzmin[im1][im2]-=epszdrift; | |
183 | fzmax[im1][im2]+=epszdrift; | |
184 | } // end if im1==2 || im1==3 | |
185 | } // end for im2 | |
186 | } // end for im1 | |
13888096 | 187 | |
b48af428 | 188 | fphimin = new Double_t*[6]; fphimax = new Double_t*[6]; |
189 | for(im1=0;im1<6;im1++) { | |
190 | im2max=fNlad[im1]; | |
191 | fphimin[im1] = new Double_t[im2max]; | |
192 | fphimax[im1] = new Double_t[im2max]; | |
193 | } // end for im1 | |
194 | ||
195 | fphidet = new Double_t*[6]; | |
196 | for(im1=0; im1<6; im1++) { | |
197 | im2max=fNlad[im1]; | |
198 | fphidet[im1] = new Double_t[im2max]; | |
199 | } // end for im1 | |
200 | ||
201 | Float_t global[3],local[3]; | |
202 | Double_t pigre=TMath::Pi(); | |
203 | Double_t xmin,ymin,xmax,ymax; | |
204 | ||
205 | for(im1=0; im1<6; im1++) { | |
206 | im2max=fNlad[im1]; | |
207 | for(im2=0; im2<im2max; im2++) { | |
208 | Int_t idet=2; | |
209 | g1->GetCenterThetaPhi(im1+1,im2+1,idet,det); | |
210 | fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)), | |
211 | Double_t(det(0))); | |
212 | if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre; | |
213 | local[1]=local[2]=0.; | |
214 | local[0]= -(fDetx[im1]); | |
215 | if(im1==0) local[0]= (fDetx[im1]); //to take into account | |
216 | // different reference system | |
217 | g1->LtoG(im1+1,im2+1,idet,local,global); | |
218 | xmax=global[0]; ymax=global[1]; | |
219 | local[0]= (fDetx[im1]); | |
220 | if(im1==0) local[0]= -(fDetx[im1]);//take into account different | |
221 | // reference system | |
222 | g1->LtoG(im1+1,im2+1,idet,local,global); | |
223 | xmin=global[0]; ymin=global[1]; | |
224 | fphimin[im1][im2]= TMath::ATan2(ymin,xmin); | |
225 | if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre; | |
226 | fphimax[im1][im2]= TMath::ATan2(ymax,xmax); | |
227 | if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre; | |
228 | } // end for im2 | |
229 | } // end for im1 | |
230 | ||
231 | ////////// gets magnetic field factor ////////////////////////////// | |
232 | ||
233 | AliMagF * fieldPointer = gAlice->Field(); | |
234 | fFieldFactor = (Double_t)fieldPointer->Factor(); | |
235 | //cout<< " field factor = "<<fFieldFactor<<"\n"; getchar(); | |
236 | } | |
237 | //______________________________________________________________________ | |
04b80329 | 238 | AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) { |
b48af428 | 239 | // Origin A. Badala' and G.S. Pappalardo: |
240 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
241 | // copy constructor | |
242 | ||
243 | *fITS = *cobj.fITS; | |
244 | *fresult = *cobj.fresult; | |
245 | fPtref = cobj.fPtref; | |
246 | fChi2max = cobj.fChi2max; | |
247 | **fvettid = **cobj.fvettid; | |
248 | fflagvert = cobj.fflagvert; | |
249 | Int_t imax=200,jmax=450; | |
250 | frl = new AliITSRad(imax,jmax); | |
251 | *frl = *cobj.frl; | |
252 | fFieldFactor = cobj.fFieldFactor; | |
253 | Int_t i,im1,im2,im2max; | |
254 | for(i=0; i<6; i++) { | |
255 | fNlad[i] = cobj.fNlad[i]; | |
256 | fNdet[i] = cobj.fNdet[i]; | |
257 | fAvrad[i] = cobj.fAvrad[i]; | |
258 | fDetx[i] = cobj.fDetx[i]; | |
259 | fDetz[i] = cobj.fDetz[i]; | |
260 | } // end or i | |
261 | fzmin = new Double_t*[6]; fzmax = new Double_t*[6]; | |
262 | for(im1=0; im1<6; im1++) { | |
263 | im2max=fNdet[im1]; | |
264 | fzmin[im1] = new Double_t[im2max]; | |
265 | fzmax[im1] = new Double_t[im2max]; | |
266 | } // end for im1 | |
cbcfa38d | 267 | fphimin = new Double_t*[6]; fphimax = new Double_t*[6]; |
b48af428 | 268 | for(im1=0;im1<6;im1++) { |
269 | im2max=fNlad[im1]; | |
270 | fphimin[im1] = new Double_t[im2max]; | |
271 | fphimax[im1] = new Double_t[im2max]; | |
272 | } // end for im1 | |
273 | ||
274 | fphidet = new Double_t*[6]; | |
275 | for(im1=0; im1<6; im1++) { | |
276 | im2max=fNlad[im1]; | |
277 | fphidet[im1] = new Double_t[im2max]; | |
278 | } // end for im1 | |
279 | for(im1=0; im1<6; im1++) { | |
280 | im2max=fNdet[im1]; | |
281 | for(im2=0; im2<im2max; im2++) { | |
282 | fzmin[im1][im2]=cobj.fzmin[im1][im2]; | |
283 | fzmax[im1][im2]=cobj.fzmax[im1][im2]; | |
284 | } // end for im2 | |
285 | } // end for im1 | |
286 | for(im1=0; im1<6; im1++) { | |
287 | im2max=fNlad[im1]; | |
288 | for(im2=0; im2<im2max; im2++) { | |
289 | fphimin[im1][im2]=cobj.fphimin[im1][im2]; | |
290 | fphimax[im1][im2]=cobj.fphimax[im1][im2]; | |
291 | fphidet[im1][im2]=cobj.fphidet[im1][im2]; | |
292 | } // end for im2 | |
293 | } // end for im2 | |
cbcfa38d | 294 | } |
b48af428 | 295 | //______________________________________________________________________ |
cbcfa38d | 296 | AliITSTrackerV1::~AliITSTrackerV1(){ |
b48af428 | 297 | // Origin A. Badala' and G.S. Pappalardo: |
298 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
299 | // class destructor | |
13888096 | 300 | |
b48af428 | 301 | //delete fTimerKalman; |
302 | //delete fTimerIntersection; | |
13888096 | 303 | } |
b48af428 | 304 | //______________________________________________________________________ |
04b80329 | 305 | AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) { |
b48af428 | 306 | // Origin A. Badala' and G.S. Pappalardo: |
307 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
308 | // assignement operator | |
309 | ||
310 | *fITS = *obj.fITS; | |
311 | *fresult = *obj.fresult; | |
312 | fPtref = obj.fPtref; | |
313 | fChi2max = obj.fChi2max; | |
314 | **fvettid = **obj.fvettid; | |
315 | fflagvert = obj.fflagvert; | |
316 | Int_t imax=200,jmax=450; | |
317 | frl = new AliITSRad(imax,jmax); | |
318 | *frl = *obj.frl; | |
319 | fFieldFactor = obj.fFieldFactor; | |
320 | Int_t i; | |
321 | for(i=0; i<6; i++) { | |
322 | fNlad[i] = obj.fNlad[i]; | |
323 | fNdet[i] = obj.fNdet[i]; | |
324 | fAvrad[i] = obj.fAvrad[i]; | |
325 | fDetx[i] = obj.fDetx[i]; | |
326 | fDetz[i] = obj.fDetz[i]; | |
327 | } // end for i | |
328 | fzmin = new Double_t*[6]; | |
329 | fzmax = new Double_t*[6]; | |
330 | Int_t im1, im2, im2max; | |
331 | for(im1=0; im1<6; im1++) { | |
332 | im2max=fNdet[im1]; | |
333 | fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max]; | |
334 | } // end for im1 | |
cbcfa38d | 335 | fphimin = new Double_t*[6]; fphimax = new Double_t*[6]; |
b48af428 | 336 | for(im1=0;im1<6;im1++) { |
337 | im2max=fNlad[im1]; | |
338 | fphimin[im1] = new Double_t[im2max]; | |
339 | fphimax[im1] = new Double_t[im2max]; | |
340 | } // end for im1 | |
341 | ||
342 | fphidet = new Double_t*[6]; | |
343 | for(im1=0; im1<6; im1++) { | |
344 | im2max=fNlad[im1]; | |
345 | fphidet[im1] = new Double_t[im2max]; | |
346 | } // end for im1 | |
347 | for(im1=0; im1<6; im1++) { | |
348 | im2max=fNdet[im1]; | |
349 | for(im2=0; im2<im2max; im2++) { | |
350 | fzmin[im1][im2]=obj.fzmin[im1][im2]; | |
351 | fzmax[im1][im2]=obj.fzmax[im1][im2]; | |
352 | } // end for im2 | |
353 | } // end for im1 | |
354 | for(im1=0; im1<6; im1++) { | |
355 | im2max=fNlad[im1]; | |
356 | for(im2=0; im2<im2max; im2++) { | |
357 | fphimin[im1][im2]=obj.fphimin[im1][im2]; | |
358 | fphimax[im1][im2]=obj.fphimax[im1][im2]; | |
359 | fphidet[im1][im2]=obj.fphidet[im1][im2]; | |
360 | } // end for im2 | |
361 | } // end for im1 | |
362 | ||
363 | return *this; | |
04b80329 | 364 | } |
b48af428 | 365 | //______________________________________________________________________ |
366 | void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr, | |
61231d74 | 367 | TFile *file, Bool_t realmass) { |
b48af428 | 368 | // Origin A. Badala' and G.S. Pappalardo: |
369 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
370 | // The method needs the event number, the minimum and maximum order | |
371 | // number of TPC tracks that | |
372 | // are to be tracked trough the ITS, and the file where the recpoints | |
373 | // are registered. | |
374 | // The method can be called by a macro. It preforms the tracking for | |
375 | // all good TPC tracks | |
376 | ||
377 | printf("begin DoTracking - file %p\n",file); | |
378 | ||
379 | gAlice->GetEvent(evNumber); //modificato per gestire hbt | |
13888096 | 380 | |
b48af428 | 381 | AliKalmanTrack *kkprov; |
382 | kkprov->SetConvConst(100/0.299792458/0.2/fFieldFactor); | |
383 | ||
384 | TFile *cf=TFile::Open("AliTPCclusters.root"); | |
385 | AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60"); | |
386 | if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();} | |
387 | ||
388 | cf->cd(); | |
389 | AliTPCtracker *tracker = new AliTPCtracker(digp,evNumber); | |
390 | ||
391 | // Load clusters | |
392 | tracker->LoadInnerSectors(); | |
393 | tracker->LoadOuterSectors(); | |
394 | ||
395 | // Load tracks | |
396 | TFile *tf=TFile::Open("AliTPCtracksSorted.root"); //modificato per hbt | |
397 | if (!tf->IsOpen()) { | |
398 | cerr<<"Can't open AliTPCtracksSorted.root !\n"; | |
399 | return ; | |
400 | } // end if | |
401 | TObjArray tracks(200000); | |
402 | char tname[100]; | |
403 | sprintf(tname,"TreeT_TPC_%d",evNumber); | |
404 | ||
405 | TTree *tracktree=(TTree*)tf->Get(tname); | |
406 | if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";} | |
407 | TBranch *tbranch=tracktree->GetBranch("tracks"); | |
408 | Int_t nentr=(Int_t)tracktree->GetEntries(); | |
409 | Int_t kk; | |
410 | ||
411 | AliTPCtrack *ioTrackTPC=0; | |
412 | for (kk=0; kk<nentr; kk++) { | |
413 | ioTrackTPC=new AliTPCtrack; | |
414 | tbranch->SetAddress(&ioTrackTPC); | |
415 | tracktree->GetEvent(kk); | |
416 | tracker->CookLabel(ioTrackTPC,0.1); | |
417 | tracks.AddLast(ioTrackTPC); | |
418 | } // end for kk | |
419 | delete tracker; | |
420 | tf->Close(); | |
421 | ||
422 | Int_t nt = tracks.GetEntriesFast(); | |
423 | cerr<<"Number of found tracks "<<nt<<endl; | |
424 | ||
425 | TVector vec(5); | |
426 | TTree *tr=gAlice->TreeR(); | |
427 | Int_t nent=(Int_t)tr->GetEntries(); | |
428 | frecPoints = fITS->RecPoints(); | |
429 | ||
430 | Int_t numbpoints; | |
431 | Int_t totalpoints=0; | |
432 | Int_t *np = new Int_t[nent]; | |
433 | fvettid = new Int_t* [nent]; | |
434 | Int_t mod; | |
435 | ||
436 | for (mod=0; mod<nent; mod++) { | |
437 | fvettid[mod]=0; | |
438 | fITS->ResetRecPoints(); | |
439 | gAlice->TreeR()->GetEvent(mod); | |
440 | numbpoints = frecPoints->GetEntries(); | |
441 | totalpoints+=numbpoints; | |
442 | np[mod] = numbpoints; | |
443 | //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar(); | |
444 | fvettid[mod] = new Int_t[numbpoints]; | |
445 | Int_t ii; | |
446 | for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0; | |
447 | } // end for mod | |
448 | ||
449 | AliTPCtrack *track=0; | |
450 | ||
451 | if(minTr < 0) {minTr = 0; maxTr = nt-1;} | |
452 | ||
453 | TVector vgeant(3); | |
454 | ||
455 | TTree tracktree1("TreeT","Tree with ITS tracks"); | |
456 | AliITSIOTrack *ioTrack=0; | |
457 | tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0); | |
458 | ||
61231d74 | 459 | TDatabasePDG * db = new TDatabasePDG; |
460 | ||
b48af428 | 461 | Int_t j; |
462 | for (j=minTr; j<=maxTr; j++) { | |
463 | track=(AliTPCtrack*)tracks.UncheckedAt(j); | |
464 | if (!track) continue; | |
61231d74 | 465 | |
466 | /// mass definition //////////////////////// | |
467 | Double_t mass=0.13956995; | |
468 | Int_t pcode=211; // a pion by default | |
469 | if(realmass) { | |
470 | Int_t TPClabel=TMath::Abs( track->GetLabel() ); | |
471 | TParticle *p = (TParticle*)gAlice->Particle(TPClabel); | |
472 | pcode=p->GetPdgCode(); | |
473 | // Int_t mothercode=p->GetFirstMother(); | |
474 | //if(mothercode>0 ) numofsecondaries++; else numofprimaries++; | |
475 | } | |
476 | //if(!pcode) pcode=211; | |
477 | if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass(); | |
478 | ||
479 | ||
480 | /////////////////////////////////////////////// | |
d3ab000e | 481 | /* |
b48af428 | 482 | ////// propagation to the end of TPC ////////////// |
483 | Double_t xk=77.415; | |
61231d74 | 484 | track->PropagateTo(xk, 28.94, 1.204e-3,mass); //Ne |
b48af428 | 485 | xk -=0.01; |
61231d74 | 486 | track->PropagateTo(xk, 44.77, 1.71,mass); //Tedlar |
b48af428 | 487 | xk -=0.04; |
61231d74 | 488 | track->PropagateTo(xk, 44.86, 1.45,mass); //kevlar |
b48af428 | 489 | xk -=2.0; |
61231d74 | 490 | track->PropagateTo(xk, 41.28, 0.029,mass); //Nomex |
b48af428 | 491 | xk-=16; |
61231d74 | 492 | track->PropagateTo(xk,36.2,1.98e-3,mass); //C02 |
b48af428 | 493 | xk -=0.01; |
61231d74 | 494 | track->PropagateTo(xk, 24.01, 2.7,mass); //Al |
b48af428 | 495 | xk -=0.01; |
61231d74 | 496 | track->PropagateTo(xk, 44.77, 1.71,mass); //Tedlar |
b48af428 | 497 | xk -=0.04; |
61231d74 | 498 | track->PropagateTo(xk, 44.86, 1.45,mass); //kevlar |
b48af428 | 499 | xk -=0.5; |
61231d74 | 500 | track->PropagateTo(xk, 41.28, 0.029,mass); //Nomex |
b48af428 | 501 | //////////////////////////////////////////////////////////////////// |
d3ab000e | 502 | */ |
503 | // new propagation to the end of TPC | |
504 | //Double_t xk=80.; | |
505 | //track->PropagateTo(xk,0.,0.); //Ne if it's still there | |
506 | Double_t xk=77.415; | |
507 | track->PropagateTo(xk, 28.94, 1.204e-3); | |
508 | xk-=0.005; | |
509 | track->PropagateTo(xk, 44.77,1.71); //Tedlar | |
510 | xk-=0.02; | |
511 | track->PropagateTo(xk, 44.86, 1.45); //Kevlar | |
512 | xk-=2.0; | |
513 | track->PropagateTo(xk, 41.28, 0.029);//Nomex | |
514 | xk-=0.02; | |
515 | track->PropagateTo(xk, 44.86, 1.45); //Kevlar | |
516 | xk-=0.005; | |
517 | track->PropagateTo(xk, 44.77, 1.71); //Tedlar | |
518 | ||
519 | xk=61.; | |
520 | //track->PropagateTo(xk,0.,0.); //C02 | |
521 | track->PropagateTo(xk,36.2,1.98e-3); //C02 | |
522 | ||
523 | xk -=0.005; | |
524 | track->PropagateTo(xk, 24.01, 2.7); //Al | |
525 | xk -=0.005; | |
526 | track->PropagateTo(xk, 44.77, 1.71); //Tedlar | |
527 | xk -=0.02; | |
528 | track->PropagateTo(xk, 44.86, 1.45); //Kevlar | |
529 | xk -=0.5; | |
530 | track->PropagateTo(xk, 41.28, 0.029); //Nomex | |
531 | xk -=0.02; | |
532 | track->PropagateTo(xk, 44.86, 1.45); //Kevlar | |
533 | xk -=0.005; | |
534 | track->PropagateTo(xk, 44.77, 1.71); //Tedlar | |
535 | xk -=0.005; | |
536 | track->PropagateTo(xk, 24.01, 2.7); //Al | |
537 | ||
538 | ||
61231d74 | 539 | AliITSTrackV1 trackITS(*track); |
540 | trackITS.PutMass(mass); //new to add mass to track | |
b48af428 | 541 | if(fresult){ delete fresult; fresult=0;} |
542 | fresult = new AliITSTrackV1(trackITS); | |
543 | ||
544 | AliITSTrackV1 primaryTrack(trackITS); | |
545 | vgeant=(*fresult).GetVertex(); | |
546 | ||
547 | // Definition of dv and zv for vertex constraint | |
548 | Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010; | |
549 | //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015; | |
13888096 | 550 | Double_t uniform= gRandom->Uniform(); |
551 | Double_t signdv; | |
552 | if(uniform<=0.5) signdv=-1.; | |
b48af428 | 553 | else |
554 | signdv=1.; | |
555 | ||
04b80329 | 556 | Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1)); |
b48af428 | 557 | Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv); |
558 | Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv); | |
559 | //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n"; | |
560 | trackITS.SetDv(dv); | |
561 | trackITS.SetZv(zv); | |
562 | trackITS.SetsigmaDv(sigmaDv); | |
563 | trackITS.SetsigmaZv(sigmaZv); | |
564 | (*fresult).SetDv(dv); | |
565 | (*fresult).SetZv(zv); | |
566 | (*fresult).SetsigmaDv(sigmaDv); | |
567 | (*fresult).SetsigmaZv(sigmaZv); | |
568 | primaryTrack.SetDv(dv); | |
569 | primaryTrack.SetZv(zv); | |
570 | primaryTrack.SetsigmaDv(sigmaDv); | |
571 | primaryTrack.SetsigmaZv(sigmaZv); | |
572 | primaryTrack.PrimaryTrack(frl); | |
573 | TVector d2=primaryTrack.Getd2(); | |
574 | TVector tgl2=primaryTrack.Gettgl2(); | |
575 | TVector dtgl=primaryTrack.Getdtgl(); | |
576 | trackITS.Setd2(d2); trackITS.Settgl2(tgl2); | |
577 | trackITS.Setdtgl(dtgl); | |
578 | (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2); | |
579 | (*fresult).Setdtgl(dtgl); | |
580 | /* | |
581 | trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex); | |
582 | (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex); | |
583 | */ | |
584 | TList *list= new TList(); | |
585 | ||
586 | list->AddLast(&trackITS); | |
587 | ||
588 | fPtref=TMath::Abs( (trackITS).GetPt() ); | |
589 | if(fPtref>1.0) fChi2max=40.; | |
590 | if(fPtref<=1.0) fChi2max=20.; | |
591 | if(fPtref<0.4 ) fChi2max=100.; | |
592 | if(fPtref<0.2 ) fChi2max=40.; | |
593 | // if(fPtref<0.4 ) fChi2max=30.; | |
594 | // if(fPtref<0.2 ) fChi2max=20.; | |
595 | //if(fPtref<0.2 ) fChi2max=10.; | |
596 | //if(fPtref<0.1 ) fChi2max=5.; | |
11091b43 | 597 | //cout << "\n Pt = " << fPtref <<"\n"; //stampa |
b48af428 | 598 | RecursiveTracking(list); |
599 | list->Delete(); | |
600 | delete list; | |
601 | ||
602 | Int_t itot=-1; | |
603 | TVector vecTotLabRef(18); | |
604 | Int_t lay, k; | |
605 | for(lay=5; lay>=0; lay--) { | |
606 | TVector vecLabRef(3); | |
607 | vecLabRef=(*fresult).GetLabTrack(lay); | |
608 | Float_t clustZ=(*fresult).GetZclusterTrack( lay); | |
609 | for(k=0; k<3; k++){ | |
04b80329 | 610 | Int_t lpp=(Int_t)vecLabRef(k); |
611 | if(lpp>=0) { | |
b48af428 | 612 | TParticle *p=(TParticle*) gAlice->Particle(lpp); |
613 | Int_t pcode=p->GetPdgCode(); | |
614 | if(pcode==11) vecLabRef(k)=p->GetFirstMother(); | |
615 | } // end if | |
616 | itot++; vecTotLabRef(itot)=vecLabRef(k); | |
617 | if(vecLabRef(k)==0. && clustZ == 0.) vecTotLabRef(itot) =-3.; | |
618 | } // end for k | |
619 | } // end for lay | |
620 | Long_t labref; | |
621 | Int_t freq; | |
622 | (*fresult).Search(vecTotLabRef, labref, freq); | |
623 | ||
624 | //if(freq < 6) labref=-labref; // cinque - sei | |
625 | if(freq < 5) labref=-labref; // cinque - sei | |
626 | (*fresult).SetLabel(labref); | |
627 | ||
628 | // cout<<" progressive track number = "<<j<<"\r"; | |
629 | // cout<<j<<"\r"; | |
630 | Int_t numOfCluster=(*fresult).GetNumClust(); | |
11091b43 | 631 | //cout<<" progressive track number = "<<j<<"\n"; // stampa |
b48af428 | 632 | Long_t labITS=(*fresult).GetLabel(); |
11091b43 | 633 | //cout << " ITS track label = " << labITS << "\n"; // stampa |
b48af428 | 634 | Int_t lab=track->GetLabel(); |
11091b43 | 635 | //cout << " TPC track label = " << lab <<"\n"; // stampa |
b48af428 | 636 | //propagation to vertex |
637 | ||
638 | Double_t rbeam=3.; | |
61231d74 | 639 | if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe |
b48af428 | 640 | (*fresult).Propagation(rbeam); |
641 | Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44; | |
642 | (*fresult).GetCElements(c00, | |
643 | c10,c11, | |
644 | c20,c21,c22, | |
645 | c30,c31,c32,c33, | |
646 | c40,c41,c42,c43,c44); | |
13888096 | 647 | |
b48af428 | 648 | Double_t pt=TMath::Abs((*fresult).GetPt()); |
649 | Double_t dr=(*fresult).GetD(); | |
650 | Double_t z=(*fresult).GetZ(); | |
651 | Double_t tgl=(*fresult).GetTgl(); | |
652 | Double_t c=(*fresult).GetC(); | |
653 | Double_t cy=c/2.; | |
654 | Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam)); | |
655 | dz-=vgeant(2); | |
656 | // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar(); | |
657 | Double_t phi=(*fresult).Getphi(); | |
658 | Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam)); | |
659 | Double_t duepi=2.*TMath::Pi(); | |
660 | if(phivertex>duepi) phivertex-=duepi; | |
661 | if(phivertex<0.) phivertex+=duepi; | |
662 | ///////////////////////////////////////////////////////////// | |
663 | Int_t idmodule,idpoint; | |
664 | if(numOfCluster >=5) { // cinque - sei | |
665 | //if(numOfCluster ==6) { // cinque - sei | |
666 | AliITSIOTrack outTrack; | |
667 | ioTrack=&outTrack; | |
668 | ioTrack->SetStatePhi(phi); | |
669 | ioTrack->SetStateZ(z); | |
670 | ioTrack->SetStateD(dr); | |
671 | ioTrack->SetStateTgl(tgl); | |
672 | ioTrack->SetStateC(c); | |
673 | Double_t radius=(*fresult).Getrtrack(); | |
674 | ioTrack->SetRadius(radius); | |
675 | Int_t charge; | |
676 | if(c>0.) charge=-1; else charge=1; | |
677 | ioTrack->SetCharge(charge); | |
678 | ioTrack->SetCovMatrix(c00, | |
679 | c10,c11, | |
680 | c20,c21,c22, | |
681 | c30,c31,c32,c33, | |
682 | c40,c41,c42,c43,c44); | |
683 | Double_t px=pt*TMath::Cos(phivertex); | |
684 | Double_t py=pt*TMath::Sin(phivertex); | |
685 | Double_t pz=pt*tgl; | |
686 | Double_t xtrack=dr*TMath::Sin(phivertex); | |
687 | Double_t ytrack=dr*TMath::Cos(phivertex); | |
688 | Double_t ztrack=dz+vgeant(2); | |
689 | ioTrack->SetPx(px); | |
690 | ioTrack->SetPy(py); | |
691 | ioTrack->SetPz(pz); | |
692 | ioTrack->SetX(xtrack); | |
693 | ioTrack->SetY(ytrack); | |
694 | ioTrack->SetZ(ztrack); | |
695 | ioTrack->SetLabel(labITS); | |
696 | ioTrack->SetTPCLabel(lab); | |
61231d74 | 697 | ioTrack->SetDz(dz); |
b48af428 | 698 | Int_t il; |
699 | for(il=0;il<6; il++){ | |
700 | ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il)); | |
701 | ioTrack->SetIdModule(il,(*fresult).GetIdModule(il)); | |
702 | } // end for il | |
703 | tracktree1.Fill(); | |
704 | for (il=0;il<6;il++) { | |
705 | idpoint=(*fresult).GetIdPoint(il); | |
706 | idmodule=(*fresult).GetIdModule(il); | |
61231d74 | 707 | if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1; |
708 | ||
b48af428 | 709 | ioTrack->SetIdPoint(il,idpoint); |
710 | ioTrack->SetIdModule(il,idmodule); | |
711 | } // end for il | |
712 | } // end if on numOfCluster | |
713 | //gObjectTable->Print(); // stampa memoria | |
714 | } // end for (int j=minTr; j<=maxTr; j++) | |
61231d74 | 715 | delete db; |
b48af428 | 716 | static Bool_t first=kTRUE; |
717 | static TFile *tfile; | |
718 | if(first) { | |
719 | tfile=new TFile("itstracks.root","RECREATE"); | |
720 | //cout<<"I have opened itstracks.root file "<<endl; | |
721 | } // end if | |
722 | first=kFALSE; | |
723 | tfile->cd(); | |
724 | tfile->ls(); | |
725 | char hname[30]; | |
726 | sprintf(hname,"TreeT%d",evNumber); | |
727 | tracktree1.Write(hname); | |
728 | ||
729 | TTree *fAli=gAlice->TreeK(); | |
730 | TFile *fileAli=0; | |
731 | if (fAli) fileAli =fAli->GetCurrentFile(); | |
732 | fileAli->cd(); | |
733 | //////////////////////////////////////////////////////////////////// | |
734 | ||
735 | printf("delete vectors\n"); | |
736 | if(np) delete [] np; | |
737 | if(fvettid) delete [] fvettid; | |
738 | if(fresult) {delete fresult; fresult=0;} | |
04b80329 | 739 | } |
b48af428 | 740 | //______________________________________________________________________ |
04b80329 | 741 | void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) { |
b48af428 | 742 | // This function perform the recursive tracking in ITS detectors |
743 | // reference is a pointer to the final best track | |
744 | // Origin A. Badala' and G.S. Pappalardo: | |
745 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
746 | // The authors thank Mariana Bondila to have help them to resolve some | |
747 | // problems. July-2000 | |
748 | ||
749 | //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9; | |
750 | // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio | |
751 | ||
752 | ////////////////////// | |
753 | Float_t sigmaphil[6], sigmazl[6]; | |
754 | sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]); | |
755 | sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]); | |
756 | sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]); | |
757 | sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]); | |
758 | sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]); | |
759 | sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]); | |
760 | sigmazl[0]=1e-2; | |
761 | sigmazl[1]=1e-2; | |
762 | sigmazl[2]=7.84e-4; | |
763 | sigmazl[3]=7.84e-4; | |
764 | sigmazl[4]=0.6889; | |
765 | sigmazl[5]=0.6889; | |
766 | /////////////////////////////////////////////////////////// | |
767 | Int_t index; | |
768 | AliITSgeom *g1 = fITS->GetITSgeom(); | |
769 | AliITSRecPoint *recp; | |
770 | for(index =0; index<trackITSlist->GetSize(); index++) { | |
771 | AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index); | |
772 | if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140); | |
773 | // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n"; | |
774 | // cout<<"fvtrack =" <<"\n"; | |
775 | // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" " | |
776 | // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" " | |
777 | // <<(*trackITS)(4)<<"\n"; | |
778 | // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n"; | |
779 | // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n"; | |
780 | // getchar(); | |
781 | Double_t chi2Now, chi2Ref; | |
782 | Float_t numClustRef = fresult->GetNumClust(); | |
783 | if((*trackITS).GetLayer()==1 ) { | |
784 | chi2Now = trackITS->GetChi2(); | |
785 | Float_t numClustNow = trackITS->GetNumClust(); | |
786 | if(trackITS->GetNumClust()) | |
787 | chi2Now /= (Double_t)trackITS->GetNumClust(); | |
788 | chi2Ref = fresult->GetChi2(); | |
789 | if(fresult->GetNumClust()) | |
790 | chi2Ref /= (Double_t)fresult->GetNumClust(); | |
791 | //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n"; | |
792 | if( numClustNow > numClustRef ) {*fresult = *trackITS;} | |
793 | if((numClustNow == numClustRef )&& | |
794 | (chi2Now < chi2Ref)) { | |
795 | *fresult = *trackITS; | |
796 | } // end if | |
797 | continue; | |
798 | } // end if | |
799 | ||
800 | if(trackITS->Getfnoclust()>=2) continue; | |
801 | Float_t numClustNow = trackITS->GetNumClust(); | |
802 | if(numClustNow) { | |
803 | chi2Now = trackITS->GetChi2(); | |
804 | ||
805 | if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue; | |
806 | //cout<<" chi2Now = "<<chi2Now<<"\n"; | |
807 | // commentato il 30-7-2001 | |
808 | chi2Now/=numClustNow; | |
809 | if(fPtref > 1.0 && chi2Now > 30.) continue; | |
810 | if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue; | |
811 | // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue; | |
812 | // if(fPtref <= 0.2 && chi2Now > 8.) continue; | |
813 | if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue; | |
814 | if(fPtref <= 0.2 && chi2Now > 7.) continue; | |
815 | ///////////////////////////// | |
816 | } // end if | |
817 | ||
818 | Int_t layerInit = (*trackITS).GetLayer(); | |
819 | Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index | |
820 | TList listoftrack; | |
821 | Int_t ladp, ladm, detp,detm,ladinters,detinters; | |
822 | Int_t layerfin=layerInit-1; | |
823 | // cout<<"Prima di intersection \n"; | |
824 | //if(!fTimerIntersection) fTimerIntersection = new TStopwatch(); | |
825 | // timer | |
826 | //fTimerIntersection->Continue(); | |
827 | // timer | |
828 | Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters); | |
829 | //fTimerIntersection->Stop(); | |
830 | // timer | |
831 | // cout<<" outinters = "<<outinters<<"\n"; | |
832 | // cout<<" Layer ladder detector intersection =" | |
833 | // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n"; | |
834 | // cout << " phiinters zinters = "<<(*trackITS)(0) | |
835 | // << " "<<(*trackITS)(1)<<"\n"; getchar(); | |
836 | if(outinters==-1) continue; | |
837 | Int_t flaghit=0; | |
838 | if(outinters==0){ | |
839 | TVector toucLad(9), toucDet(9); | |
840 | Int_t lycur=layerfin; | |
841 | ladp=ladinters+1; | |
842 | ladm=ladinters-1; | |
843 | if(ladm <= 0) ladm=fNlad[layerfin-1]; | |
844 | if(ladp > fNlad[layerfin-1]) ladp=1; | |
845 | detp=detinters+1; | |
846 | detm=detinters-1; | |
847 | Int_t idetot=1; | |
848 | /* | |
849 | toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp; | |
850 | toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp; | |
851 | toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp; | |
852 | toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters; | |
853 | if(detm > 0 && detp <= fNdet[layerfin-1]) { | |
854 | idetot=9; | |
855 | toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm; | |
856 | toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp; | |
857 | } // end if | |
858 | if(detm > 0 && detp > fNdet[layerfin-1]) { | |
859 | idetot=6; | |
860 | toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm; | |
861 | } // end if | |
862 | if(detm <= 0 && detp <= fNdet[layerfin-1]) { | |
863 | idetot=6; | |
864 | toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp; | |
865 | } // end if | |
866 | */ | |
f66ae545 | 867 | Float_t epsphi=5.0, epsz=5.0; |
b48af428 | 868 | if(fPtref<0.2) {epsphi=3.; epsz=3.;} |
869 | // nuova definizione idetot e toucLad e toucDet to be | |
870 | // transformed in a method | |
871 | // these values could be modified | |
872 | Float_t pigre=TMath::Pi(); | |
873 | Float_t rangephi=5., rangez=5.; | |
874 | if(layerfin==1 || layerfin ==2){ | |
875 | rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+ | |
876 | (*trackITS).GetSigmaphi()); | |
877 | rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+ | |
878 | (*trackITS).GetSigmaZ()); | |
879 | } // end if | |
880 | if(layerfin==3 || layerfin ==4){ | |
881 | //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+ | |
882 | // (*trackITS).GetSigmaphi()); | |
883 | //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+ | |
884 | // (*trackITS).GetSigmaZ()); | |
885 | rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+ | |
886 | (*trackITS).GetSigmaphi()); | |
887 | rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+ | |
888 | (*trackITS).GetSigmaZ()); | |
889 | } // end if | |
890 | if(layerfin==5 || layerfin ==6){ | |
891 | rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+ | |
892 | (*trackITS).GetSigmaphi()); | |
893 | rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+ | |
894 | (*trackITS).GetSigmaZ()); | |
895 | } // end if | |
896 | Float_t phinters, zinters; | |
897 | phinters=(*trackITS).Getphi(); | |
898 | zinters=(*trackITS).GetZ(); | |
899 | Float_t distz = 0.0; | |
900 | Float_t phicm, phicp, distphim, distphip; | |
901 | phicm=phinters; | |
902 | if(phinters>fphimax[layerfin-1][ladm]) phicm=phinters-2*pigre; | |
903 | distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm]); | |
904 | phicp=phinters; | |
905 | if(phinters>fphimin[layerfin-1][ladp]) phicp=phinters-2.*pigre; | |
906 | distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp]); | |
907 | Int_t flagzmin=0; | |
908 | Int_t flagzmax=0; | |
909 | idetot=1; | |
910 | toucLad(0)=ladinters; toucDet(0)=detinters; | |
911 | if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]); | |
912 | if(detm>0 && rangez>=distz){ | |
913 | flagzmin=1; | |
914 | idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm; | |
915 | if(rangephi>=distphim){ | |
916 | idetot++; | |
917 | toucLad(idetot-1)=ladm; | |
918 | toucDet(idetot-1)=detinters; | |
919 | idetot++; | |
920 | toucLad(idetot-1)=ladm; | |
921 | toucDet(idetot-1)=detm; | |
922 | } // end if | |
923 | if(rangephi>=distphip){ | |
924 | idetot++; | |
925 | toucLad(idetot-1)=ladp; | |
926 | toucDet(idetot-1)=detinters; | |
927 | idetot++; | |
928 | toucLad(idetot-1)=ladp; | |
929 | toucDet(idetot-1)=detm; | |
930 | } // end if | |
931 | } //end detm>0.... | |
932 | if(detp<=fNdet[layerfin-1]) | |
933 | distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]); | |
934 | if(detp<=fNdet[layerfin-1] && rangez>=distz){ | |
935 | flagzmax=1; | |
936 | idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp; | |
937 | if(rangephi>=distphim){ | |
938 | idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp; | |
939 | if(flagzmin == 0) { | |
940 | idetot++; | |
941 | toucLad(idetot-1)=ladm; | |
942 | toucDet(idetot-1)=detinters; | |
943 | } // end if | |
944 | } // end if | |
945 | if(rangephi>=distphip){ | |
946 | idetot++; | |
947 | toucLad(idetot-1)=ladp; | |
948 | toucDet(idetot-1)=detp; | |
949 | if(flagzmin == 0) { | |
950 | idetot++; | |
951 | toucLad(idetot-1)=ladp; | |
952 | toucDet(idetot-1)=detinters; | |
953 | } // end if | |
954 | } // end if | |
955 | } //end detm<fNdet[....... | |
956 | ||
957 | if(flagzmin == 0 && flagzmax==0){ | |
958 | if(rangephi>=distphim){ | |
959 | idetot++; | |
960 | toucLad(idetot-1)=ladm; | |
961 | toucDet(idetot-1)=detinters; | |
962 | } // end if | |
963 | if(rangephi>=distphip){ | |
964 | idetot++; | |
965 | toucLad(idetot-1)=ladp; | |
966 | toucDet(idetot-1)=detinters; | |
967 | } // end if | |
968 | } // end if | |
969 | //////////////////////////////////////////////////////////// | |
970 | Int_t iriv; | |
971 | for (iriv=0; iriv<idetot; iriv++) { //for on detectors | |
972 | /////////////////////////////////////////////////////// | |
973 | /*** Rec points sorted by module *****/ | |
974 | /**************************************/ | |
975 | Int_t indexmod; //mod ott | |
976 | // AliITSRecPoint *recp; | |
977 | indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv), | |
978 | (Int_t)toucDet(iriv)); | |
979 | //mod ott | |
980 | fITS->ResetRecPoints(); | |
981 | gAlice->TreeR()->GetEvent(indexmod); | |
982 | Int_t npoints=frecPoints->GetEntries(); | |
983 | /* mod ott | |
984 | Int_t *indlist=new Int_t[npoints+1]; | |
985 | Int_t counter=0; | |
986 | Int_t ind; | |
987 | for (ind=0; ind<=npoints; ind++) { | |
988 | indlist[ind]=-1; | |
989 | if (*(fvettid[index]+ind)==0) { | |
990 | indlist[counter]=ind; | |
991 | counter++; | |
992 | } // end if | |
993 | } // end for ind | |
994 | ind=-1; | |
995 | for(;;) { | |
996 | ind++; | |
997 | if(indlist[ind] < 0) recp=0; | |
998 | else | |
999 | recp = (AliITSRecPoint*)frecPoints-> | |
1000 | UncheckedAt(indlist[ind]); | |
1001 | if((!recp) ) break; | |
1002 | } // end for ;; | |
1003 | */ | |
1004 | ///////////////////////// new ////////////////////////// | |
1005 | Int_t indnew; | |
1006 | for(indnew=0; indnew<npoints; indnew++){ | |
1007 | if (*(fvettid[indexmod]+indnew)==0) | |
1008 | recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew); | |
1009 | else | |
f66ae545 | 1010 | continue; |
b48af428 | 1011 | //////////////////////////////////////////////////// |
1012 | TVector cluster(3),vecclust(9); | |
1013 | vecclust(6)=vecclust(7)=vecclust(8)=-1.; | |
1014 | Double_t sigma[2]; | |
1015 | // set veclust in global | |
1016 | Float_t global[3], local[3]; | |
1017 | local[0]=recp->GetX(); | |
1018 | local[1]=0.; | |
1019 | local[2]= recp->GetZ(); | |
1020 | Int_t play = lycur; | |
1021 | Int_t plad = TMath::Nint(toucLad(iriv)); | |
1022 | Int_t pdet = TMath::Nint(toucDet(iriv)); | |
1023 | g1->LtoG(play,plad,pdet,local,global); | |
1024 | vecclust(0)=global[0]; | |
1025 | vecclust(1)=global[1]; | |
1026 | vecclust(2)=global[2]; | |
1027 | ||
1028 | vecclust(3) = (Float_t)recp->fTracks[0]; | |
1029 | //vecclust(4) = (Float_t)indlist[ind]; | |
1030 | vecclust(4) = (Float_t)indnew; | |
1031 | vecclust(5) = (Float_t)indexmod; //mod ott | |
1032 | vecclust(6) = (Float_t)recp->fTracks[0]; | |
1033 | vecclust(7) = (Float_t)recp->fTracks[1]; | |
1034 | vecclust(8) = (Float_t)recp->fTracks[2]; | |
1035 | sigma[0] = (Double_t) recp->GetSigmaX2(); | |
1036 | sigma[1] = (Double_t) recp->GetSigmaZ2(); | |
1037 | //now we are in r,phi,z in global | |
1038 | cluster(0) = TMath::Sqrt(vecclust(0)*vecclust(0)+ | |
1039 | vecclust(1)*vecclust(1));//r hit | |
1040 | cluster(1) = TMath::ATan2(vecclust(1),vecclust(0)); | |
1041 | if(cluster(1)<0.) cluster(1)+=2.*TMath::Pi(); | |
1042 | cluster(2) = vecclust(2); // z hit | |
1043 | // cout<<" layer = "<<play<<"\n"; | |
1044 | // cout<<" cluster prima = "<<vecclust(0)<<" " | |
1045 | // <<vecclust(1)<<" " | |
1046 | // <<vecclust(2)<<"\n"; getchar(); | |
1047 | ||
1048 | Float_t sigmatotphi, sigmatotz; | |
1049 | // Float_t epsphi=5.0, epsz=5.0; | |
1050 | //if(fPtref<0.2) {epsphi=3.; epsz=3.;} | |
1051 | Double_t rTrack=(*trackITS).Getrtrack(); | |
1052 | Double_t sigmaphi=sigma[0]/(rTrack*rTrack); | |
1053 | sigmatotphi=epsphi*TMath::Sqrt(sigmaphi + | |
1054 | (*trackITS).GetSigmaphi()); | |
1055 | sigmatotz=epsz*TMath::Sqrt(sigma[1] + | |
1056 | (*trackITS).GetSigmaZ()); | |
1057 | //cout<<"cluster e sigmatotphi e track = "<<cluster(0) | |
1058 | // <<" "<<cluster(1)<<" "<<sigmatotphi<<" " | |
1059 | // <<vecclust(3)<<"\n"; | |
1060 | //if(vecclust(3)==481) getchar(); | |
1061 | if(cluster(1)<6. && (*trackITS).Getphi()>6.) | |
1062 | cluster(1)=cluster(1)+(2.*TMath::Pi()); | |
1063 | if(cluster(1)>6. && (*trackITS).Getphi()<6.) | |
1064 | cluster(1)=cluster(1)-(2.*TMath::Pi()); | |
1065 | if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi) | |
1066 | continue; | |
1067 | // cout<<" supero sigmaphi \n"; | |
1068 | AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS)); | |
1069 | (*newTrack).SetLayer((*trackITS).GetLayer()-1); | |
1070 | if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6) | |
1071 | (*newTrack).Correct(Double_t(cluster(0))); | |
1072 | //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" " | |
1073 | // << (*newTrack).GetZ()<<"\n"; | |
1074 | if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){ | |
1075 | delete newTrack; | |
1076 | continue; | |
1077 | } // end if | |
1078 | Double_t sigmanew[2]; | |
1079 | sigmanew[0]= sigmaphi; | |
1080 | sigmanew[1]=sigma[1]; | |
1081 | Double_t m[2]; | |
1082 | m[0]=cluster(1); | |
1083 | m[1]=cluster(2); | |
1084 | // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew); | |
1085 | // cout<<" chi2pred = "<<chi2pred<<"\n"; | |
1086 | // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001 | |
1087 | if(iriv == 0) flaghit=1; | |
1088 | (*newTrack).AddMS(frl); // add the multiple scattering | |
1089 | //matrix to the covariance matrix | |
1090 | (*newTrack).AddEL(frl,1.,0); | |
1091 | ||
1092 | //if(!fTimerKalman) fTimerKalman = new TStopwatch();//timer | |
1093 | //fTimerKalman->Continue(); // timer | |
1094 | if(fflagvert){ | |
1095 | KalmanFilterVert(newTrack,cluster,sigmanew); | |
1096 | //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred); | |
1097 | }else{ | |
1098 | KalmanFilter(newTrack,cluster,sigmanew); | |
1099 | } // end if | |
1100 | //fTimerKalman->Stop(); // timer | |
1101 | (*newTrack).PutCluster(layernew, vecclust); | |
1102 | newTrack->AddClustInTrack(); | |
1103 | listoftrack.AddLast(newTrack); | |
1104 | } // end for indnew | |
1105 | // delete [] indlist; //mod ott | |
1106 | } // end of for on detectors (iriv) | |
1107 | }//end if(outinters==0) | |
1108 | ||
1109 | if(flaghit==0 || outinters==-2) { | |
1110 | AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS); | |
1111 | (*newTrack).Setfnoclust(); | |
1112 | (*newTrack).SetLayer((*trackITS).GetLayer()-1); | |
1113 | (*newTrack).AddMS(frl); // add the multiple scattering matrix | |
1114 | // to the covariance matrix | |
1115 | (*newTrack).AddEL(frl,1.,0); | |
1116 | listoftrack.AddLast(newTrack); | |
1117 | } // end if | |
1118 | ||
1119 | //gObjectTable->Print(); // stampa memoria | |
04b80329 | 1120 | |
b48af428 | 1121 | RecursiveTracking(&listoftrack); |
1122 | listoftrack.Delete(); | |
1123 | } // end of for on tracks (index) | |
04b80329 | 1124 | |
b48af428 | 1125 | //gObjectTable->Print(); // stampa memoria |
13888096 | 1126 | } |
b48af428 | 1127 | //______________________________________________________________________ |
1128 | Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer, | |
1129 | Int_t &ladder,Int_t &detector) { | |
1130 | // Origin A. Badala' and G.S. Pappalardo | |
1131 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
1132 | // Found the intersection and the detector | |
1133 | ||
1134 | Double_t rk=fAvrad[layer-1]; | |
1135 | if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;} | |
1136 | track.Propagation(rk); | |
1137 | Double_t zinters=track.GetZ(); | |
1138 | Double_t phinters=track.Getphi(); | |
1139 | //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n"; | |
1140 | ||
1141 | TVector det(9); | |
1142 | TVector listDet(2); | |
1143 | TVector distZCenter(2); | |
1144 | ||
1145 | Int_t iz=0; | |
1146 | Int_t iD; | |
1147 | for(iD = 1; iD<= fNdet[layer-1]; iD++) { | |
1148 | if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) { | |
1149 | if(iz>1) { | |
1150 | cout<< " Errore su iz in Intersection \n"; | |
1151 | getchar(); | |
1152 | }else { | |
1153 | listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2)); | |
1154 | iz++; | |
1155 | } // end if | |
1156 | } // end if | |
1157 | } // end for iD | |
1158 | ||
1159 | if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;} | |
1160 | detector=Int_t (listDet(0)); | |
1161 | if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1)); | |
1162 | ||
1163 | TVector listLad(2); | |
1164 | TVector distPhiCenter(2); | |
1165 | Int_t ip=0; | |
1166 | Double_t pigre=TMath::Pi(); | |
1167 | Int_t iLd; | |
1168 | for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) { | |
1169 | Double_t phimin=fphimin[layer-1][iLd-1]; | |
1170 | Double_t phimax=fphimax[layer-1][iLd-1]; | |
1171 | Double_t phidet=fphidet[layer-1][iLd-1]; | |
1172 | Double_t phiconfr=phinters; | |
1173 | if(phimin>phimax) { | |
1174 | //if(phimin <5.5) {cout<<" Error in Intersection for phi \n"; | |
1175 | // getchar();} | |
1176 | phimin-=(2.*pigre); | |
1177 | if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre); | |
1178 | if(phidet>(1.5*pigre)) phidet-=(2.*pigre); | |
1179 | } // end if | |
1180 | if(phiconfr>phimin && phiconfr<= phimax) { | |
1181 | if(ip>1) { | |
1182 | cout<< " Errore su ip in Intersection \n"; getchar(); | |
1183 | }else { | |
1184 | listLad(ip)= iLd; | |
1185 | distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++; | |
1186 | } // end if | |
1187 | } // end if | |
1188 | } // end for iLd | |
1189 | if(ip==0) { cout<< " No detector along phi \n"; getchar();} | |
1190 | ladder=Int_t (listLad(0)); | |
1191 | if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1)); | |
1192 | return 0; | |
1193 | } | |
1194 | //______________________________________________________________________ | |
1195 | void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster, | |
1196 | Double_t sigma[2]){ | |
1197 | //Origin A. Badala' and G.S. Pappalardo: | |
1198 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
1199 | // Kalman filter without vertex constraint | |
1200 | ////// Evaluation of the measurement vector //////////////////////// | |
1201 | Double_t m[2]; | |
1202 | Double_t rk,phik,zk; | |
1203 | rk=cluster(0); phik=cluster(1); zk=cluster(2); | |
1204 | m[0]=phik; m[1]=zk; | |
1205 | //////////////////////// Evaluation of the error matrix V ///////// | |
1206 | Double_t v00=sigma[0]; | |
1207 | Double_t v11=sigma[1]; | |
1208 | //////////////////////////////////////////////////////////////////// | |
1209 | Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22, | |
1210 | cin32,cin42,cin33,cin43,cin44; | |
1211 | ||
1212 | newTrack->GetCElements(cin00, | |
1213 | cin10,cin11, | |
1214 | cin20,cin21,cin22, | |
1215 | cin30,cin31,cin32,cin33, | |
1216 | cin40,cin41,cin42,cin43,cin44); //get C matrix | |
1217 | Double_t rold00=cin00+v00; | |
1218 | Double_t rold10=cin10; | |
1219 | Double_t rold11=cin11+v11; | |
1220 | ////////////////////// R matrix inversion ///////////////////////// | |
1221 | Double_t det=rold00*rold11-rold10*rold10; | |
1222 | Double_t r00=rold11/det; | |
1223 | Double_t r10=-rold10/det; | |
1224 | Double_t r11=rold00/det; | |
1225 | //////////////////////////////////////////////////////////////////// | |
1226 | Double_t k00=cin00*r00+cin10*r10; | |
1227 | Double_t k01=cin00*r10+cin10*r11; | |
1228 | Double_t k10=cin10*r00+cin11*r10; | |
1229 | Double_t k11=cin10*r10+cin11*r11; | |
1230 | Double_t k20=cin20*r00+cin21*r10; | |
1231 | Double_t k21=cin20*r10+cin21*r11; | |
1232 | Double_t k30=cin30*r00+cin31*r10; | |
1233 | Double_t k31=cin30*r10+cin31*r11; | |
1234 | Double_t k40=cin40*r00+cin41*r10; | |
1235 | Double_t k41=cin40*r10+cin41*r11; | |
1236 | Double_t x0,x1,x2,x3,x4; | |
1237 | newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector | |
1238 | Double_t savex0=x0, savex1=x1; | |
1239 | x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1); | |
1240 | x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1); | |
1241 | x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1); | |
1242 | x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1); | |
1243 | x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1); | |
1244 | Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44; | |
1245 | c00=cin00-k00*cin00-k01*cin10; | |
1246 | c10=cin10-k00*cin10-k01*cin11; | |
1247 | c20=cin20-k00*cin20-k01*cin21; | |
1248 | c30=cin30-k00*cin30-k01*cin31; | |
1249 | c40=cin40-k00*cin40-k01*cin41; | |
1250 | c11=cin11-k10*cin10-k11*cin11; | |
1251 | c21=cin21-k10*cin20-k11*cin21; | |
1252 | c31=cin31-k10*cin30-k11*cin31; | |
1253 | c41=cin41-k10*cin40-k11*cin41; | |
1254 | c22=cin22-k20*cin20-k21*cin21; | |
1255 | c32=cin32-k20*cin30-k21*cin31; | |
1256 | c42=cin42-k20*cin40-k21*cin41; | |
1257 | c33=cin33-k30*cin30-k31*cin31; | |
1258 | c43=cin43-k30*cin40-k31*cin41; | |
1259 | c44=cin44-k40*cin40-k41*cin41; | |
1260 | newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector | |
1261 | newTrack->PutCElements(c00, | |
1262 | c10,c11, | |
1263 | c20,c21,c22, | |
1264 | c30,c31,c32,c33, | |
1265 | c40,c41,c42,c43,c44); // put in track the | |
1266 | // new cov matrix | |
1267 | Double_t vmcold00=v00-c00; | |
1268 | Double_t vmcold10=-c10; | |
1269 | Double_t vmcold11=v11-c11; | |
1270 | ////////////////////// Matrix vmc inversion /////////////////////// | |
1271 | det=vmcold00*vmcold11-vmcold10*vmcold10; | |
1272 | Double_t vmc00=vmcold11/det; | |
1273 | Double_t vmc10=-vmcold10/det; | |
1274 | Double_t vmc11=vmcold00/det; | |
1275 | //////////////////////////////////////////////////////////////////// | |
1276 | Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) + | |
1277 | (m[1]-x1)*vmc11*(m[1]-x1); | |
04b80329 | 1278 | newTrack->SetChi2(newTrack->GetChi2()+chi2); |
b48af428 | 1279 | } |
1280 | //---------------------------------------------------------------------- | |
1281 | //void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack, | |
1282 | // TVector &cluster,Double_t sigma[2]){ | |
1283 | void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack, | |
1284 | TVector &cluster,Double_t sigma[2] | |
1285 | /*, Double_t chi2pred*/){ | |
1286 | //Origin A. Badala' and G.S. Pappalardo: | |
1287 | // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it | |
1288 | // Kalman filter with vertex constraint | |
1289 | ///////////////////// Evaluation of the measurement vector m //////// | |
1290 | Double_t m[4]; | |
1291 | Double_t rk,phik,zk; | |
1292 | rk=cluster(0); phik=cluster(1); zk=cluster(2); | |
1293 | m[0]=phik; m[1]=zk; | |
1294 | Double_t cc=(*newTrack).GetC(); | |
1295 | Double_t zv=(*newTrack).GetZv(); | |
1296 | Double_t dv=(*newTrack).GetDv(); | |
1297 | Double_t cy=cc/2.; | |
1298 | Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk); | |
1299 | m[2]=dv; m[3]=tgl; | |
1300 | /////////////////////// Evaluation of the error matrix V ////////// | |
1301 | Int_t layer=newTrack->GetLayer(); | |
1302 | Double_t v00=sigma[0]; | |
1303 | Double_t v11=sigma[1]; | |
1304 | Double_t v31=sigma[1]/rk; | |
1305 | Double_t sigmaDv=newTrack->GetsigmaDv(); | |
1306 | Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1); | |
1307 | Double_t v32=newTrack->Getdtgl(layer-1); | |
1308 | Double_t sigmaZv=newTrack->GetsigmaZv(); | |
1309 | Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1); | |
1310 | ////////////////////////////////////////////////////////////////// | |
1311 | Double_t cin00,cin10,cin11,cin20,cin21,cin22, | |
1312 | cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44; | |
1313 | newTrack->GetCElements(cin00, | |
1314 | cin10,cin11, | |
1315 | cin20,cin21,cin22, | |
1316 | cin30,cin31,cin32,cin33, | |
1317 | cin40,cin41,cin42,cin43,cin44); //get C matrix | |
1318 | Double_t r[4][4]; | |
1319 | r[0][0]=cin00+v00; | |
1320 | r[1][0]=cin10; | |
1321 | r[2][0]=cin20; | |
1322 | r[3][0]=cin30; | |
1323 | r[1][1]=cin11+v11; | |
1324 | r[2][1]=cin21; | |
1325 | r[3][1]=cin31+sigma[1]/rk; | |
1326 | r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1); | |
1327 | r[3][2]=cin32+newTrack->Getdtgl(layer-1); | |
1328 | r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+ | |
1329 | newTrack->Gettgl2(layer-1); | |
1330 | r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0]; | |
1331 | r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2]; | |
1332 | ///////////////////// Matrix R inversion ////////////////////////// | |
1333 | const Int_t kn=4; | |
1334 | Double_t big, hold; | |
1335 | Double_t d=1.; | |
1336 | Int_t ll[kn],mm[kn]; | |
1337 | Int_t i,j,k; | |
1338 | ||
1339 | for(k=0; k<kn; k++) { | |
1340 | ll[k]=k; | |
1341 | mm[k]=k; | |
1342 | big=r[k][k]; | |
1343 | for(j=k; j<kn ; j++) { | |
1344 | for (i=j; i<kn; i++) { | |
1345 | if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) { | |
1346 | big=r[i][j]; | |
1347 | ll[k]=i; | |
1348 | mm[k]=j; | |
1349 | } // end if | |
1350 | } // end for i | |
1351 | } // end for j | |
1352 | // | |
1353 | j= ll[k]; | |
1354 | if(j > k) { | |
1355 | for(i=0; i<kn; i++) { | |
1356 | hold=-r[k][i]; | |
1357 | r[k][i]=r[j][i]; | |
1358 | r[j][i]=hold; | |
1359 | } // end for i | |
1360 | }// end if | |
1361 | // | |
1362 | i=mm[k]; | |
1363 | if(i > k ) { | |
1364 | for(j=0; j<kn; j++) { | |
1365 | hold=-r[j][k]; | |
1366 | r[j][k]=r[j][i]; | |
1367 | r[j][i]=hold; | |
1368 | } // end for j | |
1369 | } // end if | |
1370 | // | |
1371 | if(!big) { | |
1372 | d=0.; | |
1373 | cout << "Singular matrix\n"; | |
1374 | } // end if | |
1375 | for(i=0; i<kn; i++) { | |
1376 | if(i == k) { continue; } | |
1377 | r[i][k]=r[i][k]/(-big); | |
1378 | } // end for i | |
1379 | // | |
1380 | for(i=0; i<kn; i++) { | |
1381 | hold=r[i][k]; | |
1382 | for(j=0; j<kn; j++) { | |
1383 | if(i == k || j == k) continue; | |
1384 | r[i][j]=hold*r[k][j]+r[i][j]; | |
1385 | } // end for j | |
1386 | } // end of ri | |
1387 | // | |
1388 | for(j=0; j<kn; j++) { | |
1389 | if(j == k) continue; | |
1390 | r[k][j]=r[k][j]/big; | |
1391 | } // end for j | |
1392 | // | |
1393 | d=d*big; | |
1394 | // | |
1395 | r[k][k]=1./big; | |
1396 | } // end for k | |
1397 | // | |
1398 | for(k=kn-1; k>=0; k--) { | |
1399 | i=ll[k]; | |
1400 | if(i > k) { | |
1401 | for (j=0; j<kn; j++) { | |
1402 | hold=r[j][k]; | |
1403 | r[j][k]=-r[j][i]; | |
1404 | r[j][i]=hold; | |
1405 | } // end for j | |
1406 | } // end if i | |
1407 | j=mm[k]; | |
1408 | if(j > k) { | |
1409 | for (i=0; i<kn; i++) { | |
1410 | hold=r[k][i]; | |
1411 | r[k][i]=-r[j][i]; | |
1412 | r[j][i]=hold; | |
1413 | } // end for i | |
1414 | } // end if | |
1415 | } // end for k | |
1416 | //////////////////////////////////////////////////////////////////// | |
1417 | Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0]; | |
1418 | Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1]; | |
1419 | Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2]; | |
1420 | Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3]; | |
1421 | Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0]; | |
1422 | Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1]; | |
1423 | Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2]; | |
1424 | Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3]; | |
1425 | Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0]; | |
1426 | Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1]; | |
1427 | Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2]; | |
1428 | Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3]; | |
1429 | Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0]; | |
1430 | Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1]; | |
1431 | Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2]; | |
1432 | Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3]; | |
1433 | Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0]; | |
1434 | Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1]; | |
1435 | Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2]; | |
1436 | Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3]; | |
1437 | ||
1438 | Double_t x0,x1,x2,x3,x4; | |
1439 | newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector | |
1440 | Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3; | |
1441 | x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+ | |
1442 | k03*(m[3]-savex3); | |
1443 | x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+ | |
1444 | k13*(m[3]-savex3); | |
1445 | x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+ | |
1446 | k23*(m[3]-savex3); | |
1447 | x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+ | |
1448 | k33*(m[3]-savex3); | |
1449 | x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+ | |
1450 | k43*(m[3]-savex3); | |
1451 | Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44; | |
1452 | c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30; | |
1453 | c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31; | |
1454 | c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32; | |
1455 | c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33; | |
1456 | c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43; | |
1457 | c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31; | |
1458 | c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32; | |
1459 | c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33; | |
1460 | c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43; | |
1461 | c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32; | |
1462 | c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33; | |
1463 | c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43; | |
1464 | c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33; | |
1465 | c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43; | |
1466 | c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43; | |
1467 | ||
1468 | newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector | |
1469 | newTrack->PutCElements(c00, | |
1470 | c10,c11, | |
1471 | c20,c21,c22, | |
1472 | c30,c31,c32,c33, | |
1473 | c40,c41,c42,c43,c44); // put in track the | |
1474 | // new cov matrix | |
1475 | Double_t vmc[4][4]; | |
1476 | vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30; | |
1477 | vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31; | |
1478 | vmc[2][2]=v22-c22; vmc[3][2]=v32-c32; | |
1479 | vmc[3][3]=v33-c33; | |
1480 | vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0]; | |
1481 | vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1]; | |
1482 | vmc[2][3]=vmc[3][2]; | |
1483 | /////////////////////// vmc matrix inversion /////////////////////// | |
1484 | d=1.; | |
1485 | for(k=0; k<kn; k++) { | |
1486 | ll[k]=k; | |
1487 | mm[k]=k; | |
1488 | big=vmc[k][k]; | |
1489 | for(j=k; j<kn ; j++) { | |
1490 | for (i=j; i<kn; i++) { | |
1491 | if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) { | |
1492 | big=vmc[i][j]; | |
1493 | ll[k]=i; | |
1494 | mm[k]=j; | |
1495 | } // end if | |
1496 | } // end for i | |
1497 | } // end for j | |
1498 | // | |
1499 | j= ll[k]; | |
1500 | if(j > k) { | |
1501 | for(i=0; i<kn; i++) { | |
1502 | hold=-vmc[k][i]; | |
1503 | vmc[k][i]=vmc[j][i]; | |
1504 | vmc[j][i]=hold; | |
1505 | } // end for i | |
1506 | } // end if | |
1507 | // | |
1508 | i=mm[k]; | |
1509 | if(i > k ) { | |
1510 | for(j=0; j<kn; j++) { | |
1511 | hold=-vmc[j][k]; | |
1512 | vmc[j][k]=vmc[j][i]; | |
1513 | vmc[j][i]=hold; | |
1514 | } // end for j | |
1515 | } // end if | |
1516 | // | |
1517 | if(!big) { | |
1518 | d=0.; | |
1519 | cout << "Singular matrix\n"; | |
1520 | } // end if | |
1521 | for(i=0; i<kn; i++) { | |
1522 | if(i == k) continue; | |
1523 | vmc[i][k]=vmc[i][k]/(-big); | |
1524 | } // end for i | |
1525 | // | |
1526 | for(i=0; i<kn; i++) { | |
1527 | hold=vmc[i][k]; | |
1528 | for(j=0; j<kn; j++) { | |
1529 | if(i == k || j == k) continue; | |
1530 | vmc[i][j]=hold*vmc[k][j]+vmc[i][j]; | |
1531 | } // end for j | |
1532 | } // end for i | |
1533 | // | |
1534 | for(j=0; j<kn; j++) { | |
1535 | if(j == k) continue; | |
1536 | vmc[k][j]=vmc[k][j]/big; | |
1537 | } // end for j | |
1538 | // | |
1539 | d=d*big; | |
1540 | // | |
1541 | vmc[k][k]=1./big; | |
1542 | } // end for k | |
1543 | // | |
1544 | for(k=kn-1; k>=0; k--) { | |
1545 | i=ll[k]; | |
1546 | if(i > k) { | |
1547 | for (j=0; j<kn; j++) { | |
1548 | hold=vmc[j][k]; | |
1549 | vmc[j][k]=-vmc[j][i]; | |
1550 | vmc[j][i]=hold; | |
1551 | } // end for j | |
1552 | } // end if i>k | |
1553 | j=mm[k]; | |
1554 | if(j > k) { | |
1555 | for (i=0; i<kn; i++) { | |
1556 | hold=vmc[k][i]; | |
1557 | vmc[k][i]=-vmc[j][i]; | |
1558 | vmc[j][i]=hold; | |
1559 | } // end for i | |
1560 | } // end if j>k | |
1561 | } // end for k | |
1562 | //////////////////////////////////////////////////////////////////// | |
1563 | Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) + | |
1564 | 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+ | |
1565 | (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+ | |
1566 | 2.*vmc[3][1]*(m[3]-x3) ) + | |
1567 | (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) + | |
1568 | (m[3]-x3)*vmc[3][3]*(m[3]-x3); | |
1569 | //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar(); | |
1570 | newTrack->SetChi2(newTrack->GetChi2()+chi2); | |
1571 | // newTrack->SetChi2(newTrack->GetChi2()+chi2pred); | |
1572 | } |