]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCASliceOutput.cxx
Implementing to handling for ESD members which are not TClonesArrays
[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
35void AliHLTTPCCASliceOutput::Clear()
36{
37 //Clear Slice Output and free Memory
38 if (fMemory) delete[] fMemory;
39 fMemory = NULL;
40 fNOutTracks = 0;
41 fNOutTrackHits = 0;
42 fNTracks = 0;
43 fNTrackClusters = 0;
44}
45
ef1d207e 46template<typename T> inline void AssignNoAlignment( T *&dst, char *&mem, int count )
47{
48 // assign memory to the pointer dst
c26cae51 49 dst = ( T* ) mem;
50 mem = ( char * )( dst + count );
ef1d207e 51}
6de2bc40 52
b22af1bf 53void AliHLTTPCCASliceOutput::SetPointers()
dc4788ec 54{
4acc2401 55 // set all pointers
00d07bcd 56
b22af1bf 57 char *mem = fMemory;
ef1d207e 58 AssignNoAlignment( fTracks, mem, fNTracks );
59 AssignNoAlignment( fClusterUnpackedYZ, mem, fNTrackClusters );
60 AssignNoAlignment( fClusterUnpackedX, mem, fNTrackClusters );
61 AssignNoAlignment( fClusterId, mem, fNTrackClusters );
62 AssignNoAlignment( fClusterPackedYZ, mem, fNTrackClusters );
63 AssignNoAlignment( fClusterRow, mem, fNTrackClusters );
64 AssignNoAlignment( fClusterPackedAmp, mem, fNTrackClusters );
65
b22af1bf 66 // memory for output tracks
67
68 AssignMemory( fOutTracks, mem, fNTracks );
69
70 // arrays for track hits
71
72 AssignMemory( fOutTrackHits, mem, fNTrackClusters );
73
74
75 fMemorySize = (mem - fMemory);
76}
77
78void AliHLTTPCCASliceOutput::Allocate()
79{
80 //Allocate All memory needed for slice output
81 if (fMemory) delete[] fMemory;
82 SetPointers(); // to calculate the size
83 fMemory = reinterpret_cast<char*> ( new uint4 [ fMemorySize/sizeof( uint4 ) + 100] );
84 SetPointers(); // set pointers
dc4788ec 85}
7be9b0d7 86#endif