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