]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/tracking-ca/AliHLTTPCCATracker.cxx
Obsolete tracker output removed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATracker.cxx
index 88c2690188954589dbcceca8b496f6e3040f6990..f8fed37e68128735e9b73e89c2c19ceb89017b31 100644 (file)
@@ -1,6 +1,6 @@
 // @(#) $Id$
-//***************************************************************************
-// This file is property of and copyright by the ALICE HLT Project          * 
+// **************************************************************************
+// This file is property of and copyright by the ALICE HLT Project          *
 // ALICE Experiment at CERN, All rights reserved.                           *
 //                                                                          *
 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
 // appear in the supporting documentation. The authors make no claims       *
 // about the suitability of this software for any purpose. It is            *
 // provided "as is" without express or implied warranty.                    *
+//                                                                          *
 //***************************************************************************
 
 #include "AliHLTTPCCATracker.h"
-#include "AliHLTTPCCAOutTrack.h"
-#include "AliHLTTPCCAGrid.h"
 #include "AliHLTTPCCARow.h"
 #include "AliHLTTPCCATrack.h"
 #include "AliHLTTPCCATracklet.h"
 #include "AliHLTTPCCAMath.h"
-#include "AliHLTTPCCAHit.h"
+#include "MemoryAssignmentHelpers.h"
 
 #include "TStopwatch.h"
 #include "AliHLTTPCCAHitArea.h"
 #include "AliHLTTPCCATrackletConstructor.h"
 #include "AliHLTTPCCATrackletSelector.h"
 #include "AliHLTTPCCAProcess.h"
-#include "AliHLTTPCCAUsedHitsInitialiser.h"
+#include "AliHLTTPCCASliceTrack.h"
+#include "AliHLTTPCCASliceOutput.h"
+#include "AliHLTTPCCAClusterData.h"
+#include "AliHLTTPCCADataCompressor.h"
 
 #include "AliHLTTPCCATrackParam.h"
 
+#include "AliHLTTPCCAGPUConfig.h"
+
 #if !defined(HLTCA_GPUCODE)
 #include <iostream>
+#include <iomanip>
+#include <string.h>
 #endif
 
-//#define DRAW
-
-#ifdef DRAW
-  #include "AliHLTTPCCADisplay.h"
-  #include "TApplication.h"
-#endif //DRAW
-
-ClassImp(AliHLTTPCCATracker)
-
-#if !defined(HLTCA_GPUCODE)  
-
-AliHLTTPCCATracker::AliHLTTPCCATracker()
-  :
-  fParam(),
-  fNHitsTotal(0),  
-  fCommonMemory(0), 
-  fCommonMemorySize(0),
-  fInputEvent(0),     
-  fInputEventSize(0), 
-  fRowData(0),     
-  fRowDataSize(0), 
-  fHitInputIDs(0), 
-  fHitWeights(0),  
-  fNTracklets(0),
-  fTrackletStartHits(0),
-  fTracklets(0), 
-  fNTracks(0),   
-  fTracks(0), 
-  fNTrackHits(0),
-  fTrackHits(0),
-  fNOutTracks(0),
-  fOutTracks(0), 
-  fNOutTrackHits(0),
-  fOutTrackHits(0),
-  fTmpHitInputIDs(0)
-{
-  // constructor
-}
-
-AliHLTTPCCATracker::AliHLTTPCCATracker( const AliHLTTPCCATracker& )
-  :
-  fParam(),
-  fNHitsTotal(0),
-  fCommonMemory(0), 
-  fCommonMemorySize(0),
-  fInputEvent(0),     
-  fInputEventSize(0), 
-  fRowData(0),     
-  fRowDataSize(0), 
-  fHitInputIDs(0), 
-  fHitWeights(0),  
-  fNTracklets(0),
-  fTrackletStartHits(0),
-  fTracklets(0), 
-  fNTracks(0),   
-  fTracks(0), 
-  fNTrackHits(0),
-  fTrackHits(0),
-  fNOutTracks(0),
-  fOutTracks(0), 
-  fNOutTrackHits(0),
-  fOutTrackHits(0),
-  fTmpHitInputIDs(0)
-{
-  // dummy
-}
-
-AliHLTTPCCATracker &AliHLTTPCCATracker::operator=( const AliHLTTPCCATracker& )
-{
-  // dummy
-  fCommonMemory = 0;
-  return *this;
-}
-
-GPUd() AliHLTTPCCATracker::~AliHLTTPCCATracker()
-{
-  // destructor
-  if( fCommonMemory ) delete[] fCommonMemory;
-  if( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
-}
+//#define DRAW1
+
+#ifdef DRAW1
+#include "AliHLTTPCCADisplay.h"
+#endif //DRAW1
+
+#ifdef HLTCA_INTERNAL_PERFORMANCE
+//#include "AliHLTTPCCAPerformance.h"
+#endif
+
+#ifdef HLTCA_STANDALONE
+#include "AliHLTTPCCAStandaloneFramework.h"
 #endif
 
+ClassImp( AliHLTTPCCATracker )
 
 
+#if !defined(HLTCA_GPUCODE)
+
+AliHLTTPCCATracker::~AliHLTTPCCATracker()
+{
+  // destructor
+       if (!fIsGPUTracker)
+       {
+               if (fCommonMem) delete fCommonMem;
+               if (fHitMemory) delete[] fHitMemory;
+               if (fTrackletMemory) delete[] fTrackletMemory;
+               if (fTrackMemory) delete[] fTrackMemory;
+               fCommonMem = NULL;
+               fHitMemory = fTrackMemory = NULL;
+       }
+}
+
 // ----------------------------------------------------------------------------------
-GPUd() void AliHLTTPCCATracker::Initialize( AliHLTTPCCAParam &param )
+void AliHLTTPCCATracker::Initialize( const AliHLTTPCCAParam &param )
 {
   // initialisation
   fParam = param;
   fParam.Update();
-  for( Int_t irow=0; irow<fParam.NRows(); irow++ ){
-    fRows[irow].SetX( fParam.RowX(irow) );
-    fRows[irow].SetMaxY( CAMath::Tan( fParam.DAlpha()/2.)*fRows[irow].X() );
-  }
+  fData.InitializeRows( fParam );
+
   StartEvent();
 }
 
-GPUd() void AliHLTTPCCATracker::StartEvent()
+void AliHLTTPCCATracker::StartEvent()
 {
-  // start new event and fresh the memory  
+  // start new event and fresh the memory
 
-  fNHitsTotal = 0;
-  Int_t oldSize = fCommonMemorySize;
-  SetPointers();
-  if( fCommonMemory && fCommonMemorySize > oldSize ){
-    delete[] fCommonMemory;
-    fCommonMemory = 0;
-  }
-  if( !fCommonMemory ){   
-    fCommonMemory = reinterpret_cast<Char_t*> ( new uint4 [ fCommonMemorySize/sizeof(uint4) + 100] );
-  }
-  SetPointers();  
-  *fNTracklets = 0;
-  *fNTracks = 0 ;
-  *fNTrackHits = 0;
-  *fNOutTracks = 0;
-  *fNOutTrackHits = 0;
-  if( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
-  fTmpHitInputIDs = 0;
+  SetupCommonMemory();
 }
 
-GPUhd() void  AliHLTTPCCATracker::SetPointers()
+void AliHLTTPCCATracker::SetGPUTracker()
 {
-  // set all pointers to the event memory
+       //Make this a GPU Tracker
+       fIsGPUTracker = true;
+       fData.SetGpuSliceData();
+}
 
-  Int_t gridSizeTotal = 2*(2*fNHitsTotal + 10*Param().NRows());
+char* AliHLTTPCCATracker::SetGPUTrackerCommonMemory(char* const pGPUMemory)
+{
+       //Set up common Memory Pointer for GPU Tracker
+  fCommonMem = (commonMemoryStruct*) pGPUMemory;
+  return(pGPUMemory + sizeof(commonMemoryStruct));
+}
 
-  ULong_t mem = (ULong_t) fCommonMemory;  
-  UInt_t sI = sizeof(Int_t);
-  UInt_t sF = sizeof(Float_t);
-  UInt_t sS = sizeof(Short_t);
-  UInt_t s4 = sizeof(uint4);
 
-  fInputEvent = (Char_t*) mem;  
-  fInputEventSize = (1+fParam.NRows()*2 + 1)*sI + (fNHitsTotal*2)*sF;
-  mem+= fInputEventSize;
+char* AliHLTTPCCATracker::SetGPUTrackerHitsMemory(char* pGPUMemory, int MaxNHits)
+{
+       //Set up Hits Memory Pointers for GPU Tracker
+       fHitMemory = (char*) pGPUMemory;
+       SetPointersHits(MaxNHits);
+       pGPUMemory += fHitMemorySize;
+       AssignMemory(fTrackletTmpStartHits, pGPUMemory, NHitsTotal());
+       AssignMemory(fRowStartHitCountOffset, pGPUMemory, Param().NRows());
+
+       return(pGPUMemory);
+}
 
-  mem = ( mem/s4 + 1 )*s4;
-  fRowData = (uint4*) mem;
-  fRowDataSize = ( 2*fNHitsTotal*sS +  //  yz
-                  gridSizeTotal*sS + // grid
-                  2*fNHitsTotal*sS +  // link up,link down
-                  fParam.NRows()*s4   // row alignment
-                  );
-  mem += fRowDataSize;
+char* AliHLTTPCCATracker::SetGPUTrackerTrackletsMemory(char* pGPUMemory, int MaxNTracks)
+{
+       //Set up Tracklet Memory Pointers for GPU Tracker
+       fTrackletMemory = (char*) pGPUMemory;
+       SetPointersTracklets(MaxNTracks);
+       pGPUMemory += fTrackletMemorySize;
+       AssignMemory(fGPUTrackletTemp, pGPUMemory, MaxNTracks);
+       AssignMemory(fRowBlockTracklets, pGPUMemory, MaxNTracks * 2 * (Param().NRows() / HLTCA_GPU_SCHED_ROW_STEP + 1));
+       AssignMemory(fRowBlockPos, pGPUMemory, 2 * (Param().NRows() / HLTCA_GPU_SCHED_ROW_STEP + 1));
+       AssignMemory(fBlockStartingTracklet, pGPUMemory, HLTCA_GPU_BLOCK_COUNT);
+
+       return(pGPUMemory);
+}
 
-  mem = ( mem/sI + 1 )*sI;
+char* AliHLTTPCCATracker::SetGPUTrackerTracksMemory(char* pGPUMemory, int MaxNTracks, int MaxNHits )
+{
+       //Set up Tracks Memory Pointer for GPU Tracker
+       fTrackMemory = (char*) pGPUMemory;
+       SetPointersTracks(MaxNTracks, MaxNHits);
+       pGPUMemory += fTrackMemorySize;
 
-  fHitInputIDs = (Int_t*) mem;
-  mem+= fNHitsTotal*sI;
+       return(pGPUMemory);
+}
 
-  fHitWeights = (Int_t*) mem;
-  mem+=  fNHitsTotal*sI;
+void AliHLTTPCCATracker::DumpSliceData(std::ostream &out)
+{
+       //Dump Slice Input Data to File
+       out << "Slice Data:" << std::endl;
+       for (int i = 0;i < Param().NRows();i++)
+       {
+               out << "Row: " << i << std::endl;
+               for (int j = 0;j < Row(i).NHits();j++)
+               {
+                       if (j && j % 16 == 0) out << std::endl;
+                       out << j << '-' << Data().HitDataY(Row(i), j) << '-' << Data().HitDataZ(Row(i), j) << ", ";
+               }
+               out << std::endl;
+       }
+}
 
-  fNTracklets = (Int_t*) mem;
-  mem+= sI;
+void AliHLTTPCCATracker::DumpLinks(std::ostream &out)
+{
+       //Dump Links (after Neighbours Finder / Cleaner) to file
+       out << "Hit Links:" << std::endl;
+       for (int i = 0;i < Param().NRows();i++)
+       {
+               out << "Row: " << i << std::endl;
+               for (int j = 0;j < Row(i).NHits();j++)
+               {
+                       if (j && j % 32 == 0) out << std::endl;
+                       out << HitLinkUpData(Row(i), j) << "/" << HitLinkDownData(Row(i), j) << ", ";
+               }
+               out << std::endl;
+       }
+}
 
-  fTrackletStartHits = (Int_t*) mem;
-  mem+= fNHitsTotal*sI;
+void AliHLTTPCCATracker::DumpHitWeights(std::ostream &out)
+{
+       //dump hit weights to file
+    out << "Hit Weights:" << std::endl;
+    for (int i = 0;i < Param().NRows();i++)
+    {
+       out << "Row: " << i << ":" << std::endl;
+       for (int j = 0;j < Row(i).NHits();j++)
+       {
+           if (j && j % 32 == 0) out << std::endl;
+           out << HitWeight(Row(i), j) << ", ";
+       }
+       out << std::endl;
+    }
+}
 
-  mem = ( mem/sizeof(AliHLTTPCCATracklet) + 1 )*sizeof(AliHLTTPCCATracklet);
+int AliHLTTPCCATracker::StarthitSortComparison(const void*a, const void* b)
+{
+       //qsort helper function to sort start hits
+       AliHLTTPCCAHitId* aa = (AliHLTTPCCAHitId*) a;
+       AliHLTTPCCAHitId* bb = (AliHLTTPCCAHitId*) b;
 
-  fTracklets = (AliHLTTPCCATracklet *) mem;
-  mem+= fNHitsTotal*sizeof(AliHLTTPCCATracklet);
-  
-  mem = ( mem/sI + 1 )*sI;
+       if (aa->RowIndex() != bb->RowIndex()) return(aa->RowIndex() - bb->RowIndex());
+       return(aa->HitIndex() - bb->HitIndex());
+}
 
-  fNTracks = (Int_t*) mem;
-  mem+= sI;
+void AliHLTTPCCATracker::DumpStartHits(std::ostream &out)
+{
+       //sort start hits and dump to file
+       out << "Start Hits: (" << *NTracklets() << ")" << std::endl;
+#ifdef HLTCA_GPU_SORT_DUMPDATA
+       qsort(TrackletStartHits(), *NTracklets(), sizeof(AliHLTTPCCAHitId), StarthitSortComparison);
+#endif
+       for (int i = 0;i < *NTracklets();i++)
+       {
+               out << TrackletStartHit(i).RowIndex() << "-" << TrackletStartHit(i).HitIndex() << std::endl;
+       }
+       out << std::endl;
+}
 
-  mem = ( mem/sizeof(AliHLTTPCCATrack) + 1 )*sizeof(AliHLTTPCCATrack);
+void AliHLTTPCCATracker::DumpTrackHits(std::ostream &out)
+{
+       //dump tracks to file
+       out << "Tracks: (" << *NTracks() << ")" << std::endl;
+#ifdef HLTCA_GPU_SORT_DUMPDATA
+       for (int k = 0;k < Param().NRows();k++)
+       {
+               for (int l = 0;l < Row(k).NHits();l++)
+               {
+#endif
+                       for (int j = 0;j < *NTracks();j++)
+                       {
+                               if (Tracks()[j].NHits() == 0 || !Tracks()[j].Alive()) continue;
+#ifdef HLTCA_GPU_SORT_DUMPDATA
+                               if (TrackHits()[Tracks()[j].FirstHitID()].RowIndex() == k && TrackHits()[Tracks()[j].FirstHitID()].HitIndex() == l)
+                               {
+#endif
+                                       for (int i = 0;i < Tracks()[j].NHits();i++)
+                                       {
+                                               out << TrackHits()[Tracks()[j].FirstHitID() + i].RowIndex() << "-" << TrackHits()[Tracks()[j].FirstHitID() + i].HitIndex() << ", ";
+                                       }
+                                       out << "(Track: " << j << ")" << std::endl;
+#ifdef HLTCA_GPU_SORT_DUMPDATA
+                               }
+                       }       
+#endif
+               }       
+#ifdef HLTCA_GPU_SORT_DUMPDATA
+       }
+#endif
+}
 
-  fTracks = (AliHLTTPCCATrack*) mem;
-  mem+= fNHitsTotal*sizeof(AliHLTTPCCATrack);
-  
-  mem = ( mem/sI + 1 )*sI;
-  fNTrackHits = (Int_t*) mem;
-  mem+= sI;
+void AliHLTTPCCATracker::DumpTrackletHits(std::ostream &out)
+{
+       //dump tracklets to file
+       out << "Tracklets: (" << *NTracklets() << ")" << std::endl;
+#ifdef HLTCA_GPU_SORT_DUMPDATA
+       AliHLTTPCCAHitId* tmpIds = new AliHLTTPCCAHitId[*NTracklets()];
+       AliHLTTPCCATracklet* tmpTracklets = new AliHLTTPCCATracklet[*NTracklets()];
+       memcpy(tmpIds, TrackletStartHits(), *NTracklets() * sizeof(AliHLTTPCCAHitId));
+       memcpy(tmpTracklets, Tracklets(), *NTracklets() * sizeof(AliHLTTPCCATracklet));
+#ifdef EXTERN_ROW_HITS
+       int* tmpHits = new int[*NTracklets() * Param().NRows()];
+       memcpy(tmpHits, TrackletRowHits(), *NTracklets() * Param().NRows() * sizeof(int));
+#endif
+       qsort(TrackletStartHits(), *NTracklets(), sizeof(AliHLTTPCCAHitId), StarthitSortComparison);
+       for (int i = 0;i < *NTracklets();i++)
+       {
+               for (int j = 0;j < *NTracklets();j++)
+               {
+                       if (tmpIds[i].RowIndex() == TrackletStartHit(j).RowIndex() && tmpIds[i].HitIndex() == TrackletStartHit(j).HitIndex())
+                       {
+                               memcpy(&Tracklets()[j], &tmpTracklets[i], sizeof(AliHLTTPCCATracklet));
+#ifdef EXTERN_ROW_HITS
+                               if (tmpTracklets[i].NHits())
+                               {
+                                       for (int k = tmpTracklets[i].FirstRow();k <= tmpTracklets[i].LastRow();k++)
+                                       {
+                                               fTrackletRowHits[k * *NTracklets() + j] = tmpHits[k * *NTracklets() + i];
+                                       }
+                               }
+#endif
+                               break;
+                       }
+               }
+       }
+       delete[] tmpIds;
+       delete[] tmpTracklets;
+#ifdef EXTERN_ROW_HITS
+       delete[] tmpHits;
+#endif
+#endif
+       for (int j = 0;j < *NTracklets();j++)
+       {
+               out << "Tracklet " << j << " (Hits: " << std::setw(3) << Tracklets()[j].NHits() << ", Start: " << std::setw(3) << TrackletStartHit(j).RowIndex() << "-" << std::setw(3) << TrackletStartHit(j).HitIndex() << ") ";
+               if (Tracklets()[j].NHits() == 0);
+               else if (Tracklets()[j].LastRow() > Tracklets()[j].FirstRow() && (Tracklets()[j].FirstRow() >= Param().NRows() || Tracklets()[j].LastRow() >= Param().NRows()))
+               {
+#ifdef HLTCA_STANDALONE
+                       printf("\nError: First %d Last %d Num %d", Tracklets()[j].FirstRow(), Tracklets()[j].LastRow(), Tracklets()[j].NHits());
+#endif
+               }
+               else if (Tracklets()[j].NHits() && Tracklets()[j].LastRow() > Tracklets()[j].FirstRow())
+               {
+                       for (int i = Tracklets()[j].FirstRow();i <= Tracklets()[j].LastRow();i++)
+                       {
+                               //if (Tracklets()[j].RowHit(i) != -1)
+#ifdef EXTERN_ROW_HITS
+                                       out << i << "-" << fTrackletRowHits[i * fCommonMem->fNTracklets + j] << ", ";
+#else
+                                       out << i << "-" << Tracklets()[j].RowHit(i) << ", ";
+#endif
+                       }
+               }
+               out << std::endl;
+       }
+}
 
-  fTrackHits = (Int_t*) mem;
-  mem+= fNHitsTotal*sI;
 
-  fNOutTracks = (Int_t*) mem;
-  mem+= sI;
+void AliHLTTPCCATracker::SetupCommonMemory()
+{
+  // set up common memory
 
-  mem = ( mem/sizeof(AliHLTTPCCAOutTrack) + 1 )*sizeof(AliHLTTPCCAOutTrack);
-  
-  fOutTracks = (AliHLTTPCCAOutTrack*) mem;
-  mem+= fNHitsTotal*sizeof(AliHLTTPCCAOutTrack);
+  if (!fIsGPUTracker)
+  {
+    if ( !fCommonMem ) {
+      // the 1600 extra bytes are not used unless fCommonMemorySize increases with a later event
+      //fCommonMemory = reinterpret_cast<char*> ( new uint4 [ fCommonMemorySize/sizeof( uint4 ) + 100] );
+         fCommonMem = new commonMemoryStruct;
+    }
 
-  mem = ( mem/sI + 1 )*sI;
-  fNOutTrackHits = (Int_t*) mem;
-  mem+= sI;
-  fOutTrackHits = (Int_t*) mem;
-  mem+= fNHitsTotal*sI;
+       if (fHitMemory) delete[] fHitMemory;
+       if (fTrackletMemory) delete[] fTrackletMemory;
+       if (fTrackMemory) delete[] fTrackMemory;
+  }
 
-  fCommonMemorySize = mem - (ULong_t) fCommonMemory;
-}
+  fHitMemory = fTrackletMemory = fTrackMemory = 0;
 
+  fData.Clear();
+  fCommonMem->fNTracklets = 0;
+  fCommonMem->fNTracks = 0 ;
+  fCommonMem->fNTrackHits = 0;
+}
 
-GPUd() void AliHLTTPCCATracker::ReadEvent( Int_t *RowFirstHit, Int_t *RowNHits, Float_t *Y, Float_t *Z, Int_t NHits )
+void AliHLTTPCCATracker::ReadEvent( AliHLTTPCCAClusterData *clusterData )
 {
-  //* Read event
+  // read event
+
+  fClusterData = clusterData;
 
-  fNHitsTotal = NHits;
+  StartEvent();
 
+  //* Convert input hits, create grids, etc.
+  fData.InitFromClusterData( *clusterData );
   {
-    Int_t oldSize = fCommonMemorySize;
-    SetPointers();
-    if( fCommonMemory && fCommonMemorySize > oldSize ){
-      delete[] fCommonMemory;
-      fCommonMemory = 0;
-    }
-    if( !fCommonMemory ){   
-      fCommonMemory = reinterpret_cast<Char_t*> ( new uint4 [ fCommonMemorySize/sizeof(uint4) + 100] );
-    }
-    SetPointers();  
-    *fNTracklets = 0;
-    *fNTracks = 0 ;
-    *fNOutTracks = 0;
-    *fNOutTrackHits = 0;
+    if (!fIsGPUTracker)
+       {
+               SetPointersHits( fData.NumberOfHits() ); // to calculate the size
+               fHitMemory = reinterpret_cast<char*> ( new uint4 [ fHitMemorySize/sizeof( uint4 ) + 100] );
+       }
+    SetPointersHits( fData.NumberOfHits() ); // set pointers for hits
   }
+}
 
-  reinterpret_cast<Int_t*>( fInputEvent )[0] = fParam.NRows();
-  reinterpret_cast<Int_t*>( fInputEvent )[1+fParam.NRows()*2] = NHits;
-  Int_t *rowHeaders = reinterpret_cast<Int_t*>( fInputEvent ) +1;
-  Float_t *hitsYZ = reinterpret_cast<Float_t*>( fInputEvent ) + 1+fParam.NRows()*2+1;
-  for( Int_t iRow=0; iRow<fParam.NRows(); iRow++ ){
-    rowHeaders[iRow*2  ] = RowFirstHit[iRow];
-    rowHeaders[iRow*2+1] = RowNHits[iRow];
-  }
-  for( Int_t iHit=0; iHit<NHits; iHit++ ){
-    hitsYZ[iHit*2  ] = Y[iHit];
-    hitsYZ[iHit*2+1] = Z[iHit];
-  }
+GPUhd() void  AliHLTTPCCATracker::SetPointersHits( int MaxNHits )
+{
+  // set all pointers to the event memory
 
-  //SG cell finder - test code
-
-  if( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
-  fTmpHitInputIDs = new Int_t [NHits];
-  const Float_t areaY = .5;
-  const Float_t areaZ = 1.;
-  Int_t newRowNHitsTotal = 0;
-  Bool_t *usedHits = new Bool_t [NHits];
-  for( Int_t iHit=0; iHit<NHits; iHit++ ) usedHits[iHit] = 0;
-  for( Int_t iRow=0; iRow<fParam.NRows(); iRow++ ){
-    rowHeaders[iRow*2  ] = newRowNHitsTotal; // new first hit
-    rowHeaders[iRow*2+1] = 0; // new N hits
-    Int_t newRowNHits = 0;
-    Int_t oldRowFirstHit = RowFirstHit[iRow];
-    Int_t oldRowLastHit = oldRowFirstHit + RowNHits[iRow];
-    for( Int_t iHit=oldRowFirstHit; iHit<oldRowLastHit; iHit++ ){
-      if( usedHits[iHit] ) continue;
-      Float_t y0 = Y[iHit];
-      Float_t z0 = Z[iHit];
-      Float_t cy = y0;
-      Float_t cz = z0;
-      Int_t nclu = 1;
-      usedHits[iHit]=1;
-      if(0) for( Int_t jHit=iHit+1; jHit<oldRowLastHit; jHit++ ){//SG!!!
-       //if( usedHits[jHit] ) continue;
-       Float_t dy = Y[jHit] - y0;
-       Float_t dz = Z[jHit] - z0;
-       if( CAMath::Abs(dy)<areaY && CAMath::Abs(dz)<areaZ ){
-         cy+=Y[jHit];
-         cz+=Z[jHit];
-         nclu++;
-         usedHits[jHit]=1;
-       }
-      }
-      Int_t id = newRowNHitsTotal+newRowNHits;
-      hitsYZ[id*2  ] = cy/nclu;
-      hitsYZ[id*2+1] = cz/nclu;
-      fTmpHitInputIDs[id] = iHit;
-      newRowNHits++;
-    }
-    rowHeaders[iRow*2+1] = newRowNHits;
-    newRowNHitsTotal+=newRowNHits;
-  }
-  fNHitsTotal = newRowNHitsTotal;
-  reinterpret_cast<Int_t*>( fInputEvent )[1+fParam.NRows()*2] = newRowNHitsTotal;
+  char *mem = fHitMemory;
+
+  // extra arrays for tpc clusters
+
+#ifdef HLTCA_GPU_SORT_STARTHITS_2
+  AssignMemory( fTrackletStartHits, mem, MaxNHits + 32);
+#else
+  AssignMemory( fTrackletStartHits, mem, MaxNHits);
+#endif
 
-  delete[] usedHits;  
-  SetupRowData();
+  // calculate the size
+
+  fHitMemorySize = mem - fHitMemory;
 }
 
+GPUhd() void  AliHLTTPCCATracker::SetPointersTracklets( int MaxNTracklets )
+{
+  // set all pointers to the tracklets memory
+  char *mem = fTrackletMemory;
+
+  // memory for tracklets
+
+  AssignMemory( fTracklets, mem, MaxNTracklets );
+#ifdef EXTERN_ROW_HITS
+  AssignMemory( fTrackletRowHits, mem, MaxNTracklets * Param().NRows());
+#endif
+
+  fTrackletMemorySize = mem - fTrackletMemory;
+}
 
-GPUd() void AliHLTTPCCATracker::SetupRowData()
+
+GPUhd() void  AliHLTTPCCATracker::SetPointersTracks( int MaxNTracks, int MaxNHits )
 {
-  //* Convert input hits, create grids, etc.
+  // set all pointers to the tracks memory
+  char *mem = fTrackMemory;
 
-  fNHitsTotal = reinterpret_cast<Int_t*>( fInputEvent )[1+fParam.NRows()*2];
-  Int_t *rowHeaders = reinterpret_cast<Int_t*>( fInputEvent ) +1;
-  Float_t *hitsYZ = reinterpret_cast<Float_t*>( fInputEvent ) + 1+fParam.NRows()*2+1;
-
-  for( Int_t iRow=0; iRow<fParam.NRows(); iRow++ ){
-    
-    AliHLTTPCCARow &row = fRows[iRow];
-    row.SetFirstHit( rowHeaders[iRow*2] );
-    row.SetNHits( rowHeaders[iRow*2+1] );
-    Float_t yMin=1.e3, yMax=-1.e3, zMin=1.e3, zMax=-1.e3;
-    Int_t nGrid =  row.NHits();
-    for( Int_t i=0; i<row.NHits(); i++ ){
-      Int_t j = row.FirstHit()+i;
-      Float_t y = hitsYZ[j*2];
-      Float_t z = hitsYZ[j*2+1];
-      if( yMax < y ) yMax = y;
-      if( yMin > y ) yMin = y;
-      if( zMax < z ) zMax = z;
-      if( zMin > z ) zMin = z;
-    }
-    if( nGrid <= 0 ){
-      yMin = yMax = zMin = zMax = 0;
-      nGrid = 1;
-    }
+  // memory for selected tracks
 
-    AliHLTTPCCAGrid grid;
-    grid.Create( yMin, yMax, zMin, zMax, nGrid );
-    
-    Float_t sy = ( CAMath::Abs( grid.StepYInv() ) >1.e-4 ) ?1./grid.StepYInv() :1;
-    Float_t sz = ( CAMath::Abs( grid.StepZInv() ) >1.e-4 ) ?1./grid.StepZInv() :1;
-    
-    //cout<<"grid n = "<<row.Grid().N()<<" "<<sy<<" "<<sz<<" "<<yMin<<" "<<yMax<<" "<<zMin<<" "<<zMax<<endl;
-    
-    Bool_t recreate=0;
-    if( sy < 2. ) { recreate = 1; sy = 2; }
-    if( sz < 2. ) { recreate = 1; sz = 2; }
-    if( recreate ) grid.Create( yMin, yMax, zMin, zMax, sy, sz );
-    row.SetGrid( grid );
-  }    
-
-  AliHLTTPCCAHit ffHits[fNHitsTotal];
-
-  Int_t rowDataOffset = 0;
-
-  for( Int_t iRow=0; iRow<fParam.NRows(); iRow++ ){
-
-    AliHLTTPCCARow &row = fRows[iRow];
-    const AliHLTTPCCAGrid &grid = row.Grid();
-
-    Int_t c[grid.N()+3+10];
-    Int_t bins[row.NHits()];
-    Int_t filled[ row.Grid().N() +3+10 ];
-
-    for( UInt_t bin=0; bin<row.Grid().N()+3; bin++ ) filled[bin] = 0;  
-
-    for( Int_t i=0; i<row.NHits(); i++ ){
-      Int_t j = row.FirstHit()+i;
-      Int_t bin = row.Grid().GetBin( hitsYZ[2*j], hitsYZ[2*j+1] );
-      bins[i] = bin;
-      filled[bin]++;
-    }
+  AssignMemory( fTracks, mem, MaxNTracks );
+  AssignMemory( fTrackHits, mem, 2 * MaxNHits );
+
+  // calculate the size
 
+  fTrackMemorySize = mem - fTrackMemory;
+}
+
+GPUh() int AliHLTTPCCATracker::CheckEmptySlice() const
+{
+       //Check if the Slice is empty, if so set the output apropriate and tell the reconstuct procesdure to terminate
+  if ( NHitsTotal() < 1 ) {
     {
-      Int_t n=0;
-      for( UInt_t bin=0; bin<row.Grid().N()+3; bin++ ){
-       c[bin] = n;
-       n+=filled[bin];
-      }
+      AliHLTTPCCASliceOutput::Allocate(*fOutput, 0, 0, fOutputControl);
+      AliHLTTPCCASliceOutput* useOutput = *fOutput;
+      if (useOutput == NULL) return(1);
+      useOutput->SetNTracks( 0 );
+      useOutput->SetNTrackClusters( 0 );
     }
 
-    for( Int_t i=0; i<row.NHits(); i++ ){ 
-      Int_t bin = bins[i];
-      Int_t ind = c[bin] + filled[bin]-1;
-      AliHLTTPCCAHit &h = ffHits[row.FirstHit()+ind];
-      fHitInputIDs[row.FirstHit()+ind] = fTmpHitInputIDs[row.FirstHit()+i];
-      h.SetY( hitsYZ[2*(row.FirstHit()+i)] );
-      h.SetZ( hitsYZ[2*(row.FirstHit()+i)+1] );
-      filled[bin]--;
-    }
+    return 1;
+  }
+  return 0;
+}
 
-    {
-      Float_t y0 = row.Grid().YMin();
-      Float_t stepY = (row.Grid().YMax() - y0)*(1./65535.);
-      Float_t z0 = row.Grid().ZMin();
-      Float_t stepZ = (row.Grid().ZMax() - z0)*(1./65535.);
-      if( stepY<1.e-4 ) stepY = 1.e-4;
-      if( stepZ<1.e-4 ) stepZ = 1.e-4;
-      Float_t stepYi = 1./stepY;
-      Float_t stepZi = 1./stepZ;
-      
-      row.SetHy0( y0 );
-      row.SetHz0( z0 );
-      row.SetHstepY( stepY );
-      row.SetHstepZ( stepZ );
-      row.SetHstepYi( stepYi );
-      row.SetHstepZi( stepZi );
-      
-      row.SetFullOffset( rowDataOffset );
-      ushort2 *p= (ushort2*)( fRowData + row.FullOffset() );
-      for( Int_t ih=0; ih<row.NHits(); ih++ ){
-       Int_t ihTot = row.FirstHit()+ih;
-       AliHLTTPCCAHit &hh = ffHits[ihTot];
-       Float_t xx = ((hh.Y() - y0)*stepYi);
-       Float_t yy = ((hh.Z() - z0)*stepZi);
-       if( xx<0 || yy<0 || xx>=65536 || yy>= 65536 ){
-         std::cout<<"!!!! hit packing error!!! "<<xx<<" "<<yy<<" "<<std::endl;
-       }
-       p[ih].x = (UShort_t) xx;
-       p[ih].y = (UShort_t) yy;
-      }
-      Int_t size = row.NHits()*sizeof(ushort2);
+void AliHLTTPCCATracker::RunNeighboursFinder()
+{
+       //Run the CPU Neighbours Finder
+       AliHLTTPCCAProcess<AliHLTTPCCANeighboursFinder>( Param().NRows(), 1, *this );
+}
 
-      row.SetFullGridOffset( row.NHits()*2 );   
-      UShort_t *p1 = ((UShort_t *)p) + row.FullGridOffset();
+void AliHLTTPCCATracker::RunNeighboursCleaner()
+{
+       //Run the CPU Neighbours Cleaner
+       AliHLTTPCCAProcess<AliHLTTPCCANeighboursCleaner>( Param().NRows() - 2, 1, *this );
+}
 
-      Int_t n = grid.N();
-      for( Int_t i=0; i<n; i++ ){
-       p1[i] = c[i];
-      }     
-      UShort_t a = c[n];
-      Int_t nn = n+grid.Ny()+3;
-      for( Int_t i=n; i<nn; i++ ) p1[i] = a;
+void AliHLTTPCCATracker::RunStartHitsFinder()
+{
+       //Run the CPU Start Hits Finder
+       AliHLTTPCCAProcess<AliHLTTPCCAStartHitsFinder>( Param().NRows() - 4, 1, *this );
+}
 
-      size+= (nn)*sizeof(UShort_t);
-      row.SetFullLinkOffset( row.NHits()*2 + nn );
-      size+= row.NHits()*2*sizeof(Short_t);
-      if( size%16 ) size = size/sizeof(uint4)+1;
-      else size = size/sizeof(uint4);
-      row.SetFullSize( size );
-      //cout<<iRow<<", "<<row.fNHits<<"= "<<size*16<<"b: "<<row.fFullOffset<<" "<<row.fFullSize<<" "<<row.fFullGridOffset<<" "<<row.fFullLinkOffset<<std::endl;
+void AliHLTTPCCATracker::RunTrackletConstructor()
+{
+       //Run CPU Tracklet Constructor
+  AliHLTTPCCATrackletConstructor::AliHLTTPCCATrackletConstructorNewCPU(*this);
+}
 
-      rowDataOffset+=size;
-    }  
-  } 
+void AliHLTTPCCATracker::RunTrackletSelector()
+{
+       //Run CPU Tracklet Selector
+  AliHLTTPCCAProcess<AliHLTTPCCATrackletSelector>( 1, fCommonMem->fNTracklets, *this );
 }
 
+#ifdef HLTCA_STANDALONE
+void AliHLTTPCCATracker::StandalonePerfTime(int i)
+{
+  //Query Performance Timer for Standalone Version of Tracker
+  if (fGPUDebugLevel >= 1)
+  {
+    AliHLTTPCCAStandaloneFramework::StandaloneQueryTime(&fPerfTimers[i]);
+  }
+}
+#else
+void AliHLTTPCCATracker::StandalonePerfTime(int /*i*/) {}
+#endif
 
 GPUh() void AliHLTTPCCATracker::Reconstruct()
 {
   //* reconstruction of event
-  //std::cout<<"Reconstruct slice "<<fParam.ISlice()<<", nHits="<<fNHitsTotal<<std::endl;
+  //std::cout<<"Reconstruct slice "<<fParam.ISlice()<<", nHits="<<NHitsTotal()<<std::endl;
 
   fTimers[0] = 0; // find neighbours
   fTimers[1] = 0; // construct tracklets
@@ -482,251 +488,302 @@ GPUh() void AliHLTTPCCATracker::Reconstruct()
   fTimers[5] = 0; // write output
   fTimers[6] = 0;
   fTimers[7] = 0;
-  
+
   //if( fParam.ISlice()<1 ) return; //SG!!!
 
   TStopwatch timer0;
 
-  //SetupRowData();
-  if( fNHitsTotal < 1 ) return;
+  StandalonePerfTime(0);
 
-#ifdef DRAW
-  if( !gApplication ){
-    TApplication *myapp = new TApplication("myapp",0,0);
-  }
-  //AliHLTTPCCADisplay::Instance().Init();  
+  if (CheckEmptySlice()) return;
 
-  AliHLTTPCCADisplay::Instance().ClearView();  
+#ifdef DRAW1
+  //if( fParam.ISlice()==2 || fParam.ISlice()==3)
+    {
+  AliHLTTPCCADisplay::Instance().ClearView();
   AliHLTTPCCADisplay::Instance().SetSliceView();
   AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
-  AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );  
-  if( fNHitsTotal>0 ){
-    AliHLTTPCCADisplay::Instance().DrawSliceHits( -1, .5);  
+  AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
+  if ( NHitsTotal() > 0 ) {
+    AliHLTTPCCADisplay::Instance().DrawSliceHits( kRed, .5 );
     AliHLTTPCCADisplay::Instance().Ask();
   }
-#endif
+  }
+#endif //DRAW1
 
-  *fNTracks = 0;
-  *fNTracklets = 0;
+       fCommonMem->fNTracklets = fCommonMem->fNTracks = fCommonMem->fNTrackHits = 0;
 
-#if !defined(HLTCA_GPUCODE)  
+#if !defined(HLTCA_GPUCODE)
 
-  AliHLTTPCCAProcess<AliHLTTPCCANeighboursFinder>( Param().NRows(), 1, *this );
+  if (fGPUDebugLevel >= 6)
+  {
+         *fGPUDebugOut << std::endl << std::endl << "Slice: " << Param().ISlice() << std::endl;
+         *fGPUDebugOut << "Slice Data:" << std::endl;
+         DumpSliceData(*fGPUDebugOut);
+  }
+
+  StandalonePerfTime(1);
 
-  AliHLTTPCCAProcess<AliHLTTPCCANeighboursCleaner>( Param().NRows()-2, 1, *this );
-  AliHLTTPCCAProcess<AliHLTTPCCAStartHitsFinder>( Param().NRows()-4, 1, *this );
+  RunNeighboursFinder();
 
-  Int_t nStartHits = *fNTracklets;
+  StandalonePerfTime(2);
+
+  if (fGPUDebugLevel >= 6) DumpLinks(*fGPUDebugOut);
   
-  Int_t nThreads = 128;
-  Int_t nBlocks = fNHitsTotal/nThreads + 1;
-  if( nBlocks<12 ){
-    nBlocks = 12; 
-    nThreads = fNHitsTotal/12+1;
-    if( nThreads%32 ) nThreads = (nThreads/32+1)*32;
-  }
-      
-  nThreads = fNHitsTotal;
-  nBlocks = 1;
-
-  AliHLTTPCCAProcess<AliHLTTPCCAUsedHitsInitialiser>(nBlocks, nThreads,*this);
-
-  Int_t nMemThreads = AliHLTTPCCATrackletConstructor::NMemThreads();
-  nThreads = 256;//96;
-  nBlocks = nStartHits/nThreads + 1;
-  if( nBlocks<30 ){
-    nBlocks = 30;
-    nThreads = (nStartHits)/30+1;
-    if( nThreads%32 ) nThreads = (nThreads/32+1)*32;
-  }
+#ifdef HLTCA_INTERNAL_PERFORMANCE
+  //if( Param().ISlice()<=2 )
+  //AliHLTTPCCAPerformance::Instance().LinkPerformance( Param().ISlice() );
+#endif
 
-  nThreads = nStartHits;
-  nBlocks = 1;
 
-  AliHLTTPCCAProcess1<AliHLTTPCCATrackletConstructor>(nBlocks, nMemThreads+nThreads,*this);
+#ifdef DRAW1
+  if ( NHitsTotal() > 0 ) {
+    AliHLTTPCCADisplay::Instance().DrawSliceLinks( -1, -1, 1 );
+    AliHLTTPCCADisplay::Instance().Ask();
+  }
+#endif //DRAW1
 
-  { 
-    nThreads = 128;
-    nBlocks = nStartHits/nThreads + 1;
-    if( nBlocks<12 ){
-      nBlocks = 12;  
-      nThreads = nStartHits/12+1;
-      nThreads = (nThreads/32+1)*32;
-    }
-        
-    *fNTrackHits = 0;
+  RunNeighboursCleaner();
 
-    nThreads = nStartHits;
-    nBlocks = 1;
+  StandalonePerfTime(3);
 
+  if (fGPUDebugLevel >= 6) DumpLinks(*fGPUDebugOut);
 
-    AliHLTTPCCAProcess<AliHLTTPCCATrackletSelector>(nBlocks, nThreads,*this);
+  RunStartHitsFinder();
 
-    //std::cout<<"Slice "<<Param().ISlice()<<": N start hits/tracklets/tracks = "<<nStartHits<<" "<<nStartHits<<" "<<*fNTracks<<std::endl;
-   }
-  
-  WriteOutput();      
+  StandalonePerfTime(4);
+  StandalonePerfTime(5);
+
+  if (fGPUDebugLevel >= 6) DumpStartHits(*fGPUDebugOut);
   
+  fData.ClearHitWeights();
 
-#endif
+  SetPointersTracklets( fCommonMem->fNTracklets * 2 ); // to calculate the size
+  fTrackletMemory = reinterpret_cast<char*> ( new uint4 [ fTrackletMemorySize/sizeof( uint4 ) + 100] );
+  SetPointersTracklets( fCommonMem->fNTracklets * 2 ); // set pointers for hits
 
-#ifdef DRAW
- {
-   AliHLTTPCCADisplay &disp = AliHLTTPCCADisplay::Instance();
-   AliHLTTPCCATracker &slice = *this;
-   std::cout<<"N out tracks = "<<*slice.NOutTracks()<<std::endl;
-   //disp.Ask();
-   AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
-   AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
-   disp.DrawSliceHits(-1,.5);
-   for( Int_t itr=0; itr<*slice.NOutTracks(); itr++ ){
-     std::cout<<"track N "<<itr<<", nhits="<<slice.OutTracks()[itr].NHits()<<std::endl;
-     disp.DrawSliceOutTrack( itr, kBlue );
-     //disp.Ask();
-     //int id = slice.OutTracks()[itr].OrigTrackID();
-     //AliHLTTPCCATrack &tr = Tracks()[id];
-     //for( Int_t ih=0; ih<tr.NHits(); ih++ ){       
-     //Int_t ic = (fTrackHits[tr.FirstHitID()+ih]);
-     //std::cout<<ih<<" "<<ID2IRow(ic)<<" "<<ID2IHit(ic)<<std::endl;
-     //}
-     //disp.DrawSliceTrack( id, kBlue );
-     //disp.Ask();
-   }
-   disp.Ask();
- }
-#endif
+  SetPointersTracks( fCommonMem->fNTracklets * 2, NHitsTotal() ); // to calculate the size
+  fTrackMemory = reinterpret_cast<char*> ( new uint4 [ fTrackMemorySize/sizeof( uint4 ) + 100] );
+  SetPointersTracks( fCommonMem->fNTracklets * 2, NHitsTotal() ); // set pointers for hits
+
+  StandalonePerfTime(6);
+  StandalonePerfTime(7);
+
+  RunTrackletConstructor();
+
+  StandalonePerfTime(8);
+
+  if (fGPUDebugLevel >= 6) DumpTrackletHits(*fGPUDebugOut);
+  if (fGPUDebugLevel >= 6) DumpHitWeights(*fGPUDebugOut);
 
-  timer0.Stop();  
-  fTimers[0] = timer0.CpuTime()/100.;
+  //std::cout<<"Slice "<<Param().ISlice()<<": NHits="<<NHitsTotal()<<", NTracklets="<<*NTracklets()<<std::endl;
 
- }
+  RunTrackletSelector();
 
+  StandalonePerfTime(9);
 
+  //std::cout<<"Slice "<<Param().ISlice()<<": N start hits/tracklets/tracks = "<<nStartHits<<" "<<nStartHits<<" "<<*fNTracks<<std::endl;
 
+  if (fGPUDebugLevel >= 6) DumpTrackHits(*fGPUDebugOut);
+
+  //std::cout<<"Memory used for slice "<<fParam.ISlice()<<" : "<<fCommonMemorySize/1024./1024.<<" + "<<fHitMemorySize/1024./1024.<<" + "<<fTrackMemorySize/1024./1024.<<" = "<<( fCommonMemorySize+fHitMemorySize+fTrackMemorySize )/1024./1024.<<" Mb "<<std::endl;
+
+  WriteOutput();
+
+  StandalonePerfTime(10);
+
+#endif
+
+#ifdef DRAW1
+  {
+    AliHLTTPCCADisplay &disp = AliHLTTPCCADisplay::Instance();
+    AliHLTTPCCATracker &slice = *this;
+    std::cout << "N out tracks = " << slice.NOutTracks() << std::endl;
+    AliHLTTPCCADisplay::Instance().SetSliceView();
+    AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
+    AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
+    disp.DrawSliceHits( kRed, .5 );
+    disp.Ask();
+    for ( int itr = 0; itr < slice.NOutTracks(); itr++ ) {
+      std::cout << "track N " << itr << ", nhits=" << slice.OutTracks()[itr].NHits() << std::endl;
+      disp.DrawSliceOutTrack( itr, kBlue );      
+      //disp.Ask();
+      //int id = slice.OutTracks()[itr].OrigTrackID();
+      //AliHLTTPCCATrack &tr = Tracks()[id];
+      //for( int ih=0; ih<tr.NHits(); ih++ ){
+      //int ic = (fTrackHits[tr.FirstHitID()+ih]);
+      //std::cout<<ih<<" "<<ID2IRow(ic)<<" "<<ID2IHit(ic)<<std::endl;
+      //}
+      //disp.DrawSliceTrack( id, kBlue );
+      //disp.Ask();
+    }
+    disp.Ask();
+  }
+#endif //DRAW1
+
+  timer0.Stop();
+  fTimers[0] = timer0.CpuTime() / 100.;
+
+}
 
 GPUh() void AliHLTTPCCATracker::WriteOutput()
 {
   // write output
 
   TStopwatch timer;
-  *fNOutTrackHits = 0;
-  *fNOutTracks = 0;
 
-  //cout<<"output: nTracks = "<<*fNTracks<<", nHitsTotal="<<fNHitsTotal<<std::endl;  
+  //cout<<"output: nTracks = "<<*fNTracks<<", nHitsTotal="<<NHitsTotal()<<std::endl;
+  
+  if (fOutputControl == NULL) fOutputControl = new AliHLTTPCCASliceOutput::outputControlStruct;
+  AliHLTTPCCASliceOutput::Allocate(*fOutput, fCommonMem->fNTracks, fCommonMem->fNTrackHits, fOutputControl);
+  AliHLTTPCCASliceOutput* useOutput = *fOutput;
+  if (useOutput == NULL) return;
+
+  useOutput->SetNTracks( fCommonMem->fNTracks );
+  useOutput->SetNTrackClusters( fCommonMem->fNTrackHits );
 
-  for( Int_t iTr=0; iTr<*fNTracks; iTr++){
+  int nStoredHits = 0;
 
+  for ( int iTr = 0; iTr < fCommonMem->fNTracks; iTr++ ) {
     AliHLTTPCCATrack &iTrack = fTracks[iTr];
-
-    //cout<<"iTr = "<<iTr<<", nHits="<<iTrack.NHits()<<std::endl;
-
-    //if( !iTrack.Alive() ) continue;
-    if( iTrack.NHits()<3 ) continue;          
-    AliHLTTPCCAOutTrack &out = fOutTracks[*fNOutTracks];
-    out.SetFirstHitRef( *fNOutTrackHits );
-    out.SetNHits( 0 );
-    out.SetOrigTrackID( iTr );    
-    out.SetStartPoint( iTrack.Param() );
-    out.SetEndPoint( iTrack.Param() );    
-
-    Int_t iID = iTrack.FirstHitID();
-    Int_t nOutTrackHitsOld = *fNOutTrackHits;
-    for( Int_t ith=0; ith<iTrack.NHits(); ith++ ){
-      Int_t ic = (fTrackHits[iID+ith]);
-      const AliHLTTPCCARow &row = ID2Row(ic);
-      Int_t ih = ID2IHit(ic);
-      fOutTrackHits[*fNOutTrackHits] = fHitInputIDs[row.FirstHit()+ih];      
-      (*fNOutTrackHits)++;
-      //cout<<"write i,row,hit,id="<<ith<<", "<<ID2IRow(ic)<<", "<<ih<<", "<<fHitInputIDs[row.FirstHit()+ih]<<std::endl;     
-      if( *fNOutTrackHits>fNHitsTotal ){
-       std::cout<<"fNOutTrackHits>fNHitsTotal"<<std::endl;
-       //exit(0);
-       return;
+    AliHLTTPCCASliceTrack out;
+    out.SetFirstClusterRef( nStoredHits );
+    out.SetNClusters( iTrack.NHits() );
+    out.SetParam( iTrack.Param() );
+   
+    useOutput->SetTrack( iTr, out );
+   
+    int iID = iTrack.FirstHitID();
+    for ( int ith = 0; ith < iTrack.NHits(); ith++ ) {
+      const AliHLTTPCCAHitId &ic = fTrackHits[iID + ith];
+      int iRow = ic.RowIndex();
+      int ih = ic.HitIndex();
+      
+      const AliHLTTPCCARow &row = fData.Row( iRow );
+      
+      //float y0 = row.Grid().YMin();
+      //float z0 = row.Grid().ZMin();
+      //float stepY = row.HstepY();
+      //float stepZ = row.HstepZ();
+      //float x = row.X();
+      
+      //const uint4 *tmpint4 = RowData() + row.FullOffset();
+      //const ushort2 *hits = reinterpret_cast<const ushort2*>(tmpint4);
+      //ushort2 hh = hits[ih];
+      //float y = y0 + hh.x*stepY;
+      //float z = z0 + hh.y*stepZ;
+      
+      int clusterIndex = fData.ClusterDataIndex( row, ih );
+      int clusterRowIndex = clusterIndex - fClusterData->RowOffset( iRow );
+      
+      if ( clusterIndex < 0 || clusterIndex >= fClusterData->NumberOfClusters() ) {
+       //std::cout << inpIDtot << ", " << fClusterData->NumberOfClusters()
+       //<< "; " << inpID << ", " << fClusterData->NumberOfClusters( iRow ) << std::endl;
+       //abort();
+       continue;
       }
-      out.SetNHits( out.NHits() + 1 );      
-    }    
-    if( out.NHits() >= 2 ){
-      (*fNOutTracks)++;
-    }else {
-      (*fNOutTrackHits) = nOutTrackHitsOld;
+      if ( clusterRowIndex < 0 || clusterRowIndex >= fClusterData->NumberOfClusters( iRow ) ) {
+       //std::cout << inpIDtot << ", " << fClusterData->NumberOfClusters()
+       //<< "; " << inpID << ", " << fClusterData->NumberOfClusters( iRow ) << std::endl;
+       //abort();
+       continue;
+      }
+      
+      float origX = fClusterData->X( clusterIndex );
+      float origY = fClusterData->Y( clusterIndex );
+      float origZ = fClusterData->Z( clusterIndex );
+      
+      int id = fClusterData->Id( clusterIndex );
+      AliHLTTPCCACompressedCluster cXYZ = AliHLTTPCCADataCompressor::PackXYZ( iRow, origX, origY, origZ );
+      
+      //float2 hUnpackedYZ;
+      //hUnpackedYZ.x = origY;
+      //hUnpackedYZ.y = origZ;
+      //float hUnpackedX = origX;
+      
+      useOutput->SetClusterId( nStoredHits, id  );
+      useOutput->SetClusterRow( nStoredHits, ( unsigned char ) iRow  );
+      useOutput->SetClusterPackedXYZ( nStoredHits, cXYZ );
+      nStoredHits++;
     }
   }
+
   timer.Stop();
-  fTimers[5]+=timer.CpuTime();
+  fTimers[5] += timer.CpuTime();
 }
 
-GPUh() void AliHLTTPCCATracker::FitTrackFull( AliHLTTPCCATrack &/**/, Float_t * /**/ ) const 
-{  
+#endif
+
+GPUh() void AliHLTTPCCATracker::FitTrackFull( const AliHLTTPCCATrack &/**/, float * /**/ ) const
+{
   // fit track with material
-#ifdef XXX    
-  //* Fit the track   
+#ifdef XXX
+  //* Fit the track
   FitTrack( iTrack, tt0 );
-  if( iTrack.NHits()<=3 ) return;
-    
+  if ( iTrack.NHits() <= 3 ) return;
+
   AliHLTTPCCATrackParam &t = iTrack.Param();
   AliHLTTPCCATrackParam t0 = t;
 
   t.Chi2() = 0;
-  t.NDF() = -5;        
-  Bool_t first = 1;
-
-  Int_t iID = iTrack.FirstHitID();
-  for( Int_t ih=0; ih<iTrack.NHits(); ih++, iID++ ){
-    Int_t *ic = &(fTrackHits[iID]);
-    Int_t iRow = ID2IRow(*ic);
-    AliHLTTPCCARow &row = fRows[iRow];      
-    if( !t0.TransportToX( row.X() ) ) continue;      
-    Float_t dy, dz;
-    AliHLTTPCCAHit &h = ID2Hit(*ic);
-
-    // check for wrong hits    
-    if(0){
+  t.NDF() = -5;
+  bool first = 1;
+
+  int iID = iTrack.FirstHitID();
+  for ( int ih = 0; ih < iTrack.NHits(); ih++, iID++ ) {
+    const AliHLTTPCCAHitId &ic = fTrackHits[iID];
+    int iRow = ic.rowIndex();
+    const AliHLTTPCCARow &row = fData.Row( iRow );
+    if ( !t0.TransportToX( row.X() ) ) continue;
+    float dy, dz;
+    const AliHLTTPCCAHit &h = ic.hitIndex();
+
+    // check for wrong hits
+    if ( 0 ) {
       dy = t0.GetY() - h.Y();
       dz = t0.GetZ() - h.Z();
-      
+
       //if( dy*dy > 3.5*3.5*(/*t0.GetErr2Y() + */h.ErrY()*h.ErrY() ) ) continue;//SG!!!
-      //if( dz*dz > 3.5*3.5*(/*t0.GetErr2Z() + */h.ErrZ()*h.ErrZ() ) ) continue;      
+      //if( dz*dz > 3.5*3.5*(/*t0.GetErr2Z() + */h.ErrZ()*h.ErrZ() ) ) continue;
     }
 
-    if( !t.TransportToX( row.X() ) ) continue;  
+    if ( !t.TransportToX( row.X() ) ) continue;
 
     //* Update the track
-           
-    if( first ){
-      t.Cov()[ 0] = .5*.5;
+
+    if ( first ) {
+      t.Cov()[ 0] = .5 * .5;
       t.Cov()[ 1] = 0;
-      t.Cov()[ 2] = .5*.5;
+      t.Cov()[ 2] = .5 * .5;
       t.Cov()[ 3] = 0;
       t.Cov()[ 4] = 0;
-      t.Cov()[ 5] = .2*.2;
+      t.Cov()[ 5] = .2 * .2;
       t.Cov()[ 6] = 0;
       t.Cov()[ 7] = 0;
       t.Cov()[ 8] = 0;
-      t.Cov()[ 9] = .2*.2;
+      t.Cov()[ 9] = .2 * .2;
       t.Cov()[10] = 0;
       t.Cov()[11] = 0;
       t.Cov()[12] = 0;
       t.Cov()[13] = 0;
-      t.Cov()[14] = .2*.2;
+      t.Cov()[14] = .2 * .2;
       t.Chi2() = 0;
       t.NDF() = -5;
     }
-    Float_t err2Y, err2Z;
+    float err2Y, err2Z;
     GetErrors2( iRow, t, err2Y, err2Z );
 
-    if( !t.Filter2( h.Y(), h.Z(), err2Y, err2Z ) ) continue;
+    if ( !t.Filter2( h.Y(), h.Z(), err2Y, err2Z ) ) continue;
 
-    first = 0;      
-  }  
+    first = 0;
+  }
   /*
-  Float_t cosPhi = iTrack.Param().GetCosPhi();
+  float cosPhi = iTrack.Param().GetCosPhi();
   p0.Param().TransportToX(ID2Row( iTrack.PointID()[0] ).X());
-  p2.Param().TransportToX(ID2Row( iTrack.PointID()[1] ).X());  
+  p2.Param().TransportToX(ID2Row( iTrack.PointID()[1] ).X());
   if( p0.Param().GetCosPhi()*cosPhi<0 ){ // change direction
-  Float_t *par = p0.Param().Par();
-  Float_t *cov = p0.Param().Cov();
+  float *par = p0.Param().Par();
+  float *cov = p0.Param().Cov();
   par[2] = -par[2]; // sin phi
   par[3] = -par[3]; // DzDs
     par[4] = -par[4]; // kappa
@@ -742,24 +799,24 @@ GPUh() void AliHLTTPCCATracker::FitTrackFull( AliHLTTPCCATrack &/**/, Float_t *
 #endif
 }
 
-GPUh() void AliHLTTPCCATracker::FitTrack( AliHLTTPCCATrack &/*track*/, Float_t */*t0[]*/ ) const 
-{      
-  //* Fit the track   
+GPUh() void AliHLTTPCCATracker::FitTrack( const AliHLTTPCCATrack &/*track*/, float * /*t0[]*/ ) const
+{
+  //* Fit the track
 #ifdef XXX
-  AliHLTTPCCAEndPoint &p2 = ID2Point(track.PointID()[1]);
-  AliHLTTPCCAHit &c0 = ID2Hit(fTrackHits[p0.TrackHitID()].HitID());    
-  AliHLTTPCCAHit &c1 = ID2Hit(fTrackHits[track.HitID()[1]].HitID());   
-  AliHLTTPCCAHit &c2 = ID2Hit(fTrackHits[p2.TrackHitID()].HitID());    
-  AliHLTTPCCARow &row0 = ID2Row(fTrackHits[p0.TrackHitID()].HitID());
-  AliHLTTPCCARow &row1 = ID2Row(fTrackHits[track.HitID()[1]].HitID());
-  AliHLTTPCCARow &row2 = ID2Row(fTrackHits[p2.TrackHitID()].HitID());
-  Float_t sp0[5] = {row0.X(), c0.Y(), c0.Z(), c0.ErrY(), c0.ErrZ() };
-  Float_t sp1[5] = {row1.X(), c1.Y(), c1.Z(), c1.ErrY(), c1.ErrZ() };
-  Float_t sp2[5] = {row2.X(), c2.Y(), c2.Z(), c2.ErrY(), c2.ErrZ() };
-  //cout<<"Fit track, points ="<<sp0[0]<<" "<<sp0[1]<<" / "<<sp1[0]<<" "<<sp1[1]<<" / "<<sp2[0]<<" "<<sp2[1]<<std::endl;
-  if( track.NHits()>=3 ){    
-    p0.Param().ConstructXYZ3(sp0,sp1,sp2,p0.Param().CosPhi(), t0);
-    p2.Param().ConstructXYZ3(sp2,sp1,sp0,p2.Param().CosPhi(), t0);
+  AliHLTTPCCAEndPoint &p2 = ID2Point( track.PointID()[1] );
+  const AliHLTTPCCAHit &c0 = ID2Hit( fTrackHits[p0.TrackHitID()].HitID() );
+  const AliHLTTPCCAHit &c1 = ID2Hit( fTrackHits[track.HitID()[1]].HitID() );
+  const AliHLTTPCCAHit &c2 = ID2Hit( fTrackHits[p2.TrackHitID()].HitID() );
+  const AliHLTTPCCARow &row0 = ID2Row( fTrackHits[p0.TrackHitID()].HitID() );
+  const AliHLTTPCCARow &row1 = ID2Row( fTrackHits[track.HitID()[1]].HitID() );
+  const AliHLTTPCCARow &row2 = ID2Row( fTrackHits[p2.TrackHitID()].HitID() );
+  float sp0[5] = {row0.X(), c0.Y(), c0.Z(), c0.ErrY(), c0.ErrZ() };
+  float sp1[5] = {row1.X(), c1.Y(), c1.Z(), c1.ErrY(), c1.ErrZ() };
+  float sp2[5] = {row2.X(), c2.Y(), c2.Z(), c2.ErrY(), c2.ErrZ() };
+  //std::cout<<"Fit track, points ="<<sp0[0]<<" "<<sp0[1]<<" / "<<sp1[0]<<" "<<sp1[1]<<" / "<<sp2[0]<<" "<<sp2[1]<<std::endl;
+  if ( track.NHits() >= 3 ) {
+    p0.Param().ConstructXYZ3( sp0, sp1, sp2, p0.Param().CosPhi(), t0 );
+    p2.Param().ConstructXYZ3( sp2, sp1, sp0, p2.Param().CosPhi(), t0 );
     //p2.Param() = p0.Param();
     //p2.Param().TransportToX(row2.X());
     //p2.Param().Par()[1] = -p2.Param().Par()[1];
@@ -768,175 +825,75 @@ GPUh() void AliHLTTPCCATracker::FitTrack( AliHLTTPCCATrack &/*track*/, Float_t *
     p0.Param().X() = row0.X();
     p0.Param().Y() = c0.Y();
     p0.Param().Z() = c0.Z();
-    p0.Param().Err2Y() = c0.ErrY()*c0.ErrY();
-    p0.Param().Err2Z() = c0.ErrZ()*c0.ErrZ();
+    p0.Param().Err2Y() = c0.ErrY() * c0.ErrY();
+    p0.Param().Err2Z() = c0.ErrZ() * c0.ErrZ();
     p2.Param().X() = row2.X();
     p2.Param().Y() = c2.Y();
     p2.Param().Z() = c2.Z();
-    p2.Param().Err2Y() = c2.ErrY()*c2.ErrY();
-    p2.Param().Err2Z() = c2.ErrZ()*c2.ErrZ();
+    p2.Param().Err2Y() = c2.ErrY() * c2.ErrY();
+    p2.Param().Err2Z() = c2.ErrZ() * c2.ErrZ();
   }
 #endif
 }
 
 
-
-GPUd() void AliHLTTPCCATracker::GetErrors2( Int_t iRow, Float_t z, Float_t sinPhi, Float_t cosPhi, Float_t DzDs, Float_t &Err2Y, Float_t &Err2Z ) const
+GPUd() void AliHLTTPCCATracker::GetErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const
 {
   //
   // Use calibrated cluster error from OCDB
   //
 
-  z = CAMath::Abs((250.-0.275)-CAMath::Abs(z));
-  Int_t    type = (iRow<63) ? 0: ( (iRow>126) ? 1:2 );
-  Float_t cosPhiInv = CAMath::Abs(cosPhi)>1.e-2 ?1./cosPhi :0;
-  Float_t angleY = sinPhi*cosPhiInv ;
-  Float_t angleZ = DzDs*cosPhiInv ; // SG was bug??? 
-
-  Err2Y = fParam.GetClusterError2(0,type, z,angleY);  
-  Err2Z = fParam.GetClusterError2(1,type, z,angleZ);
+  fParam.GetClusterErrors2( iRow, z, sinPhi, cosPhi, DzDs, Err2Y, Err2Z );
+  Err2Y*=fParam.ClusterError2CorrectionY();
+  Err2Z*=fParam.ClusterError2CorrectionZ();
 }
 
-GPUd() void AliHLTTPCCATracker::GetErrors2( Int_t iRow, const AliHLTTPCCATrackParam &t, Float_t &Err2Y, Float_t &Err2Z ) const
+GPUd() void AliHLTTPCCATracker::GetErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const
 {
   //
   // Use calibrated cluster error from OCDB
   //
 
-  Float_t z = CAMath::Abs((250.-0.275)-CAMath::Abs(t.GetZ()));
-  Int_t    type = (iRow<63) ? 0: ( (iRow>126) ? 1:2 );
-  Float_t cosPhiInv = CAMath::Abs(t.GetCosPhi())>1.e-2 ?1./t.GetCosPhi() :0;
-  Float_t angleY = t.GetSinPhi()*cosPhiInv ;
-  Float_t angleZ = t.GetDzDs()*cosPhiInv ; // SG was bug??? 
-
-  Err2Y = fParam.GetClusterError2(0,type, z,angleY);  
-  Err2Z = fParam.GetClusterError2(1,type, z,angleZ);
+  fParam.GetClusterErrors2( iRow, t.GetZ(), t.SinPhi(), t.GetCosPhi(), t.DzDs(), Err2Y, Err2Z );
 }
 
 
-#if !defined(HLTCA_GPUCODE)  
+#if !defined(HLTCA_GPUCODE)
 
-GPUh() void AliHLTTPCCATracker::WriteEvent( std::ostream &out ) 
+GPUh() void AliHLTTPCCATracker::WriteEvent( std::ostream &out )
 {
   // write event to the file
-  for( Int_t iRow=0; iRow<fParam.NRows(); iRow++ ){
-    out<<fRows[iRow].FirstHit()<<" "<<fRows[iRow].NHits()<<std::endl;
-  } 
-  out<<fNHitsTotal<<std::endl;
-
-  Float_t y[fNHitsTotal], z[fNHitsTotal];
-  for( Int_t iRow=0; iRow<fParam.NRows(); iRow++){
-    AliHLTTPCCARow &row = fRows[iRow];
-    Float_t y0 = row.Grid().YMin();
-    Float_t z0 = row.Grid().ZMin();
-    Float_t stepY = row.HstepY();
-    Float_t stepZ = row.HstepZ();
-    const uint4* tmpint4 = RowData() + row.FullOffset();
-    const ushort2 *hits = reinterpret_cast<const ushort2*>(tmpint4);
-    for( Int_t ih=0; ih<fRows[iRow].NHits(); ih++ ){
-      Int_t ihTot = row.FirstHit() + ih;
-      Int_t id = fHitInputIDs[ihTot];
-      ushort2 hh = hits[ih];
-      y[id] = y0 + hh.x*stepY;
-      z[id] = z0 + hh.y*stepZ;
+  for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
+    out << fData.Row( iRow ).HitNumberOffset() << " " << fData.Row( iRow ).NHits() << std::endl;
+  }
+  out << NHitsTotal() << std::endl;
+
+  AliHLTResizableArray<float> y( NHitsTotal() ), z( NHitsTotal() );
+
+  for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
+    const AliHLTTPCCARow &row = Row( iRow );
+    float y0 = row.Grid().YMin();
+    float z0 = row.Grid().ZMin();
+    float stepY = row.HstepY();
+    float stepZ = row.HstepZ();
+    for ( int ih = 0; ih < fData.Row( iRow ).NHits(); ih++ ) {
+      int id = HitInputID( row, ih );
+      y[id] = y0 + HitDataY( row, ih ) * stepY;
+      z[id] = z0 + HitDataZ( row, ih ) * stepZ;
     }
   }
-  for( Int_t ih=0; ih<fNHitsTotal; ih++ ){
-    out<<y[ih]<<" "<<z[ih]<<std::endl;
+  for ( int ih = 0; ih < NHitsTotal(); ih++ ) {
+    out << y[ih] << " " << z[ih] << std::endl;
   }
 }
 
-GPUh() void AliHLTTPCCATracker::ReadEvent( std::istream &in ) 
-{
-  //* Read event from file 
-
-  Int_t rowFirstHit[Param().NRows()], rowNHits[Param().NRows()];  
-  for( Int_t iRow=0; iRow<Param().NRows(); iRow++ ){
-    in>>rowFirstHit[iRow]>>rowNHits[iRow];
-  }
-  Int_t nHits;
-  in >> nHits;
-  Float_t y[nHits], z[nHits];
-  for( Int_t ih=0; ih<nHits; ih++ ){
-    in>>y[ih]>>z[ih];
-  }
-  ReadEvent( rowFirstHit, rowNHits, y, z, nHits );
-} 
-
-GPUh() void AliHLTTPCCATracker::WriteTracks( std::ostream &out ) 
+GPUh() void AliHLTTPCCATracker::WriteTracks( std::ostream &/*out*/ )
 {
-  //* Write tracks to file 
-  out<<fTimers[0]<<std::endl;
-  out<<*fNOutTrackHits<<std::endl;
-  for( Int_t ih=0; ih<*fNOutTrackHits; ih++ ){
-    out<< fOutTrackHits[ih]<<" ";
-  }
-  out<<std::endl;
-  
-  out<<*fNOutTracks<<std::endl;
-
-  for( Int_t itr=0; itr<*fNOutTracks; itr++ ){
-    AliHLTTPCCAOutTrack &t = fOutTracks[itr];    
-    AliHLTTPCCATrackParam p1 = t.StartPoint(); 
-    AliHLTTPCCATrackParam p2 = t.EndPoint();   
-    out<< t.NHits()<<" ";
-    out<< t.FirstHitRef()<<" ";
-    out<< t.OrigTrackID()<<" ";
-    out<<std::endl;
-    out<< p1.X()<<" ";
-    out<< p1.CosPhi()<<" ";
-    out<< p1.Chi2()<<" ";
-    out<< p1.NDF()<<std::endl;
-    for( Int_t i=0; i<5; i++ ) out<<p1.Par()[i]<<" ";
-    out<<std::endl;
-    for( Int_t i=0; i<15; i++ ) out<<p1.Cov()[i]<<" ";
-    out<<std::endl;
-    out<< p2.X()<<" ";
-    out<< p2.CosPhi()<<" ";
-    out<< p2.Chi2()<<" ";
-    out<< p2.NDF()<<std::endl;
-    for( Int_t i=0; i<5; i++ ) out<<p2.Par()[i]<<" ";
-    out<<std::endl;
-    for( Int_t i=0; i<15; i++ ) out<<p2.Cov()[i]<<" ";
-    out<<std::endl;
-  }
+  //* Write tracks to file --- dummy
 }
 
-GPUh() void AliHLTTPCCATracker::ReadTracks( std::istream &in )
+GPUh() void AliHLTTPCCATracker::ReadTracks( std::istream &/*in*/ )
 {
-  //* Read tracks  from file 
-  in>>fTimers[0];
-  in>>*fNOutTrackHits;  
-
-  for( Int_t ih=0; ih<*fNOutTrackHits; ih++ ){
-    in>>fOutTrackHits[ih];
-  }
-  in>>*fNOutTracks;
-
-  for( Int_t itr=0; itr<*fNOutTracks; itr++ ){
-    AliHLTTPCCAOutTrack &t = fOutTracks[itr];    
-    AliHLTTPCCATrackParam p1, p2;
-    Int_t i;
-    Float_t f;
-    in>> i; t.SetNHits( i );
-    in>> i; t.SetFirstHitRef( i );
-    in>> i; t.SetOrigTrackID( i );
-    in>> f; p1.SetX( f );
-    in>> f; p1.SetCosPhi( f );
-    in>> f; p1.SetChi2( f );
-    in>> i; p1.SetNDF( i );
-    for( Int_t j=0; j<5; j++ ){ in>>f; p1.SetPar(j,f); }
-    for( Int_t j=0; j<15; j++ ){ in>>f; p1.SetCov(j,f); }
-    in>> f; p2.SetX( f );
-    in>> f; p2.SetCosPhi( f );
-    in>> f; p2.SetChi2( f );
-    in>> i; p2.SetNDF( i );
-    for( Int_t j=0; j<5; j++ ){ in>>f; p2.SetPar(j,f); }
-    for( Int_t j=0; j<15; j++ ){ in>>f; p2.SetCov(j,f); }
-    t.SetStartPoint( p1 );
-    t.SetEndPoint( p2 );
-  }
+  //* Read tracks  from file -- dummy
 }
 #endif