Improved cuts for the reconstruction of V0s (M.Ivanov)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 22 Mar 2004 07:30:44 +0000 (07:30 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 22 Mar 2004 07:30:44 +0000 (07:30 +0000)
17 files changed:
ITS/AliITS.cxx
ITS/AliITSFindClustersV2.cxx
ITS/AliITSclusterTable.cxx
ITS/AliITSclusterV2.h
ITS/AliITSclustererV2.cxx
ITS/AliITSrecoV2.h
ITS/AliITStrackV2.cxx
ITS/AliITStrackV2.h
ITS/AliITStrackerV2.cxx
ITS/AliITStrackerV2.h
STEER/AliESDtrack.cxx
STEER/AliESDtrack.h
STEER/AliKalmanTrack.cxx
STEER/AliKalmanTrack.h
STEER/AliTracker.cxx
TPC/AliSimDigits.cxx
TPC/AliTPCtrack.cxx

index 001322c..3d3727d 100644 (file)
@@ -1790,6 +1790,7 @@ void AliITS::Reconstruct() const
   AliITSclustererV2 clusterer(GetITSgeom());
   AliRunLoader* runLoader = loader->GetRunLoader();
   Int_t nEvents = runLoader->GetNumberOfEvents();
+  runLoader->LoadKinematics();
 
   for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
     runLoader->GetEvent(iEvent);
index b56125a..15e3710 100644 (file)
@@ -353,7 +353,8 @@ void AliITSFindClustersV2::Exec(const Option_t *opt){
                else if(lab[2]<0) lab[2] = lad;
                else Warning("Exec","No empty lables!");
            } // end if lab>=0
-           new(cl[j]) AliITSclusterV2(lab,lp);
+           Int_t info[3]={0,0,0};
+           new(cl[j]) AliITSclusterV2(lab,lp,info);
        } // end for j
        cTree->Fill();
        cluster->Delete();
index 27734c4..228fce2 100644 (file)
@@ -171,7 +171,8 @@ void AliITSclusterTable::FillArray(TTree* clusterTree){
     else {
       for(Int_t n=0;n<vect[nlr]->GetSize();n++){
        Int_t mm=vect[nlr]->At(n);
-       if(mm==mod) {fDet[mod]->AddAt(n,nc); nc+=1; }
+       if (nc>=fDet[mod]->GetSize()) fDet[mod]->Set(nc*2+10);  
+       if(mm==mod) {(*fDet[mod])[nc]=n; nc+=1; }
       }
     }
   }
index 26c354a..26b1359 100644 (file)
 //_____________________________________________________________________________
 class AliITSclusterV2 : public AliCluster {
 public:
-  AliITSclusterV2() : AliCluster() {fQ=0;}
-  AliITSclusterV2(Int_t *lab,Float_t *hit) : AliCluster(lab,hit) {
+  AliITSclusterV2() : AliCluster() {fQ=0; fLayer=0; fNz=0; fNy=0;}
+  AliITSclusterV2(Int_t *lab,Float_t *hit, Int_t *info) : AliCluster(lab,hit) {
     fIndex=lab[3];
     fQ=hit[4];
+    fNy    = info[0];
+    fNz    = info[1];
+    fLayer = info[2];
+
   }
   void Use() {fQ=-fQ;}
   void SetQ(Float_t q) {fQ=q;}
   void SetDetectorIndex(Int_t i) { fIndex=i; }
-
+  void SetLayer(Int_t layer) {fLayer=layer;}
+  void SetNz(Int_t nz) {fNz =nz;}
+  void SetNy(Int_t ny){fNy=ny;}
   Int_t IsUsed() const {return (fQ<0) ? 1 : 0;}
   Float_t GetQ() const {return TMath::Abs(fQ);}
   Int_t GetDetectorIndex() const { return 0x3FF&fIndex; }
-
+  Int_t GetLayer() const {return fLayer;}
+  Int_t GetNz() const {return fNz;}
+  Int_t GetNy() const {return fNy;}
   Int_t GetPindex() const { return 0xFFF00000&fIndex; }  //SSD clusters only
   Int_t GetNindex() const { return 0xFFC00&fIndex; }  //SSD clusters only
 
 private:
   Int_t    fIndex;    // detector index
   Float_t  fQ ;       // Q of cluster (in ADC counts)
-  
-  ClassDef(AliITSclusterV2,1)  // ITS clusters
+  Char_t   fLayer;    // layer number
+  Char_t   fNz;       //number of digits in Z direction
+  Char_t   fNy;       //number of digits in y direction 
+  ClassDef(AliITSclusterV2,2)  // ITS clusters
 };
 
 #endif
index 7b8b131..3a72144 100644 (file)
@@ -122,12 +122,13 @@ Int_t AliITSclustererV2::Digits2Clusters(TTree *dTree, TTree *cTree) {
     dTree->GetEvent(fI);
 
     if     (digitsSPD->GetEntriesFast()!=0) 
-                          FindClustersSPD(digitsSPD,clusters);
-    else if(digitsSDD->GetEntriesFast()!=0) 
-                          FindClustersSDD(digitsSDD,clusters);
-    else if(digitsSSD->GetEntriesFast()!=0) 
-                          FindClustersSSD(digitsSSD,clusters);
-
+      FindClustersSPD(digitsSPD,clusters);
+    else 
+      if(digitsSDD->GetEntriesFast()!=0) 
+       FindClustersSDD(digitsSDD,clusters);
+      else if(digitsSSD->GetEntriesFast()!=0) 
+       FindClustersSSD(digitsSSD,clusters);
+    
     ncl+=clusters->GetEntriesFast();
 
     cTree->Fill();
@@ -162,6 +163,7 @@ void AliITSclustererV2::Digits2Clusters(AliRawReader* rawReader) {
     Error("Digits2Clusters", "no run loader found");
     return;
   }
+  runLoader->LoadKinematics();
   AliLoader* itsLoader = runLoader->GetLoader("ITSLoader");
   if (!itsLoader) {
     Error("Digits2Clusters", "no loader for ITS found");
@@ -222,6 +224,7 @@ void AliITSclustererV2::Digits2Clusters(AliRawReader* rawReader) {
 #include "AliITSsimulationFastPoints.h"
 #include "AliITSRecPoint.h"
 
+/*
 static void CheckLabels(Int_t lab[3]) {
   //------------------------------------------------------------
   // Tries to find mother's labels
@@ -248,6 +251,80 @@ static void CheckLabels(Int_t lab[3]) {
         else ;//cerr<<"CheckLabels : No empty labels !\n";
     }
 }
+*/
+static void CheckLabels(Int_t lab[3]) {
+  //------------------------------------------------------------
+  // Tries to find mother's labels
+  //------------------------------------------------------------
+
+  Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
+  for (Int_t i=0;i<3;i++){
+    Int_t label = lab[i];
+    if (label>=0 && label<ntracks) {
+      TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
+      if (part->P() < 0.005) {
+       Int_t m=part->GetFirstMother();
+       if (m<0) {      
+         continue;
+       }
+       if (part->GetStatusCode()>0) {
+         continue;
+       }
+       lab[i]=m;       
+      }
+    }    
+  }
+  
+}
+
+static void CheckLabels2(Int_t lab[10]) {
+  //------------------------------------------------------------
+  // Tries to find mother's labels
+  //------------------------------------------------------------
+
+  Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
+  for (Int_t i=0;i<10;i++){
+    Int_t label = lab[i];
+    if (label>=0 && label<ntracks) {
+      TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
+      if (part->P() < 0.005) {
+       Int_t m=part->GetFirstMother();
+       if (m<0) {      
+         continue;
+       }
+       if (part->GetStatusCode()>0) {
+         continue;
+       }
+       lab[i]=m;       
+      }
+    }    
+  }
+  //compress labels -- if multi-times the same
+  Int_t lab2[10];
+  for (Int_t i=0;i<10;i++) lab2[i]=-2;
+  for (Int_t i=0;i<10  ;i++){
+    if (lab[i]<0) continue;
+    for (Int_t j=0;j<10 &&lab2[j]!=lab[i];j++){
+      if (lab2[j]<0) {
+       lab2[j]= lab[i];
+       break;
+      }
+    }
+  }
+  for (Int_t j=0;j<10;j++) lab[j]=lab2[j];
+  
+}
+
+static void AddLabel(Int_t lab[10], Int_t label) {
+  for (Int_t i=0;i<10;i++){
+    if (label<0) break;
+    if (lab[i]==label) break;
+    if (lab[i]<0) {
+      lab[i]= label;
+      break;
+    }
+  }
+}
 
 void AliITSclustererV2::RecPoints2Clusters
 (const TClonesArray *points, Int_t idx, TClonesArray *clusters) {
@@ -269,7 +346,8 @@ void AliITSclustererV2::RecPoints2Clusters
     lab[0]=p->GetLabel(0); lab[1]=p->GetLabel(1); lab[2]=p->GetLabel(2);
     lab[3]=fNdet[idx];
     CheckLabels(lab);
-    new (cl[i]) AliITSclusterV2(lab,lp);
+    Int_t dummy[3]={0,0,0};
+    new (cl[i]) AliITSclusterV2(lab,lp, dummy);
   }  
 } 
 
@@ -382,6 +460,11 @@ FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) {
      lab[1]=-2;
      lab[2]=-2;
      lab[3]=fNdet[fI];
+     Int_t milab[10];
+     for (Int_t ilab=0;ilab<10;ilab++){
+       milab[ilab]=-2;
+     }
+
 
      d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]);
      Int_t ymin=d->GetCoord2(),ymax=ymin;
@@ -408,21 +491,39 @@ FindClustersSPD(const TClonesArray *digits, TClonesArray *clusters) {
         }
         Float_t qq=d->GetSignal();
         y+=qq*fYSPD[d->GetCoord2()]; z+=qq*fZSPD[d->GetCoord1()]; q+=qq;   
-     }
+       // MI addition - find all labels
+       for (Int_t dlab=0;dlab<3;dlab++){
+         Int_t digitlab = (d->GetTracks())[dlab];
+         if (digitlab<0) continue;
+         for (Int_t index=0;index<10;index++){
+           if (milab[index]<0)  {
+             milab[index] = digitlab;      
+             break;
+           }
+           if (milab[index]==digitlab) break;
+         }
+       }
+     }     
      y/=q; z/=q;
      y-=fHwSPD; z-=fHlSPD;
 
      Float_t lp[5];
      lp[0]=-(-y+fYshift[fI]); if (fI<=fLastSPD1) lp[0]=-lp[0];
      lp[1]=  -z+fZshift[fI];
-     lp[2]= fYpitchSPD*fYpitchSPD/12.;
-     lp[3]= fZ1pitchSPD*fZ1pitchSPD/12.;
+     // Float_t factor=TMath::Max(double(ni-3.),1.5);
+     Float_t factor=1.5;
+     lp[2]= (fYpitchSPD*fYpitchSPD/12.)*factor;
+     lp[3]= (fZ1pitchSPD*fZ1pitchSPD/12.)*factor;
      //lp[4]= q;
      lp[4]= (zmax-zmin+1)*100 + (ymax-ymin+1);
 
-     //CheckLabels(lab);
+     CheckLabels(lab);
+     CheckLabels2(milab);
+     CheckLabels2(milab);
+     milab[3]=fNdet[fI];
      d=(AliITSdigitSPD*)digits->UncheckedAt(idx[0]);
-     new (cl[n]) AliITSclusterV2(lab,lp); n++; 
+     Int_t info[3] = {ni,0,1};
+     new (cl[n]) AliITSclusterV2(milab,lp,info); n++; 
   }
 
   delete [] bins;
@@ -503,9 +604,10 @@ void AliITSclustererV2::FindClustersSPD(AliITSRawStream* input,
 //       hit[4] = q;
          hit[4] = (zmax-zmin+1)*100 + (ymax-ymin+1);
 
-         //CheckLabels(label);
+         CheckLabels(label);
+         Int_t info[3]={0,0,0};
          new (clusters[iModule]->AddrAt(nClusters)) 
-           AliITSclusterV2(label, hit); 
+           AliITSclusterV2(label, hit,info); 
          nClusters++;
        }
 
@@ -647,6 +749,11 @@ FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
          if (idx[k] < 0) continue; //removed peak
          AliITSclusterV2 c;
          MakeCluster(idx[k], nzBins, bins[s], msk[k], c);
+        //mi change
+        Int_t milab[10];
+        for (Int_t ilab=0;ilab<10;ilab++){
+          milab[ilab]=-2;
+        }
 
         /*
          Float_t s2 = c.GetSigmaY2()/c.GetQ() - c.GetY()*c.GetY();
@@ -694,73 +801,99 @@ FindClustersSDD(AliBin* bins[2], Int_t nMaxBin, Int_t nzBins,
           AliBin *b=&bins[s][idx[k]];
           AliITSdigitSDD* d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
           Int_t l0=(d->GetTracks())[0];
-          if (l0<0) {
+          //if (l0<0) {
             b=&bins[s][idx[k]-1];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
-          if (l0<0) {
+            //}
+            //if (l0<0) {
             b=&bins[s][idx[k]+1];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
-          if (l0<0) {
+            // }
+            //if (l0<0) {
             b=&bins[s][idx[k]-nzBins];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
-          if (l0<0) {
+            //}
+            //if (l0<0) {
             b=&bins[s][idx[k]+nzBins];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
+            //}
 
-          if (l0<0) {
+            //if (l0<0) {
             b=&bins[s][idx[k]+nzBins+1];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
-          if (l0<0) {
+            //}
+            //if (l0<0) {
             b=&bins[s][idx[k]+nzBins-1];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
-          if (l0<0) {
+            //}
+            //if (l0<0) {
             b=&bins[s][idx[k]-nzBins+1];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
-          if (l0<0) {
+            //}
+            //if (l0<0) {
             b=&bins[s][idx[k]-nzBins-1];
             if (b->GetQ()>0) {
               d=(AliITSdigitSDD*)digits->UncheckedAt(b->GetIndex());
               l0=(d->GetTracks())[0];
+              AddLabel(milab, (d->GetTracks())[0]); 
+              AddLabel(milab, (d->GetTracks())[1]); 
+              AddLabel(milab, (d->GetTracks())[2]); 
             }
-          }
+            //}
 
           {
             Int_t lab[3];
             lab[0]=(d->GetTracks())[0];
             lab[1]=(d->GetTracks())[1];
             lab[2]=(d->GetTracks())[2];
-            //CheckLabels(lab);
-            c.SetLabel(lab[0],0);
-            c.SetLabel(lab[1],1);
-            c.SetLabel(lab[2],2);
+            CheckLabels(lab);
+            CheckLabels2(milab); 
+            c.SetLabel(milab[0],0);
+            c.SetLabel(milab[1],1);
+            c.SetLabel(milab[2],2);
+            c.SetLayer(3);
           }
         }
 
@@ -893,16 +1026,27 @@ FindClustersSSD(Ali1Dcluster* neg, Int_t nn,
         Float_t lp[5];
         lp[0]=-(-ybest+fYshift[fI]);
         lp[1]=  -zbest+fZshift[fI];
-        lp[2]=0.0025*0.0025;  //SigmaY2
-        lp[3]=0.110*0.110;  //SigmaZ2
+        lp[2]=0.0025*0.0025*1.5;  //SigmaY2 - 1.5 safety factor
+        lp[3]=0.110*0.110*1.5;  //SigmaZ2   - 1.5 safety factor
         if (pos[i].GetNd()+neg[j].GetNd() > 4) {
            lp[2]*=9;
            lp[3]*=9;
         }
         lp[4]=qbest;        //Q
-
-        //CheckLabels(lab);
-        new (cl[ncl]) AliITSclusterV2(lab,lp); ncl++;
+       Int_t milab[10];
+       for (Int_t ilab=0;ilab<10;ilab++) milab[ilab]=-2;
+       milab[0]=pos[i].GetLabel(0);
+        milab[1]=neg[j].GetLabel(0);
+       milab[2]=pos[i].GetLabel(1);
+        milab[3]=neg[j].GetLabel(1);
+       milab[4]=pos[i].GetLabel(2);
+        milab[5]=neg[j].GetLabel(2);
+       //
+        CheckLabels(lab);
+       CheckLabels2(milab);
+       milab[3]=(((i<<10) + j)<<10) + idet; // pos|neg|det
+       Int_t info[3] = {0,0,5};
+        new (cl[ncl]) AliITSclusterV2(milab,lp,info); ncl++;
       }
     }
     /*
index 72213fc..714794d 100644 (file)
@@ -17,7 +17,8 @@
    const Int_t kLayersNotToSkip[]={0,0,0,0,0,0};
    const Int_t kLastLayerToTrackTo=0;
 
-   const Int_t kMaxLayer=6;
+   const Int_t kMaxLayer  = 6;
+const Double_t kMaxSnp = 0.6;
    const Double_t kSigmaY2[kMaxLayer]={
       1.44e-6, 1.44e-6, 1.444e-5, 1.444e-5, 4.0e-6, 4.0e-6 
    };
@@ -28,6 +29,8 @@
 
    const Double_t kChi2PerCluster=7.;
    const Double_t kMaxChi2=25.;
+   const Double_t kMaxChi2In=16.;
+
    const Double_t kMaxRoad=6.0;
 
    const Double_t kXV=0.0e+0;
index 957ab76..6a499f1 100644 (file)
@@ -58,10 +58,14 @@ AliITStrackV2::AliITStrackV2():AliKalmanTrack(),
   fC42(0),
   fC43(0),
   fC44(0),
+  fNUsed(0),
+  fNSkipped(0),
+  fReconstructed(kFALSE),                             
   fESDtrack(0)
   {
   for(Int_t i=0; i<kMaxLayer; i++) fIndex[i]=0;
   for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
+  for(Int_t i=0; i<6; i++) {fDy[i]=0; fDz[i]=0; fSigmaY[i]=0; fSigmaZ[i]=0; fChi2MIP[i]=0;}
 }
 
 //____________________________________________________________________________
@@ -98,6 +102,8 @@ AliKalmanTrack(t) {
   fC30=c[6 ];   fC31=c[7 ];   fC32=c[8 ];   fC33=c[9 ];
   fC40=c[10]/x; fC41=c[11]/x; fC42=c[12]/x; fC43=c[13]/x; fC44=c[14]/x/x;
 
+  for(Int_t i=0; i<6; i++) {fDy[i]=0; fDz[i]=0; fSigmaY[i]=0; fSigmaZ[i]=0;}
+  //
   if (!Invariant()) throw "AliITStrackV2: conversion failed !\n";
 
 }
@@ -145,13 +151,17 @@ AliKalmanTrack() {
     SetIntegratedLength(t.GetIntegratedLength());
   }
   fESDtrack=&t;
-
+  fNUsed = 0;
+  fReconstructed = kFALSE;
+  fNSkipped =0;
+  for(Int_t i=0; i<6; i++) {fDy[i]=0; fDz[i]=0; fSigmaY[i]=0; fSigmaZ[i]=0;; fChi2MIP[i]=0;}
   //if (!Invariant()) throw "AliITStrackV2: conversion failed !\n";
-
+  SetFakeRatio(t.GetITSFakeRatio());
 }
 
 void AliITStrackV2::UpdateESDtrack(ULong_t flags) {
   fESDtrack->UpdateTrackParams(this,flags);
+  if (flags == AliESDtrack::kITSin) fESDtrack->SetITSChi2MIP(fChi2MIP);
 }
 void AliITStrackV2::SetConstrainedESDtrack(Double_t chi2) {
   fESDtrack->SetConstrainedTrackParams(this,chi2);
@@ -180,6 +190,10 @@ AliITStrackV2::AliITStrackV2(const AliITStrackV2& t) : AliKalmanTrack(t) {
       if (i<4) fdEdxSample[i]=t.fdEdxSample[i];
   }
   fESDtrack=t.fESDtrack;
+  fNUsed = t.fNUsed;
+  fReconstructed = t.fReconstructed;
+  fNSkipped = t.fNSkipped;
+  for(Int_t i=0; i<6; i++) {fDy[i]=t.fDy[i]; fDz[i]=t.fDz[i]; fSigmaY[i]=t.fSigmaY[i]; fSigmaZ[i]=t.fSigmaZ[i];; fChi2MIP[i]=t.fChi2MIP[i];}
 }
 
 //_____________________________________________________________________________
@@ -190,8 +204,8 @@ Int_t AliITStrackV2::Compare(const TObject *o) const {
   AliITStrackV2 *t=(AliITStrackV2*)o;
   //Double_t co=TMath::Abs(t->Get1Pt());
   //Double_t c =TMath::Abs(Get1Pt());
-  Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
-  Double_t c =GetSigmaY2()*GetSigmaZ2();
+  Double_t co=t->GetSigmaY2()*t->GetSigmaZ2()*TMath::Sqrt(TMath::Abs(fP4));
+  Double_t c =GetSigmaY2()*GetSigmaZ2()*TMath::Sqrt(TMath::Abs(fP4));
   if (c>co) return 1;
   else if (c<co) return -1;
   return 0;
@@ -260,7 +274,7 @@ Double_t AliITStrackV2::GetPredictedChi2(const AliCluster *c) const
   //-----------------------------------------------------------------
   Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
   r00+=fC00; r01+=fC10; r11+=fC11;
-
+  //
   Double_t det=r00*r11 - r01*r01;
   if (TMath::Abs(det) < 1.e-30) {
     Int_t n=GetNumberOfClusters();
@@ -404,6 +418,7 @@ Int_t AliITStrackV2::Update(const AliCluster* c, Double_t chi2, UInt_t index) {
   Double_t det=r00*r11 - r01*r01;
   Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
 
   Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
   Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
   Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
@@ -411,6 +426,12 @@ Int_t AliITStrackV2::Update(const AliCluster* c, Double_t chi2, UInt_t index) {
   Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
 
   Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
+  Int_t layer = (index & 0xf0000000) >> 28;
+  fDy[layer] = dy;
+  fDz[layer] = dz;
+  fSigmaY[layer] = TMath::Sqrt(c->GetSigmaY2()+fC00);
+  fSigmaZ[layer] = TMath::Sqrt(c->GetSigmaZ2()+fC11);
+
   Double_t sf=fP2 + k20*dy + k21*dz;
   
   fP0 += k00*dy + k01*dz;
@@ -611,6 +632,25 @@ Double_t AliITStrackV2::GetD(Double_t x, Double_t y) const {
   return a/(1 + TMath::Sqrt(sn*sn + cs*cs));
 }
 
+Double_t AliITStrackV2::GetZat(Double_t x) const {
+  //------------------------------------------------------------------
+  // This function calculates the z at given x point - in current coordinate system
+  //------------------------------------------------------------------
+  Double_t x1=fX, x2=x, dx=x2-x1;
+  //
+  Double_t f1=fP2, f2=f1 + fP4*dx;
+  if (TMath::Abs(f2) >= 0.9999) {
+    return 10000000;
+  }
+
+  Double_t r1=sqrt(1.- f1*f1), r2=sqrt(1.- f2*f2);
+  Double_t z =  fP1 + dx*(f1+f2)/(f1*r2 + f2*r1)*fP3;
+  return z;
+}
+
+
+
+
 Int_t AliITStrackV2::Improve(Double_t x0,Double_t xyz[3],Double_t ers[3]) {
   //------------------------------------------------------------------
   //This function improves angular track parameters  
index e26a27a..a58be03 100644 (file)
@@ -53,7 +53,7 @@ public:
   void ResetCovariance();
   void ResetClusters() { SetChi2(0.); SetNumberOfClusters(0); }
   void UpdateESDtrack(ULong_t flags);
-  void SetConstrainedESDtrack(Double_t chi2);
+  void SetConstrainedESDtrack(Double_t chi2); 
   
   Int_t GetDetectorIndex() const {return GetLabel();}
   Double_t GetX()    const {return fX;}
@@ -68,6 +68,8 @@ public:
   Double_t
     Get1Pt() const { return (1e-9*TMath::Abs(fP4)/fP4 + fP4)*GetConvConst(); }
   Double_t GetD(Double_t x=0, Double_t y=0) const;
+  Double_t GetZat(Double_t x=0) const;
+
   Double_t GetSigmaY2() const {return fC00;}
   Double_t GetSigmaZ2() const {return fC11;}
   Int_t Compare(const TObject *o) const;
@@ -95,14 +97,19 @@ protected:
   Double_t fC20, fC21, fC22;             // of the
   Double_t fC30, fC31, fC32, fC33;       // track
   Double_t fC40, fC41, fC42, fC43, fC44; // parameters 
-
+  Int_t fNUsed;                          // number of shared clusters
+  Int_t fNSkipped;                       // number of skipped clusters
+  Bool_t fReconstructed;                 // reconstructed - accepted flag
+  Float_t fChi2MIP[6];                   // MIP chi squres 
   UInt_t fIndex[kMaxLayer]; // indices of associated clusters 
-
   Float_t fdEdxSample[4];   // array of dE/dx samples b.b.
-
+  Float_t fDy[6];           //dy in layer
+  Float_t fDz[6];           //dz in layer
+  Float_t fSigmaY[6];       //sigma y 
+  Float_t fSigmaZ[6];       //sigma z
   AliESDtrack *fESDtrack;   //! pointer to the connected ESD track
 
-  ClassDef(AliITStrackV2,2)   //ITS reconstructed track
+  ClassDef(AliITStrackV2,3)   //ITS reconstructed track
 };
 
 inline 
index ab854f4..6b4be64 100644 (file)
@@ -117,6 +117,7 @@ Int_t AliITStrackerV2::LoadClusters(TTree *cTree) {
   branch->SetAddress(&clusters);
 
   Int_t j=0;
+  Int_t detector=0;
   for (Int_t i=0; i<kMaxLayer; i++) {
     Int_t ndet=fgLayers[i].GetNdetectors();
     Int_t jmax = j + fgLayers[i].GetNladders()*ndet;
@@ -125,10 +126,26 @@ Int_t AliITStrackerV2::LoadClusters(TTree *cTree) {
       Int_t ncl=clusters->GetEntriesFast();
       while (ncl--) {
         AliITSclusterV2 *c=(AliITSclusterV2*)clusters->UncheckedAt(ncl);
+       detector = c->GetDetectorIndex();
         fgLayers[i].InsertCluster(new AliITSclusterV2(*c));
       }
       clusters->Delete();
+      //add dead zone virtual "cluster"
+      
+      if (i<1){
+       for (Float_t ydead = -2.; ydead < 2. ; ydead+=0.05){     
+         Int_t lab[4] = {0,0,0,detector};
+         Int_t info[3] = {0,0,0};
+         Float_t hit[5]={ydead,0,1,0.01,0};
+         fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info));
+         //
+         hit[1]=-7.;
+         fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info));
+       }       
+      }
+      
     }
+    //
     fgLayers[i].ResetRoad(); //road defined by the cluster density
   }
 
@@ -201,7 +218,7 @@ Int_t AliITStrackerV2::Clusters2Tracks(AliESD *event) {
         delete t;
         continue;
       }
-      if (TMath::Abs(t->GetD())>4) {
+      if (TMath::Abs(t->GetD())>5) {
        delete t;
        continue;
       }
@@ -212,6 +229,7 @@ Int_t AliITStrackerV2::Clusters2Tracks(AliESD *event) {
          delete t;
          continue;
       }
+      t->fReconstructed = kFALSE;
       itsTracks.AddLast(t);
     }
   } /* End Read ESD tracks */
@@ -223,9 +241,14 @@ Int_t AliITStrackerV2::Clusters2Tracks(AliESD *event) {
   for (fPass=0; fPass<2; fPass++) {
      Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue;
      for (Int_t i=0; i<nentr; i++) {
+       cerr<<fPass<<"    "<<i<<'\r';
        fCurrentEsdTrack = i;
        AliITStrackV2 *t=(AliITStrackV2*)itsTracks.UncheckedAt(i);
-       if (t==0) continue;           //this track has been already tracked
+       if (t==0) continue;              //this track has been already tracked
+       if (t->fReconstructed) continue;  //this track was  already  "succesfully" reconstructed
+       if ( (TMath::Abs(t->GetD(GetX(),GetY()))  >2.) && fConstraint[fPass]) continue;
+       if ( (TMath::Abs(t->GetZat(GetX())-GetZ())>2.) && fConstraint[fPass]) continue;
+
        Int_t tpcLabel=t->GetLabel(); //save the TPC track label
 
        ResetTrackToFollow(*t);
@@ -237,7 +260,8 @@ Int_t AliITStrackerV2::Clusters2Tracks(AliESD *event) {
         }
        }
 
-       CompressTrackHypothesys(fCurrentEsdTrack,5);  //MI change
+       SortTrackHypothesys(fCurrentEsdTrack,0.9);  //MI change
+       CompressTrackHypothesys(fCurrentEsdTrack,0.90,2);  //MI change
 
        /*
        if (fBestTrack.GetNumberOfClusters() == 0) continue;
@@ -256,17 +280,49 @@ Int_t AliITStrackerV2::Clusters2Tracks(AliESD *event) {
        delete itsTracks.RemoveAt(i);
        ntrk++;
        */
-       AliITStrackV2 * besttrack = GetBestHypothesys(fCurrentEsdTrack,t);
+       AliITStrackV2 * besttrack = GetBestHypothesys(fCurrentEsdTrack,t,5);
        if (!besttrack) continue;
        besttrack->SetLabel(tpcLabel);
        besttrack->CookdEdx();
+       besttrack->fFakeRatio=1.;
        CookLabel(besttrack,0.); //For comparison only
-       besttrack->UpdateESDtrack(AliESDtrack::kITSin);
-       delete itsTracks.RemoveAt(i);
+       //       besttrack->UpdateESDtrack(AliESDtrack::kITSin);
+       
+       if (besttrack->GetChi2()/besttrack->GetNumberOfClusters()>3.5){
+        if ( (TMath::Abs(besttrack->GetD(GetX(),GetY()))>0.4) && fConstraint[fPass]) {
+          CompressTrackHypothesys(fCurrentEsdTrack,0.0,0);
+          continue;
+        }
+        if ( (TMath::Abs(besttrack->GetZat(GetX()) -GetZ() )>0.4) && fConstraint[fPass]){
+          CompressTrackHypothesys(fCurrentEsdTrack,0.0,0);
+          continue;
+        }
+       }
+       
+       //delete itsTracks.RemoveAt(i);
+       t->fReconstructed = kTRUE;
        ntrk++;              
        
      }
   }
+  
+  for (Int_t i=0; i<nentr; i++) {
+    fCurrentEsdTrack = i;
+    AliITStrackV2 *t=(AliITStrackV2*)itsTracks.UncheckedAt(i);
+    if (t==0) continue;         
+    Int_t tpcLabel=t->GetLabel(); //save the TPC track label
+    cerr<<i<<'\r';
+    AliITStrackV2 * besttrack = GetBestHypothesysMIP(fCurrentEsdTrack,t);
+    if (!besttrack) continue;
+
+    besttrack->SetLabel(tpcLabel);
+    besttrack->CookdEdx();
+    besttrack->fFakeRatio=1.;
+    CookLabel(besttrack,0.); //For comparison only
+    besttrack->UpdateESDtrack(AliESDtrack::kITSin);
+  }
+  //
+
   itsTracks.Delete();
   //
   Int_t entries = fTrackHypothesys.GetEntriesFast();
@@ -535,7 +591,6 @@ void AliITStrackerV2::FollowProlongation() {
   //--------------------------------------------------------------------
   //This function finds a track prolongation 
   //--------------------------------------------------------------------
-  Int_t skipped=0;
   while (fI>fLastLayerToTrackTo) {
     Int_t i=fI-1;
 
@@ -594,9 +649,13 @@ void AliITStrackerV2::FollowProlongation() {
       return;
     }
 
-    if (TMath::Abs(fTrackToFollow.GetZ()-GetZ()) > r+dz) return;
+    //    if (TMath::Abs(fTrackToFollow.GetZ()-GetZ()) > r+dz) return;
 
     //Double_t dy=4*TMath::Sqrt(track.GetSigmaY2() + kSigmaY2[i]);
+    if (TMath::Abs(track.GetSnp()>kMaxSnp)) {
+      fI--;
+      continue;   // MI
+    }
     if (dy < 0.5*TMath::Abs(track.GetSnp())) dy=0.5*TMath::Abs(track.GetSnp());
     if (dy > kMaxRoad) {
       //Warning("FollowProlongation","too broad road in Y !\n");
@@ -612,18 +671,36 @@ void AliITStrackerV2::FollowProlongation() {
 
     //take another prolongation
     if (!TakeNextProlongation()){ 
-      skipped++;
-      if (fLayersNotToSkip[fI]||skipped>1) return;
+      //skipped++;
+      fTrackToFollow.fNSkipped++;
+      if (fLayersNotToSkip[fI]||fTrackToFollow.fNSkipped>1) return;
     }
+    if (fTrackToFollow.fNUsed>1) return;
+    if (fTrackToFollow.fNUsed+fTrackToFollow.fNSkipped>1) return;    
+    if ( (fI<3) && ( fTrackToFollow.GetChi2()/fTrackToFollow.GetNumberOfClusters()>kChi2PerCluster)) return;
   } 
 
   //deal with the best track
   Int_t ncl=fTrackToFollow.GetNumberOfClusters();
   Int_t nclb=fBestTrack.GetNumberOfClusters();
   if (ncl){
-    if ( (ncl>1) && (nclb>3) && ((fTrackToFollow.GetChi2()/ncl)<(2*fBestTrack.GetChi2()/(nclb))))
+    if (ncl<4) return;
+    if ( (ncl<6) && (fTrackToFollow.GetChi2()/float(ncl))>3) return;
+    if (fTrackToFollow.GetChi2()/ncl>5.5) return;
+    fTrackToFollow.CookdEdx();
+    if (fTrackToFollow.fESDtrack->GetTPCsignal()>80.)
+      if ((fTrackToFollow.GetdEdx()/fTrackToFollow.fESDtrack->GetTPCsignal())<0.35){
+       // mismatch in dedx
+       return;
+      }
+    //
+    fTrackToFollow.SetLabel(fTrackToFollow.fESDtrack->GetLabel());
+    CookLabel(&fTrackToFollow,0.); //
+    //
+    if ( (nclb>3) && ((fTrackToFollow.GetChi2()/ncl)<(3*fBestTrack.GetChi2()/(nclb))))
       AddTrackHypothesys(new AliITStrackV2(fTrackToFollow), fCurrentEsdTrack);
-    else if (ncl>3) AddTrackHypothesys(new AliITStrackV2(fTrackToFollow), fCurrentEsdTrack);
+    else 
+      if (ncl>3) AddTrackHypothesys(new AliITStrackV2(fTrackToFollow), fCurrentEsdTrack);
     if (ncl >= nclb) {
       Double_t chi2=fTrackToFollow.GetChi2();
       if (chi2/ncl < kChi2PerCluster) {        
@@ -659,7 +736,6 @@ Int_t AliITStrackerV2::TakeNextProlongation() {
   Double_t chi2=12345.;
   while ((c=layer.GetNextCluster(ci))!=0) {
     Int_t idet=c->GetDetectorIndex();
-
     if (fTrackToFollow.GetDetectorIndex()!=idet) {
        const AliITSdetector &det=layer.GetDetector(idet);
        ResetTrackToFollow(fTracks[fI]);
@@ -679,12 +755,23 @@ Int_t AliITStrackerV2::TakeNextProlongation() {
 
   if (chi2>=kMaxChi2) return 0;
   if (!c) return 0;
+  if (c->IsUsed()&&c->GetNy()<5) {  //shared factor    
+    chi2+=1;
+    chi2*=2*(1./(TMath::Max(c->GetNy(),1)));
+  }
+  if (c->GetQ()==0){  //dead zone virtual cluster
+    chi2*=4.;
+    chi2+=20;
+    fTrackToFollow.fNUsed++;
+    return 1;
+  }
+  //if ((fI<2)&&chi2>kMaxChi2In) return 0;
 
   if (!fTrackToFollow.Update(c,chi2,(fI<<28)+ci)) {
      //Warning("TakeNextProlongation","filtering failed !\n");
      return 0;
   }
-
+  if (c->IsUsed()&&c->GetNy()<5) fTrackToFollow.fNUsed++;
   if (fTrackToFollow.GetNumberOfClusters()>1)
   if (TMath::Abs(fTrackToFollow.GetD())>4) return 0;
 
@@ -701,6 +788,15 @@ Int_t AliITStrackerV2::TakeNextProlongation() {
     Double_t d=GetEffectiveThickness(0,0); //Think of this !!!!
     Double_t xyz[]={GetX(),GetY(),GetZ()};
     Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()};
+    Double_t deltad = TMath::Abs(fTrackToFollow.GetD(GetX(),GetY()));
+    Double_t deltaz = TMath::Abs(fTrackToFollow.GetZat(GetX())-GetZ());
+
+    if ( (fI==4) &&  (deltad>2.0 || deltaz>1.5))  return 0; // don't "improve" secondaries     
+    if ( (fI==3) &&  (deltad>1.5 || deltaz>0.9))  return 0; // don't "improve" secondaries 
+    if ( (fI==2) &&  (deltad>0.9 || deltaz>0.6))  return 1; // don't "improve" secondaries 
+    if ( (fI==1) &&  (deltad>0.3 || deltaz>0.3))  return 1; // don't "improve" secondaries 
+    if ( (fI==0) &&  (deltad>0.1 || deltaz>0.1))  return 1; // don't "improve" secondaries 
+
     fTrackToFollow.Improve(d,xyz,ers);
   }
 
@@ -737,6 +833,7 @@ AliITStrackerV2::AliITSlayer::~AliITSlayer() {
   //--------------------------------------------------------------------
   delete[] fDetectors;
   for (Int_t i=0; i<fN; i++) delete fClusters[i];
+  for (Int_t i=0; i<kMaxClusterPerLayer;i++) fClusterWeight[i]=0;
 }
 
 void AliITStrackerV2::AliITSlayer::ResetClusters() {
@@ -744,10 +841,18 @@ void AliITStrackerV2::AliITSlayer::ResetClusters() {
   // This function removes loaded clusters
   //--------------------------------------------------------------------
   for (Int_t i=0; i<fN; i++) delete fClusters[i];
+  for (Int_t i=0; i<kMaxClusterPerLayer;i++) fClusterWeight[i]=0;
   fN=0;
   fI=0;
 }
 
+void AliITStrackerV2::AliITSlayer::ResetWeights() {
+  //--------------------------------------------------------------------
+  // This function reset weights of the clusters
+  //--------------------------------------------------------------------
+  for (Int_t i=0; i<kMaxClusterPerLayer;i++) fClusterWeight[i]=0;
+}
+
 void AliITStrackerV2::AliITSlayer::ResetRoad() {
   //--------------------------------------------------------------------
   // This function calculates the road defined by the cluster density
@@ -810,7 +915,7 @@ const AliITSclusterV2 *AliITStrackerV2::AliITSlayer::GetNextCluster(Int_t &ci){
   for (Int_t i=fI; i<fN; i++) {
     const AliITSclusterV2 *c=fClusters[i];
     if (c->GetZ() > fZmax) break;
-    if (c->IsUsed()) continue;
+    //    if (c->IsUsed()) continue;
     const AliITSdetector &det=GetDetector(c->GetDetectorIndex());    
     Double_t y=fR*det.GetPhi() + c->GetY();
 
@@ -1131,6 +1236,18 @@ AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,const AliITStrackV2 *c) {
   return kTRUE;
 }
 
+
+Float_t  *AliITStrackerV2::GetWeight(Int_t index) {
+  //--------------------------------------------------------------------
+  //       Return pointer to a given cluster
+  //--------------------------------------------------------------------
+  Int_t l=(index & 0xf0000000) >> 28;
+  Int_t c=(index & 0x0fffffff) >> 00;
+  return fgLayers[l].GetWeight(c);
+}
+
+
+
 void AliITStrackerV2::UseClusters(const AliKalmanTrack *t, Int_t from) const {
   //--------------------------------------------------------------------
   // This function marks clusters assigned to the track
@@ -1163,7 +1280,7 @@ void AliITStrackerV2::AddTrackHypothesys(AliITStrackV2 * track, Int_t esdindex)
   array->AddLast(track);
 }
 
-void AliITStrackerV2::CompressTrackHypothesys(Int_t esdindex, Int_t maxsize)
+void AliITStrackerV2::SortTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel)
 {
   //-------------------------------------------------------------------
   // compress array of track hypothesys
@@ -1172,26 +1289,52 @@ void AliITStrackerV2::CompressTrackHypothesys(Int_t esdindex, Int_t maxsize)
   if (esdindex>fTrackHypothesys.GetEntriesFast()) return;
   if (! (fTrackHypothesys.At(esdindex)) ) return;
   TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
-  Int_t entries = array->GetEntries();
-  if (entries<maxsize) return;
-  Float_t * chi2 = new Float_t[entries];
-  Int_t * index = new Int_t[entries];
-  Int_t current=0;
+  Int_t entries = array->GetEntriesFast();
+
+  Float_t * chi2        = new Float_t[entries];
+  Float_t * probability = new Float_t[entries];
+  Float_t sumprobabilityall=0;
+  Int_t * index         = new Int_t[entries];
+  //
   //
-  for (Int_t i=0;i<array->GetEntriesFast();i++){
-    AliITStrackV2 * track = (AliITStrackV2*)array->At(i);
-    if (track)
-      chi2[current] = track->GetNumberOfClusters()+0.001+track->GetChi2()/track->GetNumberOfClusters();
+  for (Int_t itrack=0;itrack<array->GetEntriesFast();itrack++){
+    AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
+    //
+    if (track && track->GetNumberOfClusters()>(track->fNUsed+track->fNSkipped)){
+      //
+      chi2[itrack] = track->GetChi2()/(track->GetNumberOfClusters()-track->fNUsed-track->fNSkipped);      
+      if (track->fESDtrack)
+       if (track->fESDtrack->GetTPCsignal()>80){
+         track->CookdEdx();
+         if ((track->GetdEdx()/track->fESDtrack->GetTPCsignal())<0.4){
+           Float_t factor = 2.+10.*(0.6-track->GetdEdx()/track->fESDtrack->GetTPCsignal());
+           chi2[itrack]*= factor;  //mismatch in dEdx
+         }
+       }      
+    }
     else
-      chi2[current] = 100000000;
-    current++;
+      chi2[itrack] = 10000000.;
+    probability[itrack] = 1./(0.3+chi2[itrack]);
+    sumprobabilityall+=probability[itrack];
   }
-  TMath::Sort(current,chi2,index,kFALSE);
+
+  TMath::Sort(entries,chi2,index,kFALSE);
   TObjArray * newarray = new TObjArray();
-  maxsize = TMath::Min(current, maxsize);
-  for (Int_t i=0;i<maxsize;i++){
-    newarray->AddLast(array->RemoveAt(index[i]));
+  Float_t     sumprobability = 0.;
+  for (Int_t i=0;i<entries;i++){
+    AliITStrackV2 * track = (AliITStrackV2*)array->At(index[i]);
+    if (!track) break;
+    if (chi2[index[i]]<30){
+      newarray->AddLast(array->RemoveAt(index[i]));      
+      track->fChi2MIP[0] = chi2[index[i]];     // base chi 2
+      sumprobability+= probability[index[i]]/sumprobabilityall;
+      if (sumprobability> likelihoodlevel) break;
+    }
+    else{
+      delete array->RemoveAt(index[i]);
+    }
   }
+
   array->Delete();
   delete fTrackHypothesys.RemoveAt(esdindex);
   fTrackHypothesys.AddAt(newarray,esdindex);
@@ -1202,23 +1345,305 @@ void AliITStrackerV2::CompressTrackHypothesys(Int_t esdindex, Int_t maxsize)
 }
 
 
+void AliITStrackerV2::CompressTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel, Int_t maxsize)
+{
+  //
+  //
+  if (esdindex>fTrackHypothesys.GetEntriesFast()) return;
+  if (! (fTrackHypothesys.At(esdindex)) ) return;
+  TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
+  Int_t entries = array->GetEntriesFast();
+  //
+  if (likelihoodlevel>0.000001){
+    Float_t *probability = new Float_t[entries];
+    for (Int_t i=0;i<entries;i++) probability[i]=0.;
+    Float_t  sumprobabilityall=0;
+    Int_t   *index         = new Int_t[entries];
+    
+    for (Int_t itrack=0;itrack<entries;itrack++){
+      AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
+      probability[itrack]=0;
+      if (!track) continue;
+      probability[itrack] = 1./(0.3+track->fChi2MIP[0]);
+      sumprobabilityall  += probability[itrack];
+      //    
+    }
+    if (sumprobabilityall<=0.000000000000001){
+      return;
+    }
+    for (Int_t itrack=0;itrack<entries;itrack++){
+      probability[itrack]/=sumprobabilityall;
+    }
+    
+    TMath::Sort(entries, probability, index, kTRUE);
+    //
+    TObjArray * newarray = new TObjArray();
+    Float_t     sumprobability = 0.;
+    for (Int_t i=0;i<entries;i++){
+      AliITStrackV2 * track = (AliITStrackV2*)array->At(index[i]);
+      if (!track) continue;    
+      newarray->AddLast(array->RemoveAt(index[i]));      
+      sumprobability+= probability[index[i]];
+      if (sumprobability> likelihoodlevel) break;
+      if (i>maxsize) break;
+    }
+    
+    array->Delete();
+    delete fTrackHypothesys.RemoveAt(esdindex);
+    fTrackHypothesys.AddAt(newarray,esdindex);
+    //    
+    delete []index;
+    delete []probability;
+  }
+  else{
+    array->Delete();
+    delete fTrackHypothesys.RemoveAt(esdindex);
+  }
+}
+
 
-AliITStrackV2 * AliITStrackerV2::GetBestHypothesys(Int_t esdindex, AliITStrackV2 * original)
+AliITStrackV2 * AliITStrackerV2::GetBestHypothesys(Int_t esdindex, AliITStrackV2 * original, Int_t checkmax)
 {
   //-------------------------------------------------------------
   // try to find best hypothesy
   // currently - minimal chi2 of track+backpropagated track+matching to the tpc track
   //-------------------------------------------------------------
+  if (fTrackHypothesys.GetEntriesFast()<=esdindex) return 0;
   TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
   if (!array) return 0;
   Int_t entries = array->GetEntriesFast();
   if (!entries) return 0;  
   Float_t minchi2 = 100000;
-  Int_t   maxn    = 2;
+  Int_t   maxn    = 3;
   AliITStrackV2 * besttrack=0;
+  Int_t accepted =0;
+  Int_t maxindex=0;
+  //
+  Float_t sumz2=0;
+  Float_t sumy2=0;
+  Float_t sumall=0;
+  for (Int_t itrack=0;itrack<entries; itrack++){
+    AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
+    if (!track) continue;
+    sumall++;
+    sumz2+=track->GetSigmaZ2();
+    sumy2+=track->GetSigmaY2();
+  }
+  sumz2/=sumall;
+  sumy2/=sumall;
+
+  Float_t dedxmismatch=1;
+  for (Int_t i=0;i<entries;i++){    
+    maxindex = i;
+    AliITStrackV2 * track = (AliITStrackV2*)array->At(i);    
+    if (!track) continue;
+    track->fChi2MIP[1] = 1000000;
+    track->fChi2MIP[2] = 1000000;
+
+    if ( (track->GetNumberOfClusters()-track->fNSkipped-track->fNUsed)<2) continue;
+    //
+    if (track->fESDtrack)
+      if (track->fESDtrack->GetTPCsignal()>80){
+       track->CookdEdx();      
+       if ((track->GetdEdx()/track->fESDtrack->GetTPCsignal())<0.4){
+         //mismatch in dEdx 
+         dedxmismatch= 2.+ 10.*(0.6-track->GetdEdx()/track->fESDtrack->GetTPCsignal());
+       }
+      }
+
+    //    track->SetLabel(original->GetLabel());
+    //CookLabel(track,0.0);
+    //if (track->GetFakeRatio()>0.01) continue;
+    //
+    //
+    // backtrack
+    AliITStrackV2 * backtrack = new AliITStrackV2(*track);
+    backtrack->ResetCovariance();
+    backtrack->ResetClusters();
+    Double_t x = original->GetX();
+    if (!RefitAt(x,backtrack,track)){
+      delete backtrack;
+      delete array->RemoveAt(i);
+      continue;
+    }
+    if (  (backtrack->GetChi2() / float(backtrack->GetNumberOfClusters()-track->fNSkipped-track->fNUsed-0.5))>6) 
+      {
+       delete backtrack; 
+       delete array->RemoveAt(i);
+       continue;
+      }
+    Double_t deltac   = backtrack->GetC()-original->GetC();
+    Double_t deltatgl = backtrack->GetTgl()-original->GetTgl();
+    //
+    Double_t poolc2      = (deltac*deltac)/(original->fC44+backtrack->fC44);
+    Double_t pooltgl2    = (deltatgl*deltatgl)/(original->fC33+backtrack->fC33);
+    if ((poolc2+pooltgl2)>32){  //4 sigma
+      delete backtrack; 
+      delete array->RemoveAt(i);
+      continue;      
+    }
+    //Double_t bpoolc      = (deltac*deltac)/(original->fC44);
+    //Double_t bpooltgl    = (deltatgl*deltatgl)/(original->fC33);
+
+    //
+    //forward track - without constraint
+    AliITStrackV2 * forwardtrack = new AliITStrackV2(*original);
+    //    forwardtrack->ResetCovariance();
+    forwardtrack->ResetClusters();
+    x = track->GetX();
+    if (!RefitAt(x,forwardtrack,track)){
+      delete forwardtrack;
+      delete backtrack;
+      delete array->RemoveAt(i);
+      continue;
+    }
+    if ( (forwardtrack->GetChi2()/float(forwardtrack->GetNumberOfClusters()-track->fNSkipped-track->fNUsed))>6) 
+      {
+       delete forwardtrack; 
+       delete array->RemoveAt(i);
+       continue;
+      }
+    //
+    accepted++;
+    if (accepted>checkmax){
+      delete backtrack;
+      delete forwardtrack;
+      break;
+    }
+    Double_t chi2 = (backtrack->GetChi2()/(backtrack->GetNumberOfClusters()-1-track->fNSkipped-track->fNUsed)+
+                    forwardtrack->GetChi2()/(forwardtrack->GetNumberOfClusters()-track->fNSkipped-track->fNUsed));
+      //                     bpoolc+bpooltgl;
+    //    chi2 *= (forwardtrack->GetSigmaZ2()/sumz2+forwardtrack->GetSigmaY2()/sumy2);
+    chi2 *= dedxmismatch;
+    //
+    //
+    track->fChi2MIP[1] = backtrack->GetChi2()/(backtrack->GetNumberOfClusters()-1-track->fNSkipped-track->fNUsed);
+    track->fChi2MIP[2] = forwardtrack->GetChi2()/(forwardtrack->GetNumberOfClusters()-track->fNSkipped-track->fNUsed);
+    track->fChi2MIP[3] = poolc2+pooltgl2;
+    //
+    
+    if (track->GetNumberOfClusters()>maxn){
+      besttrack =  new AliITStrackV2(*forwardtrack);
+      maxn      =  track->GetNumberOfClusters();
+      minchi2   =  chi2;
+      delete backtrack;
+      delete forwardtrack;
+      continue;
+    }   
+    //
+    if (chi2 < minchi2){
+      besttrack = new AliITStrackV2(*forwardtrack);
+      minchi2   = chi2;      
+    }    
+    delete backtrack;
+    delete forwardtrack;
+  }
+  //
+  //
+  if (!besttrack || besttrack->GetNumberOfClusters()<4) {
+    return 0;
+  }
+
+  //
+  besttrack->SetLabel(original->GetLabel());
+  CookLabel(besttrack,0.0);
   //
   // calculate "weight of the cluster"
   //
+
+  {
+    //sign usage information for clusters
+    Int_t clusterindex[6][100];
+    Double_t clusterweight[6][100];
+    for (Int_t ilayer=0;ilayer<6;ilayer++)
+      for (Int_t icluster=0;icluster<100;icluster++){
+       clusterindex[ilayer][icluster]   = -1;
+       clusterweight[ilayer][icluster]  = 0;
+      }
+    //printf("%d\t%d\n",esdindex, entries);
+    //
+    Float_t sumchi2=0;
+    for (Int_t itrack=0;itrack<entries; itrack++){
+      AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
+      if (!track) continue;
+      if (track->fChi2MIP[1]>1000) continue;  //not accepted
+      sumchi2 +=1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[2]);
+    }
+    for (Int_t itrack=0;itrack<entries;itrack++){
+      AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
+      if (!track) continue;
+      if (track->fChi2MIP[1]>1000) continue;  //not accepted  
+      for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){     
+       Int_t tindex = track->GetClusterIndex(icluster);
+       Int_t ilayer = (tindex & 0xf0000000) >> 28;
+       if (tindex<0) continue;
+       Int_t cindex =0;
+       //
+       for (cindex=0;cindex<100;cindex++){
+         if (clusterindex[ilayer][cindex]<0) break;
+         if (clusterindex[ilayer][cindex]==tindex) break;
+       }
+       if (cindex>100) break;
+       if (clusterindex[ilayer][cindex]!=tindex) clusterindex[ilayer][cindex] = tindex;
+       clusterweight[ilayer][cindex]+= (1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[2]))* (1./sumchi2); 
+       Float_t *weight = GetWeight(tindex);
+       
+       if (weight){
+         *weight+= (1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[2]))* (1./sumchi2);
+       }
+      }
+    }
+    
+    if (besttrack->GetChi2()/besttrack->GetNumberOfClusters()>3.5) return besttrack; //don't sign clusters
+    Int_t current=0;
+    Double_t deltad = besttrack->GetD(GetX(),GetY());
+    Double_t deltaz = besttrack->GetZat(GetX()) - GetZ();
+    Double_t deltaprim = TMath::Sqrt(deltad*deltad+deltaz*deltaz);
+
+    for (Int_t icluster=0;icluster<besttrack->GetNumberOfClusters();icluster++){
+      Int_t index = besttrack->GetClusterIndex(icluster);
+      Int_t ilayer =  (index & 0xf0000000) >> 28;
+      AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(index);
+      if (!c) continue;
+      // 
+      for (Int_t icluster=0;icluster<100;icluster++){
+       // sign non "doubt" clusters as used
+       if (clusterindex[ilayer][icluster]!=index) continue;
+       //      Float_t * weight = GetWeight(index);
+       //if (weight) if (*weight>1){
+       //  if (c->IsUsed()) continue;
+       //  c->Use();
+       //}      
+       if ( (ilayer*0.2+0.2)<deltaprim) continue; // secondaries
+       if (c->GetNy()>4) continue; // don sign cluster
+       if ( (ilayer>1&&clusterweight[ilayer][icluster]>0.7) || (ilayer<2&&clusterweight[ilayer][icluster]>0.8) ){
+         current++;
+         if (c->IsUsed()) continue;
+         c->Use();
+       }
+      }
+    }
+  }
+  //
+  return besttrack;
+} 
+
+
+AliITStrackV2 * AliITStrackerV2::GetBestHypothesysMIP(Int_t esdindex, AliITStrackV2 * original)
+{
+  //-------------------------------------------------------------
+  // try to find best hypothesy
+  // currently - minimal chi2 of track+backpropagated track+matching to the tpc track
+  //-------------------------------------------------------------
+  if (fTrackHypothesys.GetEntriesFast()<=esdindex) return 0;
+  TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
+  if (!array) return 0;
+  Int_t entries = array->GetEntriesFast();
+  if (!entries) return 0;  
+  AliITStrackV2 * besttrack=0;
+  //
+  //sign usage information for clusters
   Int_t clusterindex[6][100];
   Double_t clusterweight[6][100];
   for (Int_t ilayer=0;ilayer<6;ilayer++)
@@ -1229,14 +1654,18 @@ AliITStrackV2 * AliITStrackerV2::GetBestHypothesys(Int_t esdindex, AliITStrackV2
   //printf("%d\t%d\n",esdindex, entries);
   //
   Float_t sumchi2=0;
-  for (Int_t itrack=0;itrack<entries;itrack++){
+  for (Int_t itrack=0;itrack<entries; itrack++){
     AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
     if (!track) continue;
-    sumchi2 +=track->GetChi2();
+    if (track->fChi2MIP[1]>1000) continue;  //not accepted - before
+    sumchi2 +=1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[2]);
   }
+  //
+  // get cluster weight 
   for (Int_t itrack=0;itrack<entries;itrack++){
     AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
     if (!track) continue;
+    if (track->fChi2MIP[1]>1000) continue;  // track not accepted in previous iterration  
     for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){     
       Int_t tindex = track->GetClusterIndex(icluster);
       Int_t ilayer = (tindex & 0xf0000000) >> 28;
@@ -1249,73 +1678,121 @@ AliITStrackV2 * AliITStrackerV2::GetBestHypothesys(Int_t esdindex, AliITStrackV2
       }
       if (cindex>100) break;
       if (clusterindex[ilayer][cindex]!=tindex) clusterindex[ilayer][cindex] = tindex;
-      clusterweight[ilayer][cindex]+= track->GetChi2()/sumchi2; 
+      clusterweight[ilayer][cindex]+= (1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[2]))* (1./sumchi2); 
     }
   }
+  //  
+  // get cluster relative sharing - factor
   //
-  for (Int_t i=0;i<entries;i++){
-    AliITStrackV2 * track = (AliITStrackV2*)array->At(i);
-    if (!track) continue;
-    AliITStrackV2 * backtrack = new AliITStrackV2(*track);
-    backtrack->ResetCovariance();
-    backtrack->ResetClusters();
-    Double_t x = original->GetX();
-    RefitAt(x,backtrack,track);
-    if (track->GetNumberOfClusters()<maxn) {
-      delete backtrack;
-      continue;
+  // 
+  for (Int_t ilayer=0;ilayer<6;ilayer++)
+    for (Int_t cindex=0;cindex<100;cindex++){
+      if (clusterindex[ilayer][cindex]<0) continue;
+      Int_t tindex = clusterindex[ilayer][cindex];
+      Float_t *weight = GetWeight(tindex);
+      if (!weight){
+       printf("Problem 1\n");  // not existing track
+       continue;
+      }
+      if (*weight<(clusterweight[ilayer][cindex]-0.00001)){
+       printf("Problem 2\n");  // not normalized probability
+       continue;
+      }   
+      AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(tindex);
+      if (c->GetNy()<5){
+       clusterweight[ilayer][cindex]/= *weight; 
+      }
+      else{
+       Float_t weight2 = TMath::Max(*weight-0.5*clusterweight[ilayer][cindex],0.0000001);
+       clusterweight[ilayer][cindex]/= weight2;
+       if (    clusterweight[ilayer][cindex]>1)   clusterweight[ilayer][cindex] =1.;
+      }
     }
-    Double_t deltac   = backtrack->GetC()-original->GetC();
-    Double_t deltatgl = backtrack->GetTgl()-original->GetTgl();
-    Double_t poolc      = (deltac*deltac)/(original->fC44);
-    Double_t pooltgl    = (deltatgl*deltatgl)/(original->fC33);
-    Double_t chi2 = 0.5*(track->GetChi2()+backtrack->GetChi2())+poolc+pooltgl;
-    
-    if (track->GetNumberOfClusters()>maxn){
-      besttrack =  track;
-      maxn      =  track->GetNumberOfClusters();
-      minchi2   =  chi2;
-      delete backtrack;
-      continue;
+  //
+  //take to the account sharing factor
+  //
+  Float_t chi2 =10000000;
+  Float_t sharefactor=0;
+  Float_t minchi2 = 100000000;
+  Float_t secchi2 = 100000000;
+  Float_t norm=0;
+  for (Int_t itrack=0;itrack<entries; itrack++){
+    AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
+    if (!track) continue;
+    if (track->fChi2MIP[1]>1000) continue;  //not accepted - before
+    chi2 = track->fChi2MIP[1];
+    Float_t newchi2=0;
+    sharefactor=0;
+    norm =0;
+    //
+    for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){     
+      Int_t tindex = track->GetClusterIndex(icluster);
+      Int_t ilayer = (tindex & 0xf0000000) >> 28;
+      if (tindex<0) continue;
+      Int_t cindex =0;
+      Float_t cchi2 = (track->fDy[ilayer]*track->fDy[ilayer])/(track->fSigmaY[ilayer]*track->fSigmaY[ilayer]) +
+       (track->fDz[ilayer]*track->fDz[ilayer])/(track->fSigmaZ[ilayer]*track->fSigmaZ[ilayer]) ;
+      //
+      for (cindex=0;cindex<100;cindex++){
+       if (clusterindex[ilayer][cindex]<0) break;
+       if (clusterindex[ilayer][cindex]==tindex) break;
+      }
+      if (cindex>100) continue;
+      if (clusterweight[ilayer][cindex]>0.00001){
+       sharefactor+= clusterweight[ilayer][cindex];
+       cchi2/=clusterweight[ilayer][cindex];
+       norm++;
+      }
+      newchi2+=cchi2;
     }
-    if (chi2 < minchi2){
+    newchi2/=(norm-track->fNSkipped-track->fNUsed);
+    track->fChi2MIP[4] = newchi2;
+    //if (norm>0) sharefactor/=norm;
+    //if (sharefactor<0.5) return 0;
+    //    chi2*=1./(0.5+sharefactor);
+    if (newchi2<minchi2){
       besttrack = track;
-      minchi2   = chi2;      
-    }    
-    delete backtrack;
+      minchi2   = newchi2;
+    }
+    else{
+      if (newchi2<secchi2){
+       secchi2 = newchi2;
+      }
+    }
+    //
   }
+
+  //
   //
+  if (!besttrack || besttrack->GetNumberOfClusters()<4) {
+    return 0;
+  }
   //
-  AliITStrackV2 * track2 = new AliITStrackV2(*original);
+  if ((minchi2/secchi2)<0.7){
+    //
+    //increase the weight for clusters if the probability of other hypothesys is small
+    Double_t deltad = besttrack->GetD(GetX(),GetY());
+    Double_t deltaz = besttrack->GetZat(GetX()) - GetZ();
+    Double_t deltaprim = TMath::Sqrt(deltad*deltad+deltaz*deltaz);
+    //
+    for (Int_t icluster=0;icluster<besttrack->GetNumberOfClusters();icluster++){
+      Int_t index = besttrack->GetClusterIndex(icluster);
+      Int_t ilayer =  (index & 0xf0000000) >> 28;
+      AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(index);
+      if (!c) continue; 
+      if (c->GetNy()>3) continue;
+      if ( (ilayer*0.2+0.2)<deltaprim) continue; // secondaries     
+      Float_t * weight = GetWeight(index);
+      *weight*=2.;
+      *weight+=1.;
+    }   
+  }
+  
+
+  besttrack->SetLabel(original->GetLabel());
+  CookLabel(besttrack,0.0);
   
-  Int_t current=0;
-  for (Int_t icluster=0;icluster<besttrack->GetNumberOfClusters();icluster++){
-    Int_t index = besttrack->GetClusterIndex(icluster);
-    Int_t ilayer =  (index & 0xf0000000) >> 28;
-    AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(index);
-    if (!c) continue;
-    // 
-    if (ilayer>1){     
-      track2->fIndex[current] = index; 
-      track2->fN++;
-    }
-    for (Int_t icluster=0;icluster<100;icluster++){
-      // sign non "doubt" clusters as used
-      if (clusterindex[ilayer][icluster]!=index) continue;      
-      if (clusterweight[ilayer][icluster]>0.9){
-       if (ilayer<=1){
-         track2->fIndex[current] = index;      
-         track2->fN++;
-       }
-       current++;
-       if (c->IsUsed()) continue;
-       c->Use();
-      }
-    }
-  }  
-  //  besttrack = new AliITStrackV2(*original);
-  //RefitAt(3.7, besttrack, track2);
-  delete track2;
   //
   return besttrack;
 } 
+
index 8cca95b..7540b0d 100644 (file)
@@ -46,7 +46,7 @@ public:
 
   void UseClusters(const AliKalmanTrack *t, Int_t from=0) const;
 
-  class AliITSdetector {
+  class AliITSdetector { 
   public:
     AliITSdetector(){}
     AliITSdetector(Double_t r,Double_t phi) {fR=r; fPhi=phi;}
@@ -58,18 +58,21 @@ public:
   };
 
   class AliITSlayer {
+    friend class AliITStrackerV2;
   public:
     AliITSlayer();
     AliITSlayer(Double_t r, Double_t p, Double_t z, Int_t nl, Int_t nd);
    ~AliITSlayer();
     Int_t InsertCluster(AliITSclusterV2 *c);
     void ResetClusters();
+    void ResetWeights();
     void SelectClusters(Double_t zmi,Double_t zma,Double_t ymi,Double_t yma);
     const AliITSclusterV2 *GetNextCluster(Int_t &ci);
     void ResetRoad();
     Double_t GetRoad() const {return fRoad;}
     Double_t GetR() const {return fR;}
     AliITSclusterV2 *GetCluster(Int_t i) const {return i<fN? fClusters[i]:0;} 
+    Float_t         *GetWeight(Int_t i) {return i<fN ?&fClusterWeight[i]:0;}
     AliITSdetector &GetDetector(Int_t n) const { return fDetectors[n]; }
     Int_t FindDetectorIndex(Double_t phi, Double_t z) const;
     Double_t GetThickness(Double_t y, Double_t z, Double_t &x0) const;
@@ -86,6 +89,7 @@ public:
     AliITSdetector *fDetectors; // array of detectors
     Int_t fN;                   // number of clusters
     AliITSclusterV2 *fClusters[kMaxClusterPerLayer]; // pointers to clusters
+    Float_t  fClusterWeight[kMaxClusterPerLayer]; // probabilistic weight of the cluster
     Double_t fZmax;      //    edges
     Double_t fYmin;      //   of  the
     Double_t fYmax;      //   "window"
@@ -107,9 +111,12 @@ protected:
      fTrackToFollow.~AliITStrackV2();
      new(&fTrackToFollow) AliITStrackV2(t);
   }
+  Float_t    *GetWeight(Int_t index);
   void AddTrackHypothesys(AliITStrackV2 * track, Int_t esdindex);
-  void CompressTrackHypothesys(Int_t esdindex, Int_t maxsize);
-  AliITStrackV2 * GetBestHypothesys(Int_t esdindex, AliITStrackV2 * original); 
+  void SortTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel);
+  void CompressTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel, Int_t maxsize);
+  AliITStrackV2 * GetBestHypothesys(Int_t esdindex, AliITStrackV2 * original, Int_t checkmax); 
+  AliITStrackV2 * GetBestHypothesysMIP(Int_t esdindex, AliITStrackV2 * original); 
   Int_t fI;                              // index of the current layer
   static AliITSlayer fgLayers[kMaxLayer];// ITS layers
   AliITStrackV2 fTracks[kMaxLayer];      // track estimations at the ITS layers
@@ -122,7 +129,6 @@ protected:
 
   Int_t fLayersNotToSkip[kMaxLayer];     // layer masks
   Int_t fLastLayerToTrackTo;             // the innermost layer to track to
-
   ClassDef(AliITStrackerV2,1)   //ITS tracker V2
 };
 
@@ -158,7 +164,12 @@ inline void AliITStrackerV2::CookLabel(AliKalmanTrack *t,Float_t wrong) const {
    Int_t tpcLabel=t->GetLabel();
    if (tpcLabel<0) return;
    AliTracker::CookLabel(t,wrong);
-   if (tpcLabel != t->GetLabel()) t->SetLabel(-tpcLabel); 
+   if (tpcLabel!=TMath::Abs(t->GetLabel())){
+     t->SetFakeRatio(1.);
+   }
+   if (tpcLabel !=t->GetLabel()) {
+     t->SetLabel(-tpcLabel);      
+   }
 }
 
 #endif
index d1d0c29..0798f51 100644 (file)
@@ -128,6 +128,7 @@ Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
     for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
     fITSsignal=t->GetPIDsignal();
     fITSLabel = t->GetLabel();
+    fITSFakeRatio = t->GetFakeRatio();
     break;
     
   case kTPCin: case kTPCrefit:
@@ -403,6 +404,9 @@ void AliESDtrack::SetITSpid(const Double_t *p) {
   SetStatus(AliESDtrack::kITSpid);
 }
 
+void AliESDtrack::SetITSChi2MIP(const Float_t *chi2mip){
+  for (Int_t i=0; i<6; i++) fITSchi2MIP[i]=chi2mip[i];
+}
 //_______________________________________________________________________
 void AliESDtrack::GetITSpid(Double_t *p) const {
   // Gets the probability of each particle type (in ITS)
index 367978a..05249f8 100644 (file)
@@ -60,11 +60,14 @@ public:
   void GetOuterXYZ(Double_t *r) const;
 
   void SetITSpid(const Double_t *p);
+  void SetITSChi2MIP(const Float_t *chi2mip);
   void GetITSpid(Double_t *p) const;
   Float_t GetITSsignal() const {return fITSsignal;}
   Float_t GetITSchi2() const {return fITSchi2;}
   Int_t GetITSclusters(UInt_t *idx) const;
   Int_t GetITSLabel() const {return fITSLabel;}
+  Float_t GetITSFakeRatio() const {return fITSFakeRatio;}
+
 
   void SetTPCpid(const Double_t *p);
   void GetTPCpid(Double_t *p) const;
@@ -150,12 +153,13 @@ protected:
 
   // ITS related track information
   Float_t fITSchi2;        // chi2 in the ITS
+  Float_t fITSchi2MIP[6];     // chi2s in the ITS
   Int_t   fITSncls;        // number of clusters assigned in the ITS
   UInt_t  fITSindex[6];    //! indices of the assigned ITS clusters
   Float_t fITSsignal;      // detector's PID signal
   Float_t fITSr[kSPECIES]; // "detector response probabilities" (for the PID)
   Int_t   fITSLabel;       // label according TPC
-
+  Float_t fITSFakeRatio;   // ration of fake tracks
   // TPC related track information
   Float_t fTPCchi2;        // chi2 in the TPC
   Int_t   fTPCncls;        // number of clusters assigned in the TPC
@@ -188,7 +192,7 @@ protected:
   Float_t fRICHsignal;     // detector's PID signal (beta for RICH)
   Float_t fRICHr[kSPECIES];// "detector response probabilities" (for the PID)
        
-  ClassDef(AliESDtrack,3)  //ESDtrack 
+  ClassDef(AliESDtrack,4)  //ESDtrack 
 };
 
 #endif 
index 9f50922..5d6dfb2 100644 (file)
@@ -53,6 +53,7 @@ AliKalmanTrack::AliKalmanTrack():
 AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
   TObject(t),
   fLab(t.fLab),
+  fFakeRatio(t.fFakeRatio),
   fChi2(t.fChi2),
   fMass(t.fMass),
   fN(t.fN)
index 3244187..53c7140 100644 (file)
@@ -23,9 +23,11 @@ public:
 
   virtual ~AliKalmanTrack(){};
   void SetLabel(Int_t lab) {fLab=lab;}
+  void SetFakeRatio(Float_t ratio) {fFakeRatio=ratio;}
 
   Bool_t   IsSortable() const {return kTRUE;}
   Int_t    GetLabel()   const {return fLab;}
+  Float_t    GetFakeRatio()   const {return fFakeRatio;}
   Double_t GetChi2()    const {return fChi2;}
   Double_t GetMass()    const {return fMass;}
   Int_t    GetNumberOfClusters() const {return fN;}
@@ -114,6 +116,7 @@ protected:
   void SetNumberOfClusters(Int_t n) {fN=n;} 
 
   Int_t fLab;             // track label
+  Float_t fFakeRatio;     // fake ratio
   Double_t fChi2;         // total chi2 value for this track
   Double_t fMass;         // mass hypothesis
   Int_t fN;               // number of associated clusters
@@ -126,7 +129,7 @@ protected:
   Double_t fIntegratedTime[5];       // integrated time
   Double_t fIntegratedLength;        // integrated length
   
-  ClassDef(AliKalmanTrack,2)    // Reconstructed track
+  ClassDef(AliKalmanTrack,3)    // Reconstructed track
 };
 
 #endif
index 8e9ec13..e8da02f 100644 (file)
@@ -94,11 +94,15 @@ void AliTracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
     
   for (i=0; i<noc; i++) {
     AliCluster *c=clusters[i];
-    if (TMath::Abs(c->GetLabel(1)) == lab ||
-        TMath::Abs(c->GetLabel(2)) == lab ) max++;
+    //if (TMath::Abs(c->GetLabel(1)) == lab ||
+    //    TMath::Abs(c->GetLabel(2)) == lab ) max++;
+    if (TMath::Abs(c->GetLabel(0)!=lab))
+       if (TMath::Abs(c->GetLabel(1)) == lab ||
+           TMath::Abs(c->GetLabel(2)) == lab ) max++;
   }
 
   if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
+  t->SetFakeRatio((1.- Float_t(max)/noc));
   t->SetLabel(lab);
 
   delete[] lb;
index e182ced..3edbdfb 100644 (file)
@@ -170,7 +170,7 @@ Int_t  AliSimDigits::GetTrackID1(Int_t row, Int_t column, Int_t level)
       id = fTracks->At(i);
     }
     id-=2;
-    if ( (row>=rowold) && (row<=rownew) ) return id;
+    if ( (row>=rowold) && (row<rownew) ) return id;
     if (row < rownew ) return -2; //empty track
   }
   return -2;
index 42c78d0..e5d94c6 100644 (file)
@@ -171,6 +171,7 @@ AliTPCtrack::AliTPCtrack(const AliESDtrack& t) : AliKalmanTrack() {
   fRemoval    = 0;
   fTrackType  = 0;
   fLab2       = 0;
+  //  SetFakeRatio(t.GetTPCFakeRatio());
 }
 
 //_____________________________________________________________________________
@@ -369,6 +370,7 @@ Int_t AliTPCtrack::PropagateTo(Double_t xk,Double_t /*x0*/,Double_t rho) {
   Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fP0)*(y1-fP0)+(z1-fP1)*(z1-fP1));
   Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
   Double_t beta2=p2/(p2 + GetMass()*GetMass());
+  beta2 = TMath::Min(beta2,0.99999999999);
   //Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
   Double_t theta2=1.0259e-6*10*10/20/(beta2*p2)*d*rho;