]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCtrackerMI.cxx
warning fix
[u/mrichter/AliRoot.git] / TPC / AliTPCtrackerMI.cxx
index e7c5a8981c2ddd09010c0a52636d9276a8e8cbed..68aa0da4a097c532fb526e2f7ce8589caeca5029 100644 (file)
 #include "AliTPCcalibDButil.h"
 #include "AliTPCTransform.h"
 #include "AliTPCClusterParam.h"
+#include "AliTPCdEdxInfo.h"
 
 //
 
@@ -199,7 +200,8 @@ AliTPCtrackerMI::AliTPCtrackerMI()
                 fSeeds(0),
                 fIteration(0),
                 fkParam(0),
-                fDebugStreamer(0)
+                fDebugStreamer(0),
+                fUseHLTClusters(4)
 {
   //
   // default constructor
@@ -221,8 +223,10 @@ Int_t AliTPCtrackerMI::UpdateTrack(AliTPCseed * track, Int_t accept){
 
 
   AliTPCclusterMI* c =track->GetCurrentCluster();
-  if (accept>0) track->SetCurrentClusterIndex1(track->GetCurrentClusterIndex1() | 0x8000);  //sign not accepted clusters
-
+  if (accept > 0) //sign not accepted clusters
+    track->SetCurrentClusterIndex1(track->GetCurrentClusterIndex1() | 0x8000);  
+  else // unsign accpeted clusters
+    track->SetCurrentClusterIndex1(track->GetCurrentClusterIndex1() & 0xffff7fff);  
   UInt_t i = track->GetCurrentClusterIndex1();
 
   Int_t sec=(i&0xff000000)>>24; 
@@ -370,6 +374,14 @@ Int_t AliTPCtrackerMI::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluste
     seed->SetNFoundable(seed->GetNFoundable()-1);
     return 2;    
   }
+
+  if (fUseHLTClusters == 3 || fUseHLTClusters == 4) {
+    if(!AliTPCReconstructor::GetRecoParam()->GetUseHLTOnePadCluster()) {
+      if (TMath::Abs(cluster->GetSigmaY2()) < kAlmost0)
+       return 2;
+    }
+  }
+
   return 0;
 }
 
@@ -397,7 +409,9 @@ AliTracker(),
                 fSeeds(0),
                 fIteration(0),
                 fkParam(0),
-                fDebugStreamer(0)
+                 fDebugStreamer(0),
+                 fUseHLTClusters(4)
+
 {
   //---------------------------------------------------------------------
   // The main TPC tracker constructor
@@ -451,12 +465,19 @@ AliTPCtrackerMI::AliTPCtrackerMI(const AliTPCtrackerMI &t):
                 fSeeds(0),
                 fIteration(0),
                 fkParam(0),
-                fDebugStreamer(0)
+                 fDebugStreamer(0),
+                 fUseHLTClusters(4)
 {
   //------------------------------------
   // dummy copy constructor
   //------------------------------------------------------------------
   fOutput=t.fOutput;
+  for (Int_t irow=0; irow<200; irow++){
+    fXRow[irow]=0;
+    fYMax[irow]=0;
+    fPadLength[irow]=0;
+  }
+
 }
 AliTPCtrackerMI & AliTPCtrackerMI::operator=(const AliTPCtrackerMI& /*r*/)
 {
@@ -1125,7 +1146,7 @@ Bool_t   AliTPCtrackerMI::GetProlongation(Double_t x1, Double_t x2, Double_t x[5
 
 Int_t  AliTPCtrackerMI::LoadClusters (TTree *const tree)
 {
-  //
+  // load clusters
   //
   fInput = tree;
   return LoadClusters();
@@ -1254,7 +1275,10 @@ Int_t  AliTPCtrackerMI::LoadClusters()
   TTree * tree = fInput;
   TBranch * br = tree->GetBranch("Segment");
   br->SetAddress(&clrow);
-  //
+
+  // Conversion of pad, row coordinates in local tracking coords.
+  // Could be skipped here; is already done in clusterfinder
+
   Int_t j=Int_t(tree->GetEntries());
   for (Int_t i=0; i<j; i++) {
     br->GetEntry(i);
@@ -1354,7 +1378,7 @@ void AliTPCtrackerMI::FillClusterArray(TObjArray* array) const{
 
 void   AliTPCtrackerMI::Transform(AliTPCclusterMI * cluster){
   //
-  //
+  // transformation
   //
   AliTPCcalibDB * calibDB = AliTPCcalibDB::Instance();
   AliTPCTransform *transform = calibDB->GetTransform() ;
@@ -1585,9 +1609,10 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
   if (fIteration>0 && tpcindex>=-1){  //if we have already clusters 
     //        
     if (tpcindex==-1) return 0; //track in dead zone
-    if (tpcindex>0){     //
+    if (tpcindex >= 0){     //
       cl = t.GetClusterPointer(nr);
-      if ( (cl==0) ) cl = GetClusterMI(tpcindex);
+      //if (cl==0) cl = GetClusterMI(tpcindex);
+      if (!cl) cl = GetClusterMI(tpcindex);
       t.SetCurrentClusterIndex1(tpcindex); 
     }
     if (cl){      
@@ -1619,7 +1644,11 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
        t.SetNFoundable(t.GetNFoundable()+1);
        UpdateTrack(&t,accept);
        return 1;
-      }    
+      }
+      else { // Remove old cluster from track
+       t.SetClusterIndex(nr, -3);
+       t.SetClusterPointer(nr, 0);
+      }
     }
   }
   if (TMath::Abs(t.GetSnp())>AliTPCReconstructor::GetMaxSnpTracker()) return 0;  // cut on angle
@@ -1631,7 +1660,11 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
   //
   UInt_t index=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 (!t.PropagateTo(x)) {
+    if (fIteration==0) t.SetRemoval(10);
+    return 0;
+  }
+  Double_t y = t.GetY(); 
   if (TMath::Abs(y)>ymax){
     if (y > ymax) {
       t.SetRelativeSector((t.GetRelativeSector()+1) % fN);
@@ -1642,14 +1675,13 @@ Int_t AliTPCtrackerMI::FollowToNext(AliTPCseed& t, Int_t nr) {
       if (!t.Rotate(-fSectors->GetAlpha())) 
        return 0;
     }
-    //return 1;
+    if (!t.PropagateTo(x)) {
+      if (fIteration==0) t.SetRemoval(10);
+      return 0;
+    }
+    y = t.GetY();
   }
   //
-  if (!t.PropagateTo(x)) {
-    if (fIteration==0) t.SetRemoval(10);
-    return 0;
-  }
-  y=t.GetY(); 
   Double_t z=t.GetZ();
   //
 
@@ -1774,7 +1806,7 @@ Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t,  Int_t nr) {
   // This function tries to find a track prolongation to next pad row
   //-----------------------------------------------------------------
   t.SetCurrentCluster(0);
-  t.SetCurrentClusterIndex1(0);   
+  t.SetCurrentClusterIndex1(-3);   
    
   Double_t xt=t.GetX();
   Int_t     row = GetRowNumber(xt)-1; 
@@ -1859,9 +1891,9 @@ Int_t AliTPCtrackerMI::UpdateClusters(AliTPCseed& t,  Int_t nr) {
 
   if (!cl){
     index = t.GetClusterIndex2(nr);    
-    if ( (index>0) && (index&0x8000)==0){
+    if ( (index >= 0) && (index&0x8000)==0){
       cl = t.GetClusterPointer(nr);
-      if ( (cl==0) && (index>0)) cl = GetClusterMI(index);
+      if ( (cl==0) && (index >= 0)) cl = GetClusterMI(index);
       t.SetCurrentClusterIndex1(index);
       if (cl) {
        t.SetCurrentCluster(cl);
@@ -1912,8 +1944,8 @@ Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
  
   } else {
     if (fIteration==0){
-      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.GetNumberOfClusters()>18 && ( (t.GetSigmaY2()+t.GetSigmaZ2())>0.16)) t.SetRemoval(10);      
+      if ( t.GetNumberOfClusters()>18 && t.GetChi2()/t.GetNumberOfClusters()>6 ) t.SetRemoval(10);      
 
       if (( (t.GetNFoundable()*0.5 > t.GetNumberOfClusters()) || t.GetNoCluster()>15)) t.SetRemoval(10);
     }
@@ -1924,19 +1956,23 @@ Int_t AliTPCtrackerMI::FollowToNextCluster(AliTPCseed & t, Int_t nr) {
 
 
 //_____________________________________________________________________________
-Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
+Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step, Bool_t fromSeeds) {
   //-----------------------------------------------------------------
   // This function tries to find a track prolongation.
   //-----------------------------------------------------------------
   Double_t xt=t.GetX();
   //
-  Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
+  Double_t alpha=t.GetAlpha();
   if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();  
   if (alpha < 0.            ) alpha += 2.*TMath::Pi();  
   //
   t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
     
-  Int_t first = GetRowNumber(xt)-1;
+  Int_t first = GetRowNumber(xt);
+  if (!fromSeeds)
+    first -= step;
+  if (first < 0)
+    first = 0;
   for (Int_t nr= first; nr>=rf; nr-=step) {
     // update kink info
     if (t.GetKinkIndexes()[0]>0){
@@ -1979,19 +2015,23 @@ Int_t AliTPCtrackerMI::FollowProlongation(AliTPCseed& t, Int_t rf, Int_t step) {
 
 
 
-Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
+Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf, Bool_t fromSeeds) {
   //-----------------------------------------------------------------
   // This function tries to find a track prolongation.
   //-----------------------------------------------------------------
   //
   Double_t xt=t.GetX();  
-  Double_t alpha=t.GetAlpha() - fSectors->GetAlphaShift();
+  Double_t alpha=t.GetAlpha();
   if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();  
   if (alpha < 0.            ) alpha += 2.*TMath::Pi();  
   t.SetRelativeSector(Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN);
     
   Int_t first = t.GetFirstPoint();
-  if (first<GetRowNumber(xt)+1) first = GetRowNumber(xt)+1;
+  Int_t ri = GetRowNumber(xt); 
+  if (!fromSeeds)
+    ri += 1;
+
+  if (first<ri) first = ri;
   //
   if (first<0) first=0;
   for (Int_t nr=first; nr<=rf; nr++) {
@@ -2034,7 +2074,7 @@ Int_t AliTPCtrackerMI::FollowBackProlongation(AliTPCseed& t, Int_t rf) {
    
 Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t & sum2)
 {
-  //
+  // overlapping factor
   //
   sum1=0;
   sum2=0;
@@ -2077,7 +2117,7 @@ Float_t AliTPCtrackerMI::OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &
 
 void  AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
 {
-  //
+  // shared clusters
   //
   Float_t thetaCut = 0.2;//+10.*TMath::Sqrt(s1->GetSigmaTglZ()+ s2->GetSigmaTglZ());
   if (TMath::Abs(s1->GetTgl()-s2->GetTgl())>thetaCut) return;
@@ -2098,11 +2138,7 @@ void  AliTPCtrackerMI::SignShared(AliTPCseed * s1, AliTPCseed * s2)
     //    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>cutN0){
     // sign clusters
@@ -2676,7 +2712,7 @@ Int_t AliTPCtrackerMI::RefitInward(AliESDEvent *event)
   }
   transform->SetCurrentRecoParam((AliTPCRecoParam*)AliTPCReconstructor::GetRecoParam());
   const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
-
+  Int_t nContribut = event->GetNumberOfTracks();
   TGraphErrors * graphMultDependenceDeDx = 0x0;
   if (recoParam && recoParam->GetUseMultiplicityCorrectionDedx() && gainCalibArray) {
     if (recoParam->GetUseTotCharge()) {
@@ -2731,11 +2767,9 @@ Int_t AliTPCtrackerMI::RefitInward(AliESDEvent *event)
     seed->PropagateTo(fkParam->GetInnerRadiusLow());
     seed->UpdatePoints();
     AddCovariance(seed);
-    MakeBitmaps(seed);
+    MakeESDBitmaps(seed, esd);
     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) {
       TTreeSRedirector &cstream = *fDebugStreamer;
@@ -2754,12 +2788,28 @@ Int_t AliTPCtrackerMI::RefitInward(AliESDEvent *event)
       Float_t dedx  = seed->GetdEdx();
       // apply mutliplicity dependent dEdx correction if available
       if (graphMultDependenceDeDx) {
-       Int_t nContribut  = event->GetPrimaryVertexTPC()->GetNContributors();
        Double_t corrGain =  AliTPCcalibDButil::EvalGraphConst(graphMultDependenceDeDx, nContribut);
-       dedx /= corrGain;
+       dedx += (1 - corrGain)*50.; // MIP is normalized to 50
       }
       esd->SetTPCsignal(dedx, sdedx, ndedx);
       //
+      // fill new dEdx information
+      //
+      Double32_t signal[4]; 
+      Char_t ncl[3]; 
+      Char_t nrows[3];
+      //
+      for(Int_t iarr=0;iarr<3;iarr++) {
+       signal[iarr] = seed->GetDEDXregion(iarr+1);
+       ncl[iarr] = seed->GetNCDEDX(iarr+1);
+       nrows[iarr] = seed->GetNCDEDXInclThres(iarr+1);
+      }
+      signal[3] = seed->GetDEDXregion(4);
+      //
+      AliTPCdEdxInfo * infoTpcPid = new AliTPCdEdxInfo();
+      infoTpcPid->SetTPCSignalRegionInfo(signal, ncl, nrows);
+      esd->SetTPCdEdxInfo(infoTpcPid);
+      //
       // add seed to the esd track in Calib level
       //
       Bool_t storeFriend = gRandom->Rndm()<(kMaxFriendTracks)/Float_t(nseed);
@@ -2805,6 +2855,7 @@ Int_t AliTPCtrackerMI::PropagateBack(AliESDEvent *event)
     seed->UpdatePoints();
     AddCovariance(seed);
     AliESDtrack *esd=event->GetTrack(i);
+    if (!esd) continue; //never happen
     if (seed->GetNumberOfClusters()<60 && seed->GetNumberOfClusters()<(esd->GetTPCclusters(0) -5)*0.8){
       AliExternalTrackParam paramIn;
       AliExternalTrackParam paramOut;
@@ -2869,7 +2920,7 @@ void AliTPCtrackerMI::DeleteSeeds()
   fSeeds =0;
 }
 
-void AliTPCtrackerMI::ReadSeeds(AliESDEvent *const event, Int_t direction)
+void AliTPCtrackerMI::ReadSeeds(const AliESDEvent *const event, Int_t direction)
 {
   //
   //read seeds from the event
@@ -2936,24 +2987,27 @@ void AliTPCtrackerMI::ReadSeeds(AliESDEvent *const event, Int_t direction)
     // rotate to the local coordinate system
     //   
     fSectors=fInnerSec; fN=fkNIS;    
-    Double_t alpha=seed->GetAlpha() - fSectors->GetAlphaShift();
+    Double_t alpha=seed->GetAlpha();
     if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
     if (alpha < 0.            ) alpha += 2.*TMath::Pi();
-    Int_t ns=Int_t(alpha/fSectors->GetAlpha())%fN;
+    Int_t ns=Int_t(alpha/fSectors->GetAlpha()+0.0001)%fN;
     alpha =ns*fSectors->GetAlpha() + fSectors->GetAlphaShift();
+    alpha-=seed->GetAlpha();  
     if (alpha<-TMath::Pi()) alpha += 2*TMath::Pi();
     if (alpha>=TMath::Pi()) alpha -= 2*TMath::Pi();
-    alpha-=seed->GetAlpha();  
-    if (!seed->Rotate(alpha)) {
-      delete seed;
-      continue;
+    if (TMath::Abs(alpha) > 0.001) { // This should not happen normally
+      AliWarning(Form("Rotating track over %f",alpha));
+      if (!seed->Rotate(alpha)) {
+       delete seed;
+       continue;
+      }
     }
     seed->SetESD(esd);
     // sign clusters
     if (esd->GetKinkIndex(0)<=0){
       for (Int_t irow=0;irow<160;irow++){
        Int_t index = seed->GetClusterIndex2(irow);    
-       if (index>0){ 
+       if (index >= 0){ 
          //
          AliTPCclusterMI * cl = GetClusterMI(index);
          seed->SetClusterPointer(irow,cl);
@@ -3377,7 +3431,7 @@ void AliTPCtrackerMI::MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2,
       y3 = kcl->GetY(); 
       // apply angular cuts
       if (TMath::Abs(y1-y3)>dymax) continue;
-      x3 = x3; 
+      //x3 = x3; 
       z3 = kcl->GetZ();        
       if (TMath::Abs(z1-z3)>dzmax) continue;
       //
@@ -3834,7 +3888,7 @@ AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *const track, Float_t r0, Float
       if ( (index<p0) || x0[0]<0 ){
        if (trpoint->GetX()>1){
          clindex = track->GetClusterIndex2(i);
-         if (clindex>0){       
+         if (clindex >= 0){    
            x0[0] = trpoint->GetX();
            x0[1] = trpoint->GetY();
            x0[2] = trpoint->GetZ();
@@ -3845,7 +3899,7 @@ AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *const track, Float_t r0, Float
 
       if ( (index<p1) &&(trpoint->GetX()>1)){
        clindex = track->GetClusterIndex2(i);
-       if (clindex>0){
+       if (clindex >= 0){
          x1[0] = trpoint->GetX();
          x1[1] = trpoint->GetY();
          x1[2] = trpoint->GetZ();
@@ -3854,7 +3908,7 @@ AliTPCseed *AliTPCtrackerMI::MakeSeed(AliTPCseed *const track, Float_t r0, Float
       }
       if ( (index<p2) &&(trpoint->GetX()>1)){
        clindex = track->GetClusterIndex2(i);
-       if (clindex>0){
+       if (clindex >= 0){
          x2[0] = trpoint->GetX();
          x2[1] = trpoint->GetY();
          x2[2] = trpoint->GetZ(); 
@@ -5857,9 +5911,15 @@ Int_t AliTPCtrackerMI::ReadSeeds(const TFile *inp) {
 Int_t AliTPCtrackerMI::Clusters2Tracks (AliESDEvent *const esd)
 {
   //
+  // clusters to tracks
   
   if (fSeeds) DeleteSeeds();
-  fEvent = esd;
+  fEvent = esd; 
+
+  AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;  
+  transform->SetCurrentTimeStamp( esd->GetTimeStamp());
+  transform->SetCurrentRun(esd->GetRunNumber());
+
   Clusters2Tracks();
   if (!fSeeds) return 1;
   FillESD(fSeeds);
@@ -5895,7 +5955,7 @@ Int_t AliTPCtrackerMI::Clusters2Tracks() {
     CookLabel(pt,0.1); 
     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
+       pt->Desactivate(10);  // make track again active  // MvL: should be 0 ?
       else{
        pt->Desactivate(20);    
        delete fSeeds->RemoveAt(i);
@@ -5987,7 +6047,7 @@ Int_t AliTPCtrackerMI::Clusters2Tracks() {
   fIteration = 2;
   
   PrepareForProlongation(fSeeds,5.);
-  PropagateForward2(fSeeds);
+  PropagateForard2(fSeeds);
    
   printf("Time for FORWARD propagation: \t");timer.Print();timer.Start();
   // RemoveUsed(fSeeds,0.7,0.7,6);
@@ -6070,7 +6130,7 @@ TObjArray * AliTPCtrackerMI::Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_
 
 TObjArray * AliTPCtrackerMI::Tracking()
 {
-  //
+  // tracking
   //
   if (AliTPCReconstructor::GetRecoParam()->GetSpecialSeeding()) return TrackingSpecial();
   TStopwatch timer;
@@ -6379,7 +6439,7 @@ void  AliTPCtrackerMI::ParallelTracking(TObjArray *const arr, Int_t rfirst, Int_
   }    
 }
 
-void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray *const arr,Float_t fac) const
+void AliTPCtrackerMI::PrepareForBackProlongation(const TObjArray *const arr,Float_t fac) const
 {
   //
   //
@@ -6401,7 +6461,7 @@ void AliTPCtrackerMI::PrepareForBackProlongation(TObjArray *const arr,Float_t fa
       Float_t angle2 = pt->GetAlpha();
       
       if (TMath::Abs(angle1-angle2)>0.001){
-       pt->Rotate(angle1-angle2);
+       if (!pt->Rotate(angle1-angle2)) return;
        //angle2 = pt->GetAlpha();
        //pt->fRelativeSector = pt->GetAlpha()/fInnerSec->GetAlpha();
        //if (pt->GetAlpha()<0) 
@@ -6434,7 +6494,7 @@ void AliTPCtrackerMI::PrepareForProlongation(TObjArray *const arr, Float_t fac)
 
 }
 
-Int_t AliTPCtrackerMI::PropagateBack(TObjArray *const arr)
+Int_t AliTPCtrackerMI::PropagateBack(const TObjArray *const arr)
 {
   //
   // make back propagation
@@ -6447,7 +6507,7 @@ Int_t AliTPCtrackerMI::PropagateBack(TObjArray *const arr)
       fSectors = fInnerSec;
       //FollowBackProlongation(*pt,fInnerSec->GetNRows()-1);
       //fSectors = fOuterSec;
-      FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);     
+      FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1,1);     
       //if (pt->GetNumberOfClusters()<(pt->fEsd->GetTPCclusters(0)) ){
       //       Error("PropagateBack","Not prolonged track %d",pt->GetLabel());
       //       FollowBackProlongation(*pt2,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);
@@ -6457,7 +6517,7 @@ Int_t AliTPCtrackerMI::PropagateBack(TObjArray *const arr)
       AliESDkink * kink = fEvent->GetKink(pt->GetKinkIndex(0)-1);
       pt->SetFirstPoint(kink->GetTPCRow0());
       fSectors = fInnerSec;
-      FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1);  
+      FollowBackProlongation(*pt,fInnerSec->GetNRows()+fOuterSec->GetNRows()-1,1);  
     }
     CookLabel(pt,0.3);
   }
@@ -6465,7 +6525,7 @@ Int_t AliTPCtrackerMI::PropagateBack(TObjArray *const arr)
 }
 
 
-Int_t AliTPCtrackerMI::PropagateForward2(TObjArray *const arr)
+Int_t AliTPCtrackerMI::PropagateForward2(const TObjArray *const arr)
 {
   //
   // make forward propagation
@@ -6475,12 +6535,12 @@ Int_t AliTPCtrackerMI::PropagateForward2(TObjArray *const arr)
   for (Int_t i=0;i<nseed;i++){
     AliTPCseed *pt = (AliTPCseed*)arr->UncheckedAt(i);
     if (pt) { 
-      FollowProlongation(*pt,0);
+      FollowProlongation(*pt,0,1,1);
       CookLabel(pt,0.3);
     }
     
   }
 return 0;
+ return 0;
 }
 
 
@@ -6547,7 +6607,7 @@ Int_t AliTPCtrackerMI::PropagateBack(AliTPCseed *const pt, Int_t row0, Int_t row
 
 void  AliTPCtrackerMI::GetShape(AliTPCseed * seed, Int_t row)
 {
-  //
+  // gets cluster shape
   // 
   AliTPCClusterParam * clparam = AliTPCcalibDB::Instance()->GetClusterParam();
   Float_t zdrift = TMath::Abs((fkParam->GetZLength(0)-TMath::Abs(seed->GetZ())));
@@ -6712,7 +6772,7 @@ Int_t AliTPCtrackerMI::CookLabel(AliTPCseed *const t, Float_t wrong,Int_t first,
      }
   }
   noc = current;
-  if (noc<5) return -1;
+  //if (noc<5) return -1;
   Int_t lab=123456789;
   for (i=0; i<noc; i++) {
     AliTPCclusterMI *c=clusters[i];
@@ -6774,7 +6834,7 @@ Int_t  AliTPCtrackerMI::GetRowNumber(Double_t x[3]) const
 
 
 
-void AliTPCtrackerMI::MakeBitmaps(AliTPCseed *t)
+void AliTPCtrackerMI::MakeESDBitmaps(AliTPCseed *t, AliESDtrack *esd)
 {
   //-----------------------------------------------------------------------
   // Fill the cluster and sharing bitmaps of the track
@@ -6785,22 +6845,30 @@ void AliTPCtrackerMI::MakeBitmaps(AliTPCseed *t)
   AliTPCTrackerPoint *point;
   AliTPCclusterMI    *cluster;
   
+  Int_t nclsf = 0;
+  TBits clusterMap(159);
+  TBits sharedMap(159);
+  TBits fitMap(159);
   for (int iter=firstpoint; iter<lastpoint; iter++) {
     // Change to cluster pointers to see if we have a cluster at given padrow
+
     cluster = t->GetClusterPointer(iter);
     if (cluster) {
-      t->SetClusterMapBit(iter, kTRUE);
+      clusterMap.SetBitNumber(iter, kTRUE);
       point = t->GetTrackPoint(iter);
       if (point->IsShared())
-       t->SetSharedMapBit(iter,kTRUE);
-      else
-       t->SetSharedMapBit(iter, kFALSE);
+       sharedMap.SetBitNumber(iter,kTRUE);
     }
-    else {
-      t->SetClusterMapBit(iter, kFALSE);
-      t->SetSharedMapBit(iter, kFALSE);
+    if (t->GetClusterIndex(iter) >= 0 && (t->GetClusterIndex(iter) & 0x8000) == 0) {
+      fitMap.SetBitNumber(iter, kTRUE);
+      nclsf++;
     }
   }
+  esd->SetTPCClusterMap(clusterMap);
+  esd->SetTPCSharedMap(sharedMap);
+  esd->SetTPCFitMap(fitMap);
+  if (nclsf != t->GetNumberOfClusters())
+    AliWarning(Form("Inconsistency between ncls %d and indices %d (found %d)",t->GetNumberOfClusters(),nclsf,esd->GetTPCClusterMap().CountBits()));
 }
 
 Bool_t AliTPCtrackerMI::IsFindable(AliTPCseed & track){
@@ -6820,9 +6888,40 @@ Bool_t AliTPCtrackerMI::IsFindable(AliTPCseed & track){
 
 void AliTPCtrackerMI::AddCovariance(AliTPCseed * seed){
   //
-  // Adding systematic error
+  // Adding systematic error estimate to the covariance matrix
   // !!!! the systematic error for element 4 is in 1/cm not in pt 
+  //
+  const Double_t *param = AliTPCReconstructor::GetRecoParam()->GetSystematicError();
+  //
+  // use only the diagonal part if not specified otherwise
+  if (!AliTPCReconstructor::GetRecoParam()->GetUseSystematicCorrelation()) return AddCovarianceAdd(seed);
+  //
+  Double_t *covarS= (Double_t*)seed->GetCovariance();
+  Double_t factor[5]={1,1,1,1,1};
+  Double_t facC =  AliTracker::GetBz()*kB2C;
+  factor[0]= TMath::Sqrt(TMath::Abs((covarS[0] + param[0]*param[0])/covarS[0]));
+  factor[1]= TMath::Sqrt(TMath::Abs((covarS[2] + param[1]*param[1])/covarS[2]));
+  factor[2]= TMath::Sqrt(TMath::Abs((covarS[5] + param[2]*param[2])/covarS[5]));
+  factor[3]= TMath::Sqrt(TMath::Abs((covarS[9] + param[3]*param[3])/covarS[9]));
+  factor[4]= TMath::Sqrt(TMath::Abs((covarS[14] + facC*facC*param[4]*param[4])/covarS[14]));
+  // 0
+  // 1    2
+  // 3    4    5
+  // 6    7    8    9 
+  // 10   11   12   13   14
+  for (Int_t i=0; i<5; i++){
+    for (Int_t j=i; j<5; j++){
+      Int_t index=seed->GetIndex(i,j);
+      covarS[index]*=factor[i]*factor[j];
+    }
+  }
+}
+
 
+void AliTPCtrackerMI::AddCovarianceAdd(AliTPCseed * seed){
+  //
+  // Adding systematic error - as additive factor without correlation
+  //
   const Double_t *param = AliTPCReconstructor::GetRecoParam()->GetSystematicError();
   Double_t *covarIn= (Double_t*)seed->GetCovariance();
   Double_t covar[15];