]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCtracker.cxx
stdlib.h included to declare exit() on HP
[u/mrichter/AliRoot.git] / TPC / AliTPCtracker.cxx
index d5333698f06a26c29b686ab3ca42628cd76507a0..e4d065e1019a3c85ed6b56964026e9176a11bb0f 100644 (file)
 
 /*
 $Log$
+Revision 1.23  2002/11/19 11:50:08  hristov
+Removing CONTAINERS (Yu.Belikov)
+
+Revision 1.19  2002/07/19 07:31:40  kowal2
+Improvement in tracking by J. Belikov
+
+Revision 1.18  2002/05/13 07:33:52  kowal2
+Added protection in Int_t AliTPCtracker::AliTPCRow::Find(Double_t y) const
+in the case of defined region of interests.
+
+Revision 1.17  2002/03/18 17:59:13  kowal2
+Chnges in the pad geometry - 3 pad lengths introduced.
+
+Revision 1.16  2001/11/08 16:39:03  hristov
+Additional protection (M.Masera)
+
 Revision 1.15  2001/11/08 16:36:33  hristov
 Updated V2 stream of tracking (Yu.Belikov). The new long waited features are: 1) Possibility to pass the primary vertex position to the trackers (both for the TPC and the ITS) 2) Possibility to specify the number of tracking passes together with applying (or not applying) the vertex constraint (ITS only) 3) Possibility to make some use of partial PID provided by the TPC when doing tracking in the ITS (ITS only) 4) V0 reconstruction with a helix minimisation of the DCA. (new macros: AliV0FindVertices.C and AliV0Comparison.C) 4a) ( Consequence of the 4) )  All the efficiencies and resolutions are from now on calculated including *secondary*particles* too. (Don't be surprised by the drop in efficiency etc)
 
@@ -59,19 +75,19 @@ Splitted from AliTPCtracking
 //
 //   Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch 
 //-------------------------------------------------------
-
 #include <TObjArray.h>
 #include <TFile.h>
 #include <TTree.h>
-#include <iostream.h>
+#include <Riostream.h>
 
 #include "AliTPCtracker.h"
 #include "AliTPCcluster.h"
 #include "AliTPCParam.h"
-#include "AliTPCClustersRow.h"
+#include "AliClusters.h"
 
+#include <stdlib.h>
 //_____________________________________________________________________________
-AliTPCtracker::AliTPCtracker(const AliTPCParam *par, Int_t eventn): 
+AliTPCtracker::AliTPCtracker(const AliTPCParam *par): 
 AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
 {
   //---------------------------------------------------------------------
@@ -84,22 +100,6 @@ AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
   for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
   for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
 
-  fN=0;  fSectors=0;
-
-  fClustersArray.Setup(par);
-  fClustersArray.SetClusterType("AliTPCcluster");
-
-  char   cname[100];
-  if (eventn==-1) {
-    sprintf(cname,"TreeC_TPC");
-  }
-  else {
-    sprintf(cname,"TreeC_TPC_%d",eventn);
-  }
-
-  fClustersArray.ConnectTree(cname);
-
-  fEventN = eventn;
   fSeeds=0;
 }
 
@@ -209,91 +209,89 @@ Double_t f3(Double_t x1,Double_t y1,
 }
 
 //_____________________________________________________________________________
-void AliTPCtracker::LoadOuterSectors() {
+void AliTPCtracker::LoadClusters() {
   //-----------------------------------------------------------------
-  // This function fills outer TPC sectors with clusters.
+  // This function loads TPC clusters.
   //-----------------------------------------------------------------
-  UInt_t index;
-  Int_t j=Int_t(fClustersArray.GetTree()->GetEntries());
-  for (Int_t i=0; i<j; i++) {
-      AliSegmentID *s=fClustersArray.LoadEntry(i);
-      Int_t sec,row;
-      AliTPCParam *par=(AliTPCParam*)fClustersArray.GetParam();
-      par->AdjustSectorRow(s->GetID(),sec,row);
-      if (sec<fkNIS*2) continue;
-      AliTPCClustersRow *clrow=fClustersArray.GetRow(sec,row);
-      Int_t ncl=clrow->GetArray()->GetEntriesFast();
-      while (ncl--) {
-         AliTPCcluster *c=(AliTPCcluster*)(*clrow)[ncl];
-         index=(((sec<<8)+row)<<16)+ncl;
-         fOuterSec[(sec-fkNIS*2)%fkNOS][row].InsertCluster(c,index);
-      }
+  if (!gFile->IsOpen()) {
+    cerr<<"AliTPCtracker::LoadClusters : "<<
+      "file with clusters has not been open !\n";
+    return;
   }
 
-  fN=fkNOS;
-  fSectors=fOuterSec;
-}
-
-//_____________________________________________________________________________
-void AliTPCtracker::UnloadOuterSectors() {
-  //-----------------------------------------------------------------
-  // This function clears outer TPC sectors.
-  //-----------------------------------------------------------------
-  Int_t nup=fOuterSec->GetNRows();
-  for (Int_t i=0; i<fkNOS; i++) {
-    for (Int_t j=0; j<nup; j++) {
-      if (fClustersArray.GetRow(i+fkNIS*2,j)) 
-          fClustersArray.ClearRow(i+fkNIS*2,j);
-      if (fClustersArray.GetRow(i+fkNIS*2+fkNOS,j)) 
-          fClustersArray.ClearRow(i+fkNIS*2+fkNOS,j);
-    }
+  Char_t name[100];
+  sprintf(name,"TreeC_TPC_%d",GetEventNumber());
+  TTree *cTree=(TTree*)gFile->Get(name);
+  if (!cTree) {
+    cerr<<"AliTPCtracker::LoadClusters : "<<
+      "can't get the tree with TPC clusters !\n";
+    return;
   }
 
-  fN=0;
-  fSectors=0;
-}
-
-//_____________________________________________________________________________
-void AliTPCtracker::LoadInnerSectors() {
-  //-----------------------------------------------------------------
-  // This function fills inner TPC sectors with clusters.
-  //-----------------------------------------------------------------
-  UInt_t index;
-  Int_t j=Int_t(fClustersArray.GetTree()->GetEntries());
-  for (Int_t i=0; i<j; i++) {
-      AliSegmentID *s=fClustersArray.LoadEntry(i);
-      Int_t sec,row;
-      AliTPCParam *par=(AliTPCParam*)fClustersArray.GetParam();
-      par->AdjustSectorRow(s->GetID(),sec,row);
-      if (sec>=fkNIS*2) continue;
-      AliTPCClustersRow *clrow=fClustersArray.GetRow(sec,row);
-      Int_t ncl=clrow->GetArray()->GetEntriesFast();
-      while (ncl--) {
-         AliTPCcluster *c=(AliTPCcluster*)(*clrow)[ncl];
-         index=(((sec<<8)+row)<<16)+ncl;
-         fInnerSec[sec%fkNIS][row].InsertCluster(c,index);
-      }
+  TBranch *branch=cTree->GetBranch("Segment");
+  if (!branch) {
+    cerr<<"AliTPCtracker::LoadClusters : "<<
+      "can't get the segment branch !\n";
+    return;
   }
+  AliClusters carray, *addr=&carray; carray.SetClass("AliTPCcluster");
+  branch->SetAddress(&addr);
+
+  Int_t nentr=(Int_t)cTree->GetEntries();
+
+  for (Int_t i=0; i<nentr; i++) {
+      cTree->GetEvent(i);
+
+      Int_t ncl=carray.GetArray()->GetEntriesFast();
+
+      Int_t nir=fInnerSec->GetNRows(), nor=fOuterSec->GetNRows();
+      Int_t id=carray.GetID();
+      if ((id<0) || (id>2*(fkNIS*nir + fkNOS*nor))) {
+         cerr<<"AliTPCtracker::LoadClusters : "<<
+              "wrong index !\n";
+         exit(1);
+      }        
+      Int_t outindex = 2*fkNIS*nir;
+      if (id<outindex) {
+         Int_t sec = id/nir;
+         Int_t row = id - sec*nir;
+         sec %= fkNIS;
+         AliTPCRow &padrow=fInnerSec[sec][row];
+         while (ncl--) {
+           AliTPCcluster *c=(AliTPCcluster*)carray[ncl];
+           padrow.InsertCluster(c,sec,row);
+         }           
+      } else {
+         id -= outindex;
+         Int_t sec = id/nor;
+         Int_t row = id - sec*nor;
+         sec %= fkNOS;
+         AliTPCRow &padrow=fOuterSec[sec][row];
+         while (ncl--) {
+           AliTPCcluster *c=(AliTPCcluster*)carray[ncl];
+           padrow.InsertCluster(c,sec+fkNIS,row);
+         }
+      }
 
-  fN=fkNIS;
-  fSectors=fInnerSec;
+      carray.GetArray()->Clear();
+  }
+  delete cTree;
 }
 
 //_____________________________________________________________________________
-void AliTPCtracker::UnloadInnerSectors() {
+void AliTPCtracker::UnloadClusters() {
   //-----------------------------------------------------------------
-  // This function clears inner TPC sectors.
+  // This function unloads TPC clusters.
   //-----------------------------------------------------------------
-  Int_t nlow=fInnerSec->GetNRows();
-  for (Int_t i=0; i<fkNIS; i++) {
-    for (Int_t j=0; j<nlow; j++) {
-      if (fClustersArray.GetRow(i,j)) fClustersArray.ClearRow(i,j);
-      if (fClustersArray.GetRow(i+fkNIS,j)) fClustersArray.ClearRow(i+fkNIS,j);
-    }
+  Int_t i;
+  for (i=0; i<fkNIS; i++) {
+    Int_t nr=fInnerSec->GetNRows();
+    for (Int_t n=0; n<nr; n++) fInnerSec[i][n].ResetClusters();
+  }
+  for (i=0; i<fkNOS; i++) {
+    Int_t nr=fOuterSec->GetNRows();
+    for (Int_t n=0; n<nr; n++) fOuterSec[i][n].ResetClusters();
   }
-
-  fN=0;
-  fSectors=0;
 }
 
 //_____________________________________________________________________________
@@ -311,7 +309,8 @@ Int_t AliTPCtracker::FollowProlongation(AliTPCseed& t, Int_t rf) {
   if (alpha < 0.            ) alpha += 2.*TMath::Pi();  
   Int_t s=Int_t(alpha/fSectors->GetAlpha())%fN;
 
-  for (Int_t nr=fSectors->GetRowNumber(xt)-1; nr>=rf; nr--) {
+  Int_t nrows=fSectors->GetRowNumber(xt)-1;
+  for (Int_t nr=nrows; nr>=rf; nr--) {
     Double_t x=fSectors->GetX(nr), ymax=fSectors->GetMaxY(nr);
     if (!t.PropagateTo(x)) return 0;
 
@@ -346,7 +345,8 @@ Int_t AliTPCtracker::FollowProlongation(AliTPCseed& t, Int_t rf) {
     }
     if (cl) {
       Float_t l=fSectors->GetPadPitchWidth();
-      t.SetSampledEdx(cl->GetQ()/l,t.GetNumberOfClusters());
+      Float_t corr=1.; if (nr>63) corr=0.67; // new (third) pad response !
+      t.SetSampledEdx(cl->GetQ()/l*corr,t.GetNumberOfClusters());
       if (!t.Update(cl,maxchi2,index)) {
          if (!tryAgain--) return 0;
       } else tryAgain=kSKIP;
@@ -383,8 +383,8 @@ Int_t AliTPCtracker::FollowBackProlongation
      idx=track.GetClusterIndex(nc);
      sec=(idx&0xff000000)>>24; row=(idx&0x00ff0000)>>16;
   }
-  if (fSectors==fInnerSec) { if (sec >= 2*fkNIS) row=-1; } 
-  else { if (sec <  2*fkNIS) row=-1; }   
+  if (fSectors==fInnerSec) { if (sec >= fkNIS) row=-1; } 
+  else { if (sec <  fkNIS) row=-1; }   
 
   Int_t nr=fSectors->GetNRows();
   for (Int_t i=0; i<nr; i++) {
@@ -428,8 +428,8 @@ Int_t AliTPCtracker::FollowBackProlongation
           idx=track.GetClusterIndex(nc); 
           sec=(idx&0xff000000)>>24; row=(idx&0x00ff0000)>>16;
        } 
-       if (fSectors==fInnerSec) { if (sec >= 2*fkNIS) row=-1; }
-       else { if (sec <  2*fkNIS) row=-1; }   
+       if (fSectors==fInnerSec) { if (sec >= fkNIS) row=-1; }
+       else { if (sec < fkNIS) row=-1; }   
 
     }
     if (!cl) {
@@ -453,7 +453,8 @@ Int_t AliTPCtracker::FollowBackProlongation
 
     if (cl) {
       Float_t l=fSectors->GetPadPitchWidth();
-      seed.SetSampledEdx(cl->GetQ()/l,seed.GetNumberOfClusters());
+      Float_t corr=1.; if (i>63) corr=0.67; // new (third) pad response !
+      seed.SetSampledEdx(cl->GetQ()/l*corr,seed.GetNumberOfClusters());
       seed.Update(cl,maxchi2,index);
     }
 
@@ -469,21 +470,19 @@ void AliTPCtracker::MakeSeeds(Int_t i1, Int_t i2) {
   //-----------------------------------------------------------------
   // This function creates track seeds.
   //-----------------------------------------------------------------
-  if (fSeeds==0) fSeeds=new TObjArray(15000);
-
   Double_t x[5], c[15];
 
-  Double_t alpha=fOuterSec->GetAlpha(), shift=fOuterSec->GetAlphaShift();
+  Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
   Double_t cs=cos(alpha), sn=sin(alpha);
 
-  Double_t x1 =fOuterSec->GetX(i1);
-  Double_t xx2=fOuterSec->GetX(i2);
+  Double_t x1 =fSectors->GetX(i1);
+  Double_t xx2=fSectors->GetX(i2);
 
-  for (Int_t ns=0; ns<fkNOS; ns++) {
-    Int_t nl=fOuterSec[(ns-1+fkNOS)%fkNOS][i2];
-    Int_t nm=fOuterSec[ns][i2];
-    Int_t nu=fOuterSec[(ns+1)%fkNOS][i2];
-    const AliTPCRow& kr1=fOuterSec[ns][i1];
+  for (Int_t ns=0; ns<fN; ns++) {
+    Int_t nl=fSectors[(ns-1+fN)%fN][i2];
+    Int_t nm=fSectors[ns][i2];
+    Int_t nu=fSectors[(ns+1)%fN][i2];
+    const AliTPCRow& kr1=fSectors[ns][i1];
     for (Int_t is=0; is < kr1; is++) {
       Double_t y1=kr1[is]->GetY(), z1=kr1[is]->GetZ();
       for (Int_t js=0; js < nl+nm+nu; js++) {
@@ -492,18 +491,18 @@ void AliTPCtracker::MakeSeeds(Int_t i1, Int_t i2) {
         Double_t x3=GetX(), y3=GetY(), z3=GetZ();
 
        if (js<nl) {
-         const AliTPCRow& kr2=fOuterSec[(ns-1+fkNOS)%fkNOS][i2];
+         const AliTPCRow& kr2=fSectors[(ns-1+fN)%fN][i2];
          kcl=kr2[js];
           y2=kcl->GetY(); z2=kcl->GetZ();
           x2= xx2*cs+y2*sn;
           y2=-xx2*sn+y2*cs;
        } else 
          if (js<nl+nm) {
-           const AliTPCRow& kr2=fOuterSec[ns][i2];
+           const AliTPCRow& kr2=fSectors[ns][i2];
            kcl=kr2[js-nl];
             x2=xx2; y2=kcl->GetY(); z2=kcl->GetZ();
          } else {
-           const AliTPCRow& kr2=fOuterSec[(ns+1)%fkNOS][i2];
+           const AliTPCRow& kr2=fSectors[(ns+1)%fN][i2];
            kcl=kr2[js-nl-nm];
             y2=kcl->GetY(); z2=kcl->GetZ();
             x2=xx2*cs-y2*sn;
@@ -530,7 +529,8 @@ void AliTPCtracker::MakeSeeds(Int_t i1, Int_t i2) {
 
         Double_t sy1=kr1[is]->GetSigmaY2(), sz1=kr1[is]->GetSigmaZ2();
         Double_t sy2=kcl->GetSigmaY2(),     sz2=kcl->GetSigmaZ2();
-       Double_t sy3=400*3./12., sy=0.1, sz=0.1;
+       //Double_t sy3=400*3./12., sy=0.1, sz=0.1;
+        Double_t sy3=25000*x[4]*x[4]+0.1, sy=0.1, sz=0.1;
 
        Double_t f40=(f1(x1,y1+sy,x2,y2,x3,y3)-x[4])/sy;
        Double_t f42=(f1(x1,y1,x2,y2+sy,x3,y3)-x[4])/sy;
@@ -554,7 +554,7 @@ void AliTPCtracker::MakeSeeds(Int_t i1, Int_t i2) {
 
         UInt_t index=kr1.GetIndex(is);
        AliTPCseed *track=new AliTPCseed(index, x, c, x1, ns*alpha+shift);
-        Float_t l=fOuterSec->GetPadPitchWidth();
+        Float_t l=fSectors->GetPadPitchWidth();
         track->SetSampledEdx(kr1[is]->GetQ()/l,0);
 
         Int_t rc=FollowProlongation(*track, i2);
@@ -625,53 +625,49 @@ Int_t AliTPCtracker::Clusters2Tracks(const TFile *inp, TFile *out) {
      return 2;
   }
 
+  LoadClusters();
+
   out->cd();
 
   char   tname[100];
-  sprintf(tname,"TreeT_TPC_%d",fEventN);
+  sprintf(tname,"TreeT_TPC_%d",GetEventNumber());
   TTree tracktree(tname,"Tree with TPC tracks");
   AliTPCtrack *iotrack=0;
   tracktree.Branch("tracks","AliTPCtrack",&iotrack,32000,0);
 
-  LoadOuterSectors();
-
   //find track seeds
   Int_t nup=fOuterSec->GetNRows(), nlow=fInnerSec->GetNRows();
   Int_t nrows=nlow+nup;
   if (fSeeds==0) {
      Int_t gap=Int_t(0.125*nrows), shift=Int_t(0.5*gap);
+     fSectors=fOuterSec; fN=fkNOS;
+     fSeeds=new TObjArray(15000);     
      MakeSeeds(nup-1, nup-1-gap);
      MakeSeeds(nup-1-shift, nup-1-shift-gap);
-  }    
+  }
   fSeeds->Sort();
 
-  //tracking in outer sectors
+  Int_t found=0;
   Int_t nseed=fSeeds->GetEntriesFast();
-  Int_t i;
-  for (i=0; i<nseed; i++) {
+  for (Int_t i=0; i<nseed; i++) {
+    //tracking in the outer sectors
+    fSectors=fOuterSec; fN=fkNOS;
+
     AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
-    if (FollowProlongation(t)) {
-       UseClusters(&t);
+    if (!FollowProlongation(t)) {
+       delete fSeeds->RemoveAt(i);
        continue;
     }
-    delete fSeeds->RemoveAt(i);
-  }  
-  //UnloadOuterSectors();
 
-  //tracking in inner sectors
-  LoadInnerSectors();
-  Int_t found=0;
-  for (i=0; i<nseed; i++) {
-    AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;
-    if (!pt) continue;
-    Int_t nc=t.GetNumberOfClusters();
+    //tracking in the inner sectors
+    fSectors=fInnerSec; fN=fkNIS;
 
     Double_t alpha=t.GetAlpha() - fInnerSec->GetAlphaShift();
     if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
     if (alpha < 0.            ) alpha += 2.*TMath::Pi();
     Int_t ns=Int_t(alpha/fInnerSec->GetAlpha())%fkNIS;
 
-    alpha=ns*fInnerSec->GetAlpha() + fInnerSec->GetAlphaShift() - t.GetAlpha();
+    alpha=ns*fInnerSec->GetAlpha()+fInnerSec->GetAlphaShift()-t.GetAlpha();
 
     if (t.Rotate(alpha)) {
        if (FollowProlongation(t)) {
@@ -680,15 +676,13 @@ Int_t AliTPCtracker::Clusters2Tracks(const TFile *inp, TFile *out) {
              CookLabel(pt,0.1); //For comparison only
              iotrack=pt;
              tracktree.Fill();
-             UseClusters(&t,nc);
+             UseClusters(&t);
              cerr<<found++<<'\r';
           }
        }
     }
     delete fSeeds->RemoveAt(i); 
-  }  
-  UnloadInnerSectors();
-  UnloadOuterSectors();
+  }
 
   tracktree.Write();
 
@@ -696,6 +690,9 @@ Int_t AliTPCtracker::Clusters2Tracks(const TFile *inp, TFile *out) {
 
   savedir->cd();
 
+  UnloadClusters();
+  fSeeds->Clear(); delete fSeeds; fSeeds=0;
+
   return 0;
 }
 
@@ -721,6 +718,8 @@ Int_t AliTPCtracker::PropagateBack(const TFile *inp, TFile *out) {
      return 2;
   }
 
+  LoadClusters();
+
   in->cd();
   TTree *bckTree=(TTree*)in->Get("TreeT_ITSb_0");
   if (!bckTree) {
@@ -770,7 +769,7 @@ Int_t AliTPCtracker::PropagateBack(const TFile *inp, TFile *out) {
   backTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);
 
 //*** Back propagation through inner sectors
-  LoadInnerSectors();
+  fSectors=fInnerSec; fN=fkNIS;
   Int_t nseed=fSeeds->GetEntriesFast();
   for (i=0; i<nseed; i++) {
      AliTPCseed *ps=(AliTPCseed*)fSeeds->UncheckedAt(i), &s=*ps;
@@ -785,10 +784,9 @@ Int_t AliTPCtracker::PropagateBack(const TFile *inp, TFile *out) {
      }
      delete fSeeds->RemoveAt(i);
   }  
-  UnloadInnerSectors();
 
 //*** Back propagation through outer sectors
-  LoadOuterSectors();
+  fSectors=fOuterSec; fN=fkNOS;
   Int_t found=0;
   for (i=0; i<nseed; i++) {
      AliTPCseed *ps=(AliTPCseed*)fSeeds->UncheckedAt(i), &s=*ps;
@@ -819,7 +817,6 @@ Int_t AliTPCtracker::PropagateBack(const TFile *inp, TFile *out) {
      }
      delete fSeeds->RemoveAt(i);
   }  
-  UnloadOuterSectors();
 
   backTree.Write();
   savedir->cd();
@@ -833,6 +830,8 @@ Int_t AliTPCtracker::PropagateBack(const TFile *inp, TFile *out) {
   delete bckTree; //Thanks to Mariana Bondila
   delete tpcTree; //Thanks to Mariana Bondila
 
+  UnloadClusters();  
+
   return 0;
 }
 
@@ -845,8 +844,16 @@ AliCluster *AliTPCtracker::GetCluster(Int_t index) const {
   Int_t row=(index&0x00ff0000)>>16; 
   Int_t ncl=(index&0x0000ffff)>>00;
 
-  AliTPCClustersRow *clrow=((AliTPCtracker *) this)->fClustersArray.GetRow(sec,row);
-  return (AliCluster*)(*clrow)[ncl];      
+  const AliTPCcluster *cl=0;
+
+  if (sec<fkNIS) {
+    cl=fInnerSec[sec][row].GetUnsortedCluster(ncl); 
+  } else {
+    sec-=fkNIS;
+    cl=fOuterSec[sec][row].GetUnsortedCluster(ncl);
+  }
+
+  return (AliCluster*)cl;      
 }
 
 //__________________________________________________________________________
@@ -915,7 +922,8 @@ void AliTPCtracker::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
      fAlpha=par->GetInnerAngle();
      fAlphaShift=par->GetInnerAngleShift();
      fPadPitchWidth=par->GetInnerPadPitchWidth();
-     fPadPitchLength=par->GetInnerPadPitchLength();
+     f1PadPitchLength=par->GetInnerPadPitchLength();
+     f2PadPitchLength=f1PadPitchLength;
 
      fN=par->GetNRowLow();
      fRow=new AliTPCRow[fN];
@@ -924,28 +932,51 @@ void AliTPCtracker::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
      fAlpha=par->GetOuterAngle();
      fAlphaShift=par->GetOuterAngleShift();
      fPadPitchWidth=par->GetOuterPadPitchWidth();
-     fPadPitchLength=par->GetOuterPadPitchLength();
+     f1PadPitchLength=par->GetOuter1PadPitchLength();
+     f2PadPitchLength=par->GetOuter2PadPitchLength();
 
      fN=par->GetNRowUp();
      fRow=new AliTPCRow[fN];
-     for (Int_t i=0; i<fN; i++) fRow[i].SetX(par->GetPadRowRadiiUp(i));
+     for (Int_t i=0; i<fN; i++){ 
+     fRow[i].SetX(par->GetPadRowRadiiUp(i));
+     }
   } 
 }
 
 //_________________________________________________________________________
-void 
-AliTPCtracker::AliTPCRow::InsertCluster(const AliTPCcluster* c, UInt_t index) {
+void AliTPCtracker::
+AliTPCRow::InsertCluster(const AliTPCcluster* c, Int_t sec, Int_t row) {
   //-----------------------------------------------------------------------
   // Insert a cluster into this pad row in accordence with its y-coordinate
   //-----------------------------------------------------------------------
   if (fN==kMaxClusterPerRow) {
     cerr<<"AliTPCRow::InsertCluster(): Too many clusters !\n"; return;
   }
-  if (fN==0) {fIndex[0]=index; fClusters[fN++]=c; return;}
+
+  Int_t index=(((sec<<8)+row)<<16)+fN;
+
+  if (fN==0) {
+     fIndex[0]=index;
+     fClusterArray[0]=*c; fClusters[fN++]=fClusterArray; 
+     return;
+  }
+
+  if (fN==fSize) {
+     Int_t size=fSize*2;
+     AliTPCcluster *buff=new AliTPCcluster[size];
+     memcpy(buff,fClusterArray,fSize*sizeof(AliTPCcluster));
+     for (Int_t i=0; i<fN; i++) 
+        fClusters[i]=buff+(fClusters[i]-fClusterArray);
+     delete[] fClusterArray;
+     fClusterArray=buff;
+     fSize=size;
+  }
+
   Int_t i=Find(c->GetY());
   memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCcluster*));
   memmove(fIndex   +i+1 ,fIndex   +i,(fN-i)*sizeof(UInt_t));
-  fIndex[i]=index; fClusters[i]=c; fN++;
+  fIndex[i]=index; 
+  fClusters[i]=fClusterArray+fN; fClusterArray[fN++]=*c;
 }
 
 //___________________________________________________________________
@@ -953,6 +984,7 @@ Int_t AliTPCtracker::AliTPCRow::Find(Double_t y) const {
   //-----------------------------------------------------------------------
   // Return the index of the nearest cluster 
   //-----------------------------------------------------------------------
+  if(fN<=0) return 0;
   if (y <= fClusters[0]->GetY()) return 0;
   if (y > fClusters[fN-1]->GetY()) return fN;
   Int_t b=0, e=fN-1, m=(b+e)/2;
@@ -991,14 +1023,15 @@ void AliTPCtracker::AliTPCseed::CookdEdx(Double_t low, Double_t up) {
   //Very rough PID
   Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
 
+  Double_t log1=TMath::Log(p+0.45), log2=TMath::Log(p+0.12);
   if (p<0.6) {
-    if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
-    if (dedx < 39.+ 12./p/p) { SetMass(0.49368); return;}
+    if (dedx < 34 + 30/(p+0.45)/(p+0.45) + 24*log1) {SetMass(0.13957); return;}
+    if (dedx < 34 + 30/(p+0.12)/(p+0.12) + 24*log2) {SetMass(0.49368); return;}
     SetMass(0.93827); return;
   }
 
   if (p<1.2) {
-    if (dedx < 39.+ 12./(p+0.25)/(p+0.25)) { SetMass(0.13957); return;}
+    if (dedx < 34 + 30/(p+0.12)/(p+0.12) + 24*log2) {SetMass(0.13957); return;}
     SetMass(0.93827); return;
   }