]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCATracker.h
clean up
[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 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() ); }
84
85     GPUhd() double Timer( int i ) const { return fTimers[i]; }
86     GPUhd() void SetTimer( int i, double v ) { fTimers[i] = v; }
87
88     GPUhd() int NHitsTotal() const { return fData.NumberOfHits(); }
89
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 ); }
94
95      int FirstHitInBin( const AliHLTTPCCARow &row, int binIndex ) const { return fData.FirstHitInBin( row, binIndex ); }
96
97      unsigned short HitDataY( const AliHLTTPCCARow &row, int hitIndex ) const {
98       return fData.HitDataY( row, hitIndex );
99     }
100      unsigned short HitDataZ( const AliHLTTPCCARow &row, int hitIndex ) const {
101       return fData.HitDataZ( row, hitIndex );
102     }
103
104     int HitInputID( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.ClusterDataIndex( row, hitIndex ); }
105
106     /**
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
112      * the weight
113      */
114     static int CalculateHitWeight( int NHits, int unique ) {
115       return ( NHits << 16 ) + unique;
116     }
117      void MaximizeHitWeight( const AliHLTTPCCARow &row, int hitIndex, int weight ) {
118       fData.MaximizeHitWeight( row, hitIndex, weight );
119     }
120     int HitWeight( const AliHLTTPCCARow &row, int hitIndex ) const {
121       return fData.HitWeight( row, hitIndex );
122     }
123
124   GPUhd() int NTracklets() const { return *fNTracklets; }
125     GPUhd() int  *NTracklets() { return fNTracklets; }
126
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;}
131
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; }
136
137     GPUhd() const AliHLTTPCCASliceOutput * Output() const { return fOutput; }
138
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]; }
145
146
147   private:
148     void SetupCommonMemory();
149
150     AliHLTTPCCAParam fParam; // parameters
151     double fTimers[10]; // running CPU time for different parts of the algorithm
152
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
157
158     // event
159
160     char *fCommonMemory; // common event memory
161     int   fCommonMemorySize; // size of the event memory [bytes]
162
163     char *fHitMemory; // event memory for hits
164     int   fHitMemorySize; // size of the event memory [bytes]
165
166     char *fTrackMemory; // event memory for tracks
167     int   fTrackMemorySize; // size of the event memory [bytes]
168
169
170     int *fNTracklets;     // number of tracklets
171     AliHLTTPCCAHitId *fTrackletStartHits;   // start hits for the tracklets
172     AliHLTTPCCATracklet *fTracklets; // tracklets
173
174     //
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
179
180     // output
181
182     AliHLTTPCCASliceOutput *fOutput;
183
184     // obsolete output
185
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
190
191     // disable copy
192     AliHLTTPCCATracker( const AliHLTTPCCATracker& );
193     AliHLTTPCCATracker &operator=( const AliHLTTPCCATracker& );
194 };
195
196
197 #endif