]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCASliceOutput.cxx
Obsolete tracker output removed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCASliceOutput.cxx
CommitLineData
4acc2401 1// @(#) $Id$
ce565086 2// **************************************************************************
fbb9b71b 3// This file is property of and copyright by the ALICE HLT Project *
d54804bf 4// ALICE Experiment at CERN, All rights reserved. *
5// *
6// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7// Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8// for The ALICE HLT Project. *
9// *
10// Permission to use, copy, modify and distribute this software and its *
11// documentation strictly for non-commercial purposes is hereby granted *
12// without fee, provided that the above copyright notice appears in all *
13// copies and that both the copyright notice and this permission notice *
14// appear in the supporting documentation. The authors make no claims *
15// about the suitability of this software for any purpose. It is *
16// provided "as is" without express or implied warranty. *
ce565086 17// *
d54804bf 18//***************************************************************************
326c2d4b 19
4acc2401 20#include "AliHLTTPCCASliceOutput.h"
b22af1bf 21#include "MemoryAssignmentHelpers.h"
22
326c2d4b 23
4acc2401 24GPUhd() int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
25{
26 // calculate the amount of memory [bytes] needed for the event
27
b8139972 28 const int kClusterDataSize = sizeof( int ) + sizeof( unsigned short ) + sizeof( float2 ) + sizeof( float ) + sizeof( UChar_t ) + sizeof( UChar_t );
4acc2401 29
30 return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceTrack )*nOfTracks + kClusterDataSize*nOfTrackClusters;
31}
326c2d4b 32
7be9b0d7 33#ifndef HLTCA_GPUCODE
b22af1bf 34
e65db743 35inline void AssignNoAlignment( int &dst, int &size, int count )
ef1d207e 36{
37 // assign memory to the pointer dst
e65db743 38 dst = size;
39 size = dst + count ;
ef1d207e 40}
6de2bc40 41
d4594e7d 42void AliHLTTPCCASliceOutput::SetPointers(int nTracks, int nTrackClusters, const outputControlStruct* outputControl)
dc4788ec 43{
4acc2401 44 // set all pointers
98512261 45 if (nTracks == -1) nTracks = fNTracks;
d3ccf1c0 46 if (nTrackClusters == -1) nTrackClusters = fNTrackClusters;
00d07bcd 47
e65db743 48 int size = 0;
ef1d207e 49
d4594e7d 50 {
e65db743 51 AssignNoAlignment( fTracksOffset, size, nTracks*sizeof(AliHLTTPCCASliceTrack) );
cc2710b2 52 AssignNoAlignment( fClusterIdOffset, size, nTrackClusters*sizeof(int) );
e65db743 53 AssignNoAlignment( fClusterRowOffset, size, nTrackClusters*sizeof(float) );
70e4a065 54 AssignNoAlignment( fClusterPackedXYZOffset, size, nTrackClusters*sizeof(AliHLTTPCCACompressedCluster) );
5cb6ddd4 55 }
56
e65db743 57 char *mem = fMemory + size;
58
d4594e7d 59 if ((size_t) (mem - fMemory) + sizeof(AliHLTTPCCASliceOutput) > fMemorySize)
60 {
5cb6ddd4 61 fMemorySize = NULL;
62 //printf("\nINTERNAL ERROR IN AliHLTTPCCASliceOutput MEMORY MANAGEMENT req: %d avail: %d\n", (int) ((size_t) (mem - fMemory) + sizeof(AliHLTTPCCASliceOutput)), (int) fMemorySize);
d4594e7d 63 }
b22af1bf 64}
65
d4594e7d 66void AliHLTTPCCASliceOutput::Allocate(AliHLTTPCCASliceOutput* &ptrOutput, int nTracks, int nTrackHits, outputControlStruct* outputControl)
b22af1bf 67{
68 //Allocate All memory needed for slice output
5cb6ddd4 69 const int memsize = EstimateSize(nTracks, nTrackHits);
70
d4594e7d 71 if (outputControl->fOutputPtr)
72 {
73 if (outputControl->fOutputMaxSize < memsize)
74 {
90da1ad5 75 outputControl->fEndOfSpace = 1;
d4594e7d 76 ptrOutput = NULL;
77 return;
78 }
79 ptrOutput = (AliHLTTPCCASliceOutput*) outputControl->fOutputPtr;
80 outputControl->fOutputPtr += memsize;
81 outputControl->fOutputMaxSize -= memsize;
82 }
83 else
84 {
85 if (ptrOutput) free(ptrOutput);
86 ptrOutput = (AliHLTTPCCASliceOutput*) malloc(memsize);
87 }
88 ptrOutput->SetMemorySize(memsize);
89 ptrOutput->SetPointers(nTracks, nTrackHits, outputControl); // set pointers
dc4788ec 90}
7be9b0d7 91#endif