]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCATracker.h
AliTPCCalibRaw.cxx.diff Change to fill only sparse info to save space, Add functions...
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATracker.h
CommitLineData
326c2d4b 1//-*- Mode: C++ -*-
2// @(#) $Id$
ce565086 3// ************************************************************************
fbb9b71b 4// This file is property of and copyright by the ALICE HLT Project *
ce565086 5// ALICE Experiment at CERN, All rights reserved. *
6// See cxx source for full Copyright notice *
7// *
8//*************************************************************************
326c2d4b 9
10#ifndef ALIHLTTPCCATRACKER_H
11#define ALIHLTTPCCATRACKER_H
12
13
00d07bcd 14#include "AliHLTTPCCADef.h"
326c2d4b 15#include "AliHLTTPCCAParam.h"
16#include "AliHLTTPCCARow.h"
00d07bcd 17#include "AliHLTTPCCAHit.h"
4687b8fc 18#include <iostream>
4acc2401 19#include "AliHLTArray.h"
20#include "AliHLTTPCCAHitId.h"
21#include "AliHLTTPCCASliceData.h"
22#include "AliHLTTPCCATracklet.h"
23#include "AliHLTTPCCAOutTrack.h"
326c2d4b 24
d54804bf 25class AliHLTTPCCATrack;
d54804bf 26class AliHLTTPCCATrackParam;
4acc2401 27class AliHLTTPCCAClusterData;
63d8b79d 28class AliHLTTPCCASliceOutput;
326c2d4b 29
30/**
31 * @class AliHLTTPCCATracker
fbb9b71b 32 *
33 * Slice tracker for ALICE HLT.
dc4788ec 34 * The class reconstructs tracks in one slice of TPC.
35 * The reconstruction algorithm is based on the Cellular Automaton method
36 *
fbb9b71b 37 * The CA tracker is designed stand-alone.
dc4788ec 38 * It is integrated to the HLT framework via AliHLTTPCCATrackerComponent interface.
39 * The class is under construction.
40 *
326c2d4b 41 */
42class AliHLTTPCCATracker
43{
7be9b0d7 44 friend class AliHLTTPCCAGPUTracker;
fbb9b71b 45 public:
326c2d4b 46
7be9b0d7 47 AliHLTTPCCATracker()
48 :
49 fParam(),
50 fClusterData( 0 ),
51 fData(),
52 fIsGPUTracker( false ),
53 fGPUDebugLevel( 0 ),
54 fGPUDebugOut( 0 ),
55 fCommonMemory( 0 ),
56 fCommonMemorySize( 0 ),
57 fHitMemory( 0 ),
58 fHitMemorySize( 0 ),
59 fTrackMemory( 0 ),
60 fTrackMemorySize( 0 ),
61 fNTracklets( 0 ),
62 fTrackletStartHits( 0 ),
63 fTracklets( 0 ),
64 fNTracks( 0 ),
65 fTracks( 0 ),
66 fNTrackHits( 0 ),
67 fTrackHits( 0 ),
68 fOutput( 0 ),
69 fNOutTracks( 0 ),
70 fOutTracks( 0 ),
71 fNOutTrackHits( 0 ),
72 fOutTrackHits( 0 )
73 {
74 // constructor
75 }
fbb9b71b 76 GPUd() ~AliHLTTPCCATracker();
326c2d4b 77
7be9b0d7 78 void Initialize( const AliHLTTPCCAParam &param );
fbb9b71b 79
7be9b0d7 80 void StartEvent();
fbb9b71b 81
7be9b0d7 82 int CheckEmptySlice();
83 void WriteOutput();
fbb9b71b 84
7be9b0d7 85#if !defined(HLTCA_GPUCODE)
fbb9b71b 86 void Reconstruct();
7be9b0d7 87#endif
88
89 //Make Reconstruction steps directly callable (Used for GPU debugging)
90 void RunNeighboursFinder();
91 void RunNeighboursCleaner();
92 void RunStartHitsFinder();
93 void RunTrackletConstructor();
94 void RunTrackletSelector();
95
96 //GPU Tracker Interface
97 void SetGPUTracker();
98 void SetGPUDebugLevel(int Level, std::ostream *NewDebugOut = NULL) {fGPUDebugLevel = Level;if (NewDebugOut) fGPUDebugOut = NewDebugOut;}
99
100 char* SetGPUTrackerCommonMemory(char* pGPUMemory);
101 char* SetGPUTrackerHitsMemory(char* pGPUMemory, int MaxNHits );
102 char* SetGPUTrackerTracksMemory(char* pGPUMemory, int MaxNTracks, int MaxNHits );
103
104 //Debugging Stuff
105 void DumpLinks(std::ostream &out); //Dump all links to file (for comparison after NeighboursFinder/Cleaner)
106 void DumpStartHits(std::ostream &out); //Same for Start Hits
107 void DumpTrackHits(std::ostream &out); //Same for Track Hits
108 void DumpTrackletHits(std::ostream &out); //Same for Track Hits
fbb9b71b 109
110 GPUd() void GetErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const;
111 GPUd() void GetErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const;
112
4acc2401 113 void FitTrack( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
114 void FitTrackFull( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
fbb9b71b 115
7be9b0d7 116 void SetPointersCommon();
117 void SetPointersHits( int MaxNHits );
118 void SetPointersTracks( int MaxNTracks, int MaxNHits );
fbb9b71b 119
120#if !defined(HLTCA_GPUCODE)
7be9b0d7 121 void ReadEvent( AliHLTTPCCAClusterData *clusterData );
122
fbb9b71b 123 GPUh() void WriteEvent( std::ostream &out );
fbb9b71b 124 GPUh() void WriteTracks( std::ostream &out ) ;
125 GPUh() void ReadTracks( std::istream &in );
4687b8fc 126#endif
127
fbb9b71b 128 GPUhd() const AliHLTTPCCAParam &Param() const { return fParam; }
129 GPUhd() void SetParam( const AliHLTTPCCAParam &v ) { fParam = v; }
130
6de2bc40 131 GPUhd() const AliHLTTPCCAClusterData *ClusterData() const { return fClusterData; }
132 GPUhd() const AliHLTTPCCASliceData &Data() const { return fData; }
4acc2401 133 GPUhd() const AliHLTTPCCARow &Row( int rowIndex ) const { return fData.Row( rowIndex ); }
7be9b0d7 134 GPUh() const AliHLTTPCCARow &Row( const AliHLTTPCCAHitId &HitId ) const { return fData.Row( HitId.RowIndex() ); }
4acc2401 135
fbb9b71b 136 GPUhd() double Timer( int i ) const { return fTimers[i]; }
137 GPUhd() void SetTimer( int i, double v ) { fTimers[i] = v; }
138
4acc2401 139 GPUhd() int NHitsTotal() const { return fData.NumberOfHits(); }
fbb9b71b 140
7be9b0d7 141 GPUd() void SetHitLinkUpData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkUpData( row, hitIndex, v ); }
142 GPUd() void SetHitLinkDownData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkDownData( row, hitIndex, v ); }
143 GPUd() short HitLinkUpData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkUpData( row, hitIndex ); }
144 GPUd() short HitLinkDownData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkDownData( row, hitIndex ); }
4acc2401 145
7be9b0d7 146 GPUd() int FirstHitInBin( const AliHLTTPCCARow &row, int binIndex ) const { return fData.FirstHitInBin( row, binIndex ); }
4acc2401 147
7be9b0d7 148 GPUd() unsigned short HitDataY( const AliHLTTPCCARow &row, int hitIndex ) const {
4acc2401 149 return fData.HitDataY( row, hitIndex );
150 }
7be9b0d7 151 GPUd() unsigned short HitDataZ( const AliHLTTPCCARow &row, int hitIndex ) const {
4acc2401 152 return fData.HitDataZ( row, hitIndex );
153 }
fbb9b71b 154
7be9b0d7 155 GPUhd() int HitInputID( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.ClusterDataIndex( row, hitIndex ); }
4acc2401 156
157 /**
158 * The hit weight is used to determine whether a hit belongs to a certain tracklet or another one
159 * competing for the same hit. The tracklet that has a higher weight wins. Comparison is done
160 * using the the number of hits in the tracklet (the more hits it has the more it keeps). If
161 * tracklets have the same number of hits then it doesn't matter who gets it, but it should be
162 * only one. So a unique number (row index is good) is added in the least significant part of
163 * the weight
164 */
6de2bc40 165 static int CalculateHitWeight( int NHits, int unique ) {
4acc2401 166 return ( NHits << 16 ) + unique;
167 }
7be9b0d7 168 GPUd() void MaximizeHitWeight( const AliHLTTPCCARow &row, int hitIndex, int weight ) {
4acc2401 169 fData.MaximizeHitWeight( row, hitIndex, weight );
170 }
7be9b0d7 171 GPUd() int HitWeight( const AliHLTTPCCARow &row, int hitIndex ) const {
4acc2401 172 return fData.HitWeight( row, hitIndex );
173 }
fbb9b71b 174
b8139972 175 GPUhd() int NTracklets() const { return *fNTracklets; }
4acc2401 176 GPUhd() int *NTracklets() { return fNTracklets; }
fbb9b71b 177
4acc2401 178 GPUhd() const AliHLTTPCCAHitId &TrackletStartHit( int i ) const { return fTrackletStartHits[i]; }
179 GPUhd() AliHLTTPCCAHitId *TrackletStartHits() const { return fTrackletStartHits; }
180 GPUhd() const AliHLTTPCCATracklet &Tracklet( int i ) const { return fTracklets[i]; }
fbb9b71b 181 GPUhd() AliHLTTPCCATracklet *Tracklets() const { return fTracklets;}
182
183 GPUhd() int *NTracks() const { return fNTracks; }
184 GPUhd() AliHLTTPCCATrack *Tracks() const { return fTracks; }
185 GPUhd() int *NTrackHits() const { return fNTrackHits; }
4acc2401 186 GPUhd() AliHLTTPCCAHitId *TrackHits() const { return fTrackHits; }
fbb9b71b 187
188 GPUhd() const AliHLTTPCCASliceOutput * Output() const { return fOutput; }
189
190 GPUhd() int *NOutTracks() const { return fNOutTracks; }
191 GPUhd() AliHLTTPCCAOutTrack *OutTracks() const { return fOutTracks; }
4acc2401 192 GPUhd() const AliHLTTPCCAOutTrack &OutTrack( int index ) const { return fOutTracks[index]; }
fbb9b71b 193 GPUhd() int *NOutTrackHits() const { return fNOutTrackHits; }
194 GPUhd() int *OutTrackHits() const { return fOutTrackHits; }
4acc2401 195 GPUhd() int OutTrackHit( int i ) const { return fOutTrackHits[i]; }
fbb9b71b 196
7be9b0d7 197#ifndef CUDA_DEVICE_EMULATION
fbb9b71b 198 private:
7be9b0d7 199#endif
200
4acc2401 201 void SetupCommonMemory();
fbb9b71b 202
203 AliHLTTPCCAParam fParam; // parameters
fbb9b71b 204 double fTimers[10]; // running CPU time for different parts of the algorithm
205
4acc2401 206 /** A pointer to the ClusterData object that the SliceData was created from. This can be used to
207 * merge clusters from inside the SliceTracker code and recreate the SliceData. */
208 AliHLTTPCCAClusterData *fClusterData; // ^
209 AliHLTTPCCASliceData fData; // The SliceData object. It is used to encapsulate the storage in memory from the access
fbb9b71b 210
7be9b0d7 211 //Will this tracker run on GPU?
212 bool fIsGPUTracker; // is it GPU tracker
213 int fGPUDebugLevel; // debug level
214 std::ostream *fGPUDebugOut; // debug stream
215
4acc2401 216 // event
fbb9b71b 217
218 char *fCommonMemory; // common event memory
7be9b0d7 219 size_t fCommonMemorySize; // size of the event memory [bytes]
fbb9b71b 220
221 char *fHitMemory; // event memory for hits
7be9b0d7 222 size_t fHitMemorySize; // size of the event memory [bytes]
fbb9b71b 223
224 char *fTrackMemory; // event memory for tracks
7be9b0d7 225 size_t fTrackMemorySize; // size of the event memory [bytes]
fbb9b71b 226
fbb9b71b 227
228 int *fNTracklets; // number of tracklets
4acc2401 229 AliHLTTPCCAHitId *fTrackletStartHits; // start hits for the tracklets
fbb9b71b 230 AliHLTTPCCATracklet *fTracklets; // tracklets
231
232 //
233 int *fNTracks; // number of reconstructed tracks
234 AliHLTTPCCATrack *fTracks; // reconstructed tracks
235 int *fNTrackHits; // number of track hits
4acc2401 236 AliHLTTPCCAHitId *fTrackHits; // array of track hit numbers
fbb9b71b 237
238 // output
239
240 AliHLTTPCCASliceOutput *fOutput;
241
242 // obsolete output
243
244 int *fNOutTracks; // number of tracks in fOutTracks array
245 AliHLTTPCCAOutTrack *fOutTracks; // output array of the reconstructed tracks
246 int *fNOutTrackHits; // number of hits in fOutTrackHits array
247 int *fOutTrackHits; // output array of ID's of the reconstructed hits
248
4acc2401 249 // disable copy
250 AliHLTTPCCATracker( const AliHLTTPCCATracker& );
251 AliHLTTPCCATracker &operator=( const AliHLTTPCCATracker& );
326c2d4b 252};
253
00d07bcd 254
326c2d4b 255#endif