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