3 // ************************************************************************
4 // This file is property of and copyright by the ALICE HLT Project *
5 // ALICE Experiment at CERN, All rights reserved. *
6 // See cxx source for full Copyright notice *
8 //*************************************************************************
10 #ifndef ALIHLTTPCCATRACKER_H
11 #define ALIHLTTPCCATRACKER_H
14 #include "AliHLTTPCCADef.h"
15 #include "AliHLTTPCCAParam.h"
16 #include "AliHLTTPCCARow.h"
17 #include "AliHLTTPCCAHit.h"
19 #include "AliHLTArray.h"
20 #include "AliHLTTPCCAHitId.h"
21 #include "AliHLTTPCCASliceData.h"
22 #include "AliHLTTPCCATracklet.h"
23 #include "AliHLTTPCCAOutTrack.h"
25 class AliHLTTPCCATrack;
26 class AliHLTTPCCATrackParam;
27 class AliHLTTPCCAClusterData;
28 class AliHLTTPCCASliceOutput;
31 * @class AliHLTTPCCATracker
33 * Slice tracker for ALICE HLT.
34 * The class reconstructs tracks in one slice of TPC.
35 * The reconstruction algorithm is based on the Cellular Automaton method
37 * The CA tracker is designed stand-alone.
38 * It is integrated to the HLT framework via AliHLTTPCCATrackerComponent interface.
39 * The class is under construction.
42 class AliHLTTPCCATracker
46 #if !defined(HLTCA_GPUCODE)
49 GPUd() ~AliHLTTPCCATracker();
52 GPUd() void Initialize( const AliHLTTPCCAParam ¶m );
54 GPUd() void StartEvent();
56 void ReadEvent( AliHLTTPCCAClusterData *clusterData );
61 GPUd() void GetErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const;
62 GPUd() void GetErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const;
64 void FitTrack( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
65 void FitTrackFull( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
67 GPUhd() void SetPointersCommon();
68 GPUhd() void SetPointersHits( int MaxNHits );
69 GPUhd() void SetPointersTracks( int MaxNTracks, int MaxNHits );
71 #if !defined(HLTCA_GPUCODE)
72 GPUh() void WriteEvent( std::ostream &out );
73 GPUh() void WriteTracks( std::ostream &out ) ;
74 GPUh() void ReadTracks( std::istream &in );
77 GPUhd() const AliHLTTPCCAParam &Param() const { return fParam; }
78 GPUhd() void SetParam( const AliHLTTPCCAParam &v ) { fParam = v; }
80 GPUhd() const SliceData &Data() const { return fData; }
81 GPUhd() const AliHLTTPCCARow &Row( int rowIndex ) const { return fData.Row( rowIndex ); }
82 GPUhd() const AliHLTTPCCARow &Row( const AliHLTTPCCAHitId &HitId ) const { return fData.Row( HitId.RowIndex() ); }
84 GPUhd() double Timer( int i ) const { return fTimers[i]; }
85 GPUhd() void SetTimer( int i, double v ) { fTimers[i] = v; }
87 GPUhd() int NHitsTotal() const { return fData.NumberOfHits(); }
89 inline void SetHitLinkUpData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkUpData( row, hitIndex, v ); }
90 inline void SetHitLinkDownData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkDownData( row, hitIndex, v ); }
91 inline short HitLinkUpData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkUpData( row, hitIndex ); }
92 inline short HitLinkDownData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkDownData( row, hitIndex ); }
94 inline int FirstHitInBin( const AliHLTTPCCARow &row, int binIndex ) const { return fData.FirstHitInBin( row, binIndex ); }
96 inline unsigned short HitDataY( const AliHLTTPCCARow &row, int hitIndex ) const {
97 return fData.HitDataY( row, hitIndex );
99 inline unsigned short HitDataZ( const AliHLTTPCCARow &row, int hitIndex ) const {
100 return fData.HitDataZ( row, hitIndex );
103 int HitInputID( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.ClusterDataIndex( row, hitIndex ); }
106 * The hit weight is used to determine whether a hit belongs to a certain tracklet or another one
107 * competing for the same hit. The tracklet that has a higher weight wins. Comparison is done
108 * using the the number of hits in the tracklet (the more hits it has the more it keeps). If
109 * tracklets have the same number of hits then it doesn't matter who gets it, but it should be
110 * only one. So a unique number (row index is good) is added in the least significant part of
113 static inline int CalculateHitWeight( int NHits, int unique ) {
114 return ( NHits << 16 ) + unique;
116 inline void MaximizeHitWeight( const AliHLTTPCCARow &row, int hitIndex, int weight ) {
117 fData.MaximizeHitWeight( row, hitIndex, weight );
119 inline int HitWeight( const AliHLTTPCCARow &row, int hitIndex ) const {
120 return fData.HitWeight( row, hitIndex );
123 GPUhd() int NTracklets() const { return *fNTracklets; }
124 GPUhd() int *NTracklets() { return fNTracklets; }
126 GPUhd() const AliHLTTPCCAHitId &TrackletStartHit( int i ) const { return fTrackletStartHits[i]; }
127 GPUhd() AliHLTTPCCAHitId *TrackletStartHits() const { return fTrackletStartHits; }
128 GPUhd() const AliHLTTPCCATracklet &Tracklet( int i ) const { return fTracklets[i]; }
129 GPUhd() AliHLTTPCCATracklet *Tracklets() const { return fTracklets;}
131 GPUhd() int *NTracks() const { return fNTracks; }
132 GPUhd() AliHLTTPCCATrack *Tracks() const { return fTracks; }
133 GPUhd() int *NTrackHits() const { return fNTrackHits; }
134 GPUhd() AliHLTTPCCAHitId *TrackHits() const { return fTrackHits; }
136 GPUhd() const AliHLTTPCCASliceOutput * Output() const { return fOutput; }
138 GPUhd() int *NOutTracks() const { return fNOutTracks; }
139 GPUhd() AliHLTTPCCAOutTrack *OutTracks() const { return fOutTracks; }
140 GPUhd() const AliHLTTPCCAOutTrack &OutTrack( int index ) const { return fOutTracks[index]; }
141 GPUhd() int *NOutTrackHits() const { return fNOutTrackHits; }
142 GPUhd() int *OutTrackHits() const { return fOutTrackHits; }
143 GPUhd() int OutTrackHit( int i ) const { return fOutTrackHits[i]; }
147 void SetupCommonMemory();
149 AliHLTTPCCAParam fParam; // parameters
150 double fTimers[10]; // running CPU time for different parts of the algorithm
152 /** A pointer to the ClusterData object that the SliceData was created from. This can be used to
153 * merge clusters from inside the SliceTracker code and recreate the SliceData. */
154 AliHLTTPCCAClusterData *fClusterData; // ^
155 AliHLTTPCCASliceData fData; // The SliceData object. It is used to encapsulate the storage in memory from the access
159 char *fCommonMemory; // common event memory
160 int fCommonMemorySize; // size of the event memory [bytes]
162 char *fHitMemory; // event memory for hits
163 int fHitMemorySize; // size of the event memory [bytes]
165 char *fTrackMemory; // event memory for tracks
166 int fTrackMemorySize; // size of the event memory [bytes]
169 int *fNTracklets; // number of tracklets
170 AliHLTTPCCAHitId *fTrackletStartHits; // start hits for the tracklets
171 AliHLTTPCCATracklet *fTracklets; // tracklets
174 int *fNTracks; // number of reconstructed tracks
175 AliHLTTPCCATrack *fTracks; // reconstructed tracks
176 int *fNTrackHits; // number of track hits
177 AliHLTTPCCAHitId *fTrackHits; // array of track hit numbers
181 AliHLTTPCCASliceOutput *fOutput;
185 int *fNOutTracks; // number of tracks in fOutTracks array
186 AliHLTTPCCAOutTrack *fOutTracks; // output array of the reconstructed tracks
187 int *fNOutTrackHits; // number of hits in fOutTrackHits array
188 int *fOutTrackHits; // output array of ID's of the reconstructed hits
191 AliHLTTPCCATracker( const AliHLTTPCCATracker& );
192 AliHLTTPCCATracker &operator=( const AliHLTTPCCATracker& );