]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITStrackerV2.cxx
Including cmath
[u/mrichter/AliRoot.git] / ITS / AliITStrackerV2.cxx
CommitLineData
006b5f7f 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// Implementation of the ITS tracker class
00a7cc50 18// It reads AliITSRecPoint clusters and creates AliITStrackV2 tracks
18856a77 19// and fills with them the ESD
006b5f7f 20// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
a9a2d814 21// dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
006b5f7f 22//-------------------------------------------------------------------------
1f9a65c4 23
9c369bfe 24#include <new>
25
006b5f7f 26#include <TFile.h>
27#include <TTree.h>
28#include <TRandom.h>
a504d56f 29#include <TGeoMatrix.h>
006b5f7f 30
e341247d 31#include "AliITSgeomTGeo.h"
a504d56f 32#include "AliAlignObj.h"
006b5f7f 33#include "AliITSRecPoint.h"
c630aafd 34#include "AliESD.h"
00a7cc50 35#include "AliITSRecPoint.h"
006b5f7f 36#include "AliITStrackerV2.h"
37
8676d691 38ClassImp(AliITStrackerV2)
006b5f7f 39
a504d56f 40AliITStrackerV2::AliITSlayer AliITStrackerV2::fgLayers[kMaxLayer]; //ITS layers
006b5f7f 41
6c94f330 42AliITStrackerV2::AliITStrackerV2():
43 AliTracker(),
44 fI(kMaxLayer),
45 fBestTrack(),
46 fTrackToFollow(),
47 fPass(0),
48 fLastLayerToTrackTo(kLastLayerToTrackTo)
49{
50 //--------------------------------------------------------------------
51 //This is the AliITStrackerV2 default constructor
52 //--------------------------------------------------------------------
53
54 for (Int_t i=1; i<kMaxLayer+1; i++) new(fgLayers+i-1) AliITSlayer();
55
56 fConstraint[0]=1; fConstraint[1]=0;
57
58 Double_t xyz[]={kXV,kYV,kZV}, ers[]={kSigmaXV,kSigmaYV,kSigmaZV};
59 SetVertex(xyz,ers);
60
61 for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=kLayersNotToSkip[i];
62
63}
64
65AliITStrackerV2::AliITStrackerV2(const AliITStrackerV2 &t):
66 AliTracker(t),
67 fI(t.fI),
68 fBestTrack(t.fBestTrack),
69 fTrackToFollow(t.fTrackToFollow),
70 fPass(t.fPass),
71 fLastLayerToTrackTo(t.fLastLayerToTrackTo)
72{
73 //--------------------------------------------------------------------
74 //This is the AliITStrackerV2 copy constructor
75 //--------------------------------------------------------------------
76
77 //for (Int_t i=1; i<kMaxLayer+1; i++) new(fgLayers+i-1) AliITSlayer();
78
79 fConstraint[0]=t.fConstraint[0]; fConstraint[1]=t.fConstraint[1];
80
81 Double_t xyz[]={kXV,kYV,kZV}, ers[]={kSigmaXV,kSigmaYV,kSigmaZV};
82 xyz[0]=t.GetX(); xyz[1]=t.GetY(); xyz[2]=t.GetZ();
83 ers[0]=t.GetSigmaX(); ers[1]=t.GetSigmaY(); ers[2]=t.GetSigmaZ();
84 SetVertex(xyz,ers);
85
86 for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=t.fLayersNotToSkip[i];
87
88}
89
1f3e997f 90AliITStrackerV2::AliITStrackerV2(const Char_t *geom) :
6c94f330 91 AliTracker(),
92 fI(kMaxLayer),
93 fBestTrack(),
94 fTrackToFollow(),
95 fPass(0),
96 fLastLayerToTrackTo(kLastLayerToTrackTo)
97{
006b5f7f 98 //--------------------------------------------------------------------
61ab8ea8 99 //This is the AliITStrackerV2 constructor
006b5f7f 100 //--------------------------------------------------------------------
e341247d 101 if (geom) {
102 AliWarning("\"geom\" is actually a dummy argument !");
103 }
006b5f7f 104
e341247d 105 for (Int_t i=1; i<kMaxLayer+1; i++) {
106 Int_t nlad=AliITSgeomTGeo::GetNLadders(i);
107 Int_t ndet=AliITSgeomTGeo::GetNDetectors(i);
006b5f7f 108
e341247d 109 Double_t xyz[3], &x=xyz[0], &y=xyz[1], &z=xyz[2];
110 AliITSgeomTGeo::GetOrigTranslation(i,1,1,xyz);
006b5f7f 111 Double_t poff=TMath::ATan2(y,x);
112 Double_t zoff=z;
a504d56f 113 Double_t r=TMath::Sqrt(x*x + y*y);
006b5f7f 114
e341247d 115 AliITSgeomTGeo::GetOrigTranslation(i,1,2,xyz);
006b5f7f 116 r += TMath::Sqrt(x*x + y*y);
e341247d 117 AliITSgeomTGeo::GetOrigTranslation(i,2,1,xyz);
006b5f7f 118 r += TMath::Sqrt(x*x + y*y);
e341247d 119 AliITSgeomTGeo::GetOrigTranslation(i,2,2,xyz);
006b5f7f 120 r += TMath::Sqrt(x*x + y*y);
121 r*=0.25;
122
18856a77 123 new (fgLayers+i-1) AliITSlayer(r,poff,zoff,nlad,ndet);
006b5f7f 124
125 for (Int_t j=1; j<nlad+1; j++) {
126 for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors
e341247d 127 TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m);
1f3e997f 128 const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k);
129 m.Multiply(tm);
130 Double_t txyz[3]={0.}, xyz[3]={0.};
131 m.LocalToMaster(txyz,xyz);
132 Double_t r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
133 Double_t phi=TMath::ATan2(xyz[1],xyz[0]);
c219fd63 134
135 if (phi<0) phi+=TMath::TwoPi();
136 else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi();
137
18856a77 138 AliITSdetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1);
006b5f7f 139 new(&det) AliITSdetector(r,phi);
140 }
141 }
c630aafd 142
006b5f7f 143 }
144
c219fd63 145 fConstraint[0]=1; fConstraint[1]=0;
8676d691 146
147 Double_t xyz[]={kXV,kYV,kZV}, ers[]={kSigmaXV,kSigmaYV,kSigmaZV};
148 SetVertex(xyz,ers);
c0dd5278 149
150 for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=kLayersNotToSkip[i];
c0dd5278 151
152}
153
154void AliITStrackerV2::SetLayersNotToSkip(Int_t *l) {
155 //--------------------------------------------------------------------
156 //This function set masks of the layers which must be not skipped
157 //--------------------------------------------------------------------
158 for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=l[i];
61ab8ea8 159}
006b5f7f 160
c630aafd 161Int_t AliITStrackerV2::LoadClusters(TTree *cTree) {
61ab8ea8 162 //--------------------------------------------------------------------
163 //This function loads ITS clusters
164 //--------------------------------------------------------------------
00a7cc50 165 TBranch *branch=cTree->GetBranch("ITSRecPoints");
61ab8ea8 166 if (!branch) {
c630aafd 167 Error("LoadClusters"," can't get the branch !\n");
8676d691 168 return 1;
61ab8ea8 169 }
006b5f7f 170
00a7cc50 171 TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy;
61ab8ea8 172 branch->SetAddress(&clusters);
006b5f7f 173
61ab8ea8 174 Int_t j=0;
175 for (Int_t i=0; i<kMaxLayer; i++) {
18856a77 176 Int_t ndet=fgLayers[i].GetNdetectors();
177 Int_t jmax = j + fgLayers[i].GetNladders()*ndet;
c219fd63 178
179 Double_t r=fgLayers[i].GetR();
180 Double_t circ=TMath::TwoPi()*r;
181
61ab8ea8 182 for (; j<jmax; j++) {
183 if (!cTree->GetEvent(j)) continue;
184 Int_t ncl=clusters->GetEntriesFast();
1f3e997f 185
186 //*** The Delta transformation
187 TGeoHMatrix delta;
188 AliITSgeomTGeo::GetTrackingMatrix(j,delta);
189 TGeoHMatrix m;
190 AliITSgeomTGeo::GetOrigMatrix(j,m);
191 delta.MultiplyLeft(&(m.Inverse()));
192 const TGeoHMatrix *tm = AliITSgeomTGeo::GetTracking2LocalMatrix(j);
193 delta.MultiplyLeft(&(tm->Inverse()));
194 //***
195
61ab8ea8 196 while (ncl--) {
00a7cc50 197 AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl);
c219fd63 198
1f3e997f 199 //*** Shift the cluster to the misaligned position
200 Double_t xyz[3]={c->GetX(),c->GetY(),c->GetZ()};
201 Double_t mxyz[3]={0.};
202
203 delta.LocalToMaster(xyz,mxyz);
204
205 c->SetX(mxyz[0]);
206 c->AliCluster::SetY(mxyz[1]);
207 c->AliCluster::SetZ(mxyz[2]);
208 //***
209
c219fd63 210 Int_t idx=c->GetDetectorIndex();
a504d56f 211 AliITSdetector &det=fgLayers[i].GetDetector(idx);
212
a504d56f 213 Double_t y=r*det.GetPhi()+c->GetY();
c219fd63 214 if (y>circ) y-=circ; else if (y<0) y+=circ;
215 c->SetPhiR(y);
216
00a7cc50 217 fgLayers[i].InsertCluster(new AliITSRecPoint(*c));
61ab8ea8 218 }
219 clusters->Delete();
220 }
18856a77 221 fgLayers[i].ResetRoad(); //road defined by the cluster density
006b5f7f 222 }
c630aafd 223
8676d691 224 return 0;
61ab8ea8 225}
006b5f7f 226
61ab8ea8 227void AliITStrackerV2::UnloadClusters() {
228 //--------------------------------------------------------------------
229 //This function unloads ITS clusters
230 //--------------------------------------------------------------------
18856a77 231 for (Int_t i=0; i<kMaxLayer; i++) fgLayers[i].ResetClusters();
006b5f7f 232}
233
880f41b9 234static Int_t CorrectForDeadZoneMaterial(AliITStrackV2 *t) {
235 //--------------------------------------------------------------------
236 // Correction for the material between the TPC and the ITS
237 // (should it belong to the TPC code ?)
238 //--------------------------------------------------------------------
239 Double_t riw=80., diw=0.0053, x0iw=30; // TPC inner wall ?
240 Double_t rcd=61., dcd=0.0053, x0cd=30; // TPC "central drum" ?
241 Double_t yr=12.8, dr=0.03; // rods ?
242 Double_t zm=0.2, dm=0.40; // membrane
243 //Double_t rr=52., dr=0.19, x0r=24., yyr=7.77; //rails
244 Double_t rs=50., ds=0.001; // something belonging to the ITS (screen ?)
245
246 if (t->GetX() > riw) {
247 if (!t->PropagateTo(riw,diw,x0iw)) return 1;
248 if (TMath::Abs(t->GetY())>yr) t->CorrectForMaterial(dr);
249 if (TMath::Abs(t->GetZ())<zm) t->CorrectForMaterial(dm);
250 if (!t->PropagateTo(rcd,dcd,x0cd)) return 1;
251 //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z);
252 //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,dr,x0r);
253 if (!t->PropagateTo(rs,ds)) return 1;
254 } else if (t->GetX() < rs) {
255 if (!t->PropagateTo(rs,-ds)) return 1;
256 //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z);
257 //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,-dr,x0r);
258 if (!t->PropagateTo(rcd,-dcd,x0cd)) return 1;
ba1a3e1a 259 if (!t->PropagateTo(riw+0.001,-diw,x0iw)) return 1;
880f41b9 260 } else {
261 ::Error("CorrectForDeadZoneMaterial","track is already in the dead zone !");
262 return 1;
263 }
264
265 return 0;
266}
267
c630aafd 268Int_t AliITStrackerV2::Clusters2Tracks(AliESD *event) {
006b5f7f 269 //--------------------------------------------------------------------
c630aafd 270 // This functions reconstructs ITS tracks
271 // The clusters must be already loaded !
006b5f7f 272 //--------------------------------------------------------------------
c630aafd 273 TObjArray itsTracks(15000);
006b5f7f 274
c630aafd 275 {/* Read ESD tracks */
276 Int_t nentr=event->GetNumberOfTracks();
277 Info("Clusters2Tracks", "Number of ESD tracks: %d\n", nentr);
278 while (nentr--) {
279 AliESDtrack *esd=event->GetTrack(nentr);
280
ba1a3e1a 281 if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) continue;
282 if (esd->GetStatus()&AliESDtrack::kTPCout) continue;
283 if (esd->GetStatus()&AliESDtrack::kITSin) continue;
c630aafd 284
285 AliITStrackV2 *t=0;
286 try {
287 t=new AliITStrackV2(*esd);
288 } catch (const Char_t *msg) {
289 Warning("Clusters2Tracks",msg);
290 delete t;
291 continue;
292 }
6c94f330 293 if (TMath::Abs(t->GetD(GetX(),GetY()))>4) {
ebd8369c 294 delete t;
295 continue;
296 }
006b5f7f 297
c630aafd 298 if (CorrectForDeadZoneMaterial(t)!=0) {
299 Warning("Clusters2Tracks",
300 "failed to correct for the material in the dead zone !\n");
301 delete t;
302 continue;
303 }
304 itsTracks.AddLast(t);
305 }
306 } /* End Read ESD tracks */
307
308 itsTracks.Sort();
309 Int_t nentr=itsTracks.GetEntriesFast();
15dd636f 310
c630aafd 311 Int_t ntrk=0;
312 for (fPass=0; fPass<2; fPass++) {
313 Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue;
314 for (Int_t i=0; i<nentr; i++) {
315 AliITStrackV2 *t=(AliITStrackV2*)itsTracks.UncheckedAt(i);
15dd636f 316 if (t==0) continue; //this track has been already tracked
c630aafd 317 Int_t tpcLabel=t->GetLabel(); //save the TPC track label
318
319 ResetTrackToFollow(*t);
320 ResetBestTrack();
321
322 for (FollowProlongation(); fI<kMaxLayer; fI++) {
15dd636f 323 while (TakeNextProlongation()) FollowProlongation();
c630aafd 324 }
325
de5d3595 326 if (fBestTrack.GetNumberOfClusters() == 0) continue;
15dd636f 327
c630aafd 328 if (fConstraint[fPass]) {
15dd636f 329 ResetTrackToFollow(*t);
330 if (!RefitAt(3.7, &fTrackToFollow, &fBestTrack)) continue;
331 ResetBestTrack();
332 }
333
c630aafd 334 fBestTrack.SetLabel(tpcLabel);
335 fBestTrack.CookdEdx();
336 CookLabel(&fBestTrack,0.); //For comparison only
337 fBestTrack.UpdateESDtrack(AliESDtrack::kITSin);
15dd636f 338 UseClusters(&fBestTrack);
c630aafd 339 delete itsTracks.RemoveAt(i);
340 ntrk++;
341 }
342 }
babd135a 343
c630aafd 344 itsTracks.Delete();
2257f27e 345
c630aafd 346 Info("Clusters2Tracks","Number of prolonged tracks: %d\n",ntrk);
347
348 return 0;
349}
350
c630aafd 351Int_t AliITStrackerV2::PropagateBack(AliESD *event) {
352 //--------------------------------------------------------------------
353 // This functions propagates reconstructed ITS tracks back
354 // The clusters must be loaded !
355 //--------------------------------------------------------------------
356 Int_t nentr=event->GetNumberOfTracks();
357 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
358
359 Int_t ntrk=0;
360 for (Int_t i=0; i<nentr; i++) {
361 AliESDtrack *esd=event->GetTrack(i);
362
ba1a3e1a 363 if ((esd->GetStatus()&AliESDtrack::kITSin)==0) continue;
364 if (esd->GetStatus()&AliESDtrack::kITSout) continue;
c630aafd 365
366 AliITStrackV2 *t=0;
367 try {
368 t=new AliITStrackV2(*esd);
369 } catch (const Char_t *msg) {
370 Warning("PropagateBack",msg);
371 delete t;
372 continue;
373 }
374
375 ResetTrackToFollow(*t);
376
377 // propagete to vertex [SR, GSI 17.02.2003]
a9459f9c 378 // Start Time measurement [SR, GSI 17.02.2003], corrected by I.Belikov
379 if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {
6c94f330 380 if (fTrackToFollow.PropagateToVertex(event->GetVertex())) {
a9459f9c 381 fTrackToFollow.StartTimeIntegral();
382 }
383 fTrackToFollow.PropagateTo(3.,-0.0028,65.19);
384 }
c630aafd 385
6c94f330 386 fTrackToFollow.ResetCovariance(10.); fTrackToFollow.ResetClusters();
c630aafd 387 if (RefitAt(49.,&fTrackToFollow,t)) {
388 if (CorrectForDeadZoneMaterial(&fTrackToFollow)!=0) {
389 Warning("PropagateBack",
390 "failed to correct for the material in the dead zone !\n");
391 delete t;
392 continue;
393 }
394 fTrackToFollow.SetLabel(t->GetLabel());
ba1a3e1a 395 //fTrackToFollow.CookdEdx();
c630aafd 396 CookLabel(&fTrackToFollow,0.); //For comparison only
397 fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSout);
15dd636f 398 UseClusters(&fTrackToFollow);
c630aafd 399 ntrk++;
400 }
401 delete t;
402 }
403
404 Info("PropagateBack","Number of back propagated ITS tracks: %d\n",ntrk);
61ab8ea8 405
83d73500 406 return 0;
407}
408
c630aafd 409Int_t AliITStrackerV2::RefitInward(AliESD *event) {
83d73500 410 //--------------------------------------------------------------------
411 // This functions refits ITS tracks using the
412 // "inward propagated" TPC tracks
c630aafd 413 // The clusters must be loaded !
83d73500 414 //--------------------------------------------------------------------
c630aafd 415 Int_t nentr=event->GetNumberOfTracks();
416 Info("RefitInward", "Number of ESD tracks: %d\n", nentr);
417
418 Int_t ntrk=0;
419 for (Int_t i=0; i<nentr; i++) {
420 AliESDtrack *esd=event->GetTrack(i);
421
ba1a3e1a 422 if ((esd->GetStatus()&AliESDtrack::kITSout) == 0) continue;
423 if (esd->GetStatus()&AliESDtrack::kITSrefit) continue;
424 if (esd->GetStatus()&AliESDtrack::kTPCout)
15dd636f 425 if ((esd->GetStatus()&AliESDtrack::kTPCrefit)==0) continue;
c630aafd 426
427 AliITStrackV2 *t=0;
428 try {
429 t=new AliITStrackV2(*esd);
430 } catch (const Char_t *msg) {
431 Warning("RefitInward",msg);
432 delete t;
433 continue;
434 }
435
436 if (CorrectForDeadZoneMaterial(t)!=0) {
437 Warning("RefitInward",
438 "failed to correct for the material in the dead zone !\n");
439 delete t;
440 continue;
441 }
442
443 ResetTrackToFollow(*t);
444 fTrackToFollow.ResetClusters();
445
446 //Refitting...
ef7253ac 447 if (RefitAt(3.7, &fTrackToFollow, t, kTRUE)) {
c630aafd 448 fTrackToFollow.SetLabel(t->GetLabel());
449 fTrackToFollow.CookdEdx();
15dd636f 450 CookLabel(&fTrackToFollow,0.); //For comparison only
18856a77 451
49d13e89 452 if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {//The beam pipe
453 AliESDtrack *esdTrack =fTrackToFollow.GetESDtrack();
454 esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit);
455 Float_t r[3]={0.,0.,0.};
456 Double_t maxD=3.;
457 esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD);
458 ntrk++;
67c3dcbe 459 }
c630aafd 460 }
461 delete t;
462 }
463
464 Info("RefitInward","Number of refitted tracks: %d\n",ntrk);
83d73500 465
c630aafd 466 return 0;
467}
83d73500 468
006b5f7f 469AliCluster *AliITStrackerV2::GetCluster(Int_t index) const {
470 //--------------------------------------------------------------------
471 // Return pointer to a given cluster
472 //--------------------------------------------------------------------
473 Int_t l=(index & 0xf0000000) >> 28;
474 Int_t c=(index & 0x0fffffff) >> 00;
18856a77 475 return fgLayers[l].GetCluster(c);
006b5f7f 476}
477
478
479void AliITStrackerV2::FollowProlongation() {
480 //--------------------------------------------------------------------
481 //This function finds a track prolongation
482 //--------------------------------------------------------------------
c0dd5278 483 while (fI>fLastLayerToTrackTo) {
a9a2d814 484 Int_t i=fI-1;
8676d691 485
18856a77 486 AliITSlayer &layer=fgLayers[i];
a9a2d814 487 AliITStrackV2 &track=fTracks[i];
006b5f7f 488
14825d5a 489 Double_t r=layer.GetR();
61ab8ea8 490
a9a2d814 491 if (i==3 || i==1) {
18856a77 492 Double_t rs=0.5*(fgLayers[i+1].GetR() + r);
61ab8ea8 493 Double_t d=0.0034, x0=38.6;
494 if (i==1) {rs=9.; d=0.0097; x0=42;}
495 if (!fTrackToFollow.PropagateTo(rs,d,x0)) {
8676d691 496 //Warning("FollowProlongation","propagation failed !\n");
c0dd5278 497 return;
a9a2d814 498 }
006b5f7f 499 }
500
501 //find intersection
502 Double_t x,y,z;
14825d5a 503 if (!fTrackToFollow.GetGlobalXYZat(r,x,y,z)) {
8676d691 504 //Warning("FollowProlongation","failed to estimate track !\n");
c0dd5278 505 return;
006b5f7f 506 }
507 Double_t phi=TMath::ATan2(y,x);
f363d377 508
006b5f7f 509 Int_t idet=layer.FindDetectorIndex(phi,z);
510 if (idet<0) {
8676d691 511 //Warning("FollowProlongation","failed to find a detector !\n");
c0dd5278 512 return;
006b5f7f 513 }
514
515 //propagate to the intersection
516 const AliITSdetector &det=layer.GetDetector(idet);
14825d5a 517 phi=det.GetPhi();
a9a2d814 518 if (!fTrackToFollow.Propagate(phi,det.GetR())) {
8676d691 519 //Warning("FollowProlongation","propagation failed !\n");
c0dd5278 520 return;
006b5f7f 521 }
522 fTrackToFollow.SetDetectorIndex(idet);
523
524 //Select possible prolongations and store the current track estimation
525 track.~AliITStrackV2(); new(&track) AliITStrackV2(fTrackToFollow);
8676d691 526 Double_t dz=7*TMath::Sqrt(track.GetSigmaZ2() + kSigmaZ2[i]);
527 Double_t dy=7*TMath::Sqrt(track.GetSigmaY2() + kSigmaY2[i]);
528 Double_t road=layer.GetRoad();
529 if (dz*dy>road*road) {
530 Double_t dd=TMath::Sqrt(dz*dy), scz=dz/dd, scy=dy/dd;
531 dz=road*scz; dy=road*scy;
532 }
b87bd7cd 533
534 //Double_t dz=4*TMath::Sqrt(track.GetSigmaZ2() + kSigmaZ2[i]);
14825d5a 535 if (dz < 0.5*TMath::Abs(track.GetTgl())) dz=0.5*TMath::Abs(track.GetTgl());
7f6ddf58 536 if (dz > kMaxRoad) {
8676d691 537 //Warning("FollowProlongation","too broad road in Z !\n");
c0dd5278 538 return;
006b5f7f 539 }
a9a2d814 540
15dd636f 541 if (TMath::Abs(fTrackToFollow.GetZ()-GetZ()) > r+dz) return;
a9a2d814 542
b87bd7cd 543 //Double_t dy=4*TMath::Sqrt(track.GetSigmaY2() + kSigmaY2[i]);
14825d5a 544 if (dy < 0.5*TMath::Abs(track.GetSnp())) dy=0.5*TMath::Abs(track.GetSnp());
7f6ddf58 545 if (dy > kMaxRoad) {
8676d691 546 //Warning("FollowProlongation","too broad road in Y !\n");
c0dd5278 547 return;
006b5f7f 548 }
a9a2d814 549
c219fd63 550 fI--;
551
7f6ddf58 552 Double_t zmin=track.GetZ() - dz;
006b5f7f 553 Double_t zmax=track.GetZ() + dz;
14825d5a 554 Double_t ymin=track.GetY() + r*phi - dy;
555 Double_t ymax=track.GetY() + r*phi + dy;
c219fd63 556 if (layer.SelectClusters(zmin,zmax,ymin,ymax)==0)
557 if (fLayersNotToSkip[fI]) return;
006b5f7f 558
15dd636f 559 if (!TakeNextProlongation())
560 if (fLayersNotToSkip[fI]) return;
561
006b5f7f 562 }
563
564 //deal with the best track
565 Int_t ncl=fTrackToFollow.GetNumberOfClusters();
566 Int_t nclb=fBestTrack.GetNumberOfClusters();
15dd636f 567 if (ncl)
568 if (ncl >= nclb) {
569 Double_t chi2=fTrackToFollow.GetChi2();
570 if (chi2/ncl < kChi2PerCluster) {
571 if (ncl > nclb || chi2 < fBestTrack.GetChi2()) {
572 ResetBestTrack();
006b5f7f 573 }
15dd636f 574 }
006b5f7f 575 }
15dd636f 576
006b5f7f 577}
578
006b5f7f 579Int_t AliITStrackerV2::TakeNextProlongation() {
580 //--------------------------------------------------------------------
a9a2d814 581 // This function takes another track prolongation
582 //
583 // dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
006b5f7f 584 //--------------------------------------------------------------------
18856a77 585 AliITSlayer &layer=fgLayers[fI];
4ab260d6 586 ResetTrackToFollow(fTracks[fI]);
006b5f7f 587
b87bd7cd 588 Double_t dz=7*TMath::Sqrt(fTrackToFollow.GetSigmaZ2() + kSigmaZ2[fI]);
589 Double_t dy=7*TMath::Sqrt(fTrackToFollow.GetSigmaY2() + kSigmaY2[fI]);
8676d691 590 Double_t road=layer.GetRoad();
591 if (dz*dy>road*road) {
592 Double_t dd=TMath::Sqrt(dz*dy), scz=dz/dd, scy=dy/dd;
593 dz=road*scz; dy=road*scy;
594 }
006b5f7f 595
00a7cc50 596 const AliITSRecPoint *c=0; Int_t ci=-1;
597 const AliITSRecPoint *cc=0; Int_t cci=-1;
c219fd63 598 Double_t chi2=kMaxChi2;
006b5f7f 599 while ((c=layer.GetNextCluster(ci))!=0) {
006b5f7f 600 Int_t idet=c->GetDetectorIndex();
15dd636f 601
4ab260d6 602 if (fTrackToFollow.GetDetectorIndex()!=idet) {
006b5f7f 603 const AliITSdetector &det=layer.GetDetector(idet);
4ab260d6 604 ResetTrackToFollow(fTracks[fI]);
605 if (!fTrackToFollow.Propagate(det.GetPhi(),det.GetR())) {
8676d691 606 //Warning("TakeNextProlongation","propagation failed !\n");
006b5f7f 607 continue;
608 }
4ab260d6 609 fTrackToFollow.SetDetectorIndex(idet);
610 if (TMath::Abs(fTrackToFollow.GetZ()-GetZ())>layer.GetR()+dz) continue;
006b5f7f 611 }
612
4ab260d6 613 if (TMath::Abs(fTrackToFollow.GetZ() - c->GetZ()) > dz) continue;
614 if (TMath::Abs(fTrackToFollow.GetY() - c->GetY()) > dy) continue;
006b5f7f 615
c219fd63 616 Double_t ch2=fTrackToFollow.GetPredictedChi2(c);
617 if (ch2 > chi2) continue;
618 chi2=ch2;
619 cc=c; cci=ci;
620 break;
006b5f7f 621 }
622
c219fd63 623 if (!cc) return 0;
006b5f7f 624
1f3e997f 625 {// Take into account the mis-alignment
626 Double_t x = fTrackToFollow.GetX() + cc->GetX();
627 if (!fTrackToFollow.PropagateTo(x,0.,0.)) return 0;
628 }
c219fd63 629 if (!fTrackToFollow.Update(cc,chi2,(fI<<28)+cci)) {
8676d691 630 //Warning("TakeNextProlongation","filtering failed !\n");
006b5f7f 631 return 0;
632 }
15dd636f 633
4ab260d6 634 if (fTrackToFollow.GetNumberOfClusters()>1)
6c94f330 635 if (TMath::Abs(fTrackToFollow.GetD(GetX(),GetY()))>4) return 0;
4ab260d6 636
a9a2d814 637 fTrackToFollow.
c219fd63 638 SetSampledEdx(cc->GetQ(),fTrackToFollow.GetNumberOfClusters()-1); //b.b.
a9a2d814 639
640 {
880f41b9 641 Double_t x0;
61ab8ea8 642 Double_t d=layer.GetThickness(fTrackToFollow.GetY(),fTrackToFollow.GetZ(),x0);
880f41b9 643 fTrackToFollow.CorrectForMaterial(d,x0);
a9a2d814 644 }
4ab260d6 645
a9a2d814 646 if (fConstraint[fPass]) {
4ab260d6 647 Double_t d=GetEffectiveThickness(0,0); //Think of this !!!!
8676d691 648 Double_t xyz[]={GetX(),GetY(),GetZ()};
649 Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()};
650 fTrackToFollow.Improve(d,xyz,ers);
a9a2d814 651 }
006b5f7f 652
006b5f7f 653 return 1;
654}
655
656
6c94f330 657AliITStrackerV2::AliITSlayer::AliITSlayer():
658 fR(0.),
659 fPhiOffset(0.),
660 fNladders(0),
661 fZOffset(0.),
662 fNdetectors(0),
663 fDetectors(0),
664 fNsel(0),
665 fRoad(2*fR*TMath::Sqrt(3.14/1.)) //assuming that there's only one cluster
666{
006b5f7f 667 //--------------------------------------------------------------------
668 //default AliITSlayer constructor
669 //--------------------------------------------------------------------
c219fd63 670
671 for (Int_t i=0; i<kNsector; i++) fN[i]=0;
c219fd63 672
006b5f7f 673}
674
675AliITStrackerV2::AliITSlayer::
6c94f330 676AliITSlayer(Double_t r,Double_t p,Double_t z,Int_t nl,Int_t nd):
677 fR(r),
678 fPhiOffset(p),
679 fNladders(nl),
680 fZOffset(z),
681 fNdetectors(nd),
682 fDetectors(new AliITSdetector[nl*nd]),
683 fNsel(0),
684 fRoad(2*r*TMath::Sqrt(3.14/1.)) //assuming that there's only one cluster
685{
006b5f7f 686 //--------------------------------------------------------------------
687 //main AliITSlayer constructor
688 //--------------------------------------------------------------------
006b5f7f 689
c219fd63 690 for (Int_t i=0; i<kNsector; i++) fN[i]=0;
c219fd63 691
692 for (Int_t i=0; i<kMaxClusterPerLayer; i++) fClusters[i]=0;
b87bd7cd 693
006b5f7f 694}
695
696AliITStrackerV2::AliITSlayer::~AliITSlayer() {
697 //--------------------------------------------------------------------
698 // AliITSlayer destructor
699 //--------------------------------------------------------------------
700 delete[] fDetectors;
c219fd63 701 ResetClusters();
006b5f7f 702}
703
61ab8ea8 704void AliITStrackerV2::AliITSlayer::ResetClusters() {
705 //--------------------------------------------------------------------
706 // This function removes loaded clusters
707 //--------------------------------------------------------------------
c219fd63 708 for (Int_t s=0; s<kNsector; s++) {
709 Int_t &n=fN[s];
710 while (n) {
711 n--;
712 delete fClusters[s*kMaxClusterPerSector+n];
713 }
714 }
61ab8ea8 715}
716
b87bd7cd 717void AliITStrackerV2::AliITSlayer::ResetRoad() {
718 //--------------------------------------------------------------------
719 // This function calculates the road defined by the cluster density
720 //--------------------------------------------------------------------
721 Int_t n=0;
c219fd63 722 for (Int_t s=0; s<kNsector; s++) {
723 Int_t i=fN[s];
724 while (i--)
725 if (TMath::Abs(fClusters[s*kMaxClusterPerSector+i]->GetZ())<fR) n++;
b87bd7cd 726 }
727 if (n>1) fRoad=2*fR*TMath::Sqrt(3.14/n);
728}
729
00a7cc50 730Int_t AliITStrackerV2::AliITSlayer::InsertCluster(AliITSRecPoint *c) {
006b5f7f 731 //--------------------------------------------------------------------
c219fd63 732 // This function inserts a cluster to this layer in increasing
733 // order of the cluster's fZ
006b5f7f 734 //--------------------------------------------------------------------
c219fd63 735 Float_t circ=TMath::TwoPi()*fR;
736 Int_t sec=Int_t(kNsector*c->GetPhiR()/circ);
81e97e0d 737 if (sec>=kNsector) {
738 ::Error("InsertCluster","Wrong sector !\n");
739 return 1;
740 }
c219fd63 741 Int_t &n=fN[sec];
742 if (n>=kMaxClusterPerSector) {
743 ::Error("InsertCluster","Too many clusters !\n");
744 return 1;
006b5f7f 745 }
c219fd63 746 if (n==0) fClusters[sec*kMaxClusterPerSector]=c;
747 else {
748 Int_t i=FindClusterIndex(c->GetZ(),sec);
749 Int_t k=n-i+sec*kMaxClusterPerSector;
00a7cc50 750 memmove(fClusters+i+1 ,fClusters+i,k*sizeof(AliITSRecPoint*));
c219fd63 751 fClusters[i]=c;
752 }
753 n++;
006b5f7f 754 return 0;
755}
756
c219fd63 757Int_t
758AliITStrackerV2::AliITSlayer::FindClusterIndex(Float_t z,Int_t s) const {
006b5f7f 759 //--------------------------------------------------------------------
c219fd63 760 // For the sector "s", this function returns the index of the first
761 // with its fZ >= "z".
006b5f7f 762 //--------------------------------------------------------------------
c219fd63 763 Int_t nc=fN[s];
764 if (nc==0) return kMaxClusterPerSector*s;
765
766 Int_t b=kMaxClusterPerSector*s;
767 if (z <= fClusters[b]->GetZ()) return b;
768
769 Int_t e=b+nc-1;
770 if (z > fClusters[e]->GetZ()) return e+1;
771
772 Int_t m=(b+e)/2;
006b5f7f 773 for (; b<e; m=(b+e)/2) {
774 if (z > fClusters[m]->GetZ()) b=m+1;
775 else e=m;
776 }
777 return m;
778}
779
c219fd63 780Int_t AliITStrackerV2::AliITSlayer::
781SelectClusters(Float_t zmin,Float_t zmax,Float_t ymin, Float_t ymax) {
006b5f7f 782 //--------------------------------------------------------------------
c219fd63 783 // This function selects clusters within the "window"
006b5f7f 784 //--------------------------------------------------------------------
c219fd63 785 Float_t circ=fR*TMath::TwoPi();
786
787 if (ymin>circ) ymin-=circ; else if (ymin<0) ymin+=circ;
788 if (ymax>circ) ymax-=circ; else if (ymax<0) ymax+=circ;
789
521f4796 790 Int_t i1=Int_t(kNsector*ymin/circ); if (i1==kNsector) i1--;
c219fd63 791 if (fN[i1]!=0) {
792 Float_t ym = (ymax<ymin) ? ymax+circ : ymax;
793 Int_t i=FindClusterIndex(zmin,i1), imax=i1*kMaxClusterPerSector+fN[i1];
794 for (; i<imax; i++) {
00a7cc50 795 AliITSRecPoint *c=fClusters[i];
c219fd63 796 if (c->IsUsed()) continue;
797 if (c->GetZ()>zmax) break;
798 if (c->GetPhiR()<=ymin) continue;
799 if (c->GetPhiR()>ym) continue;
800 fIndex[fNsel++]=i;
801 }
802 }
803
521f4796 804 Int_t i2=Int_t(kNsector*ymax/circ); if (i2==kNsector) i2--;
c219fd63 805 if (i2==i1) return fNsel;
806
807 if (fN[i2]!=0) {
808 Float_t ym = (ymin>ymax) ? ymin-circ : ymin;
809 Int_t i=FindClusterIndex(zmin,i2), imax=i2*kMaxClusterPerSector+fN[i2];
810 for (; i<imax; i++) {
00a7cc50 811 AliITSRecPoint *c=fClusters[i];
c219fd63 812 if (c->IsUsed()) continue;
813 if (c->GetZ()>zmax) break;
814 if (c->GetPhiR()<=ym) continue;
815 if (c->GetPhiR()>ymax) continue;
816 fIndex[fNsel++]=i;
817 }
818 }
819
820 return fNsel;
006b5f7f 821}
822
00a7cc50 823const AliITSRecPoint *AliITStrackerV2::AliITSlayer::GetNextCluster(Int_t &ci){
006b5f7f 824 //--------------------------------------------------------------------
825 // This function returns clusters within the "window"
826 //--------------------------------------------------------------------
00a7cc50 827 AliITSRecPoint *c=0;
c219fd63 828 ci=-1;
829 if (fNsel) {
830 fNsel--;
831 ci=fIndex[fNsel];
832 c=fClusters[ci];
006b5f7f 833 }
c219fd63 834 return c;
835}
7f6ddf58 836
c219fd63 837Int_t AliITStrackerV2::AliITSlayer::GetNumberOfClusters() const {
838 Int_t n=0;
839 for (Int_t s=0; s<kNsector; s++) n+=fN[s];
840 return n;
006b5f7f 841}
842
c219fd63 843Int_t
844AliITStrackerV2::AliITSlayer::FindDetectorIndex(Double_t phi,Double_t z)const {
006b5f7f 845 //--------------------------------------------------------------------
846 //This function finds the detector crossed by the track
847 //--------------------------------------------------------------------
f363d377 848 Double_t dphi=-(phi-fPhiOffset);
006b5f7f 849 if (dphi < 0) dphi += 2*TMath::Pi();
850 else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi();
851 Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5);
3e3e8427 852 if (np>=fNladders) np-=fNladders;
853 if (np<0) np+=fNladders;
006b5f7f 854
855 Double_t dz=fZOffset-z;
856 Int_t nz=Int_t(dz*(fNdetectors-1)*0.5/fZOffset+0.5);
3e3e8427 857 if (nz>=fNdetectors) return -1;
858 if (nz<0) return -1;
006b5f7f 859
006b5f7f 860 return np*fNdetectors + nz;
861}
862
863Double_t
61ab8ea8 864AliITStrackerV2::AliITSlayer::GetThickness(Double_t y,Double_t z,Double_t &x0)
865const {
a9a2d814 866 //--------------------------------------------------------------------
867 //This function returns the layer thickness at this point (units X0)
868 //--------------------------------------------------------------------
869 Double_t d=0.0085;
61ab8ea8 870 x0=21.82;
a9a2d814 871
872 if (43<fR&&fR<45) { //SSD2
61ab8ea8 873 Double_t dd=0.0034;
874 d=dd;
875 if (TMath::Abs(y-0.00)>3.40) d+=dd;
876 if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
877 if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
a9a2d814 878 for (Int_t i=0; i<12; i++) {
61ab8ea8 879 if (TMath::Abs(z-3.9*(i+0.5))<0.15) {
880 if (TMath::Abs(y-0.00)>3.40) d+=dd;
881 d+=0.0034;
882 break;
883 }
884 if (TMath::Abs(z+3.9*(i+0.5))<0.15) {
885 if (TMath::Abs(y-0.00)>3.40) d+=dd;
886 d+=0.0034;
887 break;
888 }
889 if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
890 if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;}
a9a2d814 891 }
892 } else
893 if (37<fR&&fR<41) { //SSD1
61ab8ea8 894 Double_t dd=0.0034;
895 d=dd;
896 if (TMath::Abs(y-0.00)>3.40) d+=dd;
897 if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
898 if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
a9a2d814 899 for (Int_t i=0; i<11; i++) {
61ab8ea8 900 if (TMath::Abs(z-3.9*i)<0.15) {
901 if (TMath::Abs(y-0.00)>3.40) d+=dd;
902 d+=dd;
903 break;
904 }
905 if (TMath::Abs(z+3.9*i)<0.15) {
906 if (TMath::Abs(y-0.00)>3.40) d+=dd;
907 d+=dd;
908 break;
909 }
910 if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
911 if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;}
a9a2d814 912 }
913 } else
914 if (13<fR&&fR<26) { //SDD
61ab8ea8 915 Double_t dd=0.0033;
916 d=dd;
917 if (TMath::Abs(y-0.00)>3.30) d+=dd;
918
919 if (TMath::Abs(y-1.80)<0.55) {
920 d+=0.016;
921 for (Int_t j=0; j<20; j++) {
922 if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
923 if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
924 }
925 }
926 if (TMath::Abs(y+1.80)<0.55) {
927 d+=0.016;
928 for (Int_t j=0; j<20; j++) {
929 if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
930 if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
931 }
932 }
933
934 for (Int_t i=0; i<4; i++) {
935 if (TMath::Abs(z-7.3*i)<0.60) {
936 d+=dd;
937 if (TMath::Abs(y-0.00)>3.30) d+=dd;
938 break;
939 }
940 if (TMath::Abs(z+7.3*i)<0.60) {
941 d+=dd;
942 if (TMath::Abs(y-0.00)>3.30) d+=dd;
943 break;
944 }
a9a2d814 945 }
946 } else
947 if (6<fR&&fR<8) { //SPD2
61ab8ea8 948 Double_t dd=0.0063; x0=21.5;
949 d=dd;
950 if (TMath::Abs(y-3.08)>0.5) d+=dd;
951 //if (TMath::Abs(y-3.08)>0.45) d+=dd;
952 if (TMath::Abs(y-3.03)<0.10) {d+=0.014;}
a9a2d814 953 } else
954 if (3<fR&&fR<5) { //SPD1
61ab8ea8 955 Double_t dd=0.0063; x0=21.5;
956 d=dd;
957 if (TMath::Abs(y+0.21)>0.6) d+=dd;
958 //if (TMath::Abs(y+0.21)>0.45) d+=dd;
959 if (TMath::Abs(y+0.10)<0.10) {d+=0.014;}
a9a2d814 960 }
961
a9a2d814 962 return d;
963}
006b5f7f 964
a9a2d814 965Double_t AliITStrackerV2::GetEffectiveThickness(Double_t y,Double_t z) const
006b5f7f 966{
967 //--------------------------------------------------------------------
a9a2d814 968 //Returns the thickness between the current layer and the vertex (units X0)
006b5f7f 969 //--------------------------------------------------------------------
61ab8ea8 970 Double_t d=0.0028*3*3; //beam pipe
971 Double_t x0=0;
006b5f7f 972
18856a77 973 Double_t xn=fgLayers[fI].GetR();
006b5f7f 974 for (Int_t i=0; i<fI; i++) {
18856a77 975 Double_t xi=fgLayers[i].GetR();
976 d+=fgLayers[i].GetThickness(y,z,x0)*xi*xi;
006b5f7f 977 }
978
979 if (fI>1) {
61ab8ea8 980 Double_t xi=9.;
981 d+=0.0097*xi*xi;
006b5f7f 982 }
983
984 if (fI>3) {
18856a77 985 Double_t xi=0.5*(fgLayers[3].GetR()+fgLayers[4].GetR());
61ab8ea8 986 d+=0.0034*xi*xi;
006b5f7f 987 }
61ab8ea8 988
006b5f7f 989 return d/(xn*xn);
990}
991
ef7253ac 992Bool_t AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,
993 const AliITStrackV2 *c, Bool_t extra) {
4ab260d6 994 //--------------------------------------------------------------------
c630aafd 995 // This function refits the track "t" at the position "x" using
996 // the clusters from "c"
ef7253ac 997 // If "extra"==kTRUE,
998 // the clusters from overlapped modules get attached to "t"
4ab260d6 999 //--------------------------------------------------------------------
880f41b9 1000 Int_t index[kMaxLayer];
1001 Int_t k;
1002 for (k=0; k<kMaxLayer; k++) index[k]=-1;
c630aafd 1003 Int_t nc=c->GetNumberOfClusters();
880f41b9 1004 for (k=0; k<nc; k++) {
c630aafd 1005 Int_t idx=c->GetClusterIndex(k),nl=(idx&0xf0000000)>>28;
880f41b9 1006 index[nl]=idx;
1007 }
880f41b9 1008
4ab260d6 1009 Int_t from, to, step;
ee34184f 1010 if (xx > t->GetX()) {
4ab260d6 1011 from=0; to=kMaxLayer;
1012 step=+1;
1013 } else {
1014 from=kMaxLayer-1; to=-1;
1015 step=-1;
1016 }
1017
1018 for (Int_t i=from; i != to; i += step) {
18856a77 1019 AliITSlayer &layer=fgLayers[i];
4ab260d6 1020 Double_t r=layer.GetR();
1021
1022 {
1023 Double_t hI=i-0.5*step;
880f41b9 1024 if (TMath::Abs(hI-1.5)<0.01 || TMath::Abs(hI-3.5)<0.01) {
18856a77 1025 Double_t rs=0.5*(fgLayers[i-step].GetR() + r);
61ab8ea8 1026 Double_t d=0.0034, x0=38.6;
880f41b9 1027 if (TMath::Abs(hI-1.5)<0.01) {rs=9.; d=0.0097; x0=42;}
1028 if (!t->PropagateTo(rs,-step*d,x0)) {
4ab260d6 1029 return kFALSE;
1030 }
1031 }
1032 }
1033
880f41b9 1034 // remember old position [SR, GSI 18.02.2003]
1035 Double_t oldX=0., oldY=0., oldZ=0.;
1036 if (t->IsStartedTimeIntegral() && step==1) {
1037 t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ);
1038 }
1039 //
1040
4ab260d6 1041 Double_t x,y,z;
1042 if (!t->GetGlobalXYZat(r,x,y,z)) {
1043 return kFALSE;
1044 }
1045 Double_t phi=TMath::ATan2(y,x);
1046 Int_t idet=layer.FindDetectorIndex(phi,z);
1047 if (idet<0) {
1048 return kFALSE;
1049 }
1050 const AliITSdetector &det=layer.GetDetector(idet);
1051 phi=det.GetPhi();
1052 if (!t->Propagate(phi,det.GetR())) {
1053 return kFALSE;
1054 }
1055 t->SetDetectorIndex(idet);
1056
00a7cc50 1057 const AliITSRecPoint *cl=0;
4ab260d6 1058 Double_t maxchi2=kMaxChi2;
1059
1060 Int_t idx=index[i];
1061 if (idx>0) {
00a7cc50 1062 const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx);
4ab260d6 1063 if (idet != c->GetDetectorIndex()) {
1064 idet=c->GetDetectorIndex();
1065 const AliITSdetector &det=layer.GetDetector(idet);
1066 if (!t->Propagate(det.GetPhi(),det.GetR())) {
1067 return kFALSE;
1068 }
1069 t->SetDetectorIndex(idet);
1070 }
1071 Double_t chi2=t->GetPredictedChi2(c);
c630aafd 1072 if (chi2<maxchi2) {
1073 cl=c;
1074 maxchi2=chi2;
1075 } else {
1076 return kFALSE;
1077 }
4ab260d6 1078 }
ef7253ac 1079
4ab260d6 1080 if (cl) {
1f3e997f 1081 // Take into account the mis-alignment
1082 Double_t x=t->GetX()+cl->GetX();
1083 if (!t->PropagateTo(x,0.,0.)) return kFALSE;
4ab260d6 1084 if (!t->Update(cl,maxchi2,idx)) {
1085 return kFALSE;
1086 }
880f41b9 1087 t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1);
4ab260d6 1088 }
1089
1090 {
61ab8ea8 1091 Double_t x0;
1092 Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0);
1093 t->CorrectForMaterial(-step*d,x0);
4ab260d6 1094 }
880f41b9 1095
ef7253ac 1096 if (extra) { //search for extra clusters
1097 AliITStrackV2 tmp(*t);
1098 Double_t dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+kSigmaZ2[i]);
1099 if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl());
1100 Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[i]);
1101 if (dy < 0.5*TMath::Abs(tmp.GetSnp())) dy=0.5*TMath::Abs(tmp.GetSnp());
1102 Double_t zmin=t->GetZ() - dz;
1103 Double_t zmax=t->GetZ() + dz;
1104 Double_t ymin=t->GetY() + phi*r - dy;
1105 Double_t ymax=t->GetY() + phi*r + dy;
1106 layer.SelectClusters(zmin,zmax,ymin,ymax);
1107
1108 const AliITSRecPoint *c=0; Int_t ci=-1,cci=-1;
1109 Double_t maxchi2=1000.*kMaxChi2, tolerance=0.1;
1110 while ((c=layer.GetNextCluster(ci))!=0) {
1111 if (idet == c->GetDetectorIndex()) continue;
1112
1113 const AliITSdetector &det=layer.GetDetector(c->GetDetectorIndex());
1114
1115 if (!tmp.Propagate(det.GetPhi(),det.GetR())) continue;
1116
1117 if (TMath::Abs(tmp.GetZ() - c->GetZ()) > tolerance) continue;
1118 if (TMath::Abs(tmp.GetY() - c->GetY()) > tolerance) continue;
1119
1120 Double_t chi2=tmp.GetPredictedChi2(c);
1121 if (chi2<maxchi2) { maxchi2=chi2; cci=ci; }
1122 }
1123 if (cci>=0) t->SetExtraCluster(i,(i<<28)+cci);
1124 }
1125
880f41b9 1126 // track time update [SR, GSI 17.02.2003]
1127 if (t->IsStartedTimeIntegral() && step==1) {
1128 Double_t newX, newY, newZ;
1129 t->GetGlobalXYZat(t->GetX(),newX,newY,newZ);
1130 Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) +
1131 (oldZ-newZ)*(oldZ-newZ);
1132 t->AddTimeStep(TMath::Sqrt(dL2));
1133 }
1134 //
4ab260d6 1135
1136 }
1137
ee34184f 1138 if (!t->PropagateTo(xx,0.,0.)) return kFALSE;
4ab260d6 1139 return kTRUE;
1140}
1141
b87bd7cd 1142void AliITStrackerV2::UseClusters(const AliKalmanTrack *t, Int_t from) const {
1143 //--------------------------------------------------------------------
1144 // This function marks clusters assigned to the track
1145 //--------------------------------------------------------------------
1146 AliTracker::UseClusters(t,from);
880f41b9 1147
5482d29d 1148 Int_t clusterIndex = t->GetClusterIndex(0);
1149 AliITSRecPoint *c= 0x0;
1150
1151 if (clusterIndex>-1)
1152 c = (AliITSRecPoint *)GetCluster(clusterIndex);
d920bdee 1153 if (c && c->GetSigmaZ2()>0.1) c->UnUse();
5482d29d 1154
1155 c = 0x0;
1156 clusterIndex = t->GetClusterIndex(1);
1157 if (clusterIndex>-1)
1158 c=(AliITSRecPoint *)GetCluster(clusterIndex);
d920bdee 1159 if (c && c->GetSigmaZ2()>0.1) c->UnUse();
880f41b9 1160
b87bd7cd 1161}