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 AliHLTTPCCAClusterData *ClusterData() const { return fClusterData; }
81 GPUhd() const AliHLTTPCCASliceData &Data() const { return fData; }
82 GPUhd() const AliHLTTPCCARow &Row( int rowIndex ) const { return fData.Row( rowIndex ); }
83 GPUhd() const AliHLTTPCCARow &Row( const AliHLTTPCCAHitId &HitId ) const { return fData.Row( HitId.RowIndex() ); }
85 GPUhd() double Timer( int i ) const { return fTimers[i]; }
86 GPUhd() void SetTimer( int i, double v ) { fTimers[i] = v; }
88 GPUhd() int NHitsTotal() const { return fData.NumberOfHits(); }
90 void SetHitLinkUpData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkUpData( row, hitIndex, v ); }
91 void SetHitLinkDownData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkDownData( row, hitIndex, v ); }
92 short HitLinkUpData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkUpData( row, hitIndex ); }
93 short HitLinkDownData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkDownData( row, hitIndex ); }
95 int FirstHitInBin( const AliHLTTPCCARow &row, int binIndex ) const { return fData.FirstHitInBin( row, binIndex ); }
97 unsigned short HitDataY( const AliHLTTPCCARow &row, int hitIndex ) const {
98 return fData.HitDataY( row, hitIndex );
100 unsigned short HitDataZ( const AliHLTTPCCARow &row, int hitIndex ) const {
101 return fData.HitDataZ( row, hitIndex );
104 int HitInputID( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.ClusterDataIndex( row, hitIndex ); }
107 * The hit weight is used to determine whether a hit belongs to a certain tracklet or another one
108 * competing for the same hit. The tracklet that has a higher weight wins. Comparison is done
109 * using the the number of hits in the tracklet (the more hits it has the more it keeps). If
110 * tracklets have the same number of hits then it doesn't matter who gets it, but it should be
111 * only one. So a unique number (row index is good) is added in the least significant part of
114 static int CalculateHitWeight( int NHits, int unique ) {
115 return ( NHits << 16 ) + unique;
117 void MaximizeHitWeight( const AliHLTTPCCARow &row, int hitIndex, int weight ) {
118 fData.MaximizeHitWeight( row, hitIndex, weight );
120 int HitWeight( const AliHLTTPCCARow &row, int hitIndex ) const {
121 return fData.HitWeight( row, hitIndex );
124 GPUhd() int NTracklets() const { return *fNTracklets; }
125 GPUhd() int *NTracklets() { return fNTracklets; }
127 GPUhd() const AliHLTTPCCAHitId &TrackletStartHit( int i ) const { return fTrackletStartHits[i]; }
128 GPUhd() AliHLTTPCCAHitId *TrackletStartHits() const { return fTrackletStartHits; }
129 GPUhd() const AliHLTTPCCATracklet &Tracklet( int i ) const { return fTracklets[i]; }
130 GPUhd() AliHLTTPCCATracklet *Tracklets() const { return fTracklets;}
132 GPUhd() int *NTracks() const { return fNTracks; }
133 GPUhd() AliHLTTPCCATrack *Tracks() const { return fTracks; }
134 GPUhd() int *NTrackHits() const { return fNTrackHits; }
135 GPUhd() AliHLTTPCCAHitId *TrackHits() const { return fTrackHits; }
137 GPUhd() const AliHLTTPCCASliceOutput * Output() const { return fOutput; }
139 GPUhd() int *NOutTracks() const { return fNOutTracks; }
140 GPUhd() AliHLTTPCCAOutTrack *OutTracks() const { return fOutTracks; }
141 GPUhd() const AliHLTTPCCAOutTrack &OutTrack( int index ) const { return fOutTracks[index]; }
142 GPUhd() int *NOutTrackHits() const { return fNOutTrackHits; }
143 GPUhd() int *OutTrackHits() const { return fOutTrackHits; }
144 GPUhd() int OutTrackHit( int i ) const { return fOutTrackHits[i]; }
148 void SetupCommonMemory();
150 AliHLTTPCCAParam fParam; // parameters
151 double fTimers[10]; // running CPU time for different parts of the algorithm
153 /** A pointer to the ClusterData object that the SliceData was created from. This can be used to
154 * merge clusters from inside the SliceTracker code and recreate the SliceData. */
155 AliHLTTPCCAClusterData *fClusterData; // ^
156 AliHLTTPCCASliceData fData; // The SliceData object. It is used to encapsulate the storage in memory from the access
160 char *fCommonMemory; // common event memory
161 int fCommonMemorySize; // size of the event memory [bytes]
163 char *fHitMemory; // event memory for hits
164 int fHitMemorySize; // size of the event memory [bytes]
166 char *fTrackMemory; // event memory for tracks
167 int fTrackMemorySize; // size of the event memory [bytes]
170 int *fNTracklets; // number of tracklets
171 AliHLTTPCCAHitId *fTrackletStartHits; // start hits for the tracklets
172 AliHLTTPCCATracklet *fTracklets; // tracklets
175 int *fNTracks; // number of reconstructed tracks
176 AliHLTTPCCATrack *fTracks; // reconstructed tracks
177 int *fNTrackHits; // number of track hits
178 AliHLTTPCCAHitId *fTrackHits; // array of track hit numbers
182 AliHLTTPCCASliceOutput *fOutput;
186 int *fNOutTracks; // number of tracks in fOutTracks array
187 AliHLTTPCCAOutTrack *fOutTracks; // output array of the reconstructed tracks
188 int *fNOutTrackHits; // number of hits in fOutTrackHits array
189 int *fOutTrackHits; // output array of ID's of the reconstructed hits
192 AliHLTTPCCATracker( const AliHLTTPCCATracker& );
193 AliHLTTPCCATracker &operator=( const AliHLTTPCCATracker& );