]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerV2.cxx
Fix bug in digitization of multiple events
[u/mrichter/AliRoot.git] / ITS / AliITStrackerV2.cxx
index ba90fca08df63d9c33bc863b4a1c3af40b718446..9f40d657d23b0cc996b33039bd0ef5cdc0e6019d 100644 (file)
@@ -367,7 +367,7 @@ Int_t AliITStrackerV2::RefitInward(AliESD *event) {
     fTrackToFollow.ResetClusters();
 
     //Refitting...
-    if (RefitAt(3.7, &fTrackToFollow, t)) {
+    if (RefitAt(3.7, &fTrackToFollow, t, kTRUE)) {
        fTrackToFollow.SetLabel(t->GetLabel());
        fTrackToFollow.CookdEdx();
        CookLabel(&fTrackToFollow,0.); //For comparison only
@@ -900,11 +900,13 @@ Double_t AliITStrackerV2::GetEffectiveThickness(Double_t y,Double_t z) const
   return d/(xn*xn);
 }
 
-Bool_t 
-AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,const AliITStrackV2 *c) {
+Bool_t AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,
+                                const AliITStrackV2 *c, Bool_t extra) {
   //--------------------------------------------------------------------
   // This function refits the track "t" at the position "x" using
   // the clusters from "c"
+  // If "extra"==kTRUE, 
+  //    the clusters from overlapped modules get attached to "t" 
   //--------------------------------------------------------------------
   Int_t index[kMaxLayer];
   Int_t k;
@@ -985,25 +987,7 @@ AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,const AliITStrackV2 *c) {
          return kFALSE;
        }
      }
-     /*
-     if (cl==0)
-     if (t->GetNumberOfClusters()>2) {
-        Double_t dz=4*TMath::Sqrt(t->GetSigmaZ2()+kSigmaZ2[i]);
-        Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[i]);
-        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;
-        while ((c=layer.GetNextCluster(ci))!=0) {
-           if (idet != c->GetDetectorIndex()) continue;
-           Double_t chi2=t->GetPredictedChi2(c);
-           if (chi2<maxchi2) { cl=c; maxchi2=chi2; idx=ci; }
-        }
-     }
-     */
      if (cl) {
        if (!t->Update(cl,maxchi2,idx)) {
           return kFALSE;
@@ -1017,6 +1001,36 @@ AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,const AliITStrackV2 *c) {
      t->CorrectForMaterial(-step*d,x0);
      }
                  
+     if (extra) { //search for extra clusters
+        AliITStrackV2 tmp(*t);
+        Double_t dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+kSigmaZ2[i]);
+        if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl());
+        Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[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.*kMaxChi2, 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;
@@ -1039,9 +1053,17 @@ void AliITStrackerV2::UseClusters(const AliKalmanTrack *t, Int_t from) const {
   //--------------------------------------------------------------------
   AliTracker::UseClusters(t,from);
 
-  AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(0));
+  Int_t clusterIndex = t->GetClusterIndex(0);
+  AliITSRecPoint *c= 0x0;
+
+  if (clusterIndex>-1)
+    c = (AliITSRecPoint *)GetCluster(clusterIndex);
   if (c && c->GetSigmaZ2()>0.1) c->UnUse();
-  c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(1));
+
+  c = 0x0;
+  clusterIndex = t->GetClusterIndex(1);
+  if (clusterIndex>-1)
+    c=(AliITSRecPoint *)GetCluster(clusterIndex);
   if (c && c->GetSigmaZ2()>0.1) c->UnUse();
 
 }