+ // remember old position [SR, GSI 18.02.2003]
+ Double_t oldX=0., oldY=0., oldZ=0.;
+ if (t->IsStartedTimeIntegral() && step==1) {
+ t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ);
+ }
+ //
+
+ Double_t phi,z;
+ if (!t->GetPhiZat(r,phi,z)) {
+ return kFALSE;
+ }
+
+ Int_t idet=layer.FindDetectorIndex(phi,z);
+ if (idet<0) {
+ return kFALSE;
+ }
+ const AliITSdetector &det=layer.GetDetector(idet);
+ phi=det.GetPhi();
+ if (!t->Propagate(phi,det.GetR())) {
+ return kFALSE;
+ }
+ t->SetDetectorIndex(idet);
+
+ const AliITSRecPoint *cl=0;
+ Double_t maxchi2=AliITSReconstructor::GetRecoParam()->GetMaxChi2();
+
+ Int_t idx=index[i];
+ if (idx>=0) {
+ const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx);
+ if (idet != c->GetDetectorIndex()) {
+ idet=c->GetDetectorIndex();
+ const AliITSdetector &det=layer.GetDetector(idet);
+ if (!t->Propagate(det.GetPhi(),det.GetR())) {
+ return kFALSE;
+ }
+ t->SetDetectorIndex(idet);
+ }
+ Double_t chi2=t->GetPredictedChi2(c);
+ if (chi2<maxchi2) {
+ cl=c;
+ maxchi2=chi2;
+ } else {
+ return kFALSE;
+ }
+ }
+
+ if (cl) {
+ // Take into account the mis-alignment
+ Double_t x=t->GetX()+cl->GetX();
+ if (!t->PropagateTo(x,0.,0.)) return kFALSE;
+ if (!t->Update(cl,maxchi2,idx)) {
+ return kFALSE;
+ }
+ t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1);
+ }
+
+ {
+ Double_t x0;
+ Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0);
+ t->CorrectForMaterial(-step*d,x0);
+ }
+
+ if (extra) { //search for extra clusters
+ AliITStrackV2 tmp(*t);
+ Double_t dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+AliITSReconstructor::GetRecoParam()->GetSigmaZ2(i));
+ if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl());
+ Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+AliITSReconstructor::GetRecoParam()->GetSigmaY2(i));
+ if (dy < 0.5*TMath::Abs(tmp.GetSnp())) dy=0.5*TMath::Abs(tmp.GetSnp());
+ Double_t zmin=t->GetZ() - dz;
+ Double_t zmax=t->GetZ() + dz;
+ Double_t ymin=t->GetY() + phi*r - dy;
+ Double_t ymax=t->GetY() + phi*r + dy;
+ layer.SelectClusters(zmin,zmax,ymin,ymax);
+
+ const AliITSRecPoint *c=0; Int_t ci=-1,cci=-1;
+ Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(), tolerance=0.1;
+ while ((c=layer.GetNextCluster(ci))!=0) {
+ if (idet == c->GetDetectorIndex()) continue;
+
+ const AliITSdetector &det=layer.GetDetector(c->GetDetectorIndex());
+
+ if (!tmp.Propagate(det.GetPhi(),det.GetR())) continue;
+
+ if (TMath::Abs(tmp.GetZ() - c->GetZ()) > tolerance) continue;
+ if (TMath::Abs(tmp.GetY() - c->GetY()) > tolerance) continue;
+
+ Double_t chi2=tmp.GetPredictedChi2(c);
+ if (chi2<maxchi2) { maxchi2=chi2; cci=ci; }
+ }
+ if (cci>=0) t->SetExtraCluster(i,(i<<28)+cci);
+ }
+
+ // track time update [SR, GSI 17.02.2003]
+ if (t->IsStartedTimeIntegral() && step==1) {
+ Double_t newX, newY, newZ;
+ t->GetGlobalXYZat(t->GetX(),newX,newY,newZ);
+ Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) +
+ (oldZ-newZ)*(oldZ-newZ);
+ t->AddTimeStep(TMath::Sqrt(dL2));
+ }
+ //