]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCAMergerOutput.h
bug fix: reconstruction crash when the output buffer size exceed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAMergerOutput.h
1 //-*- Mode: C++ -*-
2 // ************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project        *
4 // ALICE Experiment at CERN, All rights reserved.                         *
5 // See cxx source for full Copyright notice                               *
6 //                                                                        *
7 //*************************************************************************
8
9
10 #ifndef ALIHLTTPCCAMERGEROUTPUT_H
11 #define ALIHLTTPCCAMERGEROUTPUT_H
12
13 #include "AliHLTTPCCADef.h"
14 #include "AliHLTTPCCAMergedTrack.h"
15
16 /**
17  * @class AliHLTTPCCAMergerOutput
18  *
19  * AliHLTTPCCAMergerOutput class is used to store the output of AliHLTTPCCATracker{Component}
20  * and transport the output to AliHLTTPCCAMerger{Component}
21  *
22  * The class contains all the necessary information about TPC tracks, reconstructed in one slice.
23  * This includes the reconstructed track parameters and some compressed information
24  * about the assigned clusters: clusterId, position and amplitude.
25  *
26  */
27 class AliHLTTPCCAMergerOutput
28 {
29   public:
30
31     AliHLTTPCCAMergerOutput()
32         : fNTracks( 0 ), fNTrackClusters( 0 ), fTracks( 0 ), fClusterId( 0 ), fClusterPackedAmp( 0 ) {}
33
34     ~AliHLTTPCCAMergerOutput() {}
35
36
37     GPUhd() int NTracks()                    const { return fNTracks;              }
38     GPUhd() int NTrackClusters()             const { return fNTrackClusters;       }
39
40     GPUhd() const AliHLTTPCCAMergedTrack &Track( int i ) const { return fTracks[i]; }
41     GPUhd()  int   ClusterId     ( int i )  const { return fClusterId[i]; }
42     GPUhd() UChar_t  ClusterPackedAmp( int i )  const { return fClusterPackedAmp[i]; }
43
44     GPUhd() static int EstimateSize( int nOfTracks, int nOfTrackClusters );
45     GPUhd() void SetPointers();
46
47     GPUhd() void SetNTracks       ( int v )  { fNTracks = v;        }
48     GPUhd() void SetNTrackClusters( int v )  { fNTrackClusters = v; }
49
50     GPUhd() void SetTrack( int i, const AliHLTTPCCAMergedTrack &v ) {  fTracks[i] = v; }
51     GPUhd() void SetClusterId( int i,  int v ) {  fClusterId[i] = v; }
52     GPUhd() void SetClusterPackedAmp( int i, UChar_t v ) {  fClusterPackedAmp[i] = v; }
53
54   private:
55
56     AliHLTTPCCAMergerOutput( const AliHLTTPCCAMergerOutput & )
57         : fNTracks( 0 ), fNTrackClusters( 0 ), fTracks( 0 ), fClusterId( 0 ), fClusterPackedAmp( 0 ) {}
58
59     const AliHLTTPCCAMergerOutput& operator=( const AliHLTTPCCAMergerOutput &/*v*/ ) const {
60       return *this;
61     }
62
63     int fNTracks;                 // number of reconstructed tracks
64     int fNTrackClusters;          // total number of track clusters
65     AliHLTTPCCAMergedTrack *fTracks; // pointer to reconstructed tracks
66     int   *fClusterId;         // pointer to cluster IDs ( packed slice, patch, cluster )
67     UChar_t  *fClusterPackedAmp;    // pointer to packed cluster amplitudes
68 };
69
70
71
72 GPUhd() inline int AliHLTTPCCAMergerOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
73 {
74   // calculate the amount of memory [bytes] needed for the event
75
76   const int kClusterDataSize = sizeof( int ) + sizeof( UChar_t );
77
78   return sizeof( AliHLTTPCCAMergerOutput ) + sizeof( AliHLTTPCCAMergedTrack )*nOfTracks + kClusterDataSize*nOfTrackClusters;
79 }
80
81
82 GPUhd() inline void AliHLTTPCCAMergerOutput::SetPointers()
83 {
84   // set all pointers
85
86   fTracks            = ( AliHLTTPCCAMergedTrack* )( ( &fClusterPackedAmp ) + 1 );
87   fClusterId         = ( int* )  ( fTracks            + fNTracks );
88   fClusterPackedAmp  = ( UChar_t* ) ( fClusterId + fNTrackClusters );
89 }
90
91 #endif //ALIHLTTPCCAMERGEROUTPUT_H