]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCtrackerMI.cxx
Adding debug stream for first track reconstrunction (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCtrackerMI.cxx
index 6c281a2c49a47ef560f5bbb1eba8219990b8f3d5..d09514a8baa919eec0def51debc4263c0d9fd550 100644 (file)
 //
 //   Origin: Marian Ivanov   Marian.Ivanov@cern.ch
 // 
-//  AliTPC parallel tracker - 
-//  How to use?  - 
-//  run AliTPCFindClusters.C macro - clusters neccessary for tracker are founded
-//  run AliTPCFindTracksMI.C macro - to find tracks
-//  tracks are written to AliTPCtracks.root file
-//  for comparison also seeds are written to the same file - to special branch
+//  AliTPC parallel tracker
+//
+//  The track fitting is based on Kalaman filtering approach
+
+//  The track finding steps:
+//      1. Seeding - with and without vertex constraint
+//                 - seeding with vertex constain done at first n^2 proble
+//                 - seeding without vertex constraint n^3 problem
+//      2. Tracking - follow prolongation road - find cluster - update kalman track
+
+//  The seeding and tracking is repeated several times, in different seeding region.
+//  This approach enables to find the track which cannot be seeded in some region of TPC
+//  This can happen because of low momenta (track do not reach outer radius), or track is currently in the ded region between sectors, or the track is for the moment overlapped with other track (seed quality is poor) ...
+
+//  With this approach we reach almost 100 % efficiency also for high occupancy events.
+//  (If the seeding efficiency in a region is about 90 % than with logical or of several 
+//  regions we will reach 100% (in theory - supposing independence) 
+
+//  Repeating several seeding - tracking procedures some of the tracks can be find 
+//  several times. 
+
+//  The procedures to remove multi find tacks are impremented:
+//  RemoveUsed2 - fast procedure n problem - 
+//                 Algorithm - Sorting tracks according quality
+//                             remove tracks with some shared fraction 
+//                             Sharing in respect to all tacks 
+//                             Signing clusters in gold region
+//  FindSplitted - slower algorithm n^2
+//                 Sort the tracks according quality
+//                 Loop over pair of tracks
+//                 If overlap with other track bigger than threshold - remove track
+//  
+//  FindCurling  - Finds the pair of tracks which are curling
+//               - About 10% of tracks can be find with this procedure
+//                 The combinatorial background is too big to be used in High 
+//                  multiplicity environment 
+//               - n^2 problem - Slow procedure - currently it is disabled because of 
+//                  low efficiency
+//                 
+//  The number of splitted tracks can be reduced disabling the sharing of the cluster.
+//  tpcRecoParam-> SetClusterSharing(kFALSE);
+//  IT IS HIGHLY non recomended to use it in high flux enviroonment
+//  Even using this switch some tracks can be found more than once 
+//  (because of multiple seeding and low quality tracks which will not cross full chamber)
+//                          
+//
+// The tracker itself can be debugged  - the information about tracks can be stored in several // phases of the reconstruction
+// To enable storage of the TPC tracks in the ESD friend track
+// use AliTPCReconstructor::SetStreamLevel(n); where nis bigger 0
+//
+// The debug level -  different procedure produce tree for numerical debugging
+//                    To enable them set AliTPCReconstructor::SetStreamLevel(n); where nis bigger 1
+//
+
+//
+// Adding systematic errors to the covariance:
+// 
+// The systematic errors due to the misalignment and miscalibration are added to the covariance matrix
+// of the tracks (not to the clusters as they are dependent):
+// The parameters form AliTPCRecoParam are used AliTPCRecoParam::GetSystematicError
+// The systematic errors are expressed there in RMS - position (cm), angle (rad), curvature (1/cm)
+// The default values are 0. 
+//
+// The sytematic errors are added to the covariance matrix in following places:
+//
+// 1. During fisrt itteration - AliTPCtrackerMI::FillESD
+// 2. Second iteration - 
+//      2.a ITS->TPC   - AliTPCtrackerMI::ReadSeeds 
+//      2.b TPC->TRD   - AliTPCtrackerMI::PropagateBack
+// 3. Third iteration  -
+//      3.a TRD->TPC   - AliTPCtrackerMI::ReadSeeds
+//      3.b TPC->ITS   - AliTPCtrackerMI::RefitInward
+//
+// There are several places in the code which can be numerically debuged
+// This code is keeped in order to enable code development and to check the calibration implementtion
+//
+//      1. ErrParam stream (Log level 9) - dump information about 
+//         1.a) cluster
+//         2.a) cluster error estimate
+//         3.a) cluster shape estimate
+//
+//
 //-------------------------------------------------------
 
 
 #include <TFile.h>
 #include <TObjArray.h>
 #include <TTree.h>
-
+#include "AliLog.h"
 #include "AliComplexCluster.h"
-#include "AliESD.h"
-#include "AliESDkink.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliESDVertex.h"
+#include "AliKink.h"
+#include "AliV0.h"
 #include "AliHelix.h"
 #include "AliRunLoader.h"
 #include "AliTPCClustersRow.h"
 #include "AliTPCParam.h"
 #include "AliTPCReconstructor.h"
-#include "AliTPCclusterMI.h"
 #include "AliTPCpolyTrack.h"
 #include "AliTPCreco.h"
-#include "AliTPCseed.h" 
+#include "AliTPCseed.h"
+
+#include "AliTPCtrackerSector.h" 
 #include "AliTPCtrackerMI.h"
 #include "TStopwatch.h"
 #include "AliTPCReconstructor.h"
-#include "AliESDkink.h"
 #include "AliPID.h"
 #include "TTreeStream.h"
+#include "AliAlignObj.h"
+#include "AliTrackPointArray.h"
+#include "TRandom.h"
+#include "AliTPCcalibDB.h"
+#include "AliTPCTransform.h"
+#include "AliTPCClusterParam.h"
+
 //
 
 ClassImp(AliTPCtrackerMI)
 
 
+
 class AliTPCFastMath {
 public:
   AliTPCFastMath();  
@@ -90,7 +177,33 @@ Double_t AliTPCFastMath::FastAsin(Double_t x){
   Int_t index = int(x*10000);
   return -(fgFastAsin[2*index]+(x*10000.-index)*fgFastAsin[2*index+1]);
 }
-
+//__________________________________________________________________
+AliTPCtrackerMI::AliTPCtrackerMI()
+                :AliTracker(),
+                fkNIS(0),
+                fInnerSec(0),
+                fkNOS(0),
+                fOuterSec(0),
+                fN(0),
+                fSectors(0),
+                fInput(0),
+                fOutput(0),
+                fSeedTree(0),
+                fTreeDebug(0),
+                fEvent(0),
+                fDebug(0),
+                fNewIO(kFALSE),
+                fNtracks(0),
+                fSeeds(0),
+                fIteration(0),
+                fParam(0),
+                fDebugStreamer(0)
+{
+  //
+  // default constructor
+  //
+}
+//_____________________________________________________________________
 
 
 
@@ -99,63 +212,63 @@ Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
   //update track information using current cluster - track->fCurrentCluster
 
 
-  AliTPCclusterMI* c =track->fCurrentCluster;
-  if (accept>0) track->fCurrentClusterIndex1 |=0x8000;  //sign not accepted clusters
+  AliTPCclusterMI* c =track->GetCurrentCluster();
+  if (accept>0) track->SetCurrentClusterIndex1(track->GetCurrentClusterIndex1() | 0x8000);  //sign not accepted clusters
 
-  UInt_t i = track->fCurrentClusterIndex1;
+  UInt_t i = track->GetCurrentClusterIndex1();
 
   Int_t sec=(i&0xff000000)>>24; 
   //Int_t row = (i&0x00ff0000)>>16; 
-  track->fRow=(i&0x00ff0000)>>16;
-  track->fSector = sec;
+  track->SetRow((i&0x00ff0000)>>16);
+  track->SetSector(sec);
   //  Int_t index = i&0xFFFF;
-  if (sec>=fParam->GetNInnerSector()) track->fRow += fParam->GetNRowLow(); 
-  track->SetClusterIndex2(track->fRow, i);  
+  if (sec>=fParam->GetNInnerSector()) track->SetRow(track->GetRow()+fParam->GetNRowLow()); 
+  track->SetClusterIndex2(track->GetRow(), i);  
   //track->fFirstPoint = row;
   //if ( track->fLastPoint<row) track->fLastPoint =row;
   //  if (track->fRow<0 || track->fRow>160) {
   //  printf("problem\n");
   //}
-  if (track->fFirstPoint>track->fRow
-    track->fFirstPoint = track->fRow;
-  if (track->fLastPoint<track->fRow
-    track->fLastPoint  = track->fRow;
+  if (track->GetFirstPoint()>track->GetRow()
+    track->SetFirstPoint(track->GetRow());
+  if (track->GetLastPoint()<track->GetRow()
+    track->SetLastPoint(track->GetRow());
   
 
-  track->fClusterPointer[track->fRow] = c;  
+  track->SetClusterPointer(track->GetRow(),c);  
   //
 
-  Float_t angle2 = track->GetSnp()*track->GetSnp();
-  angle2 = TMath::Sqrt(angle2/(1-angle2)); 
+  Double_t angle2 = track->GetSnp()*track->GetSnp();
   //
   //SET NEW Track Point
   //
-  //  if (debug)
+  if (angle2<1) //PH sometimes angle2 is very big. To be investigated...
   {
-    AliTPCTrackerPoint   &point =*(track->GetTrackPoint(track->fRow));
+    angle2 = TMath::Sqrt(angle2/(1-angle2)); 
+    AliTPCTrackerPoint   &point =*(track->GetTrackPoint(track->GetRow()));
     //
-    point.SetSigmaY(c->GetSigmaY2()/track->fCurrentSigmaY2);
-    point.SetSigmaZ(c->GetSigmaZ2()/track->fCurrentSigmaZ2);
-    point.SetErrY(sqrt(track->fErrorY2));
-    point.SetErrZ(sqrt(track->fErrorZ2));
+    point.SetSigmaY(c->GetSigmaY2()/track->GetCurrentSigmaY2());
+    point.SetSigmaZ(c->GetSigmaZ2()/track->GetCurrentSigmaZ2());
+    point.SetErrY(sqrt(track->GetErrorY2()));
+    point.SetErrZ(sqrt(track->GetErrorZ2()));
     //
     point.SetX(track->GetX());
     point.SetY(track->GetY());
     point.SetZ(track->GetZ());
     point.SetAngleY(angle2);
     point.SetAngleZ(track->GetTgl());
-    if (point.fIsShared){
-      track->fErrorY2 *= 4;
-      track->fErrorZ2 *= 4;
+    if (point.IsShared()){
+      track->SetErrorY2(track->GetErrorY2()*4);
+      track->SetErrorZ2(track->GetErrorZ2()*4);
     }
   }  
 
-  Double_t chi2 = track->GetPredictedChi2(track->fCurrentCluster);
+  Double_t chi2 = track->GetPredictedChi2(track->GetCurrentCluster());
   //
-  track->fErrorY2 *= 1.3;
-  track->fErrorY2 += 0.01;    
-  track->fErrorZ2 *= 1.3;   
-  track->fErrorZ2 += 0.005;      
+//   track->SetErrorY2(track->GetErrorY2()*1.3);
+//   track->SetErrorY2(track->GetErrorY2()+0.01);    
+//   track->SetErrorZ2(track->GetErrorZ2()*1.3);   
+//   track->SetErrorZ2(track->GetErrorZ2()+0.005);      
     //}
   if (accept>0) return 0;
   if (track->GetNumberOfClusters()%20==0){
@@ -165,47 +278,74 @@ Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
     //  new(larr[ihelix]) AliHelix(*track) ;    
     //}
   }
-  track->fNoCluster =0;
+  track->SetNoCluster(0);
   return track->Update(c,chi2,i);
 }
 
 
 
-Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor, 
-                                      Float_t cory, Float_t corz)
+Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster)
 {
   //
   // decide according desired precision to accept given 
   // cluster for tracking
-  Double_t sy2=ErrY2(seed,cluster)*cory;
-  Double_t sz2=ErrZ2(seed,cluster)*corz;
-  //sy2=ErrY2(seed,cluster)*cory;
-  //sz2=ErrZ2(seed,cluster)*cory;
+  Double_t sy2=ErrY2(seed,cluster);
+  Double_t sz2=ErrZ2(seed,cluster);
   
   Double_t sdistancey2 = sy2+seed->GetSigmaY2();
   Double_t sdistancez2 = sz2+seed->GetSigmaZ2();
   
-  Double_t rdistancey2 = (seed->fCurrentCluster->GetY()-seed->GetY())*
-    (seed->fCurrentCluster->GetY()-seed->GetY())/sdistancey2;
-  Double_t rdistancez2 = (seed->fCurrentCluster->GetZ()-seed->GetZ())*
-    (seed->fCurrentCluster->GetZ()-seed->GetZ())/sdistancez2;
+  Double_t rdistancey2 = (seed->GetCurrentCluster()->GetY()-seed->GetY())*
+    (seed->GetCurrentCluster()->GetY()-seed->GetY())/sdistancey2;
+  Double_t rdistancez2 = (seed->GetCurrentCluster()->GetZ()-seed->GetZ())*
+    (seed->GetCurrentCluster()->GetZ()-seed->GetZ())/sdistancez2;
   
   Double_t rdistance2  = rdistancey2+rdistancez2;
   //Int_t  accept =0;
   
+  if (AliTPCReconstructor::StreamLevel()>5 && seed->GetNumberOfClusters()>20) {
+    Float_t rmsy2 = seed->GetCurrentSigmaY2();
+    Float_t rmsz2 = seed->GetCurrentSigmaZ2();
+    Float_t rmsy2p30 = seed->GetCMeanSigmaY2p30();
+    Float_t rmsz2p30 = seed->GetCMeanSigmaZ2p30();
+    Float_t rmsy2p30R  = seed->GetCMeanSigmaY2p30R();
+    Float_t rmsz2p30R  = seed->GetCMeanSigmaZ2p30R();
+
+    AliExternalTrackParam param(*seed); 
+    static TVectorD gcl(3),gtr(3);
+    Float_t gclf[3];
+    param.GetXYZ(gcl.GetMatrixArray());
+    cluster->GetGlobalXYZ(gclf);
+    gcl[0]=gclf[0];    gcl[1]=gclf[1];    gcl[2]=gclf[2];
+    (*fDebugStreamer)<<"ErrParam"<<
+      "Cl.="<<cluster<<
+      "T.="<<&param<<
+      "gcl.="<<&gcl<<
+      "gtr.="<<&gtr<<
+      "erry2="<<sy2<<
+      "errz2="<<sz2<<
+      "rmsy2="<<rmsy2<<
+      "rmsz2="<<rmsz2<<        
+      "rmsy2p30="<<rmsy2p30<<
+      "rmsz2p30="<<rmsz2p30<<  
+      "rmsy2p30R="<<rmsy2p30R<<
+      "rmsz2p30R="<<rmsz2p30R<<        
+      "\n";
+  }
+  
   if (rdistance2>16) return 3;
   
   
-  if ((rdistancey2>9.*factor || rdistancez2>9.*factor) && cluster->GetType()==0)  
+  if ((rdistancey2>9. || rdistancez2>9.) && cluster->GetType()==0)  
     return 2;  //suspisiouce - will be changed
   
-  if ((rdistancey2>6.25*factor || rdistancez2>6.25*factor) && cluster->GetType()>0)  
+  if ((rdistancey2>6.25 || rdistancez2>6.25) && cluster->GetType()>0)  
     // strict cut on overlaped cluster
     return  2;  //suspisiouce - will be changed
   
-  if ( (rdistancey2>1.*factor || rdistancez2>6.25*factor ) 
+  if ( (rdistancey2>1. || rdistancez2>6.25 ) 
        && cluster->GetType()<0){
-    seed->fNFoundable--;
+    seed->SetNFoundable(seed->GetNFoundable()-1);
     return 2;    
   }
   return 0;
@@ -216,22 +356,36 @@ Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluste
 
 //_____________________________________________________________________________
 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCParam *par): 
-AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
+AliTracker(), 
+                fkNIS(par->GetNInnerSector()/2),
+                fInnerSec(0),
+                fkNOS(par->GetNOuterSector()/2),
+                fOuterSec(0),
+                fN(0),
+                fSectors(0),
+                fInput(0),
+                fOutput(0),
+                fSeedTree(0),
+                fTreeDebug(0),
+                fEvent(0),
+                fDebug(0),
+                fNewIO(0),
+                fNtracks(0),
+                fSeeds(0),
+                fIteration(0),
+                fParam(0),
+                fDebugStreamer(0)
 {
   //---------------------------------------------------------------------
   // The main TPC tracker constructor
   //---------------------------------------------------------------------
-  fInnerSec=new AliTPCSector[fkNIS];         
-  fOuterSec=new AliTPCSector[fkNOS];
+  fInnerSec=new AliTPCtrackerSector[fkNIS];         
+  fOuterSec=new AliTPCtrackerSector[fkNOS];
  
   Int_t i;
   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;
-
-  fSeeds=0;
-  fNtracks = 0;
   fParam = par;  
   Int_t nrowlow = par->GetNRowLow();
   Int_t nrowup = par->GetNRowUp();
@@ -249,26 +403,35 @@ AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
     fPadLength[i+nrowlow] = par->GetPadPitchLength(60,i);
     fYMax[i+nrowlow]      = fXRow[i+nrowlow]*TMath::Tan(0.5*par->GetOuterAngle());
   }
-  fSeeds=0;
-  //
-  fInput    = 0;
-  fOutput   = 0;
-  fSeedTree = 0;
-  fTreeDebug =0;
-  fNewIO     =0;
-  fDebug     =0;
-  fEvent     =0;
+
   fDebugStreamer = new TTreeSRedirector("TPCdebug.root");
 }
 //________________________________________________________________________
 AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
   AliTracker(t),
-  fkNIS(t.fkNIS),
-  fkNOS(t.fkNOS)
+                fkNIS(t.fkNIS),
+                fInnerSec(0),
+                fkNOS(t.fkNOS),
+                fOuterSec(0),
+                fN(0),
+                fSectors(0),
+                fInput(0),
+                fOutput(0),
+                fSeedTree(0),
+                fTreeDebug(0),
+                fEvent(0),
+                fDebug(0),
+                fNewIO(kFALSE),
+                fNtracks(0),
+                fSeeds(0),
+                fIteration(0),
+                fParam(0),
+                fDebugStreamer(0)
 {
   //------------------------------------
   // dummy copy constructor
   //------------------------------------------------------------------
+  fOutput=t.fOutput;
 }
 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/){
   //------------------------------
@@ -290,68 +453,6 @@ AliTPCtrackerMI::~AliTPCtrackerMI() {
   if (fDebugStreamer) delete fDebugStreamer;
 }
 
-void AliTPCtrackerMI::SetIO()
-{
-  //
-  fNewIO   =  kTRUE;
-  fInput   =  AliRunLoader::GetTreeR("TPC", kFALSE,AliConfig::GetDefaultEventFolderName());
-  
-  fOutput  =  AliRunLoader::GetTreeT("TPC", kTRUE,AliConfig::GetDefaultEventFolderName());
-  if (fOutput){
-    AliTPCtrack *iotrack= new AliTPCtrack;
-    fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
-    delete iotrack;
-  }
-}
-
-
-void AliTPCtrackerMI::SetIO(TTree * input, TTree * output, AliESD * event)
-{
-
-  // set input
-  fNewIO = kFALSE;
-  fInput    = 0;
-  fOutput   = 0;
-  fSeedTree = 0;
-  fTreeDebug =0;
-  fInput = input;
-  if (input==0){
-    return;
-  }  
-  //set output
-  fOutput = output;
-  if (output){
-    AliTPCtrack *iotrack= new AliTPCtrack;
-    //    iotrack->fHelixIn   = new TClonesArray("AliHelix");
-    //iotrack->fHelixOut  = new TClonesArray("AliHelix");    
-    fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
-    delete iotrack;
-  }
-  if (output && (fDebug&2)){
-    //write the full seed information if specified in debug mode
-    //
-    fSeedTree =  new TTree("Seeds","Seeds");
-    AliTPCseed * vseed = new AliTPCseed;
-    //
-    TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
-    arrtr->ExpandCreateFast(160);
-    TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
-    //
-    vseed->fPoints = arrtr;
-    vseed->fEPoints = arre;
-    //    vseed->fClusterPoints = arrcl;
-    fSeedTree->Branch("seeds","AliTPCseed",&vseed,32000,99);
-    delete arrtr;
-    delete arre;    
-    fTreeDebug = new TTree("trackDebug","trackDebug");
-    TClonesArray * arrd = new TClonesArray("AliTPCTrackPoint2",0);
-    fTreeDebug->Branch("debug",&arrd,32000,99);
-  }
-
-
-  //set ESD event  
-  fEvent  = event;  
-}
 
 void AliTPCtrackerMI::FillESD(TObjArray* arr)
 {
@@ -367,6 +468,12 @@ void AliTPCtrackerMI::FillESD(TObjArray* arr)
       AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
       if (!pt) continue; 
       pt->UpdatePoints();
+      AddCovariance(pt);
+      if (AliTPCReconstructor::StreamLevel()>1) {
+       (*fDebugStreamer)<<"Track0"<<
+         "Tr0.="<<pt<<
+         "\n";       
+      }
       //      pt->PropagateTo(fParam->GetInnerRadiusLow());
       if (pt->GetKinkIndex(0)<=0){  //don't propagate daughter tracks 
        pt->PropagateTo(fParam->GetInnerRadiusLow());
@@ -384,7 +491,7 @@ void AliTPCtrackerMI::FillESD(TObjArray* arr)
        continue;
       }
        
-      if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.55) {
+      if ( (pt->GetNumberOfClusters()>70)&& (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.55) {
        AliESDtrack iotrack;
        iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);
        iotrack.SetTPCPoints(pt->GetPoints());
@@ -398,10 +505,10 @@ void AliTPCtrackerMI::FillESD(TObjArray* arr)
       //
       // short tracks  - maybe decays
 
-      if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.70) {
+      if ( (pt->GetNumberOfClusters()>30) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.70) {
        Int_t found,foundable,shared;
        pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
-       if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2)){
+       if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2)){
          AliESDtrack iotrack;
          iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);    
          //iotrack.SetTPCindex(i);
@@ -414,11 +521,11 @@ void AliTPCtrackerMI::FillESD(TObjArray* arr)
        }
       }       
       
-      if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->fNFoundable))>0.8) {
+      if ( (pt->GetNumberOfClusters()>20) && (Float_t(pt->GetNumberOfClusters())/Float_t(pt->GetNFoundable()))>0.8) {
        Int_t found,foundable,shared;
        pt->GetClusterStatistic(0,60,found, foundable,shared,kFALSE);
        if (found<20) continue;
-       if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
+       if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
        //
        AliESDtrack iotrack;
        iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);      
@@ -435,7 +542,7 @@ void AliTPCtrackerMI::FillESD(TObjArray* arr)
       if ( (pt->GetNumberOfClusters()>30) ) {
        Int_t found,foundable,shared;
        pt->GetClusterStatistic(128,158,found, foundable,shared,kFALSE);
-       if ( (found>20) && (pt->fNShared/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
+       if ( (found>20) && (pt->GetNShared()/float(pt->GetNumberOfClusters())<0.2) &&float(found)/float(foundable)>0.8){
          AliESDtrack iotrack;
          iotrack.UpdateTrackParams(pt,AliESDtrack::kTPCin);    
          iotrack.SetTPCPoints(pt->GetPoints());
@@ -452,7 +559,8 @@ void AliTPCtrackerMI::FillESD(TObjArray* arr)
        Int_t found,foundable,shared;
        pt->GetClusterStatistic(138,158,found, foundable,shared,kFALSE);
        if (found<15) continue;
-       if (pt->fNShared/float(pt->GetNumberOfClusters())>0.2) continue;
+       if (foundable<=0) continue;
+       if (pt->GetNShared()/float(pt->GetNumberOfClusters())>0.2) continue;
        if (float(found)/float(foundable)<0.8) continue;
        //
        AliESDtrack iotrack;
@@ -470,226 +578,154 @@ void AliTPCtrackerMI::FillESD(TObjArray* arr)
   printf("Number of filled ESDs-\t%d\n",fEvent->GetNumberOfTracks());
 }
 
-void AliTPCtrackerMI::WriteTracks(TTree * tree)
-{
-  //
-  // write tracks from seed array to selected tree
-  //
-  fOutput  = tree;
-  if (fOutput){
-    AliTPCtrack *iotrack= new AliTPCtrack;
-    fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
-  }
-  WriteTracks();
-}
-
-void AliTPCtrackerMI::WriteTracks()
-{
-  //
-  // write tracks to the given output tree -
-  // output specified with SetIO routine
-  if (!fSeeds)  return;
-  if (!fOutput){
-    SetIO();
-  }
-
-  if (fOutput){
-    AliTPCtrack *iotrack= 0;
-    Int_t nseed=fSeeds->GetEntriesFast();
-    //for (Int_t i=0; i<nseed; i++) {
-    //  iotrack= (AliTPCtrack*)fSeeds->UncheckedAt(i);
-    //  if (iotrack) break;      
-    //}    
-    //TBranch * br = fOutput->Branch("tracks","AliTPCtrack",&iotrack,32000,100);
-    TBranch * br = fOutput->GetBranch("tracks");
-    br->SetAddress(&iotrack);
-    //
-    for (Int_t i=0; i<nseed; i++) {
-      AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);    
-      if (!pt) continue;    
-      AliTPCtrack * track = new AliTPCtrack(*pt);
-      iotrack = track;
-      pt->fLab2 =i; 
-      //      br->SetAddress(&iotrack);
-      fOutput->Fill();
-      delete track;
-      iotrack =0;
-    }
-    //fOutput->GetDirectory()->cd();
-    //fOutput->Write();
-  }
-  // delete iotrack;
-  //
-  if (fSeedTree){
-    //write the full seed information if specified in debug mode
-      
-    AliTPCseed * vseed = new AliTPCseed;
-    //
-    TClonesArray * arrtr = new TClonesArray("AliTPCTrackPoint",160);
-    arrtr->ExpandCreateFast(160);
-    //TClonesArray * arrcl = new TClonesArray("AliTPCclusterMI",160);
-    //arrcl->ExpandCreateFast(160);
-    TClonesArray * arre = new TClonesArray("AliTPCExactPoint",160);
-    //
-    vseed->fPoints = arrtr;
-    vseed->fEPoints = arre;
-    //    vseed->fClusterPoints = arrcl;
-    //TBranch * brseed = seedtree->Branch("seeds","AliTPCseed",&vseed,32000,99);
-    TBranch * brseed = fSeedTree->GetBranch("seeds");
-    
-    Int_t nseed=fSeeds->GetEntriesFast();
-    
-    for (Int_t i=0; i<nseed; i++) {
-      AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i);    
-      if (!pt) continue;     
-      pt->fPoints = arrtr;
-      //      pt->fClusterPoints = arrcl;
-      pt->fEPoints       = arre;
-      pt->RebuildSeed();
-      vseed = pt;
-      brseed->SetAddress(&vseed);
-      fSeedTree->Fill();
-      pt->fPoints  = 0;
-      pt->fEPoints = 0;
-      //      pt->fClusterPoints = 0;
-    }
-    fSeedTree->Write();
-    if (fTreeDebug) fTreeDebug->Write();
-  }
 
-}
-  
 
 
 
 Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
   //
   //
-  //seed->SetErrorY2(0.1);
-  //return 0.1;
-  //calculate look-up table at the beginning
-  static Bool_t  ginit = kFALSE;
-  static Float_t gnoise1,gnoise2,gnoise3;
-  static Float_t ggg1[10000];
-  static Float_t ggg2[10000];
-  static Float_t ggg3[10000];
-  static Float_t glandau1[10000];
-  static Float_t glandau2[10000];
-  static Float_t glandau3[10000];
+  // Use calibrated cluster error from OCDB
   //
-  static Float_t gcor01[500];
-  static Float_t gcor02[500];
-  static Float_t gcorp[500];
+  AliTPCClusterParam * clparam = AliTPCcalibDB::Instance()->GetClusterParam();
   //
+  Float_t z = TMath::Abs(fParam->GetZLength(0)-TMath::Abs(seed->GetZ()));
+  Int_t ctype = cl->GetType();  
+  Int_t    type = (cl->GetRow()<63) ? 0: (cl->GetRow()>126) ? 1:2;
+  Double_t angle = seed->GetSnp()*seed->GetSnp();
+  angle = TMath::Sqrt(TMath::Abs(angle/(1.-angle)));
+  Double_t erry2 = clparam->GetError0Par(0,type, z,angle);
+  if (ctype<0) {
+    erry2+=0.5;  // edge cluster
+  }
+  erry2*=erry2;
+  seed->SetErrorY2(erry2);
+  //
+  return erry2;
+
+//calculate look-up table at the beginning
+//   static Bool_t  ginit = kFALSE;
+//   static Float_t gnoise1,gnoise2,gnoise3;
+//   static Float_t ggg1[10000];
+//   static Float_t ggg2[10000];
+//   static Float_t ggg3[10000];
+//   static Float_t glandau1[10000];
+//   static Float_t glandau2[10000];
+//   static Float_t glandau3[10000];
+//   //
+//   static Float_t gcor01[500];
+//   static Float_t gcor02[500];
+//   static Float_t gcorp[500];
+//   //
 
-  //
-  if (ginit==kFALSE){
-    for (Int_t i=1;i<500;i++){
-      Float_t rsigma = float(i)/100.;
-      gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
-      gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
-      gcorp[i]  = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
-    }
+//   //
+//   if (ginit==kFALSE){
+//     for (Int_t i=1;i<500;i++){
+//       Float_t rsigma = float(i)/100.;
+//       gcor02[i] = TMath::Max(0.78 +TMath::Exp(7.4*(rsigma-1.2)),0.6);
+//       gcor01[i] = TMath::Max(0.72 +TMath::Exp(3.36*(rsigma-1.2)),0.6);
+//       gcorp[i]  = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
+//     }
 
-    //
-    for (Int_t i=3;i<10000;i++){
-      //
-      //
-      // inner sector
-      Float_t amp = float(i);
-      Float_t padlength =0.75;
-      gnoise1 = 0.0004/padlength;
-      Float_t nel     = 0.268*amp;
-      Float_t nprim   = 0.155*amp;
-      ggg1[i]          = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
-      glandau1[i]      = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-      if (glandau1[i]>1) glandau1[i]=1;
-      glandau1[i]*=padlength*padlength/12.;      
-      //
-      // outer short
-      padlength =1.;
-      gnoise2   = 0.0004/padlength;
-      nel       = 0.3*amp;
-      nprim     = 0.133*amp;
-      ggg2[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
-      glandau2[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-      if (glandau2[i]>1) glandau2[i]=1;
-      glandau2[i]*=padlength*padlength/12.;
-      //
-      //
-      // outer long
-      padlength =1.5;
-      gnoise3   = 0.0004/padlength;
-      nel       = 0.3*amp;
-      nprim     = 0.133*amp;
-      ggg3[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
-      glandau3[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-      if (glandau3[i]>1) glandau3[i]=1;
-      glandau3[i]*=padlength*padlength/12.;
-      //
-    }
-    ginit = kTRUE;
-  }
-  //
-  //
-  //
-  Int_t amp = int(TMath::Abs(cl->GetQ()));  
-  if (amp>9999) {
-    seed->SetErrorY2(1.);
-    return 1.;
-  }
-  Float_t snoise2;
-  Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
-  Int_t ctype = cl->GetType();  
-  Float_t padlength= GetPadPitchLength(seed->fRow);
-  Float_t angle2 = seed->GetSnp()*seed->GetSnp();
-  angle2 = angle2/(1-angle2); 
-  //
-  //cluster "quality"
-  Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->fCurrentSigmaY2));
-  Float_t res;
-  //
-  if (fSectors==fInnerSec){
-    snoise2 = gnoise1;
-    res     = ggg1[amp]*z+glandau1[amp]*angle2;     
-    if (ctype==0) res *= gcor01[rsigmay];
-    if ((ctype>0)){
-      res+=0.002;
-      res*= gcorp[rsigmay];
-    }
-  }
-  else {
-    if (padlength<1.1){
-      snoise2 = gnoise2;
-      res     = ggg2[amp]*z+glandau2[amp]*angle2; 
-      if (ctype==0) res *= gcor02[rsigmay];      
-      if ((ctype>0)){
-       res+=0.002;
-       res*= gcorp[rsigmay];
-      }
-    }
-    else{
-      snoise2 = gnoise3;      
-      res     = ggg3[amp]*z+glandau3[amp]*angle2; 
-      if (ctype==0) res *= gcor02[rsigmay];
-      if ((ctype>0)){
-       res+=0.002;
-       res*= gcorp[rsigmay];
-      }
-    }
-  }  
+//     //
+//     for (Int_t i=3;i<10000;i++){
+//       //
+//       //
+//       // inner sector
+//       Float_t amp = float(i);
+//       Float_t padlength =0.75;
+//       gnoise1 = 0.0004/padlength;
+//       Float_t nel     = 0.268*amp;
+//       Float_t nprim   = 0.155*amp;
+//       ggg1[i]          = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
+//       glandau1[i]      = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
+//       if (glandau1[i]>1) glandau1[i]=1;
+//       glandau1[i]*=padlength*padlength/12.;      
+//       //
+//       // outer short
+//       padlength =1.;
+//       gnoise2   = 0.0004/padlength;
+//       nel       = 0.3*amp;
+//       nprim     = 0.133*amp;
+//       ggg2[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
+//       glandau2[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
+//       if (glandau2[i]>1) glandau2[i]=1;
+//       glandau2[i]*=padlength*padlength/12.;
+//       //
+//       //
+//       // outer long
+//       padlength =1.5;
+//       gnoise3   = 0.0004/padlength;
+//       nel       = 0.3*amp;
+//       nprim     = 0.133*amp;
+//       ggg3[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
+//       glandau3[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
+//       if (glandau3[i]>1) glandau3[i]=1;
+//       glandau3[i]*=padlength*padlength/12.;
+//       //
+//     }
+//     ginit = kTRUE;
+//   }
+//   //
+//   //
+//   //
+//   Int_t amp = int(TMath::Abs(cl->GetQ()));  
+//   if (amp>9999) {
+//     seed->SetErrorY2(1.);
+//     return 1.;
+//   }
+//   Float_t snoise2;
+//   Float_t z = TMath::Abs(fParam->GetZLength(0)-TMath::Abs(seed->GetZ()));
+//   Int_t ctype = cl->GetType();  
+//   Float_t padlength= GetPadPitchLength(seed->GetRow());
+//   Double_t angle2 = seed->GetSnp()*seed->GetSnp();
+//   angle2 = angle2/(1-angle2); 
+//   //
+//   //cluster "quality"
+//   Int_t rsigmay = int(100.*cl->GetSigmaY2()/(seed->GetCurrentSigmaY2()));
+//   Float_t res;
+//   //
+//   if (fSectors==fInnerSec){
+//     snoise2 = gnoise1;
+//     res     = ggg1[amp]*z+glandau1[amp]*angle2;     
+//     if (ctype==0) res *= gcor01[rsigmay];
+//     if ((ctype>0)){
+//       res+=0.002;
+//       res*= gcorp[rsigmay];
+//     }
+//   }
+//   else {
+//     if (padlength<1.1){
+//       snoise2 = gnoise2;
+//       res     = ggg2[amp]*z+glandau2[amp]*angle2; 
+//       if (ctype==0) res *= gcor02[rsigmay];      
+//       if ((ctype>0)){
+//     res+=0.002;
+//     res*= gcorp[rsigmay];
+//       }
+//     }
+//     else{
+//       snoise2 = gnoise3;      
+//       res     = ggg3[amp]*z+glandau3[amp]*angle2; 
+//       if (ctype==0) res *= gcor02[rsigmay];
+//       if ((ctype>0)){
+//     res+=0.002;
+//     res*= gcorp[rsigmay];
+//       }
+//     }
+//   }  
 
-  if (ctype<0){
-    res+=0.005;
-    res*=2.4;  // overestimate error 2 times
-  }
-  res+= snoise2;
+//   if (ctype<0){
+//     res+=0.005;
+//     res*=2.4;  // overestimate error 2 times
+//   }
+//   res+= snoise2;
  
-  if (res<2*snoise2)
-    res = 2*snoise2;
+//   if (res<2*snoise2)
+//     res = 2*snoise2;
   
-  seed->SetErrorY2(res);
-  return res;
+//   seed->SetErrorY2(res);
+//   return res;
 
 
 }
@@ -699,216 +735,160 @@ Double_t AliTPCtrackerMI::ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl){
 Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
   //
   //
-  //seed->SetErrorY2(0.1);
-  //return 0.1;
-  //calculate look-up table at the beginning
-  static Bool_t  ginit = kFALSE;
-  static Float_t gnoise1,gnoise2,gnoise3;
-  static Float_t ggg1[10000];
-  static Float_t ggg2[10000];
-  static Float_t ggg3[10000];
-  static Float_t glandau1[10000];
-  static Float_t glandau2[10000];
-  static Float_t glandau3[10000];
-  //
-  static Float_t gcor01[1000];
-  static Float_t gcor02[1000];
-  static Float_t gcorp[1000];
-  //
-
-  //
-  if (ginit==kFALSE){
-    for (Int_t i=1;i<1000;i++){
-      Float_t rsigma = float(i)/100.;
-      gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
-      gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
-      gcorp[i]  = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
-    }
-
-    //
-    for (Int_t i=3;i<10000;i++){
-      //
-      //
-      // inner sector
-      Float_t amp = float(i);
-      Float_t padlength =0.75;
-      gnoise1 = 0.0004/padlength;
-      Float_t nel     = 0.268*amp;
-      Float_t nprim   = 0.155*amp;
-      ggg1[i]          = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
-      glandau1[i]      = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-      if (glandau1[i]>1) glandau1[i]=1;
-      glandau1[i]*=padlength*padlength/12.;      
-      //
-      // outer short
-      padlength =1.;
-      gnoise2   = 0.0004/padlength;
-      nel       = 0.3*amp;
-      nprim     = 0.133*amp;
-      ggg2[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
-      glandau2[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-      if (glandau2[i]>1) glandau2[i]=1;
-      glandau2[i]*=padlength*padlength/12.;
-      //
-      //
-      // outer long
-      padlength =1.5;
-      gnoise3   = 0.0004/padlength;
-      nel       = 0.3*amp;
-      nprim     = 0.133*amp;
-      ggg3[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
-      glandau3[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-      if (glandau3[i]>1) glandau3[i]=1;
-      glandau3[i]*=padlength*padlength/12.;
-      //
-    }
-    ginit = kTRUE;
-  }
-  //
+  // Use calibrated cluster error from OCDB
   //
+  AliTPCClusterParam * clparam = AliTPCcalibDB::Instance()->GetClusterParam();
   //
-  Int_t amp = int(TMath::Abs(cl->GetQ()));  
-  if (amp>9999) {
-    seed->SetErrorY2(1.);
-    return 1.;
-  }
-  Float_t snoise2;
-  Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
+  Float_t z = TMath::Abs(fParam->GetZLength(0)-TMath::Abs(seed->GetZ()));
   Int_t ctype = cl->GetType();  
-  Float_t padlength= GetPadPitchLength(seed->fRow);
+  Int_t    type = (cl->GetRow()<63) ? 0: (cl->GetRow()>126) ? 1:2;
   //
-  Float_t angle2 = seed->GetSnp()*seed->GetSnp();
-  //  if (angle2<0.6) angle2 = 0.6;
+  Double_t angle2 = seed->GetSnp()*seed->GetSnp();
   angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2)); 
-  //
-  //cluster "quality"
-  Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2));
-  Float_t res;
-  //
-  if (fSectors==fInnerSec){
-    snoise2 = gnoise1;
-    res     = ggg1[amp]*z+glandau1[amp]*angle2;     
-    if (ctype==0) res *= gcor01[rsigmaz];
-    if ((ctype>0)){
-      res+=0.002;
-      res*= gcorp[rsigmaz];
-    }
-  }
-  else {
-    if (padlength<1.1){
-      snoise2 = gnoise2;
-      res     = ggg2[amp]*z+glandau2[amp]*angle2; 
-      if (ctype==0) res *= gcor02[rsigmaz];      
-      if ((ctype>0)){
-       res+=0.002;
-       res*= gcorp[rsigmaz];
-      }
-    }
-    else{
-      snoise2 = gnoise3;      
-      res     = ggg3[amp]*z+glandau3[amp]*angle2; 
-      if (ctype==0) res *= gcor02[rsigmaz];
-      if ((ctype>0)){
-       res+=0.002;
-       res*= gcorp[rsigmaz];
-      }
-    }
-  }  
-
-  if (ctype<0){
-    res+=0.002;
-    res*=1.3;
-  }
-  if ((ctype<0) &&amp<70){
-    res+=0.002;
-    res*=1.3;  
+  Double_t angle = TMath::Sqrt(TMath::Abs(angle2));
+  Double_t errz2 = clparam->GetError0Par(1,type, z,angle);
+  if (ctype<0) {
+    errz2+=0.5;  // edge cluster
   }
-  res += snoise2;
-  if (res<2*snoise2)
-     res = 2*snoise2;
-  if (res>3) res =3;
-  seed->SetErrorZ2(res);
-  return res;
-}
-
-
-
-/*
-Double_t AliTPCtrackerMI::ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl){
-  //
+  errz2*=errz2;
+  seed->SetErrorZ2(errz2);
   //
-  //seed->SetErrorZ2(0.1);
-  //return 0.1;
+  return errz2;
 
-  Float_t snoise2;
-  Float_t z = TMath::Abs(fParam->GetZLength()-TMath::Abs(seed->GetZ()));
-  //
-  Float_t rsigmaz = cl->GetSigmaZ2()/(seed->fCurrentSigmaZ2);
-  Int_t ctype = cl->GetType();
-  Float_t amp = TMath::Abs(cl->GetQ());
-  
-  Float_t nel;
-  Float_t nprim;
-  //
-  Float_t landau=2 ;    //landau fluctuation part
-  Float_t gg=2;         // gg fluctuation part
-  Float_t padlength= GetPadPitchLength(seed->GetX());
-  if (fSectors==fInnerSec){
-    snoise2 = 0.0004/padlength;
-    nel     = 0.268*amp;
-    nprim   = 0.155*amp;
-    gg      = (2+0.001*nel/(padlength*padlength))/nel;
-    landau  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-    if (landau>1) landau=1;
-  }
-  else {
-    snoise2 = 0.0004/padlength;
-    nel     = 0.3*amp;
-    nprim   = 0.133*amp;
-    gg      = (2+0.0008*nel/(padlength*padlength))/nel;
-    landau  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
-    if (landau>1) landau=1;
-  }
-  Float_t sdiff = gg*fParam->GetDiffT()*fParam->GetDiffT()*z;
 
-  //
-  Float_t angle2 = seed->GetSnp()*seed->GetSnp();
-  angle2 = TMath::Sqrt((1-angle2));
-  if (angle2<0.6) angle2 = 0.6;
-  //angle2 = 1;
 
-  Float_t angle = seed->GetTgl()/angle2;
-  Float_t angular = landau*angle*angle*padlength*padlength/12.;
-  Float_t res = sdiff + angular;
+//   //seed->SetErrorY2(0.1);
+//   //return 0.1;
+//   //calculate look-up table at the beginning
+//   static Bool_t  ginit = kFALSE;
+//   static Float_t gnoise1,gnoise2,gnoise3;
+//   static Float_t ggg1[10000];
+//   static Float_t ggg2[10000];
+//   static Float_t ggg3[10000];
+//   static Float_t glandau1[10000];
+//   static Float_t glandau2[10000];
+//   static Float_t glandau3[10000];
+//   //
+//   static Float_t gcor01[1000];
+//   static Float_t gcor02[1000];
+//   static Float_t gcorp[1000];
+//   //
 
-  
-  if ((ctype==0) && (fSectors ==fOuterSec))
-    res *= 0.81 +TMath::Exp(6.8*(rsigmaz-1.2));
+//   //
+//   if (ginit==kFALSE){
+//     for (Int_t i=1;i<1000;i++){
+//       Float_t rsigma = float(i)/100.;
+//       gcor02[i] = TMath::Max(0.81 +TMath::Exp(6.8*(rsigma-1.2)),0.6);
+//       gcor01[i] = TMath::Max(0.72 +TMath::Exp(2.04*(rsigma-1.2)),0.6);
+//       gcorp[i]  = TMath::Max(TMath::Power((rsigma+0.5),1.5),1.2);
+//     }
 
-  if ((ctype==0) && (fSectors ==fInnerSec))
-    res *= 0.72 +TMath::Exp(2.04*(rsigmaz-1.2));
-  
-  if ((ctype>0)){
-    res+=0.005;
-    res*= TMath::Power(rsigmaz+0.5,1.5);  //0.31+0.147*ctype;
-  }
-  if (ctype<0){
-    res+=0.002;
-    res*=1.3;
-  }
-  if ((ctype<0) &&amp<70){
-    res+=0.002;
-    res*=1.3;  
-  }
-  res += snoise2;
-  if (res<2*snoise2)
-     res = 2*snoise2;
+//     //
+//     for (Int_t i=3;i<10000;i++){
+//       //
+//       //
+//       // inner sector
+//       Float_t amp = float(i);
+//       Float_t padlength =0.75;
+//       gnoise1 = 0.0004/padlength;
+//       Float_t nel     = 0.268*amp;
+//       Float_t nprim   = 0.155*amp;
+//       ggg1[i]          = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.001*nel/(padlength*padlength))/nel;
+//       glandau1[i]      = (2.+0.12*nprim)*0.5* (2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
+//       if (glandau1[i]>1) glandau1[i]=1;
+//       glandau1[i]*=padlength*padlength/12.;      
+//       //
+//       // outer short
+//       padlength =1.;
+//       gnoise2   = 0.0004/padlength;
+//       nel       = 0.3*amp;
+//       nprim     = 0.133*amp;
+//       ggg2[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
+//       glandau2[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
+//       if (glandau2[i]>1) glandau2[i]=1;
+//       glandau2[i]*=padlength*padlength/12.;
+//       //
+//       //
+//       // outer long
+//       padlength =1.5;
+//       gnoise3   = 0.0004/padlength;
+//       nel       = 0.3*amp;
+//       nprim     = 0.133*amp;
+//       ggg3[i]      = fParam->GetDiffT()*fParam->GetDiffT()*(2+0.0008*nel/(padlength*padlength))/nel;
+//       glandau3[i]  = (2.+0.12*nprim)*0.5*(2.+nprim*nprim*0.001/(padlength*padlength))/nprim;
+//       if (glandau3[i]>1) glandau3[i]=1;
+//       glandau3[i]*=padlength*padlength/12.;
+//       //
+//     }
+//     ginit = kTRUE;
+//   }
+//   //
+//   //
+//   //
+//   Int_t amp = int(TMath::Abs(cl->GetQ()));  
+//   if (amp>9999) {
+//     seed->SetErrorY2(1.);
+//     return 1.;
+//   }
+//   Float_t snoise2;
+//   Float_t z = TMath::Abs(fParam->GetZLength(0)-TMath::Abs(seed->GetZ()));
+//   Int_t ctype = cl->GetType();  
+//   Float_t padlength= GetPadPitchLength(seed->GetRow());
+//   //
+//   Double_t angle2 = seed->GetSnp()*seed->GetSnp();
+//   //  if (angle2<0.6) angle2 = 0.6;
+//   angle2 = seed->GetTgl()*seed->GetTgl()*(1+angle2/(1-angle2)); 
+//   //
+//   //cluster "quality"
+//   Int_t rsigmaz = int(100.*cl->GetSigmaZ2()/(seed->GetCurrentSigmaZ2()));
+//   Float_t res;
+//   //
+//   if (fSectors==fInnerSec){
+//     snoise2 = gnoise1;
+//     res     = ggg1[amp]*z+glandau1[amp]*angle2;     
+//     if (ctype==0) res *= gcor01[rsigmaz];
+//     if ((ctype>0)){
+//       res+=0.002;
+//       res*= gcorp[rsigmaz];
+//     }
+//   }
+//   else {
+//     if (padlength<1.1){
+//       snoise2 = gnoise2;
+//       res     = ggg2[amp]*z+glandau2[amp]*angle2; 
+//       if (ctype==0) res *= gcor02[rsigmaz];      
+//       if ((ctype>0)){
+//     res+=0.002;
+//     res*= gcorp[rsigmaz];
+//       }
+//     }
+//     else{
+//       snoise2 = gnoise3;      
+//       res     = ggg3[amp]*z+glandau3[amp]*angle2; 
+//       if (ctype==0) res *= gcor02[rsigmaz];
+//       if ((ctype>0)){
+//     res+=0.002;
+//     res*= gcorp[rsigmaz];
+//       }
+//     }
+//   }  
 
-  seed->SetErrorZ2(res);
-  return res;
+//   if (ctype<0){
+//     res+=0.002;
+//     res*=1.3;
+//   }
+//   if ((ctype<0) &&amp<70){
+//     res+=0.002;
+//     res*=1.3;  
+//   }
+//   res += snoise2;
+//   if (res<2*snoise2)
+//      res = 2*snoise2;
+//   if (res>3) res =3;
+//   seed->SetErrorZ2(res);
+//   return res;
 }
-*/
+
 
 
 
@@ -921,11 +901,11 @@ void AliTPCtrackerMI::RotateToLocal(AliTPCseed *seed)
   Float_t ymax = x*TMath::Tan(0.5*fSectors->GetAlpha());
   
   if (y > ymax) {
-    seed->fRelativeSector= (seed->fRelativeSector+1) % fN;
+    seed->SetRelativeSector((seed->GetRelativeSector()+1) % fN);
     if (!seed->Rotate(fSectors->GetAlpha())) 
       return;
   } else if (y <-ymax) {
-    seed->fRelativeSector= (seed->fRelativeSector-1+fN) % fN;
+    seed->SetRelativeSector((seed->GetRelativeSector()-1+fN) % fN);
     if (!seed->Rotate(-fSectors->GetAlpha())) 
       return;
   }   
@@ -1107,6 +1087,60 @@ Int_t  AliTPCtrackerMI::LoadClusters (TTree *tree)
   return LoadClusters();
 }
 
+
+Int_t  AliTPCtrackerMI::LoadClusters(TObjArray *arr)
+{
+  //
+  // load clusters to the memory
+  AliTPCClustersRow *clrow = 0x0; 
+  Int_t lower   = arr->LowerBound();
+  Int_t entries = arr->GetEntriesFast();
+
+  for (Int_t i=lower; i<entries; i++) {
+    clrow = (AliTPCClustersRow*) arr->At(i);
+       if(!clrow) continue;
+       if(!clrow->GetArray()) continue;
+
+    //  
+    Int_t sec,row;
+    fParam->AdjustSectorRow(clrow->GetID(),sec,row);
+
+    for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
+      Transform((AliTPCclusterMI*)(clrow->GetArray()->At(icl)));
+    }
+    //
+    if (clrow->GetArray()->GetEntriesFast()<=0) continue;
+    AliTPCtrackerRow * tpcrow=0;
+    Int_t left=0;
+    if (sec<fkNIS*2){
+      tpcrow = &(fInnerSec[sec%fkNIS][row]);    
+      left = sec/fkNIS;
+    }
+    else{
+      tpcrow = &(fOuterSec[(sec-fkNIS*2)%fkNOS][row]);
+      left = (sec-fkNIS*2)/fkNOS;
+    }
+    if (left ==0){
+      tpcrow->SetN1(clrow->GetArray()->GetEntriesFast());
+      tpcrow->SetClusters1(new AliTPCclusterMI[tpcrow->GetN1()]);
+      for (Int_t i=0;i<tpcrow->GetN1();i++) 
+       tpcrow->SetCluster1(i, *(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
+    }
+    if (left ==1){
+      tpcrow->SetN2(clrow->GetArray()->GetEntriesFast());
+      tpcrow->SetClusters2(new AliTPCclusterMI[tpcrow->GetN2()]);
+      for (Int_t i=0;i<tpcrow->GetN2();i++) 
+       tpcrow->SetCluster2(i,*(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
+    }
+  }
+  //
+  delete clrow;
+  LoadOuterSectors();
+  LoadInnerSectors();
+  return 0;
+}
+
+
 Int_t  AliTPCtrackerMI::LoadClusters()
 {
   //
@@ -1128,8 +1162,11 @@ Int_t  AliTPCtrackerMI::LoadClusters()
     //  
     Int_t sec,row;
     fParam->AdjustSectorRow(clrow->GetID(),sec,row);
+    for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
+      Transform((AliTPCclusterMI*)(clrow->GetArray()->At(icl)));
+    }
     //
-    AliTPCRow * tpcrow=0;
+    AliTPCtrackerRow * tpcrow=0;
     Int_t left=0;
     if (sec<fkNIS*2){
       tpcrow = &(fInnerSec[sec%fkNIS][row]);    
@@ -1140,16 +1177,16 @@ Int_t  AliTPCtrackerMI::LoadClusters()
       left = (sec-fkNIS*2)/fkNOS;
     }
     if (left ==0){
-      tpcrow->fN1 = clrow->GetArray()->GetEntriesFast();
-      tpcrow->fClusters1 = new AliTPCclusterMI[tpcrow->fN1];
-      for (Int_t i=0;i<tpcrow->fN1;i++) 
-       tpcrow->fClusters1[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
+      tpcrow->SetN1(clrow->GetArray()->GetEntriesFast());
+      tpcrow->SetClusters1(new AliTPCclusterMI[tpcrow->GetN1()]);
+      for (Int_t i=0;i<tpcrow->GetN1();i++) 
+       tpcrow->SetCluster1(i, *(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
     }
     if (left ==1){
-      tpcrow->fN2 = clrow->GetArray()->GetEntriesFast();
-      tpcrow->fClusters2 = new AliTPCclusterMI[tpcrow->fN2];
-      for (Int_t i=0;i<tpcrow->fN2;i++) 
-       tpcrow->fClusters2[i] = *(AliTPCclusterMI*)(clrow->GetArray()->At(i));
+      tpcrow->SetN2(clrow->GetArray()->GetEntriesFast());
+      tpcrow->SetClusters2(new AliTPCclusterMI[tpcrow->GetN2()]);
+      for (Int_t i=0;i<tpcrow->GetN2();i++) 
+       tpcrow->SetCluster2(i,*(AliTPCclusterMI*)(clrow->GetArray()->At(i)));
     }
   }
   //
@@ -1168,7 +1205,7 @@ void AliTPCtrackerMI::UnloadClusters()
   Int_t nrows = fOuterSec->GetNRows();
   for (Int_t sec = 0;sec<fkNOS;sec++)
     for (Int_t row = 0;row<nrows;row++){
-      AliTPCRow*  tpcrow = &(fOuterSec[sec%fkNOS][row]);
+      AliTPCtrackerRow*  tpcrow = &(fOuterSec[sec%fkNOS][row]);
       //      if (tpcrow){
       //       if (tpcrow->fClusters1) delete []tpcrow->fClusters1; 
       //       if (tpcrow->fClusters2) delete []tpcrow->fClusters2; 
@@ -1179,7 +1216,7 @@ void AliTPCtrackerMI::UnloadClusters()
   nrows = fInnerSec->GetNRows();
   for (Int_t sec = 0;sec<fkNIS;sec++)
     for (Int_t row = 0;row<nrows;row++){
-      AliTPCRow*  tpcrow = &(fInnerSec[sec%fkNIS][row]);
+      AliTPCtrackerRow*  tpcrow = &(fInnerSec[sec%fkNIS][row]);
       //if (tpcrow){
       //       if (tpcrow->fClusters1) delete []tpcrow->fClusters1; 
       //if (tpcrow->fClusters2) delete []tpcrow->fClusters2; 
@@ -1190,6 +1227,89 @@ void AliTPCtrackerMI::UnloadClusters()
   return ;
 }
 
+void AliTPCtrackerMI::FillClusterArray(TObjArray* array) const{
+  //
+  // Filling cluster to the array - For visualization purposes
+  //
+  Int_t nrows=0;
+  nrows = fOuterSec->GetNRows();
+  for (Int_t sec = 0;sec<fkNOS;sec++)
+    for (Int_t row = 0;row<nrows;row++){
+      AliTPCtrackerRow*  tpcrow = &(fOuterSec[sec%fkNOS][row]);
+      if (!tpcrow) continue;
+      for (Int_t icl = 0;icl<tpcrow->GetN();icl++){
+       array->AddLast((TObject*)((*tpcrow)[icl]));
+      }
+    } 
+  nrows = fInnerSec->GetNRows();
+  for (Int_t sec = 0;sec<fkNIS;sec++)
+    for (Int_t row = 0;row<nrows;row++){
+      AliTPCtrackerRow*  tpcrow = &(fInnerSec[sec%fkNIS][row]);
+      if (!tpcrow) continue;
+      for (Int_t icl = 0;icl<tpcrow->GetN();icl++){
+       array->AddLast((TObject*)(*tpcrow)[icl]);
+      }
+    }
+}
+
+
+void   AliTPCtrackerMI::Transform(AliTPCclusterMI * cluster){
+  //
+  //
+  //
+  AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
+  if (!transform) {
+    AliFatal("Tranformations not in calibDB");
+  }
+  Double_t x[3]={cluster->GetRow(),cluster->GetPad(),cluster->GetTimeBin()};
+  Int_t i[1]={cluster->GetDetector()};
+  transform->Transform(x,i,0,1);  
+  if (!AliTPCReconstructor::GetRecoParam()->GetBYMirror()){
+    if (cluster->GetDetector()%36>17){
+      x[1]*=-1;
+    }
+  }
+
+  //
+  // in debug mode  check the transformation
+  //
+  if (AliTPCReconstructor::StreamLevel()>1) {
+    Float_t gx[3];
+    cluster->GetGlobalXYZ(gx);
+    Int_t event = (fEvent==NULL)? 0: fEvent->GetEventNumberInFile();
+    TTreeSRedirector &cstream = *fDebugStreamer;
+    cstream<<"Transform"<<
+      "event="<<event<<
+      "x0="<<x[0]<<
+      "x1="<<x[1]<<
+      "x2="<<x[2]<<
+      "gx0="<<gx[0]<<
+      "gx1="<<gx[1]<<
+      "gx2="<<gx[2]<<
+      "Cl.="<<cluster<<
+      "\n"; 
+  }
+  cluster->SetX(x[0]);
+  cluster->SetY(x[1]);
+  cluster->SetZ(x[2]);
+  // The old stuff:
+
+  //
+  // 
+  //
+  //if (!fParam->IsGeoRead()) fParam->ReadGeoMatrices();
+  TGeoHMatrix  *mat = fParam->GetClusterMatrix(cluster->GetDetector());
+  //TGeoHMatrix  mat;
+  Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
+  Double_t posC[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
+  if (mat) mat->LocalToMaster(pos,posC);
+  else{
+    // chack Loading of Geo matrices from GeoManager - TEMPORARY FIX
+  }
+  cluster->SetX(posC[0]);
+  cluster->SetY(posC[1]);
+  cluster->SetZ(posC[2]);
+}
 
 //_____________________________________________________________________________
 Int_t AliTPCtrackerMI::LoadOuterSectors() {
@@ -1200,19 +1320,19 @@ Int_t AliTPCtrackerMI::LoadOuterSectors() {
   UInt_t index=0;
   for (Int_t sec = 0;sec<fkNOS;sec++)
     for (Int_t row = 0;row<nrows;row++){
-      AliTPCRow*  tpcrow = &(fOuterSec[sec%fkNOS][row]);  
+      AliTPCtrackerRow*  tpcrow = &(fOuterSec[sec%fkNOS][row]);  
       Int_t sec2 = sec+2*fkNIS;
       //left
-      Int_t ncl = tpcrow->fN1;
+      Int_t ncl = tpcrow->GetN1();
       while (ncl--) {
-       AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
+       AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
        index=(((sec2<<8)+row)<<16)+ncl;
        tpcrow->InsertCluster(c,index);
       }
       //right
-      ncl = tpcrow->fN2;
+      ncl = tpcrow->GetN2();
       while (ncl--) {
-       AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
+       AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
        index=((((sec2+fkNOS)<<8)+row)<<16)+ncl;
        tpcrow->InsertCluster(c,index);
       }
@@ -1220,17 +1340,17 @@ Int_t AliTPCtrackerMI::LoadOuterSectors() {
       // write indexes for fast acces
       //
       for (Int_t i=0;i<510;i++)
-       tpcrow->fFastCluster[i]=-1;
+       tpcrow->SetFastCluster(i,-1);
       for (Int_t i=0;i<tpcrow->GetN();i++){
         Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
-       tpcrow->fFastCluster[zi]=i;  // write index
+       tpcrow->SetFastCluster(zi,i);  // write index
       }
       Int_t last = 0;
       for (Int_t i=0;i<510;i++){
-       if (tpcrow->fFastCluster[i]<0)
-         tpcrow->fFastCluster[i] = last;
+       if (tpcrow->GetFastCluster(i)<0)
+         tpcrow->SetFastCluster(i,last);
        else
-         last = tpcrow->fFastCluster[i];
+         last = tpcrow->GetFastCluster(i);
       }
     }  
   fN=fkNOS;
@@ -1248,19 +1368,19 @@ Int_t  AliTPCtrackerMI::LoadInnerSectors() {
   UInt_t index=0;
   for (Int_t sec = 0;sec<fkNIS;sec++)
     for (Int_t row = 0;row<nrows;row++){
-      AliTPCRow*  tpcrow = &(fInnerSec[sec%fkNIS][row]);
+      AliTPCtrackerRow*  tpcrow = &(fInnerSec[sec%fkNIS][row]);
       //
       //left
-      Int_t ncl = tpcrow->fN1;
+      Int_t ncl = tpcrow->GetN1();
       while (ncl--) {
-       AliTPCclusterMI *c= &(tpcrow->fClusters1[ncl]);
+       AliTPCclusterMI *c= (tpcrow->GetCluster1(ncl));
        index=(((sec<<8)+row)<<16)+ncl;
        tpcrow->InsertCluster(c,index);
       }
       //right
-      ncl = tpcrow->fN2;
+      ncl = tpcrow->GetN2();
       while (ncl--) {
-       AliTPCclusterMI *c= &(tpcrow->fClusters2[ncl]);
+       AliTPCclusterMI *c= (tpcrow->GetCluster2(ncl));
        index=((((sec+fkNIS)<<8)+row)<<16)+ncl;
        tpcrow->InsertCluster(c,index);
       }
@@ -1268,17 +1388,17 @@ Int_t  AliTPCtrackerMI::LoadInnerSectors() {
       // write indexes for fast acces
       //
       for (Int_t i=0;i<510;i++)
-       tpcrow->fFastCluster[i]=-1;
+       tpcrow->SetFastCluster(i,-1);
       for (Int_t i=0;i<tpcrow->GetN();i++){
         Int_t zi = Int_t((*tpcrow)[i]->GetZ()+255.);
-       tpcrow->fFastCluster[zi]=i;  // write index
+       tpcrow->SetFastCluster(zi,i);  // write index
       }
       Int_t last = 0;
       for (Int_t i=0;i<510;i++){
-       if (tpcrow->fFastCluster[i]<0)
-         tpcrow->fFastCluster[i] = last;
+       if (tpcrow->GetFastCluster(i)<0)
+         tpcrow->SetFastCluster(i,last);
        else
-         last = tpcrow->fFastCluster[i];
+         last = tpcrow->GetFastCluster(i);
       }
 
     }  
@@ -1295,24 +1415,30 @@ AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
   //--------------------------------------------------------------------
   //       Return pointer to a given cluster
   //--------------------------------------------------------------------
+  if (index<0) return 0; // no cluster
   Int_t sec=(index&0xff000000)>>24; 
   Int_t row=(index&0x00ff0000)>>16; 
   Int_t ncl=(index&0x00007fff)>>00;
 
-  const AliTPCRow * tpcrow=0;
+  const AliTPCtrackerRow * tpcrow=0;
   AliTPCclusterMI * clrow =0;
 
+  if (sec<0 || sec>=fkNIS*4) {
+    AliWarning(Form("Wrong sector %d",sec));
+    return 0x0;
+  }
+
   if (sec<fkNIS*2){
     tpcrow = &(fInnerSec[sec%fkNIS][row]);
     if (tpcrow==0) return 0;
 
     if (sec<fkNIS) {
-      if (tpcrow->fN1<=ncl) return 0;
-      clrow = tpcrow->fClusters1;
+      if (tpcrow->GetN1()<=ncl) return 0;
+      clrow = tpcrow->GetClusters1();
     }
     else {
-      if (tpcrow->fN2<=ncl) return 0;
-      clrow = tpcrow->fClusters2;
+      if (tpcrow->GetN2()<=ncl) return 0;
+      clrow = tpcrow->GetClusters2();
     }
   }
   else {
@@ -1320,12 +1446,12 @@ AliTPCclusterMI *AliTPCtrackerMI::GetClusterMI(Int_t index) const {
     if (tpcrow==0) return 0;
 
     if (sec-2*fkNIS<fkNOS) {
-      if (tpcrow->fN1<=ncl) return 0;
-      clrow = tpcrow->fClusters1;
+      if (tpcrow->GetN1()<=ncl) return 0;
+      clrow = tpcrow->GetClusters1();
     }
     else {
-      if (tpcrow->fN2<=ncl) return 0;
-      clrow = tpcrow->fClusters2;
+      if (tpcrow->GetN2()<=ncl) return 0;
+      clrow = tpcrow->GetClusters2();
     }
   }
 
@@ -1353,9 +1479,9 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
     //        
     if (tpcindex==-1) return 0; //track in dead zone
     if (tpcindex>0){     //
-      cl = t.fClusterPointer[nr];
+      cl = t.GetClusterPointer(nr);
       if ( (cl==0) ) cl = GetClusterMI(tpcindex);
-      t.fCurrentClusterIndex1 = tpcindex
+      t.SetCurrentClusterIndex1(tpcindex)
     }
     if (cl){      
       Int_t relativesector = ((tpcindex&0xff000000)>>24)%18;  // if previously accepted cluster in different sector
@@ -1366,41 +1492,46 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
       
       if (TMath::Abs(angle-t.GetAlpha())>0.001){
        Double_t rotation = angle-t.GetAlpha();
-       t.fRelativeSector= relativesector;
-       t.Rotate(rotation);     
+       t.SetRelativeSector(relativesector);
+       if (!t.Rotate(rotation)) return 0;      
       }
-      t.PropagateTo(x);
+      if (!t.PropagateTo(x)) return 0;
       //
-      t.fCurrentCluster = cl
-      t.fRow = nr;
-      Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
+      t.SetCurrentCluster(cl)
+      t.SetRow(nr);
+      Int_t accept = AcceptCluster(&t,t.GetCurrentCluster());
       if ((tpcindex&0x8000)==0) accept =0;
       if (accept<3) { 
        //if founded cluster is acceptible
        if (cl->IsUsed(11)) {  // id cluster is shared inrease uncertainty
-         t.fErrorY2 += 0.03;
-         t.fErrorZ2 += 0.03
-         t.fErrorY2 *= 3;
-         t.fErrorZ2 *= 3
+         t.SetErrorY2(t.GetErrorY2()+0.03);
+         t.SetErrorZ2(t.GetErrorZ2()+0.03)
+         t.SetErrorY2(t.GetErrorY2()*3);
+         t.SetErrorZ2(t.GetErrorZ2()*3)
        }
-       t.fNFoundable++;
+       t.SetNFoundable(t.GetNFoundable()+1);
        UpdateTrack(&t,accept);
        return 1;
       }    
     }
   }
-  if (fIteration>1) return 0;  // not look for new cluster during refitting
+  if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;  // cut on angle
+  if (fIteration>1){
+    // not look for new cluster during refitting    
+    t.SetNFoundable(t.GetNFoundable()+1);
+    return 0;
+  }
   //
   UInt_t index=0;
-  if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;
+  //  if (TMath::Abs(t.GetSnp())>0.95 || TMath::Abs(x*t.GetC()-t.GetEta())>0.95) return 0;// patch 28 fev 06
   Double_t  y=t.GetYat(x);
   if (TMath::Abs(y)>ymax){
     if (y > ymax) {
-      t.fRelativeSector= (t.fRelativeSector+1) % fN;
+      t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
       if (!t.Rotate(fSectors->GetAlpha())) 
        return 0;
     } else if (y <-ymax) {
-      t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
+      t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
       if (!t.Rotate(-fSectors->GetAlpha())) 
        return 0;
     }
@@ -1408,25 +1539,38 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
   }
   //
   if (!t.PropagateTo(x)) {
-    if (fIteration==0) t.fRemoval = 10;
+    if (fIteration==0) t.SetRemoval(10);
     return 0;
   }
   y=t.GetY(); 
   Double_t z=t.GetZ();
   //
-  const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
-  if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
-  Double_t  roady  =1.;
-  Double_t  roadz = 1.;
-  //
-  if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
-    t.fInDead = kTRUE;
+
+  if (!IsActive(t.GetRelativeSector(),nr)) {
+    t.SetInDead(kTRUE);
+    t.SetClusterIndex2(nr,-1); 
+    return 0;
+  }
+  //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
+  Bool_t isActive  = IsActive(t.GetRelativeSector(),nr);
+  Bool_t isActive2 = (nr>=fInnerSec->GetNRows()) ? fOuterSec[t.GetRelativeSector()][nr-fInnerSec->GetNRows()].GetN()>0:fInnerSec[t.GetRelativeSector()][nr].GetN()>0;
+  
+  if (!isActive || !isActive2) return 0;
+
+  const AliTPCtrackerRow &krow=GetRow(t.GetRelativeSector(),nr);
+  if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
+  Double_t  roady  =1.;
+  Double_t  roadz = 1.;
+  //
+  if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
+    t.SetInDead(kTRUE);
     t.SetClusterIndex2(nr,-1); 
     return 0;
   } 
   else
     {
-      if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10)) t.fNFoundable++;
+      if (TMath::Abs(z)<(AliTPCReconstructor::GetCtgRange()*x+10) && TMath::Abs(z)<fParam->GetZLength(0) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) 
+       t.SetNFoundable(t.GetNFoundable()+1);
       else
        return 0;
     }   
@@ -1434,18 +1578,18 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
   if (krow) {
     //    cl = krow.FindNearest2(y+10.,z,roady,roadz,index);    
     cl = krow.FindNearest2(y,z,roady,roadz,index);    
-    if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);       
+    if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));       
   }  
   if (cl) {
-    t.fCurrentCluster = cl
-    t.fRow = nr;
+    t.SetCurrentCluster(cl)
+    t.SetRow(nr);
     if (fIteration==2&&cl->IsUsed(10)) return 0; 
-    Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
+    Int_t accept = AcceptCluster(&t,t.GetCurrentCluster());
     if (fIteration==2&&cl->IsUsed(11)) {
-      t.fErrorY2 += 0.03;
-      t.fErrorZ2 += 0.03
-      t.fErrorY2 *= 3;
-      t.fErrorZ2 *= 3
+      t.SetErrorY2(t.GetErrorY2()+0.03);
+      t.SetErrorZ2(t.GetErrorZ2()+0.03)
+      t.SetErrorY2(t.GetErrorY2()*3);
+      t.SetErrorZ2(t.GetErrorZ2()*3)
     }
     /*    
     if (t.fCurrentCluster->IsUsed(10)){
@@ -1462,7 +1606,7 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
     if (accept<3) UpdateTrack(&t,accept);
 
   } else {  
-    if ( fIteration==0 && t.fNFoundable*0.5 > t.GetNumberOfClusters()) t.fRemoval=10;
+    if ( fIteration==0 && t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) t.SetRemoval(10);
     
   }
   return 1;
@@ -1476,7 +1620,7 @@ Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
   Double_t  x= GetXrow(nr), ymax=GetMaxY(nr);
   Double_t y,z; 
   if (!t.GetProlongation(x,y,z)) {
-    t.fRemoval = 10;
+    t.SetRemoval(10);
     return 0;
   }
   //
@@ -1484,11 +1628,11 @@ Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
   if (TMath::Abs(y)>ymax){
     
     if (y > ymax) {
-      t.fRelativeSector= (t.fRelativeSector+1) % fN;
+      t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
       if (!t.Rotate(fSectors->GetAlpha())) 
        return 0;
     } else if (y <-ymax) {
-      t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
+      t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
       if (!t.Rotate(-fSectors->GetAlpha())) 
        return 0;
     }
@@ -1498,8 +1642,8 @@ Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
     t.GetProlongation(x,y,z);
   }
   //
-  // update current shape info every 3 pad-row
-  if ( (nr%6==0) || t.GetNumberOfClusters()<2 || (t.fCurrentSigmaY2<0.0001) ){
+  // update current shape info every 2 pad-row
+  if ( (nr%2==0) || t.GetNumberOfClusters()<2 || (t.GetCurrentSigmaY2()<0.0001) ){
     //    t.fCurrentSigmaY = GetSigmaY(&t);
     //t.fCurrentSigmaZ = GetSigmaZ(&t);
     GetShape(&t,nr);
@@ -1510,14 +1654,14 @@ Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
   
   
   //Int_t nr2 = nr;
-  const AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
+  const AliTPCtrackerRow &krow=GetRow(t.GetRelativeSector(),nr);
   if ( (t.GetSigmaY2()<0) || t.GetSigmaZ2()<0) return 0;
   Double_t  roady  =1.;
   Double_t  roadz = 1.;
   //
   Int_t row = nr;
-  if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
-    t.fInDead = kTRUE;
+  if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
+    t.SetInDead(kTRUE);
     t.SetClusterIndex2(row,-1); 
     return 0;
   } 
@@ -1531,15 +1675,15 @@ Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
     //    cl = krow.FindNearest2(y+10,z,roady,roadz,index);    
     cl = krow.FindNearest2(y,z,roady,roadz,index);    
 
-    if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);       
+    if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(index));       
   }  
 
   if (cl) {
-    t.fCurrentCluster = cl
-    //    Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);        
+    t.SetCurrentCluster(cl)
+    //    Int_t accept = AcceptCluster(&t,t.fCurrentCluster);        
     //if (accept<3){
       t.SetClusterIndex2(row,index);
-      t.fClusterPointer[row] = cl;
+      t.SetClusterPointer(row, cl);
       //}
   }
   return 1;
@@ -1547,26 +1691,73 @@ Int_t AliTPCtrackerMI::FollowToNextFast(AliTPCseed& t, Int_t nr) {
 
 
 
+//_________________________________________________________________________
+Bool_t AliTPCtrackerMI::GetTrackPoint(Int_t index, AliTrackPoint &p ) const
+{
+  // Get track space point by index
+  // return false in case the cluster doesn't exist
+  AliTPCclusterMI *cl = GetClusterMI(index);
+  if (!cl) return kFALSE;
+  Int_t sector = (index&0xff000000)>>24;
+  //  Int_t row = (index&0x00ff0000)>>16;
+  Float_t xyz[3];
+  //  xyz[0] = fParam->GetPadRowRadii(sector,row);
+  xyz[0] = cl->GetX();
+  xyz[1] = cl->GetY();
+  xyz[2] = cl->GetZ();
+  Float_t sin,cos;
+  fParam->AdjustCosSin(sector,cos,sin);
+  Float_t x = cos*xyz[0]-sin*xyz[1];
+  Float_t y = cos*xyz[1]+sin*xyz[0];
+  Float_t cov[6];
+  Float_t sigmaY2 = 0.027*cl->GetSigmaY2();
+  if (sector < fParam->GetNInnerSector()) sigmaY2 *= 2.07;
+  Float_t sigmaZ2 = 0.066*cl->GetSigmaZ2();
+  if (sector < fParam->GetNInnerSector()) sigmaZ2 *= 1.77;
+  cov[0] = sin*sin*sigmaY2;
+  cov[1] = -sin*cos*sigmaY2;
+  cov[2] = 0.;
+  cov[3] = cos*cos*sigmaY2;
+  cov[4] = 0.;
+  cov[5] = sigmaZ2;
+  p.SetXYZ(x,y,xyz[2],cov);
+  AliGeomManager::ELayerID iLayer;
+  Int_t idet;
+  if (sector < fParam->GetNInnerSector()) {
+    iLayer = AliGeomManager::kTPC1;
+    idet = sector;
+  }
+  else {
+    iLayer = AliGeomManager::kTPC2;
+    idet = sector - fParam->GetNInnerSector();
+  }
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet);
+  p.SetVolumeID(volid);
+  return kTRUE;
+}
+
+
+
 Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t,  Int_t nr) {
   //-----------------------------------------------------------------
   // This function tries to find a track prolongation to next pad row
   //-----------------------------------------------------------------
-  t.fCurrentCluster  = 0;
-  t.fCurrentClusterIndex1 = 0;   
+  t.SetCurrentCluster(0);
+  t.SetCurrentClusterIndex1(0);   
    
   Double_t xt=t.GetX();
   Int_t     row = GetRowNumber(xt)-1; 
   Double_t  ymax= GetMaxY(nr);
 
   if (row < nr) return 1; // don't prolongate if not information until now -
-  if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
-    t.fRemoval =10;
-    return 0;  // not prolongate strongly inclined tracks
-  } 
-  if (TMath::Abs(t.GetSnp())>0.95) {
-    t.fRemoval =10;
-    return 0;  // not prolongate strongly inclined tracks
-  }
+//   if (TMath::Abs(t.GetSnp())>0.9 && t.GetNumberOfClusters()>40. && fIteration!=2) {
+//     t.fRemoval =10;
+//     return 0;  // not prolongate strongly inclined tracks
+//   } 
+//   if (TMath::Abs(t.GetSnp())>0.95) {
+//     t.fRemoval =10;
+//     return 0;  // not prolongate strongly inclined tracks
+//   }// patch 28 fev 06
 
   Double_t x= GetXrow(nr);
   Double_t y,z;
@@ -1581,11 +1772,11 @@ Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t,  Int_t nr) {
 
   if (TMath::Abs(y)>ymax){
     if (y > ymax) {
-      t.fRelativeSector= (t.fRelativeSector+1) % fN;
+      t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
       if (!t.Rotate(fSectors->GetAlpha())) 
        return 0;
     } else if (y <-ymax) {
-      t.fRelativeSector= (t.fRelativeSector-1+fN) % fN;
+      t.SetRelativeSector((t.GetRelativeSector()-1+fN) % fN);
       if (!t.Rotate(-fSectors->GetAlpha())) 
        return 0;
     }
@@ -1596,30 +1787,38 @@ Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t,  Int_t nr) {
     //y = t.GetY();    
   }
   //
+  if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;
+
+  if (!IsActive(t.GetRelativeSector(),nr)) {
+    t.SetInDead(kTRUE);
+    t.SetClusterIndex2(nr,-1); 
+    return 0;
+  }
+  //AliInfo(Form("A - Sector%d phi %f - alpha %f", t.fRelativeSector,y/x, t.GetAlpha()));
 
-  AliTPCRow &krow=GetRow(t.fRelativeSector,nr);
+  AliTPCtrackerRow &krow=GetRow(t.GetRelativeSector(),nr);
 
-  if (TMath::Abs(TMath::Abs(y)-ymax)<krow.fDeadZone){
-    t.fInDead = kTRUE;
+  if (TMath::Abs(TMath::Abs(y)-ymax)<krow.GetDeadZone()){
+    t.SetInDead(kTRUE);
     t.SetClusterIndex2(nr,-1); 
     return 0;
   } 
   else
     {
-      if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10)) t.fNFoundable++;
+      if (TMath::Abs(t.GetZ())<(AliTPCReconstructor::GetCtgRange()*t.GetX()+10) && (TMath::Abs(t.GetSnp())<AliTPCReconstructor::GetMaxSnpTracker())) t.SetNFoundable(t.GetNFoundable()+1);
       else
        return 0;      
     }
 
   // update current
-  if ( (nr%6==0) || t.GetNumberOfClusters()<2){
+  if ( (nr%2==0) || t.GetNumberOfClusters()<2){
     //    t.fCurrentSigmaY = GetSigmaY(&t);
     //t.fCurrentSigmaZ = GetSigmaZ(&t);
     GetShape(&t,nr);
   }
     
   AliTPCclusterMI *cl=0;
-  UInt_t index=0;
+  Int_t index=0;
   //
   Double_t roady = 1.;
   Double_t roadz = 1.;
@@ -1628,23 +1827,26 @@ Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t,  Int_t nr) {
   if (!cl){
     index = t.GetClusterIndex2(nr);    
     if ( (index>0) && (index&0x8000)==0){
-      cl = t.fClusterPointer[nr];
+      cl = t.GetClusterPointer(nr);
       if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
-      t.fCurrentClusterIndex1 = index;
+      t.SetCurrentClusterIndex1(index);
       if (cl) {
-       t.fCurrentCluster  = cl;
+       t.SetCurrentCluster(cl);
        return 1;
       }
     }
   }
 
+  //  if (index<0) return 0;
+  UInt_t uindex = TMath::Abs(index);
+
   if (krow) {    
-    //cl = krow.FindNearest2(y+10,z,roady,roadz,index);      
-    cl = krow.FindNearest2(y,z,roady,roadz,index);      
+    //cl = krow.FindNearest2(y+10,z,roady,roadz,uindex);      
+    cl = krow.FindNearest2(y,z,roady,roadz,uindex);      
   }
 
-  if (cl) t.fCurrentClusterIndex1 = krow.GetIndex(index);   
-  t.fCurrentCluster  = cl;
+  if (cl) t.SetCurrentClusterIndex1(krow.GetIndex(uindex));   
+  t.SetCurrentCluster(cl);
 
   return 1;
 }
@@ -1657,18 +1859,18 @@ Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
 
   //update error according neighborhoud
 
-  if (t.fCurrentCluster) {
-    t.fRow = nr
-    Int_t accept = AcceptCluster(&t,t.fCurrentCluster,1.);
+  if (t.GetCurrentCluster()) {
+    t.SetRow(nr)
+    Int_t accept = AcceptCluster(&t,t.GetCurrentCluster());
     
-    if (t.fCurrentCluster->IsUsed(10)){
+    if (t.GetCurrentCluster()->IsUsed(10)){
       //
       //
       //  t.fErrorZ2*=2;
       //  t.fErrorY2*=2;
-      t.fNShared++;
-      if (t.fNShared>0.7*t.GetNumberOfClusters()) {
-       t.fRemoval =10;
+      t.SetNShared(t.GetNShared()+1);
+      if (t.GetNShared()>0.7*t.GetNumberOfClusters()) {
+       t.SetRemoval(10);
        return 0;
       }
     }   
@@ -1677,10 +1879,10 @@ Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
  
   } else {
     if (fIteration==0){
-      if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.fRemoval=10;      
-      if (  t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.fRemoval=10;      
+      if ( ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)&& t.GetNumberOfClusters()>18) t.SetRemoval(10);      
+      if (  t.GetChi2()/t.GetNumberOfClusters()>6 &&t.GetNumberOfClusters()>18) t.SetRemoval(10);      
 
-      if (( (t.fNFoundable*0.5 > t.GetNumberOfClusters()) || t.fNoCluster>15)) t.fRemoval=10;
+      if (( (t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) || t.GetNoCluster()>15)) t.SetRemoval(10);
     }
   }
   return 1;
@@ -1699,7 +1901,7 @@ Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
   if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();  
   if (alpha < 0.            ) alpha += 2.*TMath::Pi();  
   //
-  t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
+  t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
     
   Int_t first = GetRowNumber(xt)-1;
   for (Int_t nr= first; nr>=rf; nr-=step) {
@@ -1710,7 +1912,7 @@ Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
        if (index==0) break;
        if (index<0) continue;
        //
-       AliESDkink * kink = fEvent->GetKink(index-1);
+       AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
        if (!kink){
          printf("PROBLEM\n");
        }
@@ -1750,7 +1952,7 @@ Int_t AliTPCtrackerMI::FollowProlongationFast(AliTPCseed& t, Int_t rf, Int_t ste
   Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
   if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();  
   if (alpha < 0.            ) alpha += 2.*TMath::Pi();  
-  t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
+  t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
     
   for (Int_t nr=GetRowNumber(xt)-1; nr>=rf; nr-=step) {
     
@@ -1774,21 +1976,21 @@ Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
   Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
   if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();  
   if (alpha < 0.            ) alpha += 2.*TMath::Pi();  
-  t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
+  t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
     
-  Int_t first = t.fFirstPoint;
+  Int_t first = t.GetFirstPoint();
   if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
   //
   if (first<0) first=0;
   for (Int_t nr=first; nr<=rf; nr++) {
-    if ( (TMath::Abs(t.GetSnp())>0.95)) break;
+    //    if ( (TMath::Abs(t.GetSnp())>0.95)) break;//patch 28 fev 06
     if (t.GetKinkIndexes()[0]<0){
       for (Int_t i=0;i<3;i++){
        Int_t index = t.GetKinkIndexes()[i];
        if (index==0) break;
        if (index>0) continue;
        index = TMath::Abs(index);
-       AliESDkink * kink = fEvent->GetKink(index-1);
+       AliKink * kink = (AliKink*)fEvent->GetKink(index-1);
        if (!kink){
          printf("PROBLEM\n");
        }
@@ -1808,6 +2010,7 @@ Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
       fSectors = fInnerSec;
     else
       fSectors = fOuterSec;
+
     FollowToNext(t,nr);                                                             
   }   
   return 1;
@@ -1834,8 +2037,8 @@ Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &
   if (distance>4.) return 0; // if there are far away  - not overlap - to reduce combinatorics
  
   //  Int_t offset =0;
-  Int_t firstpoint = TMath::Min(s1->fFirstPoint,s2->fFirstPoint);
-  Int_t lastpoint = TMath::Max(s1->fLastPoint,s2->fLastPoint);
+  Int_t firstpoint = TMath::Min(s1->GetFirstPoint(),s2->GetFirstPoint());
+  Int_t lastpoint = TMath::Max(s1->GetLastPoint(),s2->GetLastPoint());
   if (lastpoint>160) 
     lastpoint =160;
   if (firstpoint<0) 
@@ -1864,31 +2067,32 @@ void  AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
 {
   //
   //
-  if (TMath::Abs(s1->GetC()-s2->GetC())>0.004) return;
-  if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>0.6) return;
-
-  Float_t dz2 =(s1->GetZ() - s2->GetZ());
-  dz2*=dz2;
-  Float_t dy2 =(s1->GetY() - s2->GetY());
-  dy2*=dy2;
-  Float_t distance = dz2+dy2;
-  if (distance>325.) return ; // if there are far away  - not overlap - to reduce combinatorics
+  Float_t thetaCut = 0.2;//+10.*TMath::Sqrt(s1->GetSigmaTglZ()+ s2->GetSigmaTglZ());
+  if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>thetaCut) return;
+  Float_t minCl = TMath::Min(s1->GetNumberOfClusters(),s2->GetNumberOfClusters());
+  Int_t cutN0 = TMath::Max(5,TMath::Nint(0.1*minCl));
   
   //
   Int_t sumshared=0;
   //
-  Int_t firstpoint = TMath::Max(s1->fFirstPoint,s2->fFirstPoint);
-  Int_t lastpoint = TMath::Min(s1->fLastPoint,s2->fLastPoint);
+  //Int_t firstpoint = TMath::Max(s1->GetFirstPoint(),s2->GetFirstPoint());
+  //Int_t lastpoint = TMath::Min(s1->GetLastPoint(),s2->GetLastPoint());
+  Int_t firstpoint = 0;
+  Int_t lastpoint = 160;
   //
-  if (firstpoint>=lastpoint-5) return;;
+  //  if (firstpoint>=lastpoint-5) return;;
 
   for (Int_t i=firstpoint;i<lastpoint;i++){
     //    if ( (s1->GetClusterIndex2(i)&0xFFFF8FFF)==(s2->GetClusterIndex2(i)&0xFFFF8FFF) && s1->GetClusterIndex2(i)>0) {
     if ( (s1->GetClusterIndex2(i))==(s2->GetClusterIndex2(i)) && s1->GetClusterIndex2(i)>0) {
       sumshared++;
+      s1->SetSharedMapBit(i, kTRUE);
+      s2->SetSharedMapBit(i, kTRUE);
     }
+    if (s1->GetClusterIndex2(i)>0)
+      s1->SetClusterMapBit(i, kTRUE);
   }
-  if (sumshared>4){
+  if (sumshared>cutN0){
     // sign clusters
     //
     for (Int_t i=firstpoint;i<lastpoint;i++){
@@ -1897,32 +2101,31 @@ void  AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
        AliTPCTrackerPoint *p1  = s1->GetTrackPoint(i);
        AliTPCTrackerPoint *p2  = s2->GetTrackPoint(i);; 
        if (s1->IsActive()&&s2->IsActive()){
-         p1->fIsShared = kTRUE;
-         p2->fIsShared = kTRUE;
+         p1->SetShared(kTRUE);
+         p2->SetShared(kTRUE);
        }       
       }
     }
   }
   //  
-  if (sumshared>10){
+  if (sumshared>cutN0){
     for (Int_t i=0;i<4;i++){
-      if (s1->fOverlapLabels[3*i]==0){
-       s1->fOverlapLabels[3*i] = s2->GetLabel();
-       s1->fOverlapLabels[3*i+1] = sumshared;
-       s1->fOverlapLabels[3*i+2] = s2->GetUniqueID();
+      if (s1->GetOverlapLabel(3*i)==0){
+       s1->SetOverlapLabel(3*i,  s2->GetLabel());
+       s1->SetOverlapLabel(3*i+1,sumshared);
+       s1->SetOverlapLabel(3*i+2,s2->GetUniqueID());
        break;
       }        
     }
     for (Int_t i=0;i<4;i++){
-      if (s2->fOverlapLabels[3*i]==0){
-       s2->fOverlapLabels[3*i] = s1->GetLabel();
-       s2->fOverlapLabels[3*i+1] = sumshared;
-       s2->fOverlapLabels[3*i+2] = s1->GetUniqueID();
+      if (s2->GetOverlapLabel(3*i)==0){
+       s2->SetOverlapLabel(3*i,  s1->GetLabel());
+       s2->SetOverlapLabel(3*i+1,sumshared);
+       s2->SetOverlapLabel(3*i+2,s1->GetUniqueID());
        break;
       }        
     }    
   }
-  
 }
 
 void  AliTPCtrackerMI::SignShared(TObjArray * arr)
@@ -1934,10 +2137,10 @@ void  AliTPCtrackerMI::SignShared(TObjArray * arr)
     AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
     if (!pt) continue;
     //if (pt) RotateToLocal(pt);
-    pt->fSort = 0;
+    pt->SetSort(0);
   }
   arr->UnSort();
-  arr->Sort();  // sorting according z
+  arr->Sort();  // sorting according relative sectors
   arr->Expand(arr->GetEntries());
   //
   //
@@ -1946,110 +2149,25 @@ void  AliTPCtrackerMI::SignShared(TObjArray * arr)
     AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
     if (!pt) continue;
     for (Int_t j=0;j<=12;j++){
-      pt->fOverlapLabels[j] =0;
+      pt->SetOverlapLabel(j,0);
     }
   }
   for (Int_t i=0; i<nseed; i++) {
     AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
     if (!pt) continue;
-    if (pt->fRemoval>10) continue;
+    if (pt->GetRemoval()>10) continue;
     for (Int_t j=i+1; j<nseed; j++){
       AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
+      if (TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>1) continue;
       //      if (pt2){
-      if (pt2->fRemoval<=10) {
-       if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
+      if (pt2->GetRemoval()<=10) {
+       //if ( TMath::Abs(pt->GetRelativeSector()-pt2->GetRelativeSector())>0) break;
        SignShared(pt,pt2);
       }
     }  
   }
 }
 
-void  AliTPCtrackerMI::RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2,  Int_t removalindex)
-{
-  //
-  //sort trackss according sectors
-  //
-  if (fDebug&1) {
-    Info("RemoveDouble","Number of tracks before double removal- %d\n",arr->GetEntries());
-  }
-  //
-  for (Int_t i=0; i<arr->GetEntriesFast(); i++) {
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
-    if (!pt) continue;
-    pt->fSort = 0;
-  }
-  arr->UnSort();
-  arr->Sort();  // sorting according z
-  arr->Expand(arr->GetEntries());
-  //
-  //reset overlap labels
-  //
-  Int_t nseed=arr->GetEntriesFast();
-  for (Int_t i=0; i<nseed; i++) {
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
-    if (!pt) continue;
-    pt->SetUniqueID(i);
-    for (Int_t j=0;j<=12;j++){
-      pt->fOverlapLabels[j] =0;
-    }
-  }
-  //
-  //sign shared tracks
-  for (Int_t i=0; i<nseed; i++) {
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
-    if (!pt) continue;
-    if (pt->fRemoval>10) continue;
-    Float_t deltac = pt->GetC()*0.1;
-    for (Int_t j=i+1; j<nseed; j++){
-      AliTPCseed *pt2=(AliTPCseed*)arr->UncheckedAt(j);
-      //      if (pt2){
-      if (pt2->fRemoval<=10) {
-       if ( TMath::Abs(pt->fRelativeSector-pt2->fRelativeSector)>0) break;
-       if (TMath::Abs(pt->GetC()  -pt2->GetC())>deltac) continue;
-       if (TMath::Abs(pt->GetTgl()-pt2->GetTgl())>0.05) continue;
-       //
-       SignShared(pt,pt2);
-      }
-    }
-  }
-  //
-  // remove highly shared tracks
-  for (Int_t i=0; i<nseed; i++) {
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
-    if (!pt) continue;
-    if (pt->fRemoval>10) continue;
-    //
-    Int_t sumshared =0;
-    for (Int_t j=0;j<4;j++){
-      sumshared = pt->fOverlapLabels[j*3+1];      
-    }
-    Float_t factor = factor1;
-    if (pt->fRemoval>0) factor = factor2;
-    if (sumshared/pt->GetNumberOfClusters()>factor){
-      for (Int_t j=0;j<4;j++){
-       if (pt->fOverlapLabels[3*j]==0) continue;
-       if (pt->fOverlapLabels[3*j+1]<5) continue; 
-       if (pt->fRemoval==removalindex) continue;      
-       AliTPCseed * pt2 = (AliTPCseed*)arr->UncheckedAt(pt->fOverlapLabels[3*j+2]);
-       if (!pt2) continue;
-       if (pt2->GetSigma2C()<pt->GetSigma2C()){
-         //      pt->fRemoval = removalindex;
-         delete arr->RemoveAt(i);        
-         break;
-       }
-      }      
-    }
-  }
-  arr->Compress();
-  if (fDebug&1) {
-    Info("RemoveDouble","Number of tracks after double removal- %d\n",arr->GetEntries());
-  }
-}
-
-
-
-
-
 
 void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
 {
@@ -2061,85 +2179,33 @@ void AliTPCtrackerMI::SortTracks(TObjArray * arr, Int_t mode) const
     if (!pt) {
       continue;
     }
-    pt->fSort = mode;
-  }
-  arr->UnSort();
-  arr->Sort();
-}
-
-void AliTPCtrackerMI::RemoveUsed(TObjArray * arr, Float_t factor1,  Float_t factor2, Int_t removalindex)
-{
-
-  //Loop over all tracks and remove "overlaps"
-  //
-  //
-  Int_t nseed = arr->GetEntriesFast();  
-  Int_t good =0;
-
-  for (Int_t i=0; i<nseed; i++) {
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
-    if (!pt) {
-      delete arr->RemoveAt(i);
-    }
-    else{
-      pt->fSort =1;
-      pt->fBSigned = kFALSE;
-    }
+    pt->SetSort(mode);
   }
-  arr->Compress();
-  nseed = arr->GetEntriesFast();
   arr->UnSort();
   arr->Sort();
-  //
-  //unsign used
-  UnsignClusters();
-  //
-  for (Int_t i=0; i<nseed; i++) {
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(i);    
-    if (!pt) {
-      continue;
-    }    
-    Int_t found,foundable,shared;
-    if (pt->IsActive()) 
-      pt->GetClusterStatistic(0,160,found, foundable,shared,kFALSE);
-    else
-      pt->GetClusterStatistic(0,160,found, foundable,shared,kTRUE); 
-    //
-    Double_t factor = factor2;
-    if (pt->fBConstrain) factor = factor1;
-
-    if ((Float_t(shared)/Float_t(found))>factor){
-      pt->Desactivate(removalindex);
-      continue;
-    }
-
-    good++;
-    for (Int_t i=0; i<160; i++) {
-      Int_t index=pt->GetClusterIndex2(i);
-      if (index<0 || index&0x8000 ) continue;
-      AliTPCclusterMI *c= pt->fClusterPointer[i];        
-      if (!c) continue;
-      //      if (!c->IsUsed(10)) c->Use(10);
-      //if (pt->IsActive()) 
-      c->Use(10);  
-      //else
-      //       c->Use(5);
-    }
-    
-  }
-  fNtracks = good;
-  if (fDebug>0){
-    Info("RemoveUsed","\n*****\nNumber of good tracks after shared removal\t%d\n",fNtracks);
-  }
 }
 
 
 void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1,  Float_t factor2, Int_t minimal)
 {
-
-  //Loop over all tracks and remove "overlaps"
   //
+  // Loop over all tracks and remove overlaped tracks (with lower quality)
+  // Algorithm:
+  //    1. Unsign clusters
+  //    2. Sort tracks according quality
+  //       Quality is defined by the number of cluster between first and last points 
+  //       
+  //    3. Loop over tracks - decreasing quality order
+  //       a.) remove - If the fraction of shared cluster less than factor (1- n or 2) 
+  //       b.) remove - If the minimal number of clusters less than minimal and not ITS
+  //       c.) if track accepted - sign clusters
   //
+  //Called in - AliTPCtrackerMI::Clusters2Tracks()
+  //          - AliTPCtrackerMI::PropagateBack()
+  //          - AliTPCtrackerMI::RefitInward()
+  //
+
   UnsignClusters();
   //
   Int_t nseed = arr->GetEntriesFast();  
@@ -2157,15 +2223,18 @@ void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1,  Float_t fac
     pt->UpdatePoints();    //select first last max dens points
     Float_t * points = pt->GetPoints();
     if (points[3]<0.8) quality[i] =-1;
-    //
     quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
+    //prefer high momenta tracks if overlaps
+    quality[i] *= TMath::Sqrt(TMath::Abs(pt->Pt())+0.5); 
   }
   TMath::Sort(nseed,quality,indexes);
   //
   //
   for (Int_t itrack=0; itrack<nseed; itrack++) {
     Int_t trackindex = indexes[itrack];
-    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);    
+    AliTPCseed *pt=(AliTPCseed*)arr->UncheckedAt(trackindex);   
+    if (!pt) continue;
+    //
     if (quality[trackindex]<0){
       if (pt) {
        delete arr->RemoveAt(trackindex);
@@ -2176,33 +2245,44 @@ void AliTPCtrackerMI::RemoveUsed2(TObjArray * arr, Float_t factor1,  Float_t fac
       continue;
     }
     //
+    //
     Int_t first = Int_t(pt->GetPoints()[0]);
     Int_t last  = Int_t(pt->GetPoints()[2]);
-    Double_t factor = (pt->fBConstrain) ? factor1: factor2;
+    Double_t factor = (pt->GetBConstrain()) ? factor1: factor2;
     //
     Int_t found,foundable,shared;
-    pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE);
-    Float_t sharedfactor = Float_t(shared+1)/Float_t(found+1);
-    //
-    if (Float_t(shared+1)/Float_t(found+1)>factor){
-      if (pt->GetKinkIndexes()[0]!=0) continue;  //don't remove tracks  - part of the kinks
-      delete arr->RemoveAt(trackindex);
-      continue;
+    pt->GetClusterStatistic(first,last, found, foundable,shared,kFALSE); // better to get statistic in "high-dens"  region do't use full track as in line bellow
+    //    pt->GetClusterStatistic(0,160, found, foundable,shared,kFALSE);
+    Bool_t itsgold =kFALSE;
+    if (pt->GetESD()){
+      Int_t dummy[12];
+      if (pt->GetESD()->GetITSclusters(dummy)>4) itsgold= kTRUE;
     }
-
-    if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){  //remove short tracks
-      if (pt->GetKinkIndexes()[0]!=0) continue;  //don't remove tracks  - part of the kinks
-      delete arr->RemoveAt(trackindex);
-      continue;
+    if (!itsgold){
+      //
+      if (Float_t(shared+1)/Float_t(found+1)>factor){
+       if (pt->GetKinkIndexes()[0]!=0) continue;  //don't remove tracks  - part of the kinks
+       delete arr->RemoveAt(trackindex);
+       continue;
+      }      
+      if (pt->GetNumberOfClusters()<50&&(found-0.5*shared)<minimal){  //remove short tracks
+       if (pt->GetKinkIndexes()[0]!=0) continue;  //don't remove tracks  - part of the kinks
+       delete arr->RemoveAt(trackindex);
+       continue;
+      }
     }
 
     good++;
-    if (sharedfactor>0.4) continue;
+    //if (sharedfactor>0.4) continue;
+    if (pt->GetKinkIndexes()[0]>0) continue;
+    //Remove tracks with undefined properties - seems
+    if (pt->GetSigmaY2()<kAlmost0) continue; // ? what is the origin ? 
+    //
     for (Int_t i=first; i<last; i++) {
       Int_t index=pt->GetClusterIndex2(i);
       // if (index<0 || index&0x8000 ) continue;
       if (index<0 || index&0x8000 ) continue;
-      AliTPCclusterMI *c= pt->fClusterPointer[i];        
+      AliTPCclusterMI *c= pt->GetClusterPointer(i);        
       if (!c) continue;
       c->Use(10);  
     }    
@@ -2223,12 +2303,12 @@ void AliTPCtrackerMI::UnsignClusters()
   
   for (Int_t sec=0;sec<fkNIS;sec++){
     for (Int_t row=0;row<fInnerSec->GetNRows();row++){
-      AliTPCclusterMI *cl = fInnerSec[sec][row].fClusters1;
-      for (Int_t icl =0;icl< fInnerSec[sec][row].fN1;icl++)
+      AliTPCclusterMI *cl = fInnerSec[sec][row].GetClusters1();
+      for (Int_t icl =0;icl< fInnerSec[sec][row].GetN1();icl++)
        //      if (cl[icl].IsUsed(10))         
        cl[icl].Use(-1);
-      cl = fInnerSec[sec][row].fClusters2;
-      for (Int_t icl =0;icl< fInnerSec[sec][row].fN2;icl++)
+      cl = fInnerSec[sec][row].GetClusters2();
+      for (Int_t icl =0;icl< fInnerSec[sec][row].GetN2();icl++)
        //if (cl[icl].IsUsed(10))       
          cl[icl].Use(-1);      
     }
@@ -2236,12 +2316,12 @@ void AliTPCtrackerMI::UnsignClusters()
   
   for (Int_t sec=0;sec<fkNOS;sec++){
     for (Int_t row=0;row<fOuterSec->GetNRows();row++){
-      AliTPCclusterMI *cl = fOuterSec[sec][row].fClusters1;
-      for (Int_t icl =0;icl< fOuterSec[sec][row].fN1;icl++)
+      AliTPCclusterMI *cl = fOuterSec[sec][row].GetClusters1();
+      for (Int_t icl =0;icl< fOuterSec[sec][row].GetN1();icl++)
        //if (cl[icl].IsUsed(10))       
          cl[icl].Use(-1);
-      cl = fOuterSec[sec][row].fClusters2;
-      for (Int_t icl =0;icl< fOuterSec[sec][row].fN2;icl++)
+      cl = fOuterSec[sec][row].GetClusters2();
+      for (Int_t icl =0;icl< fOuterSec[sec][row].GetN2();icl++)
        //if (cl[icl].IsUsed(10))       
        cl[icl].Use(-1);      
     }
@@ -2278,7 +2358,7 @@ void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fde
       continue;
     }    
     if (!(pt->IsActive())) continue;
-    Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
+    Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
     if ( (dens>0.7) && (pt->GetNumberOfClusters()>70)){
       sumdens += dens;
       sumdens2+= dens*dens;
@@ -2306,13 +2386,22 @@ void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fde
     meanchi  = sumchi/sum;
     //
     sdensity = sumdens2/sum-mdensity*mdensity;
-    sdensity = TMath::Sqrt(sdensity);
+    if (sdensity >= 0)
+       sdensity = TMath::Sqrt(sdensity);
+    else
+       sdensity = 0.1;
     //
     smeann   = sumn2/sum-meann*meann;
-    smeann   = TMath::Sqrt(smeann);
+    if (smeann >= 0)
+      smeann   = TMath::Sqrt(smeann);
+    else 
+      smeann   = 10;
     //
     smeanchi = sumchi2/sum - meanchi*meanchi;
-    smeanchi = TMath::Sqrt(smeanchi);
+    if (smeanchi >= 0)
+      smeanchi = TMath::Sqrt(smeanchi);
+    else
+      smeanchi = 0.4;
   }
 
 
@@ -2323,8 +2412,8 @@ void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fde
     if (!pt) {
       continue;
     }
-    if (pt->fBSigned) continue;
-    if (pt->fBConstrain) continue;    
+    if (pt->GetBSigned()) continue;
+    if (pt->GetBConstrain()) continue;    
     //if (!(pt->IsActive())) continue;
     /*
     Int_t found,foundable,shared;    
@@ -2337,9 +2426,9 @@ void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fde
     }
     */
     Bool_t isok =kFALSE;
-    if ( (pt->fNShared/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
+    if ( (pt->GetNShared()/pt->GetNumberOfClusters()<0.5) &&pt->GetNumberOfClusters()>60)
       isok = kTRUE;
-    if ((TMath::Abs(1/pt->GetC())<100.) && (pt->fNShared/pt->GetNumberOfClusters()<0.7))
+    if ((TMath::Abs(1/pt->GetC())<100.) && (pt->GetNShared()/pt->GetNumberOfClusters()<0.7))
       isok =kTRUE;
     if  (TMath::Abs(pt->GetZ()/pt->GetX())>1.1)
       isok =kTRUE;
@@ -2350,7 +2439,7 @@ void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fde
       for (Int_t i=0; i<160; i++) {    
        Int_t index=pt->GetClusterIndex2(i);
        if (index<0) continue;
-       AliTPCclusterMI *c= pt->fClusterPointer[i];
+       AliTPCclusterMI *c= pt->GetClusterPointer(i);
        if (!c) continue;
        //if (!(c->IsUsed(10))) c->Use();  
        c->Use(10);  
@@ -2367,12 +2456,12 @@ void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fde
       continue;
     }    
     //if (!(pt->IsActive())) continue;
-    if (pt->fBSigned) continue;
+    if (pt->GetBSigned()) continue;
     Double_t chi     = pt->GetChi2()/pt->GetNumberOfClusters();
     if (chi>maxchi) continue;
 
     Float_t bfactor=1;
-    Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->fNFoundable);
+    Float_t dens = pt->GetNumberOfClusters()/Float_t(pt->GetNFoundable());
    
     //sign only tracks with enoug big density at the beginning
     
@@ -2383,17 +2472,17 @@ void AliTPCtrackerMI::SignClusters(TObjArray * arr, Float_t fnumber, Float_t fde
     Double_t minn    = TMath::Max(Int_t(meann-fnumber*smeann*bfactor),50);
    
     //    if (pt->fBConstrain) mindens = TMath::Max(mdensity-sdensity*fdensity*bfactor,0.65);
-    if ( (pt->fRemoval==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
+    if ( (pt->GetRemoval()==10) && (pt->GetSnp()>0.8)&&(dens>mindens))
       minn=0;
 
     if ((dens>mindens && pt->GetNumberOfClusters()>minn) && chi<maxchi ){
       //Int_t noc=pt->GetNumberOfClusters();
-      pt->fBSigned = kTRUE;
+      pt->SetBSigned(kTRUE);
       for (Int_t i=0; i<160; i++) {
 
        Int_t index=pt->GetClusterIndex2(i);
        if (index<0) continue;
-       AliTPCclusterMI *c= pt->fClusterPointer[i];
+       AliTPCclusterMI *c= pt->GetClusterPointer(i);
        if (!c) continue;
        //      if (!(c->IsUsed(10))) c->Use();  
        c->Use(10);  
@@ -2436,8 +2525,8 @@ void  AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0,
   Int_t sumgood1  = 0;
   Int_t sumgood2  = 0;
   Int_t foundable = 0;
-  Int_t maxindex = seed->fLastPoint;  //last foundable row
-  if (seed->fNFoundable*th0 > seed->GetNumberOfClusters()) {
+  Int_t maxindex = seed->GetLastPoint();  //last foundable row
+  if (seed->GetNFoundable()*th0 > seed->GetNumberOfClusters()) {
     seed->Desactivate(10) ;
     return;
   }
@@ -2462,17 +2551,28 @@ void  AliTPCtrackerMI::StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0,
 }
 
 
-Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
+Int_t AliTPCtrackerMI::RefitInward(AliESDEvent *event)
 {
   //
   // back propagation of ESD tracks
   //
   //return 0;
+  const Int_t kMaxFriendTracks=2000;
   fEvent = event;
   ReadSeeds(event,2);
   fIteration=2;
   //PrepareForProlongation(fSeeds,1);
   PropagateForward2(fSeeds);
+  RemoveUsed2(fSeeds,0.4,0.4,20);
+
+  TObjArray arraySeed(fSeeds->GetEntries());
+  for (Int_t i=0;i<fSeeds->GetEntries();i++) {
+    arraySeed.AddAt(fSeeds->At(i),i);    
+  }
+  SignShared(&arraySeed);
+  //  FindCurling(fSeeds, event,2); // find multi found tracks
+  FindSplitted(fSeeds, event,2); // find multi found tracks
+
   Int_t ntracks=0;
   Int_t nseed = fSeeds->GetEntriesFast();
   for (Int_t i=0;i<nseed;i++){
@@ -2482,12 +2582,38 @@ Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
 
     seed->PropagateTo(fParam->GetInnerRadiusLow());
     seed->UpdatePoints();
+    AddCovariance(seed);
+    MakeBitmaps(seed);
     AliESDtrack *esd=event->GetTrack(i);
     seed->CookdEdx(0.02,0.6);
     CookLabel(seed,0.1); //For comparison only
+    esd->SetTPCClusterMap(seed->GetClusterMap());
+    esd->SetTPCSharedMap(seed->GetSharedMap());
+    //
+    if (AliTPCReconstructor::StreamLevel()>1 && seed!=0&&esd!=0) {
+      TTreeSRedirector &cstream = *fDebugStreamer;
+      cstream<<"Crefit"<<
+       "Esd.="<<esd<<
+       "Track.="<<seed<<
+       "\n"; 
+    }
+
     if (seed->GetNumberOfClusters()>15){
       esd->UpdateTrackParams(seed,AliESDtrack::kTPCrefit); 
       esd->SetTPCPoints(seed->GetPoints());
+      esd->SetTPCPointsF(seed->GetNFoundable());
+      Int_t ndedx   = seed->GetNCDEDX(0)+seed->GetNCDEDX(1)+seed->GetNCDEDX(2)+seed->GetNCDEDX(3);
+      Float_t sdedx = (seed->GetSDEDX(0)+seed->GetSDEDX(1)+seed->GetSDEDX(2)+seed->GetSDEDX(3))*0.25;
+      Float_t dedx  = seed->GetdEdx();
+      esd->SetTPCsignal(dedx, sdedx, ndedx);
+      //
+      // add seed to the esd track in Calib level
+      //
+      Bool_t storeFriend = gRandom->Rndm()<(kMaxFriendTracks)/Float_t(nseed);
+      if (AliTPCReconstructor::StreamLevel()>0 &&storeFriend){
+       AliTPCseed * seedCopy = new AliTPCseed(*seed, kTRUE); 
+       esd->AddCalibObject(seedCopy);
+      }
       ntracks++;
     }
     else{
@@ -2496,13 +2622,11 @@ Int_t AliTPCtrackerMI::RefitInward(AliESD *event)
   }
   //FindKinks(fSeeds,event);
   Info("RefitInward","Number of refitted tracks %d",ntracks);
-  fEvent =0;
-  //WriteTracks();
   return 0;
 }
 
 
-Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
+Int_t AliTPCtrackerMI::PropagateBack(AliESDEvent *event)
 {
   //
   // back propagation of ESD tracks
@@ -2510,8 +2634,13 @@ Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
 
   fEvent = event;
   fIteration = 1;
-  ReadSeeds(event,0);
-  PropagateBack(fSeeds);
+  ReadSeeds(event,1);
+  PropagateBack(fSeeds); 
+  RemoveUsed2(fSeeds,0.4,0.4,20);
+  //FindCurling(fSeeds, fEvent,1);  
+  FindSplitted(fSeeds, event,1); // find multi found tracks
+
+  //
   Int_t nseed = fSeeds->GetEntriesFast();
   Int_t ntracks=0;
   for (Int_t i=0;i<nseed;i++){
@@ -2519,19 +2648,34 @@ Int_t AliTPCtrackerMI::PropagateBack(AliESD *event)
     if (!seed) continue;
     if (seed->GetKinkIndex(0)<0)  UpdateKinkQualityM(seed);  // update quality informations for kinks
     seed->UpdatePoints();
+    AddCovariance(seed);
     AliESDtrack *esd=event->GetTrack(i);
     seed->CookdEdx(0.02,0.6);
     CookLabel(seed,0.1); //For comparison only
     if (seed->GetNumberOfClusters()>15){
       esd->UpdateTrackParams(seed,AliESDtrack::kTPCout);
       esd->SetTPCPoints(seed->GetPoints());
+      esd->SetTPCPointsF(seed->GetNFoundable());
+      Int_t ndedx   = seed->GetNCDEDX(0)+seed->GetNCDEDX(1)+seed->GetNCDEDX(2)+seed->GetNCDEDX(3);
+      Float_t sdedx = (seed->GetSDEDX(0)+seed->GetSDEDX(1)+seed->GetSDEDX(2)+seed->GetSDEDX(3))*0.25;
+      Float_t dedx  = seed->GetdEdx();
+      esd->SetTPCsignal(dedx, sdedx, ndedx);
       ntracks++;
+      Int_t eventnumber = event->GetEventNumberInFile();// patch 28 fev 06
+      // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number      
+      if (AliTPCReconstructor::StreamLevel()>1 && esd) {
+       (*fDebugStreamer)<<"Cback"<<
+         "Tr0.="<<seed<<
+         "esd.="<<esd<<
+         "EventNrInFile="<<eventnumber<<
+         "\n";       
+      }
     }
   }
   //FindKinks(fSeeds,event);
   Info("PropagateBack","Number of back propagated tracks %d",ntracks);
   fEvent =0;
-  //WriteTracks();
+  
   return 0;
 }
 
@@ -2540,16 +2684,18 @@ void AliTPCtrackerMI::DeleteSeeds()
 {
   //
   //delete Seeds
+
   Int_t nseed = fSeeds->GetEntriesFast();
   for (Int_t i=0;i<nseed;i++){
     AliTPCseed * seed = (AliTPCseed*)fSeeds->At(i);
     if (seed) delete fSeeds->RemoveAt(i);
   }
   delete fSeeds;
+
   fSeeds =0;
 }
 
-void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
+void AliTPCtrackerMI::ReadSeeds(AliESDEvent *event, Int_t direction)
 {
   //
   //read seeds from the event
@@ -2570,8 +2716,11 @@ void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
     ULong_t status=esd->GetStatus();
     if (!(status&AliESDtrack::kTPCin)) continue;
     AliTPCtrack t(*esd);
+    t.SetNumberOfClusters(0);
     //    AliTPCseed *seed = new AliTPCseed(t,t.GetAlpha());
     AliTPCseed *seed = new AliTPCseed(t/*,t.GetAlpha()*/);
+    seed->SetUniqueID(esd->GetID());
+    AddCovariance(seed);   //add systematic ucertainty
     for (Int_t ikink=0;ikink<3;ikink++) {
       Int_t index = esd->GetKinkIndex(ikink);
       seed->GetKinkIndexes()[ikink] = index;
@@ -2588,16 +2737,16 @@ void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
       }
 
     }
-    if ((status==AliESDtrack::kTPCin)&&(direction==1)) seed->ResetCovariance(); 
-    if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance();
+    if (((status&AliESDtrack::kITSout)==0)&&(direction==1)) seed->ResetCovariance(10.); 
+    if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance(10.);
     if ( direction ==2 && ((status & AliESDtrack::kTPCout) == 0) ) {
       fSeeds->AddAt(0,i);
       delete seed;
       continue;    
     }
     if ( direction ==2 &&(status & AliESDtrack::kTRDrefit) > 0 )  {
-      Double_t par0[5],par1[5],x;
-      esd->GetInnerExternalParameters(x,par0);
+      Double_t par0[5],par1[5],alpha,x;
+      esd->GetInnerExternalParameters(alpha,x,par0);
       esd->GetExternalParameters(x,par1);
       Double_t delta1 = TMath::Abs(par0[4]-par1[4])/(0.000000001+TMath::Abs(par0[4]+par1[4]));
       Double_t delta2 = TMath::Abs(par0[3]-par1[3]);
@@ -2605,7 +2754,7 @@ void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
       if (esd->GetTRDncls()>0) trdchi2 = esd->GetTRDchi2()/esd->GetTRDncls();
       //reset covariance if suspicious 
       if ( (delta1>0.1) || (delta2>0.006) ||trdchi2>7.)
-       seed->ResetCovariance();
+       seed->ResetCovariance(10.);
     }
 
     //
@@ -2625,22 +2774,24 @@ void AliTPCtrackerMI::ReadSeeds(AliESD *event, Int_t direction)
       delete seed;
       continue;
     }
-    seed->fEsd = esd;
+    seed->SetESD(esd);
     // sign clusters
-    for (Int_t irow=0;irow<160;irow++){
-      Int_t index = seed->GetClusterIndex2(irow);    
-      if (index>0){ 
-       //
-       AliTPCclusterMI * cl = GetClusterMI(index);
-       seed->fClusterPointer[irow] = cl;
-       if (cl){
-         if ((index & 0x8000)==0){
-           cl->Use(10);  // accepted cluster     
+    if (esd->GetKinkIndex(0)<=0){
+      for (Int_t irow=0;irow<160;irow++){
+       Int_t index = seed->GetClusterIndex2(irow);    
+       if (index>0){ 
+         //
+         AliTPCclusterMI * cl = GetClusterMI(index);
+         seed->SetClusterPointer(irow,cl);
+         if (cl){
+           if ((index & 0x8000)==0){
+             cl->Use(10);  // accepted cluster   
+           }else{
+             cl->Use(6);   // close cluster not accepted
+           }   
          }else{
-           cl->Use(6);   // close cluster not accepted
-         }     
-       }else{
-          Info("ReadSeeds","Not found cluster");
+           Info("ReadSeeds","Not found cluster");
+         }
        }
       }
     }
@@ -2671,7 +2822,7 @@ void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
   Double_t x[5], c[15];
   //  Int_t di = i1-i2;
   //
-  AliTPCseed * seed = new AliTPCseed;
+  AliTPCseed * seed = new AliTPCseed();
   Double_t alpha=fSectors->GetAlpha(), shift=fSectors->GetAlphaShift();
   Double_t cs=cos(alpha), sn=sin(alpha);
   //
@@ -2685,13 +2836,13 @@ void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
 
   Int_t imiddle = (i2+i1)/2;    //middle pad row index
   Double_t xm = GetXrow(imiddle); // radius of middle pad-row
-  const AliTPCRow& krm=GetRow(sec,imiddle); //middle pad -row
+  const AliTPCtrackerRow& krm=GetRow(sec,imiddle); //middle pad -row
   //
   Int_t ns =sec;   
 
-  const AliTPCRow& kr1=GetRow(ns,i1);
-  Double_t ymax  = GetMaxY(i1)-kr1.fDeadZone-1.5;  
-  Double_t ymaxm = GetMaxY(imiddle)-kr1.fDeadZone-1.5;  
+  const AliTPCtrackerRow& kr1=GetRow(ns,i1);
+  Double_t ymax  = GetMaxY(i1)-kr1.GetDeadZone()-1.5;  
+  Double_t ymaxm = GetMaxY(imiddle)-kr1.GetDeadZone()-1.5;  
 
   //
   // change cut on curvature if it can't reach this layer
@@ -2741,10 +2892,10 @@ void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
     for (Int_t dsec = dsec1; dsec<=dsec2;dsec++){
       Int_t sec2 = sec + dsec;
       // 
-      //      AliTPCRow&  kr2  = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
-      //AliTPCRow&  kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
-      AliTPCRow&  kr2  = GetRow((sec2+fkNOS)%fkNOS,i2);
-      AliTPCRow&  kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
+      //      AliTPCtrackerRow&  kr2  = fOuterSec[(sec2+fkNOS)%fkNOS][i2];
+      //AliTPCtrackerRow&  kr2m = fOuterSec[(sec2+fkNOS)%fkNOS][imiddle];
+      AliTPCtrackerRow&  kr2  = GetRow((sec2+fkNOS)%fkNOS,i2);
+      AliTPCtrackerRow&  kr2m = GetRow((sec2+fkNOS)%fkNOS,imiddle);
       Int_t  index1 = TMath::Max(kr2.Find(extraz-0.6-dddz1*TMath::Abs(z1)*0.05)-1,0);
       Int_t  index2 = TMath::Min(kr2.Find(extraz+0.6+dddz2*TMath::Abs(z1)*0.05)+1,kr2);
 
@@ -2881,12 +3032,13 @@ void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
        //      if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
        
         UInt_t index=kr1.GetIndex(is);
-       AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, ns*alpha+shift);
+       seed->~AliTPCseed(); // this does not set the pointer to 0...
+       AliTPCseed *track=new(seed) AliTPCseed(x1, ns*alpha+shift, x, c, index);
        
-       track->fIsSeeding = kTRUE;
-       track->fSeed1 = i1;
-       track->fSeed2 = i2;
-       track->fSeedType=3;
+       track->SetIsSeeding(kTRUE);
+       track->SetSeed1(i1);
+       track->SetSeed2(i2);
+       track->SetSeedType(3);
 
        
        //if (dsec==0) {
@@ -2905,37 +3057,34 @@ void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
        
        
        //Int_t rc = 1;
-       track->fBConstrain =1;
+       track->SetBConstrain(1);
        //      track->fLastPoint = i1+fInnerSec->GetNRows();  // first cluster in track position
-       track->fLastPoint = i1;  // first cluster in track position
-       track->fFirstPoint = track->fLastPoint;
+       track->SetLastPoint(i1);  // first cluster in track position
+       track->SetFirstPoint(track->GetLastPoint());
        
        if (track->GetNumberOfClusters()<(i1-i2)*0.5 || 
-           track->GetNumberOfClusters() < track->fNFoundable*0.6 || 
-           track->fNShared>0.4*track->GetNumberOfClusters() ) {
+           track->GetNumberOfClusters() < track->GetNFoundable()*0.6 || 
+           track->GetNShared()>0.4*track->GetNumberOfClusters() ) {
          seed->Reset();
          seed->~AliTPCseed();
          continue;
        }
        nout1++;
         // Z VERTEX CONDITION
-       Double_t zv;
-        zv = track->GetZ()+track->GetTgl()/track->GetC()*
-         ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
+       Double_t zv, bz=GetBz();
+        if ( !track->GetZAt(0.,bz,zv) ) continue;
        if (TMath::Abs(zv-z3)>cuts[2]) {
          FollowProlongation(*track, TMath::Max(i2-20,0));
-         zv = track->GetZ()+track->GetTgl()/track->GetC()*
-           ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
+          if ( !track->GetZAt(0.,bz,zv) ) continue;
          if (TMath::Abs(zv-z3)>cuts[2]){
            FollowProlongation(*track, TMath::Max(i2-40,0));
-           zv = track->GetZ()+track->GetTgl()/track->GetC()*
-             ( asin(-track->GetEta()) - asin(track->GetX()*track->GetC()-track->GetEta()));
-           if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->fNFoundable*0.7)){
+            if ( !track->GetZAt(0.,bz,zv) ) continue;
+           if (TMath::Abs(zv-z3)>cuts[2] &&(track->GetNumberOfClusters() > track->GetNFoundable()*0.7)){
              // make seed without constrain
              AliTPCseed * track2 = MakeSeed(track,0.2,0.5,1.);
              FollowProlongation(*track2, i2,1);
-             track2->fBConstrain = kFALSE;
-             track2->fSeedType = 1;
+             track2->SetBConstrain(kFALSE);
+             track2->SetSeedType(1);
              arr->AddLast(track2); 
              seed->Reset();
              seed->~AliTPCseed();
@@ -2949,13 +3098,13 @@ void AliTPCtrackerMI::MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
            }
          }
        }
-       
-       track->fSeedType =0;
+      
+       track->SetSeedType(0);
        arr->AddLast(track); 
        seed = new AliTPCseed;  
        nout2++;
        // don't consider other combinations
-       if (track->GetNumberOfClusters() > track->fNFoundable*0.8)
+       if (track->GetNumberOfClusters() > track->GetNFoundable()*0.8)
          break;
       }
     }
@@ -2999,25 +3148,25 @@ void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
 
   // first 3 padrows
   Double_t x1 = GetXrow(i1-1);
-  const    AliTPCRow& kr1=GetRow(sec,i1-1);
-  Double_t y1max  = GetMaxY(i1-1)-kr1.fDeadZone-1.5;  
+  const    AliTPCtrackerRow& kr1=GetRow(sec,i1-1);
+  Double_t y1max  = GetMaxY(i1-1)-kr1.GetDeadZone()-1.5;  
   //
   Double_t x1p = GetXrow(i1);
-  const    AliTPCRow& kr1p=GetRow(sec,i1);
+  const    AliTPCtrackerRow& kr1p=GetRow(sec,i1);
   //
   Double_t x1m = GetXrow(i1-2);
-  const    AliTPCRow& kr1m=GetRow(sec,i1-2);
+  const    AliTPCtrackerRow& kr1m=GetRow(sec,i1-2);
 
   //
   //last 3 padrow for seeding
-  AliTPCRow&  kr3  = GetRow((sec+fkNOS)%fkNOS,i1-7);
+  AliTPCtrackerRow&  kr3  = GetRow((sec+fkNOS)%fkNOS,i1-7);
   Double_t    x3   =  GetXrow(i1-7);
   //  Double_t    y3max= GetMaxY(i1-7)-kr3.fDeadZone-1.5;  
   //
-  AliTPCRow&  kr3p  = GetRow((sec+fkNOS)%fkNOS,i1-6);
+  AliTPCtrackerRow&  kr3p  = GetRow((sec+fkNOS)%fkNOS,i1-6);
   Double_t    x3p   = GetXrow(i1-6);
   //
-  AliTPCRow&  kr3m  = GetRow((sec+fkNOS)%fkNOS,i1-8);
+  AliTPCtrackerRow&  kr3m  = GetRow((sec+fkNOS)%fkNOS,i1-8);
   Double_t    x3m   = GetXrow(i1-8);
 
   //
@@ -3025,7 +3174,7 @@ void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
   // middle padrow
   Int_t im = i1-4;                           //middle pad row index
   Double_t xm         = GetXrow(im);         // radius of middle pad-row
-  const AliTPCRow& krm=GetRow(sec,im);   //middle pad -row
+  const AliTPCtrackerRow& krm=GetRow(sec,im);   //middle pad -row
   //  Double_t ymmax = GetMaxY(im)-kr1.fDeadZone-1.5;  
   //
   //
@@ -3172,14 +3321,15 @@ void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
       //       if (!BuildSeed(kr1[is],kcl,0,x1,x2,x3,x,c)) continue;
       
       UInt_t index=kr1.GetIndex(is);
-      AliTPCseed *track=new(seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
+      seed->~AliTPCseed();
+      AliTPCseed *track=new(seed) AliTPCseed(x1, sec*alpha+shift, x, c, index);
       
-      track->fIsSeeding = kTRUE;
+      track->SetIsSeeding(kTRUE);
 
       nin++;      
       FollowProlongation(*track, i1-7,1);
-      if (track->GetNumberOfClusters() < track->fNFoundable*0.75 || 
-         track->fNShared>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
+      if (track->GetNumberOfClusters() < track->GetNFoundable()*0.75 || 
+         track->GetNShared()>0.6*track->GetNumberOfClusters() || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.6){
        seed->Reset();
        seed->~AliTPCseed();
        continue;
@@ -3188,13 +3338,13 @@ void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
       nout2++; 
       //Int_t rc = 1;
       FollowProlongation(*track, i2,1);
-      track->fBConstrain =0;
-      track->fLastPoint = i1+fInnerSec->GetNRows();  // first cluster in track position
-      track->fFirstPoint = track->fLastPoint;
+      track->SetBConstrain(0);
+      track->SetLastPoint(i1+fInnerSec->GetNRows());  // first cluster in track position
+      track->SetFirstPoint(track->GetLastPoint());
       
       if (track->GetNumberOfClusters()<(i1-i2)*0.5 || 
-         track->GetNumberOfClusters()<track->fNFoundable*0.7 || 
-         track->fNShared>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
+         track->GetNumberOfClusters()<track->GetNFoundable()*0.7 || 
+         track->GetNShared()>2. || track->GetChi2()/track->GetNumberOfClusters()>6 || ( track->GetSigmaY2()+ track->GetSigmaZ2())>0.5 ) {
        seed->Reset();
        seed->~AliTPCseed();
        continue;
@@ -3204,8 +3354,8 @@ void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
        FollowProlongation(*track, TMath::Max(i2-10,0),1);
        AliTPCseed * track2 = MakeSeed(track,0.2,0.5,0.9);
        FollowProlongation(*track2, i2,1);
-       track2->fBConstrain = kFALSE;
-       track2->fSeedType = 4;
+       track2->SetBConstrain(kFALSE);
+       track2->SetSeedType(4);
        arr->AddLast(track2); 
        seed->Reset();
        seed->~AliTPCseed();
@@ -3248,8 +3398,8 @@ void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
   //  Double_t cs=cos(alpha), sn=sin(alpha);
   Int_t row0 = (i1+i2)/2;
   Int_t drow = (i1-i2)/2;
-  const AliTPCRow& kr0=fSectors[sec][row0];
-  AliTPCRow * kr=0;
+  const AliTPCtrackerRow& kr0=fSectors[sec][row0];
+  AliTPCtrackerRow * kr=0;
 
   AliTPCpolyTrack polytrack;
   Int_t nclusters=fSectors[sec][row0];
@@ -3262,8 +3412,8 @@ void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
     Int_t nfound =0;
     Int_t nfoundable =0;
     for (Int_t iter =1; iter<2; iter++){   //iterations
-      const AliTPCRow& krm=fSectors[sec][row0-iter];
-      const AliTPCRow& krp=fSectors[sec][row0+iter];      
+      const AliTPCtrackerRow& krm=fSectors[sec][row0-iter];
+      const AliTPCtrackerRow& krp=fSectors[sec][row0+iter];      
       const AliTPCclusterMI * cl= kr0[is];
       
       if (cl->IsUsed(10)) {
@@ -3283,7 +3433,7 @@ void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
       Float_t erry = 0;
       Float_t errz = 0;
       
-      Double_t ymax = fSectors->GetMaxY(row0)-kr0.fDeadZone-1.5;
+      Double_t ymax = fSectors->GetMaxY(row0)-kr0.GetDeadZone()-1.5;
       if (deltay>0 && TMath::Abs(ymax-TMath::Abs(y0))> deltay ) continue;  // seed only at the edge
       
       erry = (0.5)*cl->GetSigmaY2()/TMath::Sqrt(cl->GetQ())*6;     
@@ -3332,7 +3482,7 @@ void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
          Int_t row = row0+ddrow*delta;
          kr = &(fSectors[sec][row]);
          Double_t xn = kr->GetX();
-         Double_t ymax = fSectors->GetMaxY(row)-kr->fDeadZone-1.5;
+         Double_t ymax = fSectors->GetMaxY(row)-kr->GetDeadZone()-1.5;
          polytrack.GetFitPoint(xn,yn,zn);
          if (TMath::Abs(yn)>ymax) continue;
          nfoundable++;
@@ -3451,18 +3601,19 @@ void AliTPCtrackerMI::MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
 
        UInt_t index=0;
        //kr0.GetIndex(is);
-       AliTPCseed *track=new (seed) AliTPCseed(index, x, c, x1, sec*alpha+shift);
-       track->fIsSeeding = kTRUE;
+       seed->~AliTPCseed();
+       AliTPCseed *track=new(seed) AliTPCseed(x1,sec*alpha+shift,x,c,index);
+       track->SetIsSeeding(kTRUE);
        Int_t rc=FollowProlongation(*track, i2);        
-       if (constrain) track->fBConstrain =1;
+       if (constrain) track->SetBConstrain(1);
        else
-         track->fBConstrain =0;
-       track->fLastPoint = row1+fInnerSec->GetNRows();  // first cluster in track position
-       track->fFirstPoint = track->fLastPoint;
+         track->SetBConstrain(0);
+       track->SetLastPoint(row1+fInnerSec->GetNRows());  // first cluster in track position
+       track->SetFirstPoint(track->GetLastPoint());
 
        if (rc==0 || track->GetNumberOfClusters()<(i1-i2)*0.5 || 
-           track->GetNumberOfClusters() < track->fNFoundable*0.6 || 
-           track->fNShared>0.4*track->GetNumberOfClusters()) {
+           track->GetNumberOfClusters() < track->GetNFoundable()*0.6 || 
+           track->GetNShared()>0.4*track->GetNumberOfClusters()) {
          //delete track;
          seed->Reset();
          seed->~AliTPCseed();
@@ -3492,19 +3643,18 @@ AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1,
   Int_t p2 = int(r2*track->GetNumberOfClusters());   // last point
   Int_t pp2=0;
   Double_t  x0[3],x1[3],x2[3];
-  x0[0]=-1;
-  x0[0]=-1;
-  x0[0]=-1;
+  for (Int_t i=0;i<3;i++){
+    x0[i]=-1;
+    x1[i]=-1;
+    x2[i]=-1;
+  }
 
   // find track position at given ratio of the length
-  Int_t  sec0, sec1, sec2;
-  sec0=0;
-  sec1=0;
-  sec2=0;
+  Int_t  sec0=0, sec1=0, sec2=0;
   Int_t index=-1;
   Int_t clindex;
   for (Int_t i=0;i<160;i++){
-    if (track->fClusterPointer[i]){
+    if (track->GetClusterPointer(i)){
       index++;
       AliTPCTrackerPoint   *trpoint =track->GetTrackPoint(i);
       if ( (index<p0) || x0[0]<0 ){
@@ -3601,14 +3751,14 @@ AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *track, Float_t r0, Float_t r1,
   c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
   
   //  Int_t row1 = fSectors->GetRowNumber(x2[0]);
-  AliTPCseed *seed=new  AliTPCseed(0, x, c, x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift());
+  AliTPCseed *seed=new  AliTPCseed(x2[0], sec2*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
   //  Double_t y0,z0,y1,z1, y2,z2;
   //seed->GetProlongation(x0[0],y0,z0);
   // seed->GetProlongation(x1[0],y1,z1);
   //seed->GetProlongation(x2[0],y2,z2);
   //  seed =0;
-  seed->fLastPoint  = pp2;
-  seed->fFirstPoint = pp2;
+  seed->SetLastPoint(pp2);
+  seed->SetFirstPoint(pp2);
   
 
   return seed;
@@ -3721,9 +3871,9 @@ AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track, Float_t r0, Float_t r1, F
   c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
   
   //  Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
-  AliTPCseed *seed=new  AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
-  seed->fLastPoint  = row[2];
-  seed->fFirstPoint = row[2];  
+  AliTPCseed *seed=new  AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
+  seed->SetLastPoint(row[2]);
+  seed->SetFirstPoint(row[2]);  
   return seed;
 }
 
@@ -3778,109 +3928,689 @@ AliTPCseed *AliTPCtrackerMI::ReSeed(AliTPCseed *track,Int_t r0, Bool_t forward)
        row[1] = irow;
        break;
       }
-    } 
-  }
-  //
-  if ((row[2]-row[0])<20) return 0;
-  if (row[1]==0) return 0;
-  //
-  //
-  //Get cluster and sector position
-  for (Int_t ipoint=0;ipoint<3;ipoint++){
-    Int_t clindex = track->GetClusterIndex2(row[ipoint]);
-    AliTPCclusterMI * cl = GetClusterMI(clindex);
-    if (cl==0) {
-      //Error("Bug\n");
-      //      AliTPCclusterMI * cl = GetClusterMI(clindex);
-      return 0;
-    }
-    sec[ipoint]     = ((clindex&0xff000000)>>24)%18;
-    xyz[ipoint][0]  = GetXrow(row[ipoint]);
-    AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);    
-    if (point&&ipoint<2){
-      //
-       xyz[ipoint][1]  = point->GetY();
-       xyz[ipoint][2]  = point->GetZ();
-    }
-    else{
-      xyz[ipoint][1]  = cl->GetY();
-      xyz[ipoint][2]  = cl->GetZ();
+    } 
+  }
+  //
+  if ((row[2]-row[0])<20) return 0;
+  if (row[1]==0) return 0;
+  //
+  //
+  //Get cluster and sector position
+  for (Int_t ipoint=0;ipoint<3;ipoint++){
+    Int_t clindex = track->GetClusterIndex2(row[ipoint]);
+    AliTPCclusterMI * cl = GetClusterMI(clindex);
+    if (cl==0) {
+      //Error("Bug\n");
+      //      AliTPCclusterMI * cl = GetClusterMI(clindex);
+      return 0;
+    }
+    sec[ipoint]     = ((clindex&0xff000000)>>24)%18;
+    xyz[ipoint][0]  = GetXrow(row[ipoint]);
+    AliTPCTrackerPoint * point = track->GetTrackPoint(row[ipoint]);    
+    if (point&&ipoint<2){
+      //
+       xyz[ipoint][1]  = point->GetY();
+       xyz[ipoint][2]  = point->GetZ();
+    }
+    else{
+      xyz[ipoint][1]  = cl->GetY();
+      xyz[ipoint][2]  = cl->GetZ();
+    }
+  }
+  //
+  //
+  //
+  //
+  // Calculate seed state vector and covariance matrix
+
+  Double_t alpha, cs,sn, xx2,yy2;
+  //
+  alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
+  cs = TMath::Cos(alpha);
+  sn = TMath::Sin(alpha); 
+  xx2= xyz[1][0]*cs-xyz[1][1]*sn;
+  yy2= xyz[1][0]*sn+xyz[1][1]*cs;
+  xyz[1][0] = xx2;
+  xyz[1][1] = yy2;
+  //
+  alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
+  cs = TMath::Cos(alpha);
+  sn = TMath::Sin(alpha); 
+  xx2= xyz[0][0]*cs-xyz[0][1]*sn;
+  yy2= xyz[0][0]*sn+xyz[0][1]*cs;
+  xyz[0][0] = xx2;
+  xyz[0][1] = yy2;
+  //
+  //
+  //
+  Double_t x[5],c[15];
+  //
+  x[0]=xyz[2][1];
+  x[1]=xyz[2][2];
+  x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
+  x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
+  x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
+  //  
+  Double_t sy =0.1,  sz =0.1;
+  //
+  Double_t sy1=0.2, sz1=0.2;
+  Double_t sy2=0.2, sz2=0.2;
+  Double_t sy3=0.2;
+  //
+  Double_t f40=(F1(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[4])/sy;
+  Double_t f42=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[4])/sy;
+  Double_t f43=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[4])/sy;
+  Double_t f20=(F2(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[2])/sy;
+  Double_t f22=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[2])/sy;
+  Double_t f23=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[2])/sy;
+  //
+  Double_t f30=(F3(xyz[2][0],xyz[2][1]+sy,xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2])-x[3])/sy;
+  Double_t f31=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2]+sz,xyz[0][2])-x[3])/sz;
+  Double_t f32=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1]+sy,xyz[2][2],xyz[0][2])-x[3])/sy;
+  Double_t f34=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2]+sz)-x[3])/sz;
+  
+  
+  c[0]=sy1;
+  c[1]=0.;       c[2]=sz1;
+  c[3]=f20*sy1;  c[4]=0.;       c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
+  c[6]=f30*sy1;  c[7]=f31*sz1;  c[8]=f30*sy1*f20+f32*sy2*f22;
+  c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
+  c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
+  c[13]=f30*sy1*f40+f32*sy2*f42;
+  c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
+  
+  //  Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
+  AliTPCseed *seed=new  AliTPCseed(xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift(), x, c, 0);
+  seed->SetLastPoint(row[2]);
+  seed->SetFirstPoint(row[2]);  
+  for (Int_t i=row[0];i<row[2];i++){
+    seed->SetClusterIndex(i, track->GetClusterIndex(i));
+  }
+
+  return seed;
+}
+
+
+
+void  AliTPCtrackerMI::FindMultiMC(TObjArray * array, AliESDEvent */*esd*/, Int_t iter)
+{
+  //
+  //  find multi tracks - THIS FUNCTION IS ONLY FOR DEBUG PURPOSES
+  //                      USES MC LABELS
+  //  Use AliTPCReconstructor::StreamLevel()>2 if you want to tune parameters - cuts
+  //
+  //  Two reasons to have multiple find tracks
+  //  1. Curling tracks can be find more than once
+  //  2. Splitted tracks 
+  //     a.) Multiple seeding to increase tracking efficiency - (~ 100% reached)        
+  //     b.) Edge effect on the sector boundaries
+  //
+  //
+  //  Algorithm done in 2 phases - because of CPU consumption
+  //  it is n^2 algorithm - for lead-lead 20000x20000 combination are investigated                           
+  //
+  //  Algorihm for curling tracks sign:
+  //    1 phase -makes a very rough fast cuts to minimize combinatorics
+  //                 a.) opposite sign
+  //                 b.) one of the tracks - not pointing to the primary vertex - 
+  //                 c.) delta tan(theta)
+  //                 d.) delta phi
+  //    2 phase - calculates DCA between tracks  - time consument
+
+  //
+  //    fast cuts 
+  //
+  //    General cuts    - for splitted tracks and for curling tracks
+  //
+  const Float_t kMaxdPhi      = 0.2;  // maximal distance in phi
+  //
+  //    Curling tracks cuts
+  //
+  //
+  //
+  //
+  Int_t nentries = array->GetEntriesFast();  
+  AliHelix *helixes      = new AliHelix[nentries];
+  Float_t  *xm           = new Float_t[nentries];
+  Float_t  *dz0           = new Float_t[nentries];
+  Float_t  *dz1           = new Float_t[nentries];
+  //
+  //
+  TStopwatch timer;
+  timer.Start();
+  //
+  // Find track COG in x direction - point with best defined parameters
+  //
+  for (Int_t i=0;i<nentries;i++){
+    AliTPCseed* track = (AliTPCseed*)array->At(i);    
+    if (!track) continue;
+    track->SetCircular(0);
+    new (&helixes[i]) AliHelix(*track);
+    Int_t ncl=0;
+    xm[i]=0;
+    Float_t dz[2];
+    track->GetDZ(GetX(),GetY(),GetZ(),GetBz(),dz);
+    dz0[i]=dz[0];
+    dz1[i]=dz[1];
+    for (Int_t icl=0; icl<160; icl++){
+      AliTPCclusterMI * cl =  track->GetClusterPointer(icl);
+      if (cl) {
+       xm[i]+=cl->GetX();
+       ncl++;
+      }
+    }
+    if (ncl>0) xm[i]/=Float_t(ncl);
+  }  
+  TTreeSRedirector &cstream = *fDebugStreamer;
+  //
+  for (Int_t i0=0;i0<nentries;i0++){
+    AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
+    if (!track0) continue;    
+    Float_t xc0 = helixes[i0].GetHelix(6);
+    Float_t yc0 = helixes[i0].GetHelix(7);
+    Float_t r0  = helixes[i0].GetHelix(8);
+    Float_t rc0 = TMath::Sqrt(xc0*xc0+yc0*yc0);
+    Float_t fi0 = TMath::ATan2(yc0,xc0);
+    
+    for (Int_t i1=i0+1;i1<nentries;i1++){
+      AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
+      if (!track1) continue;      
+      Int_t lab0=track0->GetLabel();
+      Int_t lab1=track1->GetLabel();
+      if (TMath::Abs(lab0)!=TMath::Abs(lab1)) continue;
+      //
+      Float_t xc1 = helixes[i1].GetHelix(6);
+      Float_t yc1 = helixes[i1].GetHelix(7);
+      Float_t r1  = helixes[i1].GetHelix(8);
+      Float_t rc1 = TMath::Sqrt(xc1*xc1+yc1*yc1);
+      Float_t fi1 = TMath::ATan2(yc1,xc1);
+      //
+      Float_t dfi = fi0-fi1;
+      //
+      //
+      if (dfi>1.5*TMath::Pi())  dfi-=TMath::Pi();  // take care about edge effect 
+      if (dfi<-1.5*TMath::Pi()) dfi+=TMath::Pi();  // 
+      if (TMath::Abs(dfi)>kMaxdPhi&&helixes[i0].GetHelix(4)*helixes[i1].GetHelix(4)<0){
+       //
+       // if short tracks with undefined sign 
+       fi1 =  -TMath::ATan2(yc1,-xc1);
+       dfi = fi0-fi1;
+      }
+      Float_t dtheta = TMath::Abs(track0->GetTgl()-track1->GetTgl())<TMath::Abs(track0->GetTgl()+track1->GetTgl())? track0->GetTgl()-track1->GetTgl():track0->GetTgl()+track1->GetTgl();
+      
+      //
+      // debug stream to tune "fast cuts" 
+      //
+      Double_t dist[3];   // distance at X 
+      Double_t mdist[3]={0,0,0};  // mean distance X+-40cm
+      track0->GetDistance(track1,0.5*(xm[i0]+xm[i1])-40.,dist,AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[i]);
+      track0->GetDistance(track1,0.5*(xm[i0]+xm[i1])+40.,dist,AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[i]);
+      track0->GetDistance(track1,0.5*(xm[i0]+xm[i1]),dist,AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[i]);
+      for (Int_t i=0;i<3;i++) mdist[i]*=0.33333;
+      
+      Float_t sum =0;
+      Float_t sums=0;
+      for (Int_t icl=0; icl<160; icl++){
+       AliTPCclusterMI * cl0 =  track0->GetClusterPointer(icl);
+       AliTPCclusterMI * cl1 =  track1->GetClusterPointer(icl);
+       if (cl0&&cl1) {
+         sum++;
+         if (cl0==cl1) sums++;
+       }
+      }
+      //
+      cstream<<"Multi"<<
+       "iter="<<iter<<
+       "lab0="<<lab0<<
+       "lab1="<<lab1<<   
+       "Tr0.="<<track0<<       // seed0
+       "Tr1.="<<track1<<       // seed1
+       "h0.="<<&helixes[i0]<<
+       "h1.="<<&helixes[i1]<<
+       //
+       "sum="<<sum<<           //the sum of rows with cl in both
+       "sums="<<sums<<         //the sum of shared clusters
+       "xm0="<<xm[i0]<<        // the center of track
+       "xm1="<<xm[i1]<<        // the x center of track
+       // General cut variables                   
+       "dfi="<<dfi<<           // distance in fi angle
+       "dtheta="<<dtheta<<     // distance int theta angle
+       //
+       "dz00="<<dz0[i0]<<
+       "dz01="<<dz0[i1]<<
+       "dz10="<<dz1[i1]<<
+       "dz11="<<dz1[i1]<<
+       "dist0="<<dist[0]<<     //distance x
+       "dist1="<<dist[1]<<     //distance y
+       "dist2="<<dist[2]<<     //distance z
+       "mdist0="<<mdist[0]<<   //distance x
+       "mdist1="<<mdist[1]<<   //distance y
+       "mdist2="<<mdist[2]<<   //distance z
+       //
+       "r0="<<r0<<
+       "rc0="<<rc0<<
+       "fi0="<<fi0<<
+       "fi1="<<fi1<<
+       "r1="<<r1<<
+       "rc1="<<rc1<<
+       "\n";
+    }
+  }    
+  delete [] helixes;
+  delete [] xm;
+  if (AliTPCReconstructor::StreamLevel()>1) {
+    AliInfo("Time for curling tracks removal DEBUGGING MC");
+    timer.Print();
+  }
+}
+
+
+void  AliTPCtrackerMI::FindSplitted(TObjArray * array, AliESDEvent */*esd*/, Int_t iter)
+{
+  //
+  //
+  //  Two reasons to have multiple find tracks
+  //  1. Curling tracks can be find more than once
+  //  2. Splitted tracks 
+  //     a.) Multiple seeding to increase tracking efficiency - (~ 100% reached)        
+  //     b.) Edge effect on the sector boundaries
+  //
+  //  This function tries to find tracks closed in the parametric space
+  //
+  // cut logic if distance is bigger than cut continue - Do Nothing
+  const Float_t kMaxdTheta    = 0.05;  // maximal distance in theta
+  const Float_t kMaxdPhi      = 0.05;   // maximal deistance in phi
+  const Float_t kdelta        = 40.;   //delta r to calculate track distance
+  //
+  //  const Float_t kMaxDist0     = 1.;    // maximal distance 0 
+  //const Float_t kMaxDist1     = 0.3;   // maximal distance 1 - cut if track in separate rows 
+  //
+  /*
+    TCut csec("csec","abs(Tr0.fRelativeSector-Tr1.fRelativeSector)<2");
+    TCut cdtheta("cdtheta","abs(dtheta)<0.05");
+  */ 
+  //
+  //
+  //
+  Int_t nentries = array->GetEntriesFast();  
+  AliHelix *helixes      = new AliHelix[nentries];
+  Float_t  *xm           = new Float_t[nentries];
+  //
+  //
+  TStopwatch timer;
+  timer.Start();
+  //
+  //Sort tracks according quality
+  //
+  Int_t nseed = array->GetEntriesFast();  
+  Float_t * quality = new Float_t[nseed];
+  Int_t   * indexes = new Int_t[nseed];
+  for (Int_t i=0; i<nseed; i++) {
+    AliTPCseed *pt=(AliTPCseed*)array->UncheckedAt(i);    
+    if (!pt){
+      quality[i]=-1;
+      continue;
+    }
+    pt->UpdatePoints();    //select first last max dens points
+    Float_t * points = pt->GetPoints();
+    if (points[3]<0.8) quality[i] =-1;
+    quality[i] = (points[2]-points[0])+pt->GetNumberOfClusters();
+    //prefer high momenta tracks if overlaps
+    quality[i] *= TMath::Sqrt(TMath::Abs(pt->Pt())+0.5); 
+  }
+  TMath::Sort(nseed,quality,indexes);
+
+
+  //
+  // Find track COG in x direction - point with best defined parameters
+  //
+  for (Int_t i=0;i<nentries;i++){
+    AliTPCseed* track = (AliTPCseed*)array->At(i);    
+    if (!track) continue;
+    track->SetCircular(0);
+    new (&helixes[i]) AliHelix(*track);
+    Int_t ncl=0;
+    xm[i]=0;
+    for (Int_t icl=0; icl<160; icl++){
+      AliTPCclusterMI * cl =  track->GetClusterPointer(icl);
+      if (cl) {
+       xm[i]+=cl->GetX();
+       ncl++;
+      }
+    }
+    if (ncl>0) xm[i]/=Float_t(ncl);
+  }  
+  TTreeSRedirector &cstream = *fDebugStreamer;
+  //
+  for (Int_t is0=0;is0<nentries;is0++){
+    Int_t i0 = indexes[is0];
+    AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
+    if (!track0) continue;     
+    if (track0->GetKinkIndexes()[0]!=0) continue;
+    Float_t xc0 = helixes[i0].GetHelix(6);
+    Float_t yc0 = helixes[i0].GetHelix(7);
+    Float_t fi0 = TMath::ATan2(yc0,xc0);
+    
+    for (Int_t is1=is0+1;is1<nentries;is1++){
+      Int_t i1 = indexes[is1];
+      AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
+      if (!track1) continue;      
+      //
+      if (TMath::Abs(track0->GetRelativeSector()-track1->GetRelativeSector())>1) continue;
+      if (track1->GetKinkIndexes()[0]>0 &&track0->GetKinkIndexes()[0]<0) continue;
+      if (track1->GetKinkIndexes()[0]!=0) continue;
+
+      Float_t dtheta = TMath::Abs(track0->GetTgl()-track1->GetTgl())<TMath::Abs(track0->GetTgl()+track1->GetTgl())? track0->GetTgl()-track1->GetTgl():track0->GetTgl()+track1->GetTgl();
+      if (TMath::Abs(dtheta)>kMaxdTheta) continue;      
+      //
+      Float_t xc1 = helixes[i1].GetHelix(6);
+      Float_t yc1 = helixes[i1].GetHelix(7);
+      Float_t fi1 = TMath::ATan2(yc1,xc1);
+      //
+      Float_t dfi = fi0-fi1;
+      if (dfi>1.5*TMath::Pi())  dfi-=TMath::Pi();  // take care about edge effect 
+      if (dfi<-1.5*TMath::Pi()) dfi+=TMath::Pi();  // 
+      if (TMath::Abs(dfi)>kMaxdPhi&&helixes[i0].GetHelix(4)*helixes[i1].GetHelix(4)<0){
+       //
+       // if short tracks with undefined sign 
+       fi1 =  -TMath::ATan2(yc1,-xc1);
+       dfi = fi0-fi1;
+      }
+      if (TMath::Abs(dfi)>kMaxdPhi) continue;
+      //
+      //      
+      Float_t sum =0;
+      Float_t sums=0;
+      Float_t sum0=0;
+      Float_t sum1=0;
+      for (Int_t icl=0; icl<160; icl++){
+       Int_t index0=track0->GetClusterIndex2(icl);
+       Int_t index1=track1->GetClusterIndex2(icl);       
+       Bool_t used0 = (index0>0 && !(index0&0x8000));
+       Bool_t used1 = (index1>0 && !(index1&0x8000));
+       //
+       if (used0) sum0++;  // used cluster0
+       if (used1) sum1++;  // used clusters1
+       if (used0&&used1) sum++;
+       if (index0==index1 && used0 && used1) sums++;
+      } 
+     
+      //
+      if (sums<10) continue;
+      if (sum<40) continue;
+      if (sums/Float_t(TMath::Min(sum0,sum1))<0.5) continue;
+      //
+      Double_t dist[5][4];   // distance at X 
+      Double_t mdist[4]={0,0,0,0};  // mean distance on range +-delta
+     
+      //
+      //            
+      track0->GetDistance(track1,xm[i0],dist[0],AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[0][i]);
+      track0->GetDistance(track1,xm[i1],dist[1],AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[1][i]);
+      //
+      track0->GetDistance(track1,TMath::Min(xm[i1],xm[i0])-kdelta,dist[2],AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[2][i]);
+      track0->GetDistance(track1,TMath::Max(xm[i1],xm[i0])+kdelta,dist[3],AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[3][i]);     
+      //
+      track0->GetDistance(track1,(xm[i1]+xm[i0])*0.5,dist[4],AliTracker::GetBz());
+      for (Int_t i=0;i<3;i++) mdist[i]+=TMath::Abs(dist[4][i]);     
+      for (Int_t i=0;i<3;i++) mdist[i]*=0.2;
+      //
+      //
+      Int_t lab0=track0->GetLabel();
+      Int_t lab1=track1->GetLabel();
+      cstream<<"Splitted"<<
+       "iter="<<iter<<
+       "lab0="<<lab0<<
+       "lab1="<<lab1<<   
+       "Tr0.="<<track0<<       // seed0
+       "Tr1.="<<track1<<       // seed1
+       "h0.="<<&helixes[i0]<<
+       "h1.="<<&helixes[i1]<<
+       //
+       "sum="<<sum<<           //the sum of rows with cl in both
+       "sum0="<<sum0<<           //the sum of rows with cl in 0 track
+       "sum1="<<sum1<<           //the sum of rows with cl in 1 track
+       "sums="<<sums<<         //the sum of shared clusters
+       "xm0="<<xm[i0]<<        // the center of track
+       "xm1="<<xm[i1]<<        // the x center of track
+       // General cut variables                   
+       "dfi="<<dfi<<           // distance in fi angle
+       "dtheta="<<dtheta<<     // distance int theta angle
+       //
+       //
+       "dist0="<<dist[4][0]<<     //distance x
+       "dist1="<<dist[4][1]<<     //distance y
+       "dist2="<<dist[4][2]<<     //distance z
+       "mdist0="<<mdist[0]<<   //distance x
+       "mdist1="<<mdist[1]<<   //distance y
+       "mdist2="<<mdist[2]<<   //distance z
+
+       "\n";
+      delete array->RemoveAt(i1);
+    }
+  }    
+  delete [] helixes;
+  delete [] xm;
+  AliInfo("Time for splitted tracks removal");
+  timer.Print();
+}
+
+
+
+void  AliTPCtrackerMI::FindCurling(TObjArray * array, AliESDEvent */*esd*/, Int_t iter)
+{
+  //
+  //  find Curling tracks
+  //  Use AliTPCReconstructor::StreamLevel()>1 if you want to tune parameters - cuts
+  //
+  //
+  //  Algorithm done in 2 phases - because of CPU consumption
+  //  it is n^2 algorithm - for lead-lead 20000x20000 combination are investigated                           
+  //  see detal in MC part what can be used to cut
+  //
+  //    
+  //
+  const Float_t kMaxC         = 400;  // maximal curvature to of the track
+  const Float_t kMaxdTheta    = 0.15;  // maximal distance in theta
+  const Float_t kMaxdPhi      = 0.15;  // maximal distance in phi
+  const Float_t kPtRatio      = 0.3; // ratio between pt
+  const Float_t kMinDCAR      = 2.;   // distance to the primary vertex in r - see cpipe cut      
+
+  //
+  //    Curling tracks cuts
+  //
+  //
+  const Float_t kMaxDeltaRMax = 40;   // distance in outer radius
+  const Float_t kMaxDeltaRMin = 5.;   // distance in lower radius - see cpipe cut
+  const Float_t kMinAngle     = 2.9;  // angle between tracks
+  const Float_t kMaxDist      = 5;    // biggest distance 
+  //
+  // The cuts can be tuned using the "MC information stored in Multi tree ==> see FindMultiMC
+  /* 
+     Fast cuts:
+     TCut csign("csign","Tr0.fP[4]*Tr1.fP[4]<0"); //opposite sign
+     TCut cmax("cmax","abs(Tr0.GetC())>1/400");
+     TCut cda("cda","sqrt(dtheta^2+dfi^2)<0.15");
+     TCut ccratio("ccratio","abs((Tr0.fP[4]+Tr1.fP[4])/(abs(Tr0.fP[4])+abs(Tr1.fP[4])))<0.3");
+     TCut cpipe("cpipe", "min(abs(r0-rc0),abs(r1-rc1))>5");    
+     //
+     TCut cdrmax("cdrmax","abs(abs(rc0+r0)-abs(rc1+r1))<40")
+     TCut cdrmin("cdrmin","abs(abs(rc0+r0)-abs(rc1+r1))<10")
+     //
+     Multi->Draw("dfi","iter==0"+csign+cmax+cda+ccratio); ~94% of curling tracks fulfill 
+     Multi->Draw("min(abs(r0-rc0),abs(r1-rc1))","iter==0&&abs(lab1)==abs(lab0)"+csign+cmax+cda+ccratio+cpipe+cdrmin+cdrmax); //80%
+     //
+     Curling2->Draw("dfi","iter==0&&abs(lab0)==abs(lab1)"+csign+cmax+cdtheta+cdfi+ccratio)
+
+  */
+  //  
+  //
+  //
+  Int_t nentries = array->GetEntriesFast();  
+  AliHelix *helixes      = new AliHelix[nentries];
+  for (Int_t i=0;i<nentries;i++){
+    AliTPCseed* track = (AliTPCseed*)array->At(i);    
+    if (!track) continue;
+    track->SetCircular(0);
+    new (&helixes[i]) AliHelix(*track);
+  }
+  //
+  //
+  TStopwatch timer;
+  timer.Start();
+  Double_t phase[2][2],radius[2];
+  //
+  // Find tracks
+  //
+  TTreeSRedirector &cstream = *fDebugStreamer;
+  //
+  for (Int_t i0=0;i0<nentries;i0++){
+    AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
+    if (!track0) continue;    
+    if (TMath::Abs(track0->GetC())<1/kMaxC) continue;
+    Float_t xc0 = helixes[i0].GetHelix(6);
+    Float_t yc0 = helixes[i0].GetHelix(7);
+    Float_t r0  = helixes[i0].GetHelix(8);
+    Float_t rc0 = TMath::Sqrt(xc0*xc0+yc0*yc0);
+    Float_t fi0 = TMath::ATan2(yc0,xc0);
+    
+    for (Int_t i1=i0+1;i1<nentries;i1++){
+      AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
+      if (!track1) continue;      
+      if (TMath::Abs(track1->GetC())<1/kMaxC) continue;    
+      Float_t xc1 = helixes[i1].GetHelix(6);
+      Float_t yc1 = helixes[i1].GetHelix(7);
+      Float_t r1  = helixes[i1].GetHelix(8);
+      Float_t rc1 = TMath::Sqrt(xc1*xc1+yc1*yc1);
+      Float_t fi1 = TMath::ATan2(yc1,xc1);
+      //
+      Float_t dfi = fi0-fi1;
+      //
+      //
+      if (dfi>1.5*TMath::Pi())  dfi-=TMath::Pi();  // take care about edge effect 
+      if (dfi<-1.5*TMath::Pi()) dfi+=TMath::Pi();  // 
+      Float_t dtheta = TMath::Abs(track0->GetTgl()-track1->GetTgl())<TMath::Abs(track0->GetTgl()+track1->GetTgl())? track0->GetTgl()-track1->GetTgl():track0->GetTgl()+track1->GetTgl();
+      //
+      //
+      // FIRST fast cuts
+      if (track0->GetBConstrain()&&track1->GetBConstrain())  continue;  // not constrained
+      if (track1->GetSigned1Pt()*track0->GetSigned1Pt()>0)   continue; // not the same sign
+      if ( TMath::Abs(track1->GetTgl()+track0->GetTgl())>kMaxdTheta) continue; //distance in the Theta
+      if ( TMath::Abs(dfi)>kMaxdPhi) continue;  //distance in phi
+      if ( TMath::Sqrt(dfi*dfi+dtheta*dtheta)>kMaxdPhi) continue; //common angular offset
+      //
+      Float_t pt0 = track0->GetSignedPt();
+      Float_t pt1 = track1->GetSignedPt();
+      if ((TMath::Abs(pt0+pt1)/(TMath::Abs(pt0)+TMath::Abs(pt1)))>kPtRatio) continue;      
+      if ((iter==1) && TMath::Abs(TMath::Abs(rc0+r0)-TMath::Abs(rc1+r1))>kMaxDeltaRMax) continue;
+      if ((iter!=1) &&TMath::Abs(TMath::Abs(rc0-r0)-TMath::Abs(rc1-r1))>kMaxDeltaRMin) continue;
+      if (TMath::Min(TMath::Abs(rc0-r0),TMath::Abs(rc1-r1))<kMinDCAR) continue;
+      //
+      //
+      // Now find closest approach
+      //
+      //
+      //
+      Int_t npoints = helixes[i0].GetRPHIintersections(helixes[i1], phase, radius,10);
+      if (npoints==0) continue;
+      helixes[i0].GetClosestPhases(helixes[i1], phase);
+      //
+      Double_t xyz0[3];
+      Double_t xyz1[3];
+      Double_t hangles[3];
+      helixes[i0].Evaluate(phase[0][0],xyz0);
+      helixes[i1].Evaluate(phase[0][1],xyz1);
+
+      helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
+      Double_t deltah[2],deltabest;
+      if (TMath::Abs(hangles[2])<kMinAngle) continue;
+
+      if (npoints>0){
+       Int_t ibest=0;
+       helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
+       if (npoints==2){
+         helixes[i0].ParabolicDCA(helixes[i1],phase[1][0],phase[1][1],radius[1],deltah[1],2);
+         if (deltah[1]<deltah[0]) ibest=1;
+       }
+       deltabest  = TMath::Sqrt(deltah[ibest]);
+       helixes[i0].Evaluate(phase[ibest][0],xyz0);
+       helixes[i1].Evaluate(phase[ibest][1],xyz1);
+       helixes[i0].GetAngle(phase[ibest][0],helixes[i1],phase[ibest][1],hangles);
+       Double_t radiusbest = TMath::Sqrt(radius[ibest]);
+       //
+       if (deltabest>kMaxDist) continue;
+       //      if (mindcar+mindcaz<40 && (TMath::Abs(hangles[2])<kMinAngle ||deltabest>3)) continue;
+       Bool_t sign =kFALSE;
+       if (hangles[2]>kMinAngle) sign =kTRUE;
+       //
+       if (sign){
+         //      circular[i0] = kTRUE;
+         //      circular[i1] = kTRUE;
+         if (track0->OneOverPt()<track1->OneOverPt()){
+           track0->SetCircular(track0->GetCircular()+1);
+           track1->SetCircular(track1->GetCircular()+2);
+         }
+         else{
+           track1->SetCircular(track1->GetCircular()+1);
+           track0->SetCircular(track0->GetCircular()+2);
+         }
+       }               
+       if (AliTPCReconstructor::StreamLevel()>1){        
+         //
+         //debug stream to tune "fine" cuts      
+         Int_t lab0=track0->GetLabel();
+         Int_t lab1=track1->GetLabel();
+         cstream<<"Curling2"<<
+           "iter="<<iter<<
+           "lab0="<<lab0<<
+           "lab1="<<lab1<<   
+           "Tr0.="<<track0<<
+           "Tr1.="<<track1<<
+           //
+           "r0="<<r0<<
+           "rc0="<<rc0<<
+           "fi0="<<fi0<<
+           "r1="<<r1<<
+           "rc1="<<rc1<<
+           "fi1="<<fi1<<
+           "dfi="<<dfi<<
+           "dtheta="<<dtheta<<
+           //
+           "npoints="<<npoints<<                      
+           "hangles0="<<hangles[0]<<
+           "hangles1="<<hangles[1]<<
+           "hangles2="<<hangles[2]<<                    
+           "xyz0="<<xyz0[2]<<
+           "xyzz1="<<xyz1[2]<<
+           "radius="<<radiusbest<<
+           "deltabest="<<deltabest<< 
+           "phase0="<<phase[ibest][0]<<
+           "phase1="<<phase[ibest][1]<<
+           "\n";                 
+
+       }
+      }
     }
   }
-  //
-  //
-  //
-  //
-  // Calculate seed state vector and covariance matrix
-
-  Double_t alpha, cs,sn, xx2,yy2;
-  //
-  alpha = (sec[1]-sec[2])*fSectors->GetAlpha();
-  cs = TMath::Cos(alpha);
-  sn = TMath::Sin(alpha); 
-  xx2= xyz[1][0]*cs-xyz[1][1]*sn;
-  yy2= xyz[1][0]*sn+xyz[1][1]*cs;
-  xyz[1][0] = xx2;
-  xyz[1][1] = yy2;
-  //
-  alpha = (sec[0]-sec[2])*fSectors->GetAlpha();
-  cs = TMath::Cos(alpha);
-  sn = TMath::Sin(alpha); 
-  xx2= xyz[0][0]*cs-xyz[0][1]*sn;
-  yy2= xyz[0][0]*sn+xyz[0][1]*cs;
-  xyz[0][0] = xx2;
-  xyz[0][1] = yy2;
-  //
-  //
-  //
-  Double_t x[5],c[15];
-  //
-  x[0]=xyz[2][1];
-  x[1]=xyz[2][2];
-  x[4]=F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
-  x[2]=F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]);
-  x[3]=F3n(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2],x[4]);
-  //  
-  Double_t sy =0.1,  sz =0.1;
-  //
-  Double_t sy1=0.2, sz1=0.2;
-  Double_t sy2=0.2, sz2=0.2;
-  Double_t sy3=0.2;
-  //
-  Double_t f40=(F1(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[4])/sy;
-  Double_t f42=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[4])/sy;
-  Double_t f43=(F1(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[4])/sy;
-  Double_t f20=(F2(xyz[2][0],xyz[2][1]+sy,xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1])-x[2])/sy;
-  Double_t f22=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1]+sy,xyz[0][0],xyz[0][1])-x[2])/sy;
-  Double_t f23=(F2(xyz[2][0],xyz[2][1],xyz[1][0],xyz[1][1],xyz[0][0],xyz[0][1]+sy)-x[2])/sy;
-  //
-  Double_t f30=(F3(xyz[2][0],xyz[2][1]+sy,xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2])-x[3])/sy;
-  Double_t f31=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2]+sz,xyz[0][2])-x[3])/sz;
-  Double_t f32=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1]+sy,xyz[2][2],xyz[0][2])-x[3])/sy;
-  Double_t f34=(F3(xyz[2][0],xyz[2][1],xyz[0][0],xyz[0][1],xyz[2][2],xyz[0][2]+sz)-x[3])/sz;
-  
-  
-  c[0]=sy1;
-  c[1]=0.;       c[2]=sz1;
-  c[3]=f20*sy1;  c[4]=0.;       c[5]=f20*sy1*f20+f22*sy2*f22+f23*sy3*f23;
-  c[6]=f30*sy1;  c[7]=f31*sz1;  c[8]=f30*sy1*f20+f32*sy2*f22;
-  c[9]=f30*sy1*f30+f31*sz1*f31+f32*sy2*f32+f34*sz2*f34;
-  c[10]=f40*sy1; c[11]=0.; c[12]=f40*sy1*f20+f42*sy2*f22+f43*sy3*f23;
-  c[13]=f30*sy1*f40+f32*sy2*f42;
-  c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
-  
-  //  Int_t row1 = fSectors->GetRowNumber(xyz[2][0]);
-  AliTPCseed *seed=new  AliTPCseed(0, x, c, xyz[2][0], sec[2]*fSectors->GetAlpha()+fSectors->GetAlphaShift());
-  seed->fLastPoint  = row[2];
-  seed->fFirstPoint = row[2];  
-  for (Int_t i=row[0];i<row[2];i++){
-    seed->fIndex[i] = track->fIndex[i];
+  delete [] helixes;
+  if (AliTPCReconstructor::StreamLevel()>1) {
+    AliInfo("Time for curling tracks removal");
+    timer.Print();
   }
-
-  return seed;
 }
 
-void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
+
+
+
+
+void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESDEvent *esd)
 {
   //
   //  find kinks
@@ -3894,7 +4624,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
   Int_t    *sign         = new Int_t[nentries];
   Int_t    *nclusters    = new Int_t[nentries];
   Float_t  *alpha        = new Float_t[nentries];
-  AliESDkink * kink      = new AliESDkink();
+  AliKink  *kink         = new AliKink();
   Int_t      * usage     = new Int_t[nentries];
   Float_t  *zm           = new Float_t[nentries];
   Float_t  *z0           = new Float_t[nentries]; 
@@ -3914,7 +4644,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
     usage[i]=0;
     AliTPCseed* track = (AliTPCseed*)array->At(i);    
     if (!track) continue;
-    track->fCircular =0;
+    track->SetCircular(0);
     shared[i] = kFALSE;
     track->UpdatePoints();
     if (( track->GetPoints()[2]- track->GetPoints()[0])>5 && track->GetPoints()[3]>0.8){
@@ -3956,20 +4686,20 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
   for (Int_t i0=0;i0<nentries;i0++){
     AliTPCseed * track0 = (AliTPCseed*)array->At(i0);
     if (!track0) continue;    
-    if (track0->fN<40) continue;
-    if (TMath::Abs(1./track0->fP4)>200) continue;
+    if (track0->GetNumberOfClusters()<40) continue;
+    if (TMath::Abs(1./track0->GetC())>200) continue;
     for (Int_t i1=i0+1;i1<nentries;i1++){
       AliTPCseed * track1 = (AliTPCseed*)array->At(i1);
       if (!track1) continue;
-      if (track1->fN<40)                  continue;
-      if ( TMath::Abs(track1->fP3+track0->fP3)>0.1) continue;
-      if (track0->fBConstrain&&track1->fBConstrain) continue;
-      if (TMath::Abs(1./track1->fP4)>200) continue;
-      if (track1->fP4*track0->fP4>0)      continue;
-      if (track1->fP3*track0->fP3>0)      continue;
-      if (max(TMath::Abs(1./track0->fP4),TMath::Abs(1./track1->fP4))>190) continue;
-      if (track0->fBConstrain&&TMath::Abs(track1->fP4)<TMath::Abs(track0->fP4)) continue; //returning - lower momenta
-      if (track1->fBConstrain&&TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)) continue; //returning - lower momenta
+      if (track1->GetNumberOfClusters()<40)                  continue;
+      if ( TMath::Abs(track1->GetTgl()+track0->GetTgl())>0.1) continue;
+      if (track0->GetBConstrain()&&track1->GetBConstrain()) continue;
+      if (TMath::Abs(1./track1->GetC())>200) continue;
+      if (track1->GetSigned1Pt()*track0->GetSigned1Pt()>0)      continue;
+      if (track1->GetTgl()*track0->GetTgl()>0)      continue;
+      if (TMath::Max(TMath::Abs(1./track0->GetC()),TMath::Abs(1./track1->GetC()))>190) continue;
+      if (track0->GetBConstrain()&&track1->OneOverPt()<track0->OneOverPt()) continue; //returning - lower momenta
+      if (track1->GetBConstrain()&&track0->OneOverPt()<track1->OneOverPt()) continue; //returning - lower momenta
       //
       Float_t mindcar = TMath::Min(TMath::Abs(dca[i0]),TMath::Abs(dca[i1]));
       if (mindcar<5)   continue;
@@ -4004,14 +4734,6 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       helixes[i0].GetAngle(phase[0][0],helixes[i1],phase[0][1],hangles);
       Double_t deltah[2],deltabest;
       if (hangles[2]<2.8) continue;
-      /*
-      cstream<<"C"<<track0->fLab<<track1->fLab<<
-       track0->fP3<<track1->fP3<<
-       track0->fP4<<track1->fP4<<
-       delta<<rmean<<npoints<<
-       hangles[0]<<hangles[2]<<
-       xyz0[2]<<xyz1[2]<<radius[0]<<"\n"; 
-      */
       if (npoints>0){
        Int_t ibest=0;
        helixes[i0].ParabolicDCA(helixes[i1],phase[0][0],phase[0][1],radius[0],deltah[0],2);
@@ -4033,20 +4755,22 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
        if (sign){
          circular[i0] = kTRUE;
          circular[i1] = kTRUE;
-         if (TMath::Abs(track0->fP4)<TMath::Abs(track1->fP4)){
-           track0->fCircular += 1;
-           track1->fCircular += 2;
+         if (track0->OneOverPt()<track1->OneOverPt()){
+           track0->SetCircular(track0->GetCircular()+1);
+           track1->SetCircular(track1->GetCircular()+2);
          }
          else{
-           track1->fCircular += 1;
-           track0->fCircular += 2;
+           track1->SetCircular(track1->GetCircular()+1);
+           track0->SetCircular(track0->GetCircular()+2);
          }
        }               
-       if (sign){        
-         //debug stream
+       if (sign&&AliTPCReconstructor::StreamLevel()>1){          
+         //debug stream          
+         Int_t lab0=track0->GetLabel();
+         Int_t lab1=track1->GetLabel();
          cstream<<"Curling"<<
-           "lab0="<<track0->fLab<<
-           "lab1="<<track1->fLab<<   
+           "lab0="<<lab0<<
+           "lab1="<<lab1<<   
            "Tr0.="<<track0<<
            "Tr1.="<<track1<<      
            "dca0="<<dca[i0]<<
@@ -4078,6 +4802,10 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
   for (Int_t i =0;i<nentries;i++){
     if (sign[i]==0) continue;
     AliTPCseed * track0 = (AliTPCseed*)array->At(i);
+    if (track0==0) {
+      AliInfo("seed==0");
+      continue;
+    }
     ntracks++;
     //
     Double_t cradius0 = 40*40;
@@ -4181,7 +4909,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       if (TMath::Abs(ktrack0->GetC())>5) continue; // cut on the curvature for mother particle
       AliExternalTrackParam paramm(*ktrack0);
       AliExternalTrackParam paramd(*ktrack1);
-      if (row0>60&&ktrack1->GetReference().X()>90.) new (&paramd) AliExternalTrackParam(ktrack1->GetReference()); 
+      if (row0>60&&ktrack1->GetReference().GetX()>90.)new (&paramd) AliExternalTrackParam(ktrack1->GetReference()); 
       //
       //
       kink->SetMother(paramm);
@@ -4208,7 +4936,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
 
       if (mpt<1){
        //for high momenta momentum not defined well in first iteration
-       Double_t qt   =  TMath::Sin(kink->GetAngle(2))*ktrack1->P();
+       Double_t qt   =  TMath::Sin(kink->GetAngle(2))*ktrack1->GetP();
        if (qt>0.35) continue; 
       }
       
@@ -4235,12 +4963,12 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
        //      angle and densities  not defined yet
        if (kink->GetTPCDensityFactor()<0.8) continue;
        if ((2-kink->GetTPCDensityFactor())*kink->GetDistance() >0.25) continue;
-       if (kink->GetAngle(2)*ktrack0->P()<0.003) continue; //too small angle
+       if (kink->GetAngle(2)*ktrack0->GetP()<0.003) continue; //too small angle
        if (kink->GetAngle(2)>0.2&&kink->GetTPCDensityFactor()<1.15) continue;
        if (kink->GetAngle(2)>0.2&&kink->GetTPCDensity(0,1)>0.05) continue;
 
-       Float_t criticalangle = track0->fC22+track0->fC33;
-       criticalangle+= track1->fC22+track1->fC33;
+       Float_t criticalangle = track0->GetSigmaSnp2()+track0->GetSigmaTgl2();
+       criticalangle+= track1->GetSigmaSnp2()+track1->GetSigmaTgl2();
        criticalangle= 3*TMath::Sqrt(criticalangle);
        if (criticalangle>0.02) criticalangle=0.02;
        if (kink->GetAngle(2)<criticalangle) continue;
@@ -4252,12 +4980,12 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       for ( Int_t row = row0-drow; row<row0+drow;row++){
        if (row<0) continue;
        if (row>155) continue;
-       if (ktrack0->fClusterPointer[row]){
+       if (ktrack0->GetClusterPointer(row)){
          AliTPCTrackerPoint *point =ktrack0->GetTrackPoint(row);
          shapesum+=point->GetSigmaY()+point->GetSigmaZ();
          sum++;
        }
-       if (ktrack1->fClusterPointer[row]){
+       if (ktrack1->GetClusterPointer(row)){
          AliTPCTrackerPoint *point =ktrack1->GetTrackPoint(row);
          shapesum+=point->GetSigmaY()+point->GetSigmaZ();
          sum++;
@@ -4271,7 +4999,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       }      
       //      esd->AddKink(kink);
       kinks->AddLast(kink);
-      kink = new AliESDkink;
+      kink = new AliKink;
       ncandidates++;
     }
   }
@@ -4287,7 +5015,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
   //
   for (Int_t i=0;i<nkinks;i++){
     quality[i] =100000;
-    AliESDkink *kink = (AliESDkink*)kinks->At(i);
+    AliKink *kink = (AliKink*)kinks->At(i);
     //
     // refit kinks towards vertex
     // 
@@ -4296,7 +5024,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
     AliTPCseed * ktrack0 = (AliTPCseed*)array->At(index0);
     AliTPCseed * ktrack1 = (AliTPCseed*)array->At(index1);
     //
-    Int_t sumn=ktrack0->fN+ktrack1->fN;
+    Int_t sumn=ktrack0->GetNumberOfClusters()+ktrack1->GetNumberOfClusters();
     //
     // Refit Kink under if too small angle
     //
@@ -4308,22 +5036,22 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       //
       Int_t last  = row0-drow;
       if (last<40) last=40;
-      if (last<ktrack0->fFirstPoint+25) last = ktrack0->fFirstPoint+25;
+      if (last<ktrack0->GetFirstPoint()+25) last = ktrack0->GetFirstPoint()+25;
       AliTPCseed* seed0 = ReSeed(ktrack0,last,kFALSE);
       //
       //
       Int_t first = row0+drow;
       if (first>130) first=130;
-      if (first>ktrack1->fLastPoint-25) first = TMath::Max(ktrack1->fLastPoint-25,30);
+      if (first>ktrack1->GetLastPoint()-25) first = TMath::Max(ktrack1->GetLastPoint()-25,30);
       AliTPCseed* seed1 = ReSeed(ktrack1,first,kTRUE);
       //
       if (seed0 && seed1){
        kink->SetStatus(1,8);
        if (RefitKink(*seed0,*seed1,*kink)) kink->SetStatus(1,9);
        row0 = GetRowNumber(kink->GetR());
-       sumn = seed0->fN+seed1->fN;
-       new (&mothers[i])   AliTPCseed(*seed0);
-       new (&daughters[i]) AliTPCseed(*seed1); 
+       sumn = seed0->GetNumberOfClusters()+seed1->GetNumberOfClusters();
+       mothers[i] = *seed0;
+       daughters[i] = *seed1;
       }
       else{
        delete kinks->RemoveAt(i);
@@ -4349,12 +5077,12 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
   //remove double find kinks
   //
   for (Int_t ikink0=1;ikink0<nkinks;ikink0++){
-    AliESDkink * kink0 = (AliESDkink*) kinks->At(indexes[ikink0]);
+    AliKink * kink0 = (AliKink*) kinks->At(indexes[ikink0]);
     if (!kink0) continue;
     //
     for (Int_t ikink1=0;ikink1<ikink0;ikink1++){
       if (!kink0) continue;
-      AliESDkink * kink1 = (AliESDkink*) kinks->At(indexes[ikink1]);
+      AliKink * kink1 = (AliKink*) kinks->At(indexes[ikink1]);
       if (!kink1) continue;
       // if not close kink continue
       if (TMath::Abs(kink1->GetPosition()[2]-kink0->GetPosition()[2])>10) continue;
@@ -4375,10 +5103,10 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       Int_t bothd = 0;
       //
       for (Int_t i=0;i<row0;i++){
-       if (mother0.fIndex[i]>0 && mother1.fIndex[i]>0){
+       if (mother0.GetClusterIndex(i)>0 && mother1.GetClusterIndex(i)>0){
          both++;
          bothm++;
-         if (mother0.fIndex[i]==mother1.fIndex[i]){
+         if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
            same++;
            samem++;
          }
@@ -4386,10 +5114,10 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       }
 
       for (Int_t i=row0;i<158;i++){
-       if (daughter0.fIndex[i]>0 && daughter0.fIndex[i]>0){
+       if (daughter0.GetClusterIndex(i)>0 && daughter0.GetClusterIndex(i)>0){
          both++;
          bothd++;
-         if (mother0.fIndex[i]==mother1.fIndex[i]){
+         if (mother0.GetClusterIndex(i)==mother1.GetClusterIndex(i)){
            same++;
            samed++;
          }
@@ -4399,8 +5127,8 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       Float_t ratiom = Float_t(samem+1)/Float_t(bothm+1);
       Float_t ratiod = Float_t(samed+1)/Float_t(bothd+1);
       if (ratio>0.3 && ratiom>0.5 &&ratiod>0.5) {
-       Int_t sum0 = mother0.fN+daughter0.fN;
-       Int_t sum1 = mother1.fN+daughter1.fN;
+       Int_t sum0 = mother0.GetNumberOfClusters()+daughter0.GetNumberOfClusters();
+       Int_t sum1 = mother1.GetNumberOfClusters()+daughter1.GetNumberOfClusters();
        if (sum1>sum0){
          shared[kink0->GetIndex(0)]= kTRUE;
          shared[kink0->GetIndex(1)]= kTRUE;      
@@ -4417,7 +5145,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
 
 
   for (Int_t i=0;i<nkinks;i++){
-    AliESDkink * kink = (AliESDkink*) kinks->At(indexes[i]);
+    AliKink * kink = (AliKink*) kinks->At(indexes[i]);
     if (!kink) continue;
     kink->SetTPCRow0(GetRowNumber(kink->GetR()));
     Int_t index0 = kink->GetIndex(0);
@@ -4436,15 +5164,15 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
     Int_t index = esd->AddKink(kink);
     //
     //
-    if ( ktrack0->fKinkIndexes[0]==0 && ktrack1->fKinkIndexes[0]==0) {  //best kink
-      if (mothers[indexes[i]].fN>20 && daughters[indexes[i]].fN>20 && (mothers[indexes[i]].fN+daughters[indexes[i]].fN)>100){
-       new (ktrack0) AliTPCseed(mothers[indexes[i]]);
-       new (ktrack1) AliTPCseed(daughters[indexes[i]]);
+    if ( ktrack0->GetKinkIndex(0)==0 && ktrack1->GetKinkIndex(0)==0) {  //best kink
+      if (mothers[indexes[i]].GetNumberOfClusters()>20 && daughters[indexes[i]].GetNumberOfClusters()>20 && (mothers[indexes[i]].GetNumberOfClusters()+daughters[indexes[i]].GetNumberOfClusters())>100){
+       *ktrack0 = mothers[indexes[i]];
+       *ktrack1 = daughters[indexes[i]];
       }
     }
     //
-    ktrack0->fKinkIndexes[usage[index0]] = -(index+1);
-    ktrack1->fKinkIndexes[usage[index1]] =  (index+1);
+    ktrack0->SetKinkIndex(usage[index0],-(index+1));
+    ktrack1->SetKinkIndex(usage[index1], (index+1));
     usage[index0]++;
     usage[index1]++;
   }
@@ -4454,7 +5182,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
   for (Int_t i=0;i<nentries;i++){
     AliTPCseed * track0 = (AliTPCseed*)array->At(i);
     if (!track0) continue;
-    if (track0->fKinkIndexes[0]!=0) continue;
+    if (track0->GetKinkIndex(0)!=0) continue;
     if (shared[i]) delete array->RemoveAt(i);
   }
 
@@ -4476,28 +5204,29 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
     //remove double high momenta tracks - overlapped with kink candidates
     Int_t shared=0;
     Int_t all   =0;
-    for (Int_t icl=track0->fFirstPoint;icl<track0->fLastPoint; icl++){
-      if (track0->fClusterPointer[icl]!=0){
+    for (Int_t icl=track0->GetFirstPoint();icl<track0->GetLastPoint(); icl++){
+      if (track0->GetClusterPointer(icl)!=0){
        all++;
-       if (track0->fClusterPointer[icl]->IsUsed(10)) shared++;
+       if (track0->GetClusterPointer(icl)->IsUsed(10)) shared++;
       }
     }
-    if (Float_t(shared+1)/Float_t(nall+1)>0.5) {
+    if (Float_t(shared+1)/Float_t(all+1)>0.5) {  
       delete array->RemoveAt(i);
+      continue;
     }
     //
-    if (track0->fKinkIndexes[0]!=0) continue;
+    if (track0->GetKinkIndex(0)!=0) continue;
     if (track0->GetNumberOfClusters()<80) continue;
 
     AliTPCseed *pmother = new AliTPCseed();
     AliTPCseed *pdaughter = new AliTPCseed();
-    AliESDkink *pkink = new AliESDkink;
+    AliKink *pkink = new AliKink;
 
     AliTPCseed & mother = *pmother;
     AliTPCseed & daughter = *pdaughter;
-    AliESDkink & kink = *pkink;
+    AliKink & kink = *pkink;
     if (CheckKinkPoint(track0,mother,daughter, kink)){
-      if (mother.fN<30||daughter.fN<20) {
+      if (mother.GetNumberOfClusters()<30||daughter.GetNumberOfClusters()<20) {
        delete pmother;
        delete pdaughter;
        delete pkink;
@@ -4518,9 +5247,9 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       }
       //
       Int_t index = esd->AddKink(&kink);      
-      mother.fKinkIndexes[0] = -(index+1);
-      daughter.fKinkIndexes[0] = index+1;
-      if (mother.fN>50) {
+      mother.SetKinkIndex(0,-(index+1));
+      daughter.SetKinkIndex(0,index+1);
+      if (mother.GetNumberOfClusters()>50) {
        delete array->RemoveAt(i);
        array->AddAt(new AliTPCseed(mother),i);
       }
@@ -4529,11 +5258,11 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
       }
       array->AddLast(new AliTPCseed(daughter));      
       for (Int_t icl=0;icl<row0;icl++) {
-       if (mother.fClusterPointer[icl]) mother.fClusterPointer[icl]->Use(20);
+       if (mother.GetClusterPointer(icl)) mother.GetClusterPointer(icl)->Use(20);
       }
       //
       for (Int_t icl=row0;icl<158;icl++) {
-       if (daughter.fClusterPointer[icl]) daughter.fClusterPointer[icl]->Use(20);
+       if (daughter.GetClusterPointer(icl)) daughter.GetClusterPointer(icl)->Use(20);
       }
       //
     }
@@ -4568,7 +5297,7 @@ void  AliTPCtrackerMI::FindKinks(TObjArray * array, AliESD *esd)
   timer.Print();
 }
 
-void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
+void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESDEvent *esd)
 {
   //
   //  find V0s
@@ -4614,19 +5343,19 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
     // 
     // dca error parrameterezation + pulls
     //
-    sdcar[i]      = TMath::Sqrt(0.150*0.150+(100*track->fP4)*(100*track->fP4));
-    if (TMath::Abs(track->fP3)>1) sdcar[i]*=2.5;
-    cdcar[i]      = TMath::Exp((TMath::Abs(track->fP4)-0.0106)*525.3);
+    sdcar[i]      = TMath::Sqrt(0.150*0.150+(100*track->GetC())*(100*track->GetC()));
+    if (TMath::Abs(track->GetTgl())>1) sdcar[i]*=2.5;
+    cdcar[i]      = TMath::Exp((TMath::Abs(track->GetC())-0.0106)*525.3);
     pulldcar[i]   = (dca[i]-cdcar[i])/sdcar[i];
     pulldcaz[i]   = (z0[i]-zvertex)/sdcar[i];
     pulldca[i]    = TMath::Sqrt(pulldcar[i]*pulldcar[i]+pulldcaz[i]*pulldcaz[i]);
-    if (track->fTPCr[1]+track->fTPCr[2]+track->fTPCr[3]>0.5) {
+    if (track->TPCrPID(1)+track->TPCrPID(2)+track->TPCrPID(3)>0.5) {
       if (pulldca[i]<3.) isPrim[i]=kTRUE;  //pion, muon and Kaon  3 sigma cut
     }
-    if (track->fTPCr[4]>0.5) {
+    if (track->TPCrPID(4)>0.5) {
       if (pulldca[i]<0.5) isPrim[i]=kTRUE;  //proton 0.5 sigma cut
     }
-    if (track->fTPCr[0]>0.4) {
+    if (track->TPCrPID(0)>0.4) {
       isPrim[i]=kFALSE;  //electron no  sigma cut
     }
   }
@@ -4645,7 +5374,7 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
   // //  
   TTreeSRedirector &cstream = *fDebugStreamer; 
   Float_t fprimvertex[3]={GetX(),GetY(),GetZ()};
-  AliESDV0MI vertex; 
+  AliV0 vertex; 
   Double_t cradius0 = 10*10;
   Double_t cradius1 = 200*200;
   Double_t cdist1=3.;
@@ -4657,20 +5386,22 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
     if (sign[i]==0) continue;
     AliTPCseed * track0 = (AliTPCseed*)array->At(i);
     if (!track0) continue;
-    cstream<<"Tracks"<<
-      "Tr0.="<<track0<<
-      "dca="<<dca[i]<<
-      "z0="<<z0[i]<<
-      "zvertex="<<zvertex<<
-      "sdcar0="<<sdcar[i]<<
-      "cdcar0="<<cdcar[i]<<
-      "pulldcar0="<<pulldcar[i]<<
-      "pulldcaz0="<<pulldcaz[i]<<
-      "pulldca0="<<pulldca[i]<<
-      "isPrim="<<isPrim[i]<<
-      "\n";
+    if (AliTPCReconstructor::StreamLevel()>1){
+      cstream<<"Tracks"<<
+       "Tr0.="<<track0<<
+       "dca="<<dca[i]<<
+       "z0="<<z0[i]<<
+       "zvertex="<<zvertex<<
+       "sdcar0="<<sdcar[i]<<
+       "cdcar0="<<cdcar[i]<<
+       "pulldcar0="<<pulldcar[i]<<
+       "pulldcaz0="<<pulldcaz[i]<<
+       "pulldca0="<<pulldca[i]<<
+       "isPrim="<<isPrim[i]<<
+       "\n";
+    }
     //
-    if (track0->fP4<0) continue;
+    if (track0->GetSigned1Pt()<0) continue;
     if (track0->GetKinkIndex(0)>0||isPrim[i]) continue;   //daughter kink
     //
     if (TMath::Abs(helixes[i].GetHelix(4))<0.000000001) continue;
@@ -4684,7 +5415,7 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
       if (track1->GetKinkIndex(0)>0 || isPrim[j]) continue; //daughter kink
       if (sign[j]*sign[i]>0) continue; 
       if (TMath::Abs(helixes[j].GetHelix(4))<0.000001) continue;
-      if (track0->fCircular+track1->fCircular>1) continue;    //circling -returning track
+      if (track0->GetCircular()+track1->GetCircular()>1) continue;    //circling -returning track
       nall++;
       //
       // DCA to prim vertex cut
@@ -4716,23 +5447,26 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
       if (pointAngle<cpointAngle) continue;
       //
       Bool_t isGamma = kFALSE;
-      vertex.SetP(*track0); //track0 - plus
-      vertex.SetM(*track1); //track1 - minus
+      vertex.SetParamP(*track0); //track0 - plus
+      vertex.SetParamN(*track1); //track1 - minus
       vertex.Update(fprimvertex);
-      if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE;              // gamma conversion candidate
-      Double_t pointAngle2 = vertex.GetPointAngle();
+      if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&vertex.GetAnglep()[2]<0.15) isGamma=kTRUE;              // gamma conversion candidate
+      Double_t pointAngle2 = vertex.GetV0CosineOfPointingAngle();
       //continue;
-      if (vertex.GetPointAngle()<cpointAngle && (!isGamma)) continue; // point angle cut
-      if (vertex.GetDist2()>2&&(!isGamma)) continue;         // point angle cut
+      if (vertex.GetV0CosineOfPointingAngle()<cpointAngle && (!isGamma)) continue;// point angle cut
+      //Bo:      if (vertex.GetDist2()>2&&(!isGamma)) continue;      // point angle cut
+      if (vertex.GetDcaV0Daughters()>2&&(!isGamma)) continue;//Bo:   // point angle cut
       Float_t sigmae     = 0.15*0.15;
       if (vertex.GetRr()<80) 
        sigmae += (sdcar[i]*sdcar[i]+sdcar[j]*sdcar[j])*(1.-vertex.GetRr()/80.)*(1.-vertex.GetRr()/80.);
       sigmae+= TMath::Sqrt(sigmae);
-      if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue; 
+      //Bo:      if (vertex.GetDist2()/sigmae>3.&&(!isGamma)) continue; 
+      if (vertex.GetDcaV0Daughters()/sigmae>3.&&(!isGamma)) continue; 
       Float_t densb0=0,densb1=0,densa0=0,densa1=0;
       Int_t row0 = GetRowNumber(vertex.GetRr());
       if (row0>15){
-       if (vertex.GetDist2()>0.2) continue;             
+       //Bo:   if (vertex.GetDist2()>0.2) continue;             
+       if (vertex.GetDcaV0Daughters()>0.2) continue;             
        densb0     = track0->Density2(0,row0-5);          
        densb1     = track1->Density2(0,row0-5);         
        if (densb0>0.3|| densb1>0.3) continue;            //clusters before vertex
@@ -4745,29 +5479,35 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
        densa1     = track1->Density2(0,40);  //cluster density
        if ((vertex.GetRr()<80&&densa0+densa1<1.)&&(!isGamma)) continue;
       }
-      vertex.SetLab(0,track0->GetLabel());
-      vertex.SetLab(1,track1->GetLabel());
+//Bo:        vertex.SetLab(0,track0->GetLabel());
+//Bo:        vertex.SetLab(1,track1->GetLabel());
       vertex.SetChi2After((densa0+densa1)*0.5);
       vertex.SetChi2Before((densb0+densb1)*0.5);
       vertex.SetIndex(0,i);
       vertex.SetIndex(1,j);
-      vertex.SetStatus(1); // TPC v0 candidate
-      vertex.SetRp(track0->fTPCr);
-      vertex.SetRm(track1->fTPCr);
-      tpcv0s->AddLast(new AliESDV0MI(vertex));      
+//Bo:      vertex.SetStatus(1); // TPC v0 candidate
+      vertex.SetOnFlyStatus(2);//Bo: // TPC v0 candidate
+//Bo:        vertex.SetRp(track0->TPCrPIDs());
+//Bo:        vertex.SetRm(track1->TPCrPIDs());
+      tpcv0s->AddLast(new AliESDv0(vertex));      
       ncandidates++;
       {
-       Int_t eventNr = esd->GetEventNumber();
+       Int_t eventNr = esd->GetEventNumberInFile(); // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number
        Double_t radiusm= (delta[0]<delta[1])? TMath::Sqrt(radius[0]):TMath::Sqrt(radius[1]);  
        Double_t deltam= (delta[0]<delta[1])? TMath::Sqrt(delta[0]):TMath::Sqrt(delta[1]);  
-       cstream<<"V0"<<
+       if (AliTPCReconstructor::StreamLevel()>1) {
+         Int_t lab0=track0->GetLabel();
+         Int_t lab1=track1->GetLabel();
+         Char_t c0=track0->GetCircular();
+         Char_t c1=track1->GetCircular();
+         cstream<<"V0"<<
          "Event="<<eventNr<<
          "vertex.="<<&vertex<<
          "Tr0.="<<track0<<
-         "lab0="<<track0->fLab<<
+         "lab0="<<lab0<<
          "Helix0.="<<&helixes[i]<<     
          "Tr1.="<<track1<<
-         "lab1="<<track1->fLab<<
+         "lab1="<<lab1<<
          "Helix1.="<<&helixes[j]<<
          "pointAngle="<<pointAngle<<
          "pointAngle2="<<pointAngle2<<
@@ -4776,8 +5516,8 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
          "z0="<<z0[i]<<
          "z1="<<z0[j]<<
          "zvertex="<<zvertex<<
-         "circular0="<<track0->fCircular<<
-         "circular1="<<track1->fCircular<<
+         "circular0="<<c0<<
+         "circular1="<<c1<<
          "npoints="<<npoints<<
          "radius0="<<radius[0]<<
          "delta0="<<delta[0]<<
@@ -4800,7 +5540,7 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
          "densa0="<<densa0<<
          "densa1="<<densa1<<
          "sigmae="<<sigmae<<
-         "\n";
+           "\n";}
       }
     }
   }    
@@ -4809,24 +5549,29 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
   Int_t naccepted =0;
   for (Int_t i=0;i<ncandidates;i++){
     quality[i]     = 0; 
-    AliESDV0MI *v0 = (AliESDV0MI*)tpcv0s->At(i);
-    quality[i]     = 1./(1.00001-v0->GetPointAngle());   //base point angle
+    AliESDv0 *v0 = (AliESDv0*)tpcv0s->At(i);
+    quality[i]     = 1./(1.00001-v0->GetV0CosineOfPointingAngle());   //base point angle
     // quality[i]    /= (0.5+v0->GetDist2());  
     // quality[i]    *= v0->GetChi2After();               //density factor
-    Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) );     //pull
+
     Int_t index0 = v0->GetIndex(0);
     Int_t index1 = v0->GetIndex(1);
+    //Bo:    Double_t minpulldca = TMath::Min(2.+pulldca[v0->GetIndex(0)],(2.+pulldca[v0->GetIndex(1)]) );     //pull
+    Double_t minpulldca = TMath::Min(2.+pulldca[index0],(2.+pulldca[index1]) );//Bo:
+
+
+
     AliTPCseed * track0 = (AliTPCseed*)array->At(index0);
     AliTPCseed * track1 = (AliTPCseed*)array->At(index1);
-    if (track0->fTPCr[0]>0.3&&track1->fTPCr[0]>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000;              // gamma conversion candidate
-    if (track0->fTPCr[4]>0.9||track1->fTPCr[4]>0.9&&minpulldca>4) quality[i]*=10;    // lambda candidate candidate
+    if (track0->TPCrPID(0)>0.3&&track1->TPCrPID(0)>0.3&&v0->GetAnglep()[2]<0.15) quality[i]+=1000000;              // gamma conversion candidate
+    if (track0->TPCrPID(4)>0.9||track1->TPCrPID(4)>0.9&&minpulldca>4) quality[i]*=10;    // lambda candidate candidate
   }
 
   TMath::Sort(ncandidates,quality,indexes,kTRUE);
   //
   //
   for (Int_t i=0;i<ncandidates;i++){
-    AliESDV0MI * v0 = (AliESDV0MI*)tpcv0s->At(indexes[i]);
+    AliESDv0 * v0 = (AliESDv0*)tpcv0s->At(indexes[i]);
     if (!v0) continue;
     Int_t index0 = v0->GetIndex(0);
     Int_t index1 = v0->GetIndex(1);
@@ -4848,27 +5593,31 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
     if (v0indexes0[2]!=0) {order0=3; accept=kFALSE;}
     if (v0indexes0[2]!=0) {order1=3; accept=kFALSE;}
     //
-    AliESDV0MI * v02 = v0;
+    AliESDv0 * v02 = v0;
     if (accept){
-      v0->SetOrder(0,order0);
-      v0->SetOrder(1,order1);
-      v0->SetOrder(1,order0+order1);     
-      Int_t index = esd->AddV0MI(v0);
-      v02 = esd->GetV0MI(index);
+      //Bo:      v0->SetOrder(0,order0);
+      //Bo:      v0->SetOrder(1,order1);
+      //Bo:      v0->SetOrder(1,order0+order1);     
+      v0->SetOnFlyStatus(kTRUE);
+      Int_t index = esd->AddV0(v0);
+      v02 = esd->GetV0(index);
       v0indexes0[order0]=index;
       v0indexes1[order1]=index;
       naccepted++;
     }
     {
-      Int_t eventNr = esd->GetEventNumber();
-      cstream<<"V02"<<
+      Int_t eventNr = esd->GetEventNumberInFile(); // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number
+      if (AliTPCReconstructor::StreamLevel()>1) {
+       Int_t lab0=track0->GetLabel();
+       Int_t lab1=track1->GetLabel();
+       cstream<<"V02"<<
        "Event="<<eventNr<<
        "vertex.="<<v0<<        
        "vertex2.="<<v02<<
        "Tr0.="<<track0<<
-       "lab0="<<track0->fLab<<
+       "lab0="<<lab0<<
        "Tr1.="<<track1<<
-       "lab1="<<track1->fLab<<
+       "lab1="<<lab1<<
        "dca0="<<dca[index0]<<
        "dca1="<<dca[index1]<<
        "order0="<<order0<<
@@ -4878,7 +5627,7 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
        "pulldca0="<<pulldca[index0]<<
        "pulldca1="<<pulldca[index1]<<
        "index="<<i<<
-       "\n";
+         "\n";}
     }
   }    
 
@@ -4904,12 +5653,14 @@ void  AliTPCtrackerMI::FindV0s(TObjArray * array, AliESD *esd)
   timer.Print();
 }
 
-Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
+Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
 {
   //
   // refit kink towards to the vertex
   //
   //
+  AliKink &kink=(AliKink &)knk;
+
   Int_t row0 = GetRowNumber(kink.GetR());
   FollowProlongation(mother,0);
   mother.Reset(kFALSE);
@@ -4924,7 +5675,7 @@ Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliES
   const Int_t kNdiv =5;
   AliTPCseed  param0[kNdiv];  // parameters along the track
   AliTPCseed  param1[kNdiv];  // parameters along the track
-  AliESDkink   kinks[kNdiv];   // corresponding kink parameters
+  AliKink     kinks[kNdiv];   // corresponding kink parameters
   //
   Int_t rows[kNdiv];
   for (Int_t irow=0; irow<kNdiv;irow++){
@@ -4935,13 +5686,13 @@ Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliES
   for (Int_t irow=0;irow<kNdiv;irow++){
     FollowBackProlongation(mother, rows[irow]);
     FollowProlongation(daughter,rows[kNdiv-1-irow]);       
-    new(&param0[irow])     AliTPCseed(mother);
-    new(&param1[kNdiv-1-irow])   AliTPCseed(daughter);
+    param0[irow] = mother;
+    param1[kNdiv-1-irow] = daughter;
   }
   //
   // define kinks 
   for (Int_t irow=0; irow<kNdiv-1;irow++){
-    if (param0[irow].fN<kNdiv||param1[irow].fN<kNdiv) continue;
+    if (param0[irow].GetNumberOfClusters()<kNdiv||param1[irow].GetNumberOfClusters()<kNdiv) continue;
     kinks[irow].SetMother(param0[irow]);
     kinks[irow].SetDaughter(param1[irow]);
     kinks[irow].Update();
@@ -4951,12 +5702,12 @@ Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliES
   Int_t index =-1;
   Double_t mindist = 10000;
   for (Int_t irow=0;irow<kNdiv;irow++){
-    if (param0[irow].fN<20||param1[irow].fN<20) continue;
+    if (param0[irow].GetNumberOfClusters()<20||param1[irow].GetNumberOfClusters()<20) continue;
     if (TMath::Abs(kinks[irow].GetR())>240.) continue;
     if (TMath::Abs(kinks[irow].GetR())<100.) continue;
     //
-    Float_t normdist = TMath::Abs(param0[irow].fX-kinks[irow].GetR())*(0.1+kink.GetDistance());
-    normdist/= (param0[irow].fN+param1[irow].fN+40.);
+    Float_t normdist = TMath::Abs(param0[irow].GetX()-kinks[irow].GetR())*(0.1+kink.GetDistance());
+    normdist/= (param0[irow].GetNumberOfClusters()+param1[irow].GetNumberOfClusters()+40.);
     if (normdist < mindist){
       mindist = normdist;
       index = irow;
@@ -4969,15 +5720,15 @@ Int_t AliTPCtrackerMI::RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliES
   param0[index].Reset(kTRUE);
   FollowProlongation(param0[index],0);
   //
-  new (&mother) AliTPCseed(param0[index]);
-  new (&daughter) AliTPCseed(param1[index]);  // daughter in vertex
+  mother = param0[index];
+  daughter = param1[index];  // daughter in vertex
   //
   kink.SetMother(mother);
   kink.SetDaughter(daughter);
   kink.Update();
   kink.SetTPCRow0(GetRowNumber(kink.GetR()));
-  kink.SetTPCncls(param0[index].fN,0);
-  kink.SetTPCncls(param1[index].fN,1);
+  kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
+  kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
   kink.SetLabel(CookLabel(&mother,0.4, 0,kink.GetTPCRow0()),0);
   kink.SetLabel(CookLabel(&daughter,0.4, kink.GetTPCRow0(),160),1);
   mother.SetLabel(kink.GetLabel(0));
@@ -4997,10 +5748,8 @@ void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
     if (index>=0) break;
     index = TMath::Abs(index)-1;
     AliESDkink * kink = fEvent->GetKink(index);
-    //kink->fTPCdensity2[0][0]=-1;
-    //kink->fTPCdensity2[0][1]=-1;
-    kink->SetTPCDensity2(-1,0,0);
-    kink->SetTPCDensity2(1,0,1);
+    kink->SetTPCDensity(-1,0,0);
+    kink->SetTPCDensity(1,0,1);
     //
     Int_t row0 = kink->GetTPCRow0() - 2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
     if (row0<15) row0=15;
@@ -5010,9 +5759,9 @@ void AliTPCtrackerMI::UpdateKinkQualityM(AliTPCseed * seed){
     //
     Int_t found,foundable,shared;
     seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
-    if (foundable>5)   kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,0);
+    if (foundable>5)   kink->SetTPCDensity(Float_t(found)/Float_t(foundable),0,0);
     seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
-    if (foundable>5)   kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),0,1);
+    if (foundable>5)   kink->SetTPCDensity(Float_t(found)/Float_t(foundable),0,1);
   }
     
 }
@@ -5027,8 +5776,8 @@ void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
     if (index<=0) break;
     index = TMath::Abs(index)-1;
     AliESDkink * kink = fEvent->GetKink(index);
-    kink->SetTPCDensity2(-1,1,0);
-    kink->SetTPCDensity2(-1,1,1);
+    kink->SetTPCDensity(-1,1,0);
+    kink->SetTPCDensity(-1,1,1);
     //
     Int_t row0 = kink->GetTPCRow0() -2 - Int_t( 0.5/ (0.05+kink->GetAngle(2)));
     if (row0<15) row0=15;
@@ -5038,15 +5787,15 @@ void AliTPCtrackerMI::UpdateKinkQualityD(AliTPCseed * seed){
     //
     Int_t found,foundable,shared;
     seed->GetClusterStatistic(0,row0, found, foundable,shared,kFALSE);
-    if (foundable>5)   kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,0);
+    if (foundable>5)   kink->SetTPCDensity(Float_t(found)/Float_t(foundable),1,0);
     seed->GetClusterStatistic(row1,155, found, foundable,shared,kFALSE);
-    if (foundable>5)   kink->SetTPCDensity2(Float_t(found)/Float_t(foundable),1,1);
+    if (foundable>5)   kink->SetTPCDensity(Float_t(found)/Float_t(foundable),1,1);
   }
     
 }
 
 
-Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink)
+Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &knk)
 {
   //
   // check kink point for given track
@@ -5054,20 +5803,21 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   // otherwise seed0 correspond to mother particle
   //           seed1 correspond to daughter particle
   //           kink  parameter of kink point
+  AliKink &kink=(AliKink &)knk;
 
-  Int_t middlerow = (seed->fFirstPoint+seed->fLastPoint)/2;
-  Int_t first = seed->fFirstPoint
-  Int_t last  = seed->fLastPoint;
+  Int_t middlerow = (seed->GetFirstPoint()+seed->GetLastPoint())/2;
+  Int_t first = seed->GetFirstPoint()
+  Int_t last  = seed->GetLastPoint();
   if (last-first<20) return 0;          // shortest length - 2*30 = 60 pad-rows
 
   
   AliTPCseed *seed1 = ReSeed(seed,middlerow+20, kTRUE);  //middle of chamber
   if (!seed1) return 0;
-  FollowProlongation(*seed1,seed->fLastPoint-20);
+  FollowProlongation(*seed1,seed->GetLastPoint()-20);
   seed1->Reset(kTRUE);
   FollowProlongation(*seed1,158);
   seed1->Reset(kTRUE);  
-  last = seed1->fLastPoint;
+  last = seed1->GetLastPoint();
   //
   AliTPCseed *seed0 = new AliTPCseed(*seed);
   seed0->Reset(kFALSE);
@@ -5075,7 +5825,7 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   //
   AliTPCseed  param0[20];  // parameters along the track
   AliTPCseed  param1[20];  // parameters along the track
-  AliESDkink            kinks[20];   // corresponding kink parameters
+  AliKink     kinks[20];   // corresponding kink parameters
   Int_t rows[20];
   for (Int_t irow=0; irow<20;irow++){
     rows[irow] = first +((last-first)*irow)/19;
@@ -5085,8 +5835,8 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   for (Int_t irow=0;irow<20;irow++){
     FollowBackProlongation(*seed0, rows[irow]);
     FollowProlongation(*seed1,rows[19-irow]);       
-    new(&param0[irow])     AliTPCseed(*seed0);
-    new(&param1[19-irow])   AliTPCseed(*seed1);
+    param0[irow] = *seed0;
+    param1[19-irow] = *seed1;
   }
   //
   // define kinks 
@@ -5102,7 +5852,7 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   for (Int_t irow=1;irow<19;irow++){
     if (TMath::Abs(kinks[irow].GetR())>240.) continue;
     if (TMath::Abs(kinks[irow].GetR())<110.) continue;
-    Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
+    Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
     if ( quality > maxchange){
       maxchange = quality;
       index = irow;
@@ -5118,15 +5868,15 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   seed1 = new AliTPCseed(param1[index]);
   seed0->Reset(kFALSE);
   seed1->Reset(kFALSE);
-  seed0->ResetCovariance();
-  seed1->ResetCovariance();
+  seed0->ResetCovariance(10.);
+  seed1->ResetCovariance(10.);
   FollowProlongation(*seed0,0);
   FollowBackProlongation(*seed1,158);
-  new (&mother) AliTPCseed(*seed0);  // backup mother at position 0
+  mother = *seed0; // backup mother at position 0
   seed0->Reset(kFALSE);  
   seed1->Reset(kFALSE);
-  seed0->ResetCovariance();
-  seed1->ResetCovariance();
+  seed0->ResetCovariance(10.);
+  seed1->ResetCovariance(10.);
   //
   first = TMath::Max(row0-20,0);
   last  = TMath::Min(row0+20,158);
@@ -5139,8 +5889,8 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   for (Int_t irow=0;irow<20;irow++){
     FollowBackProlongation(*seed0, rows[irow]);
     FollowProlongation(*seed1,rows[19-irow]);       
-    new(&param0[irow])     AliTPCseed(*seed0);
-    new(&param1[19-irow])   AliTPCseed(*seed1);
+    param0[irow] = *seed0;
+    param1[19-irow] = *seed1;
   }
   //
   // define kinks 
@@ -5158,7 +5908,7 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   for (Int_t irow=0;irow<20;irow++){
     if (TMath::Abs(kinks[irow].GetR())>250.) continue;
     if (TMath::Abs(kinks[irow].GetR())<90.) continue;
-    Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].fX));
+    Float_t quality = TMath::Abs(kinks[irow].GetAngle(2))/(3.+TMath::Abs(kinks[irow].GetR()-param0[irow].GetX()));
     if ( quality > maxchange){
       maxchange = quality;
       index = irow;
@@ -5167,7 +5917,7 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   }
   //
   //
-  if (index==-1 || param0[index].fN+param1[index].fN<100){
+  if (index==-1 || param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()<100){
     delete seed0;
     delete seed1;
     return 0;
@@ -5182,17 +5932,17 @@ Int_t  AliTPCtrackerMI::CheckKinkPoint(AliTPCseed*seed,AliTPCseed &mother, AliTP
   kink.SetLabel(CookLabel(seed0,0.5,0,row0),0);
   kink.SetLabel(CookLabel(seed1,0.5,row0,158),1);
   kink.SetIndex(-10,0);
-  kink.SetIndex(int(param0[index].fN+param1[index].fN),1);
-  kink.SetTPCncls(param0[index].fN,0);
-  kink.SetTPCncls(param1[index].fN,1);
+  kink.SetIndex(int(param0[index].GetNumberOfClusters()+param1[index].GetNumberOfClusters()),1);
+  kink.SetTPCncls(param0[index].GetNumberOfClusters(),0);
+  kink.SetTPCncls(param1[index].GetNumberOfClusters(),1);
   //
   //
   //  new (&mother) AliTPCseed(param0[index]);
-  new (&daughter) AliTPCseed(param1[index]);
+  daughter = param1[index];
   daughter.SetLabel(kink.GetLabel(1));  
   param0[index].Reset(kTRUE);
   FollowProlongation(param0[index],0);  
-  new (&mother) AliTPCseed(param0[index]);
+  mother = param0[index];
   mother.SetLabel(kink.GetLabel(0));
   delete seed0;
   delete seed1;
@@ -5212,11 +5962,11 @@ AliTPCseed*  AliTPCtrackerMI::ReSeed(AliTPCseed *t)
   //  Int_t last  = fSectors->GetNRows()-1;
   //
   if (fSectors == fOuterSec){
-    first = TMath::Max(first, t->fFirstPoint-fInnerSec->GetNRows());
+    first = TMath::Max(first, t->GetFirstPoint()-fInnerSec->GetNRows());
     //last  = 
   }
   else
-    first = t->fFirstPoint;
+    first = t->GetFirstPoint();
   //
   AliTPCseed * seed = MakeSeed(t,0.1,0.5,0.9);
   FollowBackProlongation(*t,fSectors->GetNRows()-1);
@@ -5268,7 +6018,7 @@ Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
   return 0;
 }
 
-Int_t AliTPCtrackerMI::Clusters2Tracks (AliESD *esd)
+Int_t AliTPCtrackerMI::Clusters2Tracks (AliESDEvent *esd)
 {
   //
   if (fSeeds) DeleteSeeds();
@@ -5305,7 +6055,7 @@ Int_t AliTPCtrackerMI::Clusters2Tracks() {
       continue;
     } 
     CookLabel(pt,0.1); 
-    if (pt->fRemoval==10) {
+    if (pt->GetRemoval()==10) {
       if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
        pt->Desactivate(10);  // make track again active
       else{
@@ -5316,47 +6066,16 @@ Int_t AliTPCtrackerMI::Clusters2Tracks() {
   }
   //
   RemoveUsed2(fSeeds,0.85,0.85,0);
-  FindKinks(fSeeds,fEvent);
+  if (AliTPCReconstructor::GetRecoParam()->GetDoKinks()) FindKinks(fSeeds,fEvent);
+  //FindCurling(fSeeds, fEvent,0);  
+  if (AliTPCReconstructor::StreamLevel()>2)  FindMultiMC(fSeeds, fEvent,0); // find multi found tracks
   RemoveUsed2(fSeeds,0.5,0.4,20);
+  FindSplitted(fSeeds, fEvent,0); // find multi found tracks
+
  //  //
 //   // refit short tracks
 //   //
   Int_t nseed=fSeeds->GetEntriesFast();
-//   for (Int_t i=0; i<nseed; i++) {
-//     AliTPCseed *pt=(AliTPCseed*)fSeeds->UncheckedAt(i), &t=*pt;    
-//     if (!pt) continue;    
-//     Int_t nc=t.GetNumberOfClusters();
-//     if (nc<15) {
-//       delete fSeeds->RemoveAt(i);
-//       continue;
-//     }
-//     if (pt->GetKinkIndexes()[0]!=0) continue; // ignore kink candidates
-//     if (nc>100) continue;                     // hopefully, enough for ITS
-//     AliTPCseed *seed2 = new AliTPCseed(*pt);
-//     //seed2->Reset(kFALSE);
-//     //pt->ResetCovariance();
-//     seed2->Modify(1);
-//     FollowBackProlongation(*seed2,158);
-//     //seed2->Reset(kFALSE);
-//     seed2->Modify(10);
-//     FollowProlongation(*seed2,0);
-//     TTreeSRedirector &cstream = *fDebugStreamer;
-//     cstream<<"Crefit"<<
-//       "Tr0.="<<pt<<
-//       "Tr1.="<<seed2<<
-//       "\n";     
-//     if (seed2->fN>pt->fN){
-//       delete fSeeds->RemoveAt(i);
-//       fSeeds->AddAt(seed2,i);
-//     }else{
-//       delete seed2;
-//     }
-//   }
-//   RemoveUsed2(fSeeds,0.6,0.6,50);
-
-//  FindV0s(fSeeds,fEvent);  
-  //RemoveDouble(fSeeds,0.2,0.6,11);
-
   //
   Int_t found = 0;
   for (Int_t i=0; i<nseed; i++) {
@@ -5369,10 +6088,10 @@ Int_t AliTPCtrackerMI::Clusters2Tracks() {
     }
     CookLabel(pt,0.1); //For comparison only
     //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
-    if ((pt->IsActive() || (pt->fRemoval==10) )){
+    if ((pt->IsActive() || (pt->GetRemoval()==10) )){
       found++;      
       if (fDebug>0) cerr<<found<<'\r';      
-      pt->fLab2 = i;
+      pt->SetLab2(i);
     }
     else
       delete fSeeds->RemoveAt(i);
@@ -5397,12 +6116,12 @@ Int_t AliTPCtrackerMI::Clusters2Tracks() {
     t.CookdEdx(0.02,0.6);
     //    CheckKinkPoint(&t,0.05);
     //if ((pt->IsActive() || (pt->fRemoval==10) )&& nc>50 &&pt->GetNumberOfClusters()>0.4*pt->fNFoundable){
-    if ((pt->IsActive() || (pt->fRemoval==10) )){
+    if ((pt->IsActive() || (pt->GetRemoval()==10) )){
       found++;
       if (fDebug>0){
        cerr<<found<<'\r';      
       }
-      pt->fLab2 = i;
+      pt->SetLab2(i);
     }
     else
       delete fSeeds->RemoveAt(i);
@@ -5514,6 +6233,7 @@ TObjArray * AliTPCtrackerMI::Tracking()
 {
   //
   //
+  if (AliTPCReconstructor::GetRecoParam()->GetSpecialSeeding()) return TrackingSpecial();
   TStopwatch timer;
   timer.Start();
   Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
@@ -5636,8 +6356,10 @@ TObjArray * AliTPCtrackerMI::Tracking()
   fdensity = 2.;
   cuts[0]=0.0080;
 
+  Int_t fLastSeedRowSec=AliTPCReconstructor::GetRecoParam()->GetLastSeedRowSec();
+
   // find secondaries
-  for (Int_t delta = 30; delta<90; delta+=10){
+  for (Int_t delta = 30; delta<fLastSeedRowSec; delta+=10){
     //
     cuts[0] = 0.3;
     cuts[1] = 3.5;
@@ -5664,7 +6386,50 @@ TObjArray * AliTPCtrackerMI::Tracking()
 }
 
 
-void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
+TObjArray * AliTPCtrackerMI::TrackingSpecial()
+{
+  //
+  // seeding adjusted for laser and cosmic tests - short tracks with big inclination angle
+  // no primary vertex seeding tried
+  //
+  TStopwatch timer;
+  timer.Start();
+  Int_t nup=fOuterSec->GetNRows()+fInnerSec->GetNRows();
+
+  TObjArray * seeds = new TObjArray;
+  TObjArray * arr=0;
+  
+  Int_t   gap  = 15;
+  Float_t cuts[4];
+  Float_t fnumber  = 3.0;
+  Float_t fdensity = 3.0;
+  
+  // find secondaries
+  cuts[0] = AliTPCReconstructor::GetRecoParam()->GetMaxC();   // max curvature
+  cuts[1] = 3.5;    // max tan(phi) angle for seeding
+  cuts[2] = 3.;     // not used (cut on z primary vertex)     
+  cuts[3] = 3.5;    // max tan(theta) angle for seeding
+
+  for (Int_t delta = 0; nup-delta-gap-1>0; delta+=3){
+    //
+    arr = Tracking(4,nup-1-delta,nup-1-delta-gap,cuts,-1);
+    SumTracks(seeds,arr);   
+    SignClusters(seeds,fnumber,fdensity);   
+  } 
+  if (fDebug>0){
+    Info("Tracking()","\n\nSecondary seeding\t%d\n\n",seeds->GetEntriesFast());
+    timer.Print();
+    timer.Start();
+  }
+
+  return seeds;
+  //
+      
+}
+
+
+void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *&arr2) const
 {
   //
   //sum tracks to common container
@@ -5673,22 +6438,29 @@ void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
   for (Int_t i=0;i<nseed;i++){
     AliTPCseed *pt=(AliTPCseed*)arr2->UncheckedAt(i);    
     if (pt){
-      
+      //
+      // remove tracks with too big curvature
+      //
+      if (TMath::Abs(pt->GetC())>AliTPCReconstructor::GetRecoParam()->GetMaxC()){
+       delete arr2->RemoveAt(i);
+       continue;
+      }
+       // REMOVE VERY SHORT  TRACKS
+      if (pt->GetNumberOfClusters()<20){ 
+       delete arr2->RemoveAt(i);
+       continue;
+      }// patch 28 fev06
       // NORMAL ACTIVE TRACK
       if (pt->IsActive()){
        arr1->AddLast(arr2->RemoveAt(i));
        continue;
       }
       //remove not usable tracks
-      if (pt->fRemoval!=10){
-       delete arr2->RemoveAt(i);
-       continue;
-      }
-      // REMOVE VERY SHORT  TRACKS
-      if (pt->GetNumberOfClusters()<20){ 
+      if (pt->GetRemoval()!=10){
        delete arr2->RemoveAt(i);
        continue;
       }
+     
       // ENABLE ONLY ENOUGH GOOD STOPPED TRACKS
       if (pt->GetDensityFirst(20)>0.8 || pt->GetDensityFirst(30)>0.8 || pt->GetDensityFirst(40)>0.7)
        arr1->AddLast(arr2->RemoveAt(i));
@@ -5697,7 +6469,7 @@ void AliTPCtrackerMI::SumTracks(TObjArray *arr1,TObjArray *arr2) const
       }
     }
   }
-  delete arr2;  
+  delete arr2;  arr2 = 0;
 }
 
 
@@ -5714,7 +6486,7 @@ void  AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rla
     if (!pt) continue;
     if (!t.IsActive()) continue;
     // follow prolongation to the first layer
-    if ( (fSectors ==fInnerSec) || (t.fFirstPoint-fParam->GetNRowLow()>rfirst+1) )  
+    if ( (fSectors ==fInnerSec) || (t.GetFirstPoint()-fParam->GetNRowLow()>rfirst+1) )  
       FollowProlongation(t, rfirst+1);
   }
 
@@ -5734,7 +6506,7 @@ void  AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rla
       if (nr==80) pt->UpdateReference();
       if (!pt->IsActive()) continue;
       //      if ( (fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
-      if (pt->fRelativeSector>17) {
+      if (pt->GetRelativeSector()>17) {
        continue;
       }
       UpdateClusters(t,nr);
@@ -5745,7 +6517,7 @@ void  AliTPCtrackerMI::ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rla
       if (!pt) continue;
       if (!pt->IsActive()) continue; 
       // if ((fSectors ==fOuterSec) && (pt->fFirstPoint-fParam->GetNRowLow())<nr) continue;
-      if (pt->fRelativeSector>17) {
+      if (pt->GetRelativeSector()>17) {
        continue;
       }
       FollowToNextCluster(*pt,nr);
@@ -5766,7 +6538,7 @@ void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray * arr,Float_t fac) co
       pt->Modify(fac);
       //
       //rotate to current local system at first accepted  point    
-      Int_t index  = pt->GetClusterIndex2(pt->fFirstPoint); 
+      Int_t index  = pt->GetClusterIndex2(pt->GetFirstPoint()); 
       Int_t sec    = (index&0xff000000)>>24;
       sec = sec%18;
       Float_t angle1 = fInnerSec->GetAlpha()*sec+fInnerSec->GetAlphaShift();
@@ -5800,7 +6572,7 @@ void AliTPCtrackerMI::PrepareForProlongation(TObjArray * arr, Float_t fac) const
     AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
     if (pt) {
       pt->Modify(fac);
-      pt->fFirstPoint = pt->fLastPoint
+      pt->SetFirstPoint(pt->GetLastPoint())
     }
     
   }
@@ -5829,11 +6601,11 @@ Int_t AliTPCtrackerMI::PropagateBack(TObjArray * arr)
     }
     if (pt&& pt->GetKinkIndex(0)>0) {
       AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
-      pt->fFirstPoint = kink->GetTPCRow0();
+      pt->SetFirstPoint(kink->GetTPCRow0());
       fSectors = fInnerSec;
       FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);  
     }
-    
+    CookLabel(pt,0.3);
   }
   return 0;
 }
@@ -5850,7 +6622,9 @@ Int_t AliTPCtrackerMI::PropagateForward2(TObjArray * arr)
     AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
     if (pt) { 
       FollowProlongation(*pt,0);
+      CookLabel(pt,0.3);
     }
+    
   }
   return 0;
 }
@@ -5869,7 +6643,7 @@ Int_t AliTPCtrackerMI::PropagateForward()
       Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
       if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();  
       if (alpha < 0.            ) alpha += 2.*TMath::Pi();  
-      t.fRelativeSector = Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
+      t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
     }
   }
   
@@ -5877,7 +6651,6 @@ Int_t AliTPCtrackerMI::PropagateForward()
   ParallelTracking(fSeeds,fOuterSec->GetNRows()+fInnerSec->GetNRows()-1,fInnerSec->GetNRows());
   fSectors = fInnerSec;
   ParallelTracking(fSeeds,fInnerSec->GetNRows()-1,0);
-  //WriteTracks();
   return 1;
 }
 
@@ -5921,19 +6694,27 @@ Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed * pt, Int_t row0, Int_t row1)
 void  AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
 {
   //
-  //
-  Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
-  //  Float_t padlength =  fParam->GetPadPitchLength(seed->fSector);
-  Float_t padlength =  GetPadPitchLength(row);
-  //
-  Float_t sresy = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
-  Float_t angulary  = seed->GetSnp();
-  angulary = angulary*angulary/(1-angulary*angulary);
-  seed->fCurrentSigmaY2 = sd2+padlength*padlength*angulary/12.+sresy*sresy;  
-  //
-  Float_t sresz = fParam->GetZSigma();
-  Float_t angularz  = seed->GetTgl();
-  seed->fCurrentSigmaZ2 = sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz;
+  // 
+  AliTPCClusterParam * clparam = AliTPCcalibDB::Instance()->GetClusterParam();
+  Float_t zdrift = TMath::Abs((fParam->GetZLength(0)-TMath::Abs(seed->GetZ())));
+  Int_t type = (seed->GetSector() < fParam->GetNSector()/2) ? 0: (row>126) ? 1:2;
+  Double_t angulary  = seed->GetSnp();
+  angulary = angulary*angulary/(1.-angulary*angulary);
+  Double_t angularz  = seed->GetTgl()*seed->GetTgl()*(1.+angulary);
+  
+  Double_t sigmay =  clparam->GetRMS0(0,type,zdrift,TMath::Sqrt(TMath::Abs(angulary)));
+  Double_t sigmaz =  clparam->GetRMS0(1,type,zdrift,TMath::Sqrt(TMath::Abs(angularz)));
+  seed->SetCurrentSigmaY2(sigmay*sigmay);
+  seed->SetCurrentSigmaZ2(sigmaz*sigmaz);
+  // Float_t sd2 = TMath::Abs((fParam->GetZLength(0)-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
+//   //  Float_t padlength =  fParam->GetPadPitchLength(seed->fSector);
+//   Float_t padlength =  GetPadPitchLength(row);
+//   //
+//   Float_t sresy = (seed->GetSector() < fParam->GetNSector()/2) ? 0.2 :0.3;
+//   seed->SetCurrentSigmaY2(sd2+padlength*padlength*angulary/12.+sresy*sresy);  
+//   //
+//   Float_t sresz = fParam->GetZSigma();
+//   seed->SetCurrentSigmaZ2(sd2+padlength*padlength*angularz*angularz*(1+angulary)/12.+sresz*sresz);
   /*
   Float_t wy = GetSigmaY(seed);
   Float_t wz = GetSigmaZ(seed);
@@ -5946,38 +6727,18 @@ void  AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
 }
 
 
-Float_t  AliTPCtrackerMI::GetSigmaY(AliTPCseed * seed)
-{
-  //
-  //  
-  Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
-  Float_t padlength =  fParam->GetPadPitchLength(seed->fSector);
-  Float_t sres = (seed->fSector < fParam->GetNSector()/2) ? 0.2 :0.3;
-  Float_t angular  = seed->GetSnp();
-  angular = angular*angular/(1-angular*angular);
-  //  angular*=angular;
-  //angular  = TMath::Sqrt(angular/(1-angular));
-  Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular/12.+sres*sres);
-  return res;
-}
-Float_t  AliTPCtrackerMI::GetSigmaZ(AliTPCseed * seed)
-{
-  //
-  //
-  Float_t sd2 = TMath::Abs((fParam->GetZLength()-TMath::Abs(seed->GetZ())))*fParam->GetDiffL()*fParam->GetDiffL();
-  Float_t padlength =  fParam->GetPadPitchLength(seed->fSector);
-  Float_t sres = fParam->GetZSigma();
-  Float_t angular  = seed->GetTgl();
-  Float_t res = TMath::Sqrt(sd2+padlength*padlength*angular*angular/12.+sres*sres);
-  return res;
-}
-
 
 //__________________________________________________________________________
-void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
+void AliTPCtrackerMI::CookLabel(AliKalmanTrack *tk, Float_t wrong) const {
   //--------------------------------------------------------------------
   //This function "cooks" a track label. If label<0, this track is fake.
   //--------------------------------------------------------------------
+  AliTPCseed * t = dynamic_cast<AliTPCseed*>(tk);
+  if(!t){
+    printf("%s:%d wrong type \n",(char*)__FILE__,__LINE__);
+    return;
+  }
+
   Int_t noc=t->GetNumberOfClusters();
   if (noc<10){
     //printf("\nnot founded prolongation\n\n\n");
@@ -6002,8 +6763,8 @@ void AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong) const {
      if (index&0x8000) continue;
      //     
      //clusters[current]=GetClusterMI(index);
-     if (t->fClusterPointer[i]){
-       clusters[current]=t->fClusterPointer[i];     
+     if (t->GetClusterPointer(i)){
+       clusters[current]=t->GetClusterPointer(i);     
        current++;
      }
   }
@@ -6086,8 +6847,8 @@ Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t
      if (index&0x8000) continue;
      //     
      //clusters[current]=GetClusterMI(index);
-     if (t->fClusterPointer[i]){
-       clusters[current]=t->fClusterPointer[i];     
+     if (t->GetClusterPointer(i)){
+       clusters[current]=t->GetClusterPointer(i);     
        current++;
      }
   }
@@ -6140,29 +6901,6 @@ Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *t, Float_t wrong,Int_t first, Int_t
 }
 
 
-Int_t  AliTPCtrackerMI::AliTPCSector::GetRowNumber(Double_t x) const 
-{
-  //return pad row number for this x
-  Double_t r;
-  if (fN < 64){
-    r=fRow[fN-1].GetX();
-    if (x > r) return fN;
-    r=fRow[0].GetX();
-    if (x < r) return -1;
-    return Int_t((x-r)/fPadPitchLength + 0.5);}
-  else{    
-    r=fRow[fN-1].GetX();
-    if (x > r) return fN;
-    r=fRow[0].GetX();
-    if (x < r) return -1;
-    Double_t r1=fRow[64].GetX();
-    if(x<r1){       
-      return Int_t((x-r)/f1PadPitchLength + 0.5);}
-    else{
-      return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);} 
-  }
-}
-
 Int_t  AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const 
 {
   //return pad row number for given x vector
@@ -6175,190 +6913,54 @@ Int_t  AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
   return GetRowNumber(localx);
 }
 
-//_________________________________________________________________________
-void AliTPCtrackerMI::AliTPCSector::Setup(const AliTPCParam *par, Int_t f) {
-  //-----------------------------------------------------------------------
-  // Setup inner sector
-  //-----------------------------------------------------------------------
-  if (f==0) {
-     fAlpha=par->GetInnerAngle();
-     fAlphaShift=par->GetInnerAngleShift();
-     fPadPitchWidth=par->GetInnerPadPitchWidth();
-     fPadPitchLength=par->GetInnerPadPitchLength();
-     fN=par->GetNRowLow();
-     fRow=new AliTPCRow[fN];
-     for (Int_t i=0; i<fN; i++) {
-       fRow[i].SetX(par->GetPadRowRadiiLow(i));
-       fRow[i].fDeadZone =1.5;  //1.5 cm of dead zone
-     }
-  } else {
-     fAlpha=par->GetOuterAngle();
-     fAlphaShift=par->GetOuterAngleShift();
-     fPadPitchWidth  = par->GetOuterPadPitchWidth();
-     fPadPitchLength = par->GetOuter1PadPitchLength();
-     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)); 
-       fRow[i].fDeadZone =1.5;  // 1.5 cm of dead zone
-     }
-  } 
-}
-
-AliTPCtrackerMI::AliTPCRow::AliTPCRow() {
-  //
-  // default constructor
-  fN=0;
-  fN1=0;
-  fN2=0;
-  fClusters1=0;
-  fClusters2=0;
-}
-
-AliTPCtrackerMI::AliTPCRow::~AliTPCRow(){
-  //
-
-}
-
-
-
-//_________________________________________________________________________
-void 
-AliTPCtrackerMI::AliTPCRow::InsertCluster(const AliTPCclusterMI* c, UInt_t index) {
-  //-----------------------------------------------------------------------
-  // 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 i=Find(c->GetZ());
-  memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTPCclusterMI*));
-  memmove(fIndex   +i+1 ,fIndex   +i,(fN-i)*sizeof(UInt_t));
-  fIndex[i]=index; fClusters[i]=c; fN++;
-}
-
-void AliTPCtrackerMI::AliTPCRow::ResetClusters() {
-   //
-   // reset clusters
-   fN  = 0; 
-   fN1 = 0;
-   fN2 = 0;
-   //delete[] fClusterArray; 
-   if (fClusters1) delete []fClusters1; 
-   if (fClusters2) delete []fClusters2; 
-   //fClusterArray=0;
-   fClusters1 = 0;
-   fClusters2 = 0;
-}
-
-
-//___________________________________________________________________
-Int_t AliTPCtrackerMI::AliTPCRow::Find(Double_t z) const {
-  //-----------------------------------------------------------------------
-  // Return the index of the nearest cluster 
-  //-----------------------------------------------------------------------
-  if (fN==0) return 0;
-  if (z <= fClusters[0]->GetZ()) return 0;
-  if (z > fClusters[fN-1]->GetZ()) return fN;
-  Int_t b=0, e=fN-1, m=(b+e)/2;
-  for (; b<e; m=(b+e)/2) {
-    if (z > fClusters[m]->GetZ()) b=m+1;
-    else e=m; 
-  }
-  return m;
-}
-
 
 
-//___________________________________________________________________
-AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const {
-  //-----------------------------------------------------------------------
-  // Return the index of the nearest cluster in z y 
-  //-----------------------------------------------------------------------
-  Float_t maxdistance = roady*roady + roadz*roadz;
-
-  AliTPCclusterMI *cl =0;
-  for (Int_t i=Find(z-roadz); i<fN; i++) {
-      AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
-      if (c->GetZ() > z+roadz) break;
-      if ( (c->GetY()-y) >  roady ) continue;
-      Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
-      if (maxdistance>distance) {
-       maxdistance = distance;
-       cl=c;       
-      }
-  }
-  return cl;      
-}
-
-AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const 
+void AliTPCtrackerMI::MakeBitmaps(AliTPCseed *t)
 {
   //-----------------------------------------------------------------------
-  // Return the index of the nearest cluster in z y 
+  // Fill the cluster and sharing bitmaps of the track
   //-----------------------------------------------------------------------
-  Float_t maxdistance = roady*roady + roadz*roadz;
-  Int_t iz1 = TMath::Max(fFastCluster[Int_t(z-roadz+254.5)]-1,0);
-  Int_t iz2 = TMath::Min(fFastCluster[Int_t(z+roadz+255.5)]+1,fN);
-
-  AliTPCclusterMI *cl =0;
-  //FindNearest3(y,z,roady,roadz,index);
-  //  for (Int_t i=Find(z-roadz); i<fN; i++) {
-  for (Int_t i=iz1; i<iz2; i++) {
-      AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
-      if (c->GetZ() > z+roadz) break;
-      if ( c->GetY()-y >  roady ) continue;
-      if ( y-c->GetY() >  roady ) continue;
-      Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
-      if (maxdistance>distance) {
-       maxdistance = distance;
-       cl=c;       
-       index =i;
-       //roady = TMath::Sqrt(maxdistance);
-      }
-  }
-  return cl;      
-}
-
 
-
-AliTPCclusterMI * AliTPCtrackerMI::AliTPCRow::FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz,UInt_t & index) const 
-{
-  //-----------------------------------------------------------------------
-  // Return the index of the nearest cluster in z y 
-  //-----------------------------------------------------------------------
-  Float_t maxdistance = roady*roady + roadz*roadz;
-  //  Int_t iz = Int_t(z+255.);
-  AliTPCclusterMI *cl =0;
-  for (Int_t i=Find(z-roadz); i<fN; i++) {
-    //for (Int_t i=fFastCluster[iz-2]; i<fFastCluster[iz+2]; i++) {
-      AliTPCclusterMI *c=(AliTPCclusterMI*)(fClusters[i]);
-      if (c->GetZ() > z+roadz) break;
-      if ( c->GetY()-y >  roady ) continue;
-      if ( y-c->GetY() >  roady ) continue;
-      Float_t distance = (c->GetZ()-z)*(c->GetZ()-z)+(c->GetY()-y)*(c->GetY()-y);
-      if (maxdistance>distance) {
-       maxdistance = distance;
-       cl=c;       
-       index =i;
-       //roady = TMath::Sqrt(maxdistance);
-      }
+  Int_t firstpoint = 0;
+  Int_t lastpoint = 159;
+  AliTPCTrackerPoint *point;
+  
+  for (int iter=firstpoint; iter<lastpoint; iter++) {
+    point = t->GetTrackPoint(iter);
+    if (point) {
+      t->SetClusterMapBit(iter, kTRUE);
+      if (point->IsShared())
+       t->SetSharedMapBit(iter,kTRUE);
+      else
+       t->SetSharedMapBit(iter, kFALSE);
+    }
+    else {
+      t->SetClusterMapBit(iter, kFALSE);
+      t->SetSharedMapBit(iter, kFALSE);
+    }
   }
-  return cl;      
 }
 
 
 
+void AliTPCtrackerMI::AddCovariance(AliTPCseed * seed){
+  //
+  // Adding systematic error
+  // !!!! the systematic error for element 4 is in 1/cm not in pt 
 
-
-// AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
-// {
-//   //
-//   // 
-//   return &fTrackPoints[i];
-// }
-
-
+  const Double_t *param = AliTPCReconstructor::GetRecoParam()->GetSystematicError();
+  Double_t covar[15];
+  for (Int_t i=0;i<15;i++) covar[i]=0;
+  // 0
+  // 1    2
+  // 3    4    5
+  // 6    7    8    9 
+  // 10   11   12   13   14
+  covar[0] = param[0]*param[0];
+  covar[2] = param[1]*param[1];
+  covar[5] = param[2]*param[2];
+  covar[9] = param[3]*param[3];
+  Double_t facC =  AliTracker::GetBz()*kB2C;
+  covar[14]= param[4]*param[4]*facC*facC;
+  seed->AddCovariance(covar);
+}