]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerV2.cxx
Fixed bug in read "new" and old .det files. Fix missing init of
[u/mrichter/AliRoot.git] / ITS / AliITStrackerV2.cxx
index efced05e745921724aeb56ee1269835ab9eb720e..9f40d657d23b0cc996b33039bd0ef5cdc0e6019d 100644 (file)
@@ -15,7 +15,7 @@
 
 //-------------------------------------------------------------------------
 //               Implementation of the ITS tracker class
-//    It reads AliITSclusterV2 clusters and creates AliITStrackV2 tracks
+//    It reads AliITSRecPoint clusters and creates AliITStrackV2 tracks
 //                   and fills with them the ESD
 //          Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
 //     dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
@@ -30,7 +30,7 @@
 #include "AliITSgeom.h"
 #include "AliITSRecPoint.h"
 #include "AliESD.h"
-#include "AliITSclusterV2.h"
+#include "AliITSRecPoint.h"
 #include "AliITStrackerV2.h"
 
 ClassImp(AliITStrackerV2)
@@ -109,13 +109,13 @@ Int_t AliITStrackerV2::LoadClusters(TTree *cTree) {
   //--------------------------------------------------------------------
   //This function loads ITS clusters
   //--------------------------------------------------------------------
-  TBranch *branch=cTree->GetBranch("Clusters");
+  TBranch *branch=cTree->GetBranch("ITSRecPoints");
   if (!branch) { 
     Error("LoadClusters"," can't get the branch !\n");
     return 1;
   }
 
-  TClonesArray dummy("AliITSclusterV2",10000), *clusters=&dummy;
+  TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy;
   branch->SetAddress(&clusters);
 
   Int_t j=0;
@@ -130,14 +130,14 @@ Int_t AliITStrackerV2::LoadClusters(TTree *cTree) {
       if (!cTree->GetEvent(j)) continue;
       Int_t ncl=clusters->GetEntriesFast();
       while (ncl--) {
-        AliITSclusterV2 *c=(AliITSclusterV2*)clusters->UncheckedAt(ncl);
+        AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl);
 
         Int_t idx=c->GetDetectorIndex();
         Double_t y=r*fgLayers[i].GetDetector(idx).GetPhi()+c->GetY();
         if (y>circ) y-=circ; else if (y<0) y+=circ;
         c->SetPhiR(y);
 
-        fgLayers[i].InsertCluster(new AliITSclusterV2(*c));
+        fgLayers[i].InsertCluster(new AliITSRecPoint(*c));
       }
       clusters->Delete();
     }
@@ -367,43 +367,18 @@ 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
 
-       if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {//The beam pipe    
-         Double_t a=fTrackToFollow.GetAlpha();
-         Double_t cs=TMath::Cos(a),sn=TMath::Sin(a);
-         Double_t xv= GetX()*cs + GetY()*sn;
-         Double_t yv=-GetX()*sn + GetY()*cs;
-         
-         Double_t c=fTrackToFollow.GetC(), snp=fTrackToFollow.GetSnp();
-         Double_t x=fTrackToFollow.GetX(), y=fTrackToFollow.GetY();
-         Double_t tgfv=-(c*(x-xv)-snp)/(c*(y-yv) + TMath::Sqrt(1.-snp*snp));
-         Double_t fv=TMath::ATan(tgfv);
-
-         cs=TMath::Cos(fv); sn=TMath::Sin(fv);
-         x = xv*cs + yv*sn;
-         yv=-xv*sn + yv*cs; xv=x;
-
-        if (fTrackToFollow.Propagate(fv+a,xv)) {
-            fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSrefit);
-            Float_t d=fTrackToFollow.GetD(GetX(),GetY());
-            Float_t z=fTrackToFollow.GetZ()-GetZ();
-            fTrackToFollow.GetESDtrack()->SetImpactParameters(d,z);
-            UseClusters(&fTrackToFollow);
-            {
-            AliITSclusterV2 c; c.SetY(yv); c.SetZ(GetZ());
-            c.SetSigmaY2(GetSigmaY()*GetSigmaY());
-            c.SetSigmaZ2(GetSigmaZ()*GetSigmaZ());
-            Double_t chi2=fTrackToFollow.GetPredictedChi2(&c);
-            if (chi2<kMaxChi2)
-              if (fTrackToFollow.Update(&c,-chi2,0))
-                   fTrackToFollow.SetConstrainedESDtrack(chi2);            
-            }
-            ntrk++;
-         }
+       if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {//The beam pipe 
+         AliESDtrack  *esdTrack =fTrackToFollow.GetESDtrack();
+         esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit);
+         Float_t r[3]={0.,0.,0.};
+         Double_t maxD=3.;
+        esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD);
+         ntrk++;
        }
     }
     delete t;
@@ -541,8 +516,8 @@ Int_t AliITStrackerV2::TakeNextProlongation() {
      dz=road*scz; dy=road*scy;
   } 
 
-  const AliITSclusterV2 *c=0; Int_t ci=-1;
-  const AliITSclusterV2 *cc=0; Int_t cci=-1;
+  const AliITSRecPoint *c=0; Int_t ci=-1;
+  const AliITSRecPoint *cc=0; Int_t cci=-1;
   Double_t chi2=kMaxChi2;
   while ((c=layer.GetNextCluster(ci))!=0) {
     Int_t idet=c->GetDetectorIndex();
@@ -663,13 +638,17 @@ void AliITStrackerV2::AliITSlayer::ResetRoad() {
   if (n>1) fRoad=2*fR*TMath::Sqrt(3.14/n);
 }
 
-Int_t AliITStrackerV2::AliITSlayer::InsertCluster(AliITSclusterV2 *c) {
+Int_t AliITStrackerV2::AliITSlayer::InsertCluster(AliITSRecPoint *c) {
   //--------------------------------------------------------------------
   // This function inserts a cluster to this layer in increasing
   // order of the cluster's fZ
   //--------------------------------------------------------------------
   Float_t circ=TMath::TwoPi()*fR;
   Int_t sec=Int_t(kNsector*c->GetPhiR()/circ);
+  if (sec>=kNsector) {
+     ::Error("InsertCluster","Wrong sector !\n");
+     return 1;
+  }
   Int_t &n=fN[sec];
   if (n>=kMaxClusterPerSector) {
      ::Error("InsertCluster","Too many clusters !\n");
@@ -679,7 +658,7 @@ Int_t AliITStrackerV2::AliITSlayer::InsertCluster(AliITSclusterV2 *c) {
   else {
      Int_t i=FindClusterIndex(c->GetZ(),sec);
      Int_t k=n-i+sec*kMaxClusterPerSector;
-     memmove(fClusters+i+1 ,fClusters+i,k*sizeof(AliITSclusterV2*));
+     memmove(fClusters+i+1 ,fClusters+i,k*sizeof(AliITSRecPoint*));
      fClusters[i]=c;
   }
   n++;
@@ -719,12 +698,12 @@ SelectClusters(Float_t zmin,Float_t zmax,Float_t ymin, Float_t ymax) {
     if (ymin>circ) ymin-=circ; else if (ymin<0) ymin+=circ;
     if (ymax>circ) ymax-=circ; else if (ymax<0) ymax+=circ;
 
-    Int_t i1=Int_t(kNsector*ymin/circ);
+    Int_t i1=Int_t(kNsector*ymin/circ); if (i1==kNsector) i1--;
     if (fN[i1]!=0) {
        Float_t ym = (ymax<ymin) ? ymax+circ : ymax;
        Int_t i=FindClusterIndex(zmin,i1), imax=i1*kMaxClusterPerSector+fN[i1];
        for (; i<imax; i++) {
-           AliITSclusterV2 *c=fClusters[i];
+           AliITSRecPoint *c=fClusters[i];
            if (c->IsUsed()) continue;
            if (c->GetZ()>zmax) break;
            if (c->GetPhiR()<=ymin) continue;
@@ -733,14 +712,14 @@ SelectClusters(Float_t zmin,Float_t zmax,Float_t ymin, Float_t ymax) {
        }
     }
 
-    Int_t i2=Int_t(kNsector*ymax/circ);
+    Int_t i2=Int_t(kNsector*ymax/circ); if (i2==kNsector) i2--;
     if (i2==i1) return fNsel;
 
     if (fN[i2]!=0) {
        Float_t ym = (ymin>ymax) ? ymin-circ : ymin;
        Int_t i=FindClusterIndex(zmin,i2), imax=i2*kMaxClusterPerSector+fN[i2];
        for (; i<imax; i++) {
-           AliITSclusterV2 *c=fClusters[i];
+           AliITSRecPoint *c=fClusters[i];
            if (c->IsUsed()) continue;
            if (c->GetZ()>zmax) break;
            if (c->GetPhiR()<=ym) continue;
@@ -752,11 +731,11 @@ SelectClusters(Float_t zmin,Float_t zmax,Float_t ymin, Float_t ymax) {
     return fNsel;
 }
 
-const AliITSclusterV2 *AliITStrackerV2::AliITSlayer::GetNextCluster(Int_t &ci){
+const AliITSRecPoint *AliITStrackerV2::AliITSlayer::GetNextCluster(Int_t &ci){
   //--------------------------------------------------------------------
   // This function returns clusters within the "window" 
   //--------------------------------------------------------------------
-  AliITSclusterV2 *c=0;
+  AliITSRecPoint *c=0;
   ci=-1;
   if (fNsel) {
      fNsel--;
@@ -921,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;
@@ -984,12 +965,12 @@ AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,const AliITStrackV2 *c) {
      }
      t->SetDetectorIndex(idet);
 
-     const AliITSclusterV2 *cl=0;
+     const AliITSRecPoint *cl=0;
      Double_t maxchi2=kMaxChi2;
 
      Int_t idx=index[i];
      if (idx>0) {
-        const AliITSclusterV2 *c=(AliITSclusterV2 *)GetCluster(idx); 
+        const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); 
         if (idet != c->GetDetectorIndex()) {
            idet=c->GetDetectorIndex();
            const AliITSdetector &det=layer.GetDetector(idet);
@@ -1006,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 AliITSclusterV2 *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;
@@ -1038,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;
@@ -1060,9 +1053,17 @@ void AliITStrackerV2::UseClusters(const AliKalmanTrack *t, Int_t from) const {
   //--------------------------------------------------------------------
   AliTracker::UseClusters(t,from);
 
-  AliITSclusterV2 *c=(AliITSclusterV2 *)GetCluster(t->GetClusterIndex(0));
-  if (c->GetSigmaZ2()>0.1) c->UnUse();
-  c=(AliITSclusterV2 *)GetCluster(t->GetClusterIndex(1));
-  if (c->GetSigmaZ2()>0.1) c->UnUse();
+  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 = 0x0;
+  clusterIndex = t->GetClusterIndex(1);
+  if (clusterIndex>-1)
+    c=(AliITSRecPoint *)GetCluster(clusterIndex);
+  if (c && c->GetSigmaZ2()>0.1) c->UnUse();
 
 }