]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCATracker.h
changes from Matthias
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATracker.h
1 //-*- Mode: C++ -*-
2 // @(#) $Id$
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                               *
7 //                                                                        *
8 //*************************************************************************
9
10 #ifndef ALIHLTTPCCATRACKER_H
11 #define ALIHLTTPCCATRACKER_H
12
13
14 #include "AliHLTTPCCADef.h"
15 #include "AliHLTTPCCAParam.h"
16 #include "AliHLTTPCCARow.h"
17 #include "AliHLTTPCCAHit.h"
18 #include <iostream>
19 #include "AliHLTArray.h"
20 #include "AliHLTTPCCAHitId.h"
21 #include "AliHLTTPCCASliceData.h"
22 #include "AliHLTTPCCATracklet.h"
23 #include "AliHLTTPCCAOutTrack.h"
24
25 class AliHLTTPCCATrack;
26 class AliHLTTPCCATrackParam;
27 class AliHLTTPCCAClusterData;
28 class AliHLTTPCCASliceOutput;
29
30 /**
31  * @class AliHLTTPCCATracker
32  *
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
36  *
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.
40  *
41  */
42 class AliHLTTPCCATracker
43 {
44   public:
45
46 #if !defined(HLTCA_GPUCODE)
47     AliHLTTPCCATracker();
48
49     GPUd() ~AliHLTTPCCATracker();
50 #endif
51
52     GPUd() void Initialize( const AliHLTTPCCAParam &param );
53
54     GPUd() void StartEvent();
55
56     void ReadEvent( AliHLTTPCCAClusterData *clusterData );
57
58     void Reconstruct();
59     void WriteOutput();
60
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;
63
64     void FitTrack( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
65     void FitTrackFull( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
66
67     GPUhd() void SetPointersCommon();
68     GPUhd() void SetPointersHits( int MaxNHits );
69     GPUhd() void SetPointersTracks( int MaxNTracks, int MaxNHits );
70
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 );
75 #endif
76
77     GPUhd() const AliHLTTPCCAParam &Param() const { return fParam; }
78     GPUhd() void SetParam( const AliHLTTPCCAParam &v ) { fParam = v; }
79
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() ); }
83
84     GPUhd() double Timer( int i ) const { return fTimers[i]; }
85     GPUhd() void SetTimer( int i, double v ) { fTimers[i] = v; }
86
87     GPUhd() int NHitsTotal() const { return fData.NumberOfHits(); }
88
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 ); }
93
94     inline int FirstHitInBin( const AliHLTTPCCARow &row, int binIndex ) const { return fData.FirstHitInBin( row, binIndex ); }
95
96     inline unsigned short HitDataY( const AliHLTTPCCARow &row, int hitIndex ) const {
97       return fData.HitDataY( row, hitIndex );
98     }
99     inline unsigned short HitDataZ( const AliHLTTPCCARow &row, int hitIndex ) const {
100       return fData.HitDataZ( row, hitIndex );
101     }
102
103     int HitInputID( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.ClusterDataIndex( row, hitIndex ); }
104
105     /**
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
111      * the weight
112      */
113     static inline int CalculateHitWeight( int NHits, int unique ) {
114       return ( NHits << 16 ) + unique;
115     }
116     inline void MaximizeHitWeight( const AliHLTTPCCARow &row, int hitIndex, int weight ) {
117       fData.MaximizeHitWeight( row, hitIndex, weight );
118     }
119     inline int HitWeight( const AliHLTTPCCARow &row, int hitIndex ) const {
120       return fData.HitWeight( row, hitIndex );
121     }
122
123     GPUhd() int NTracklets() const { return *fNTracklets; }
124     GPUhd() int  *NTracklets() { return fNTracklets; }
125
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;}
130
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; }
135
136     GPUhd() const AliHLTTPCCASliceOutput * Output() const { return fOutput; }
137
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]; }
144
145
146   private:
147     void SetupCommonMemory();
148
149     AliHLTTPCCAParam fParam; // parameters
150     double fTimers[10]; // running CPU time for different parts of the algorithm
151
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
156
157     // event
158
159     char *fCommonMemory; // common event memory
160     int   fCommonMemorySize; // size of the event memory [bytes]
161
162     char *fHitMemory; // event memory for hits
163     int   fHitMemorySize; // size of the event memory [bytes]
164
165     char *fTrackMemory; // event memory for tracks
166     int   fTrackMemorySize; // size of the event memory [bytes]
167
168
169     int *fNTracklets;     // number of tracklets
170     AliHLTTPCCAHitId *fTrackletStartHits;   // start hits for the tracklets
171     AliHLTTPCCATracklet *fTracklets; // tracklets
172
173     //
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
178
179     // output
180
181     AliHLTTPCCASliceOutput *fOutput;
182
183     // obsolete output
184
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
189
190     // disable copy
191     AliHLTTPCCATracker( const AliHLTTPCCATracker& );
192     AliHLTTPCCATracker &operator=( const AliHLTTPCCATracker& );
193 };
194
195
196 #endif