]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/tracking-ca/AliHLTTPCCASliceOutput.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCASliceOutput.cxx
index d8e1e5a0e448e9f393411abe102fe27fa14c8ac2..3ecdcd44ed61dd8ffaf3614fa4cb40e3e6c88ba9 100644 (file)
 //***************************************************************************
 
 #include "AliHLTTPCCASliceOutput.h"
-#include "MemoryAssignmentHelpers.h"
 
-GPUhd() int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
+int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
 {
   // calculate the amount of memory [bytes] needed for the event
 
-  const int kClusterDataSize = sizeof(  int ) + sizeof( unsigned short ) + sizeof( float2 ) + sizeof( float ) + sizeof( UChar_t ) + sizeof( UChar_t );
-
-  return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceTrack )*nOfTracks + kClusterDataSize*nOfTrackClusters;
+  return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceOutTrack )*nOfTracks + sizeof(AliHLTTPCCASliceOutCluster)*nOfTrackClusters;
 }
 
+#ifndef HLTCA_GPUCODE
 
-GPUhd() void AliHLTTPCCASliceOutput::SetPointers()
+inline void AssignNoAlignment( int &dst, int &size, int count )
 {
-  // set all pointers
-
-  char *mem = &fMemory[0];
-  AssignMemory( fTracks,            mem, fNTracks );
-  AssignMemory( fClusterUnpackedYZ, mem, fNTrackClusters );
-  AssignMemory( fClusterUnpackedX,  mem, fNTrackClusters );
-  AssignMemory( fClusterId,         mem, fNTrackClusters );
-  AssignMemory( fClusterPackedYZ,   mem, fNTrackClusters );
-  AssignMemory( fClusterRow,        mem, fNTrackClusters );
-  AssignMemory( fClusterPackedAmp,  mem, fNTrackClusters );
+  // assign memory to the pointer dst
+  dst = size;
+  size = dst + count ;
 }
 
+
+void AliHLTTPCCASliceOutput::Allocate(AliHLTTPCCASliceOutput* &ptrOutput, int nTracks, int nTrackHits, outputControlStruct* outputControl)
+{
+       //Allocate All memory needed for slice output
+       const int memsize =  EstimateSize(nTracks, nTrackHits);
+
+       if (outputControl->fOutputPtr)
+       {
+               if (outputControl->fOutputMaxSize < memsize)
+               {
+                       outputControl->fEndOfSpace = 1;
+                       ptrOutput = NULL;
+                       return;
+               }
+               ptrOutput = (AliHLTTPCCASliceOutput*) outputControl->fOutputPtr;
+               outputControl->fOutputPtr += memsize;
+               outputControl->fOutputMaxSize -= memsize;
+       }
+       else
+       {
+               if (ptrOutput) free(ptrOutput);
+               ptrOutput = (AliHLTTPCCASliceOutput*) malloc(memsize);
+       }
+       ptrOutput->SetMemorySize(memsize);
+}
+#endif