]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUTrackerSAaux.h
CA tracker - updates
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUTrackerSAaux.h
1 #ifndef ALIITSUTRACKERSAAUX_H
2 #define ALIITSUTRACKERSAAUX_H
3
4 #include <vector>
5 using std::vector;
6 #include <algorithm>
7 using std::sort;
8 #include "AliExternalTrackParam.h"
9 #include "AliITSUTrackCooked.h"
10 #include "AliITSUAux.h"
11
12 #include <TMath.h>
13
14 #include <Riostream.h>
15 using std::cout;
16 using std::endl;
17
18 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
19 template <typename T> 
20 struct Comparison { //Adapted from TMath ROOT code
21   Comparison(vector<T> *d) : fData(d) {}
22
23   bool operator()(int i1, int i2) {
24     return fData->at(i1).CmpVar() < fData->at(i2).CmpVar();
25   }
26   vector<T> *fData;
27 };
28
29 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
30 struct Cell {
31   
32   Cell() : Level(1),
33            Param(),
34            Points(),
35            N(0),
36            Neighbours(),
37            Label(-1){ 
38       // Inlined standard constructor
39   } ;
40
41   Cell(int i1, int i2) : Level(1),
42                          Param(),
43                          Points(),
44                          N(2),
45                          Neighbours(),
46                          Label(-1){ 
47       // Inlined standard constructor
48       Points[0] = i1;
49       Points[1] = i2;
50   } ;
51
52   Cell(int i1, int i2, int i3) : Level(1),
53                                  Param(),
54                                  Points(),
55                                  N(3),
56                                  Neighbours(),
57                                  Label(-1) {  
58                                   
59       // Inlined standard constructor
60       Points[0] = i1;
61       Points[1] = i2;
62       Points[2] = i3;
63   } ;
64   
65   int Level;
66   float Param[3];
67   int Points[3];
68   int N;
69   vector<int> Neighbours;
70   int Label;
71 };
72
73 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
74 struct SpacePoint {
75   SpacePoint(const float *xyz, const float &alpha) : XYZ(),
76                                                      Cov(),
77                                                      Phi(),
78                                                      Alpha(alpha),
79                                                      Label(),
80                                                      Used(false) 
81   {
82       XYZ[0] = xyz[0];
83       XYZ[1] = xyz[1];
84       XYZ[2] = xyz[2];
85       Cov[0]=Cov[1]=Cov[2]=99999.f;
86   };
87
88   SpacePoint(const SpacePoint &sp) : XYZ(),
89                                      Cov(),
90                                      Phi(sp.Phi),
91                                      Alpha(sp.Alpha),
92                                      Label(),
93                                      Used(sp.Used) 
94   {
95     for(int i=0; i<3; ++i) {
96       XYZ[i]=sp.XYZ[i];
97       Label[i]=sp.Label[i];
98       Cov[i]=sp.Cov[i];
99     }
100   };
101
102   float CmpVar() const { return Phi; }
103
104   float XYZ[3];
105   float Cov[3];
106   float Phi;
107   float Alpha;
108   int Label[3];
109   bool Used;
110 };
111
112 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
113 struct Layer {
114   Layer() : Index(),
115             N(0),
116             Points() {};
117
118   int operator()(const int &i) { return Index[i]; } // Just for compatibility with old code
119   SpacePoint& operator[](const int &i) { return Points[Index[i]]; } 
120   ~Layer() { Clear(); }
121
122   void AddPoint(const float xyz[3], const float cov[3], const float &phi, const float &alpha) {
123     Index.push_back(N++);
124     Points.push_back(SpacePoint(xyz,alpha));
125     Points.back().Cov[0] = cov[0];
126     Points.back().Cov[1] = cov[1];
127     Points.back().Cov[2] = cov[2];
128     Points.back().Phi = phi;
129   }
130
131   void Sort() {
132     Comparison<SpacePoint> cmp(&Points);
133     sort(Index.begin(),Index.end(),cmp); 
134   }
135
136   void Clear() { 
137     Index.clear();
138     Points.clear();
139     N=0;
140   }
141
142   vector<int> Index;
143   int N;
144   vector<SpacePoint> Points;
145 };
146
147 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
148 struct Road {
149
150   Road() : Elements(), N(0), Label(-1) {
151     ResetElements(); 
152   }
153
154   Road(int layer, int id) : Elements(), N(1), Label(-1) {
155     ResetElements();
156     Elements[layer] = id;
157   }
158
159   Road(const Road& copy) : Elements(), N(copy.N), Label(copy.Label) {
160     for ( int i=0; i<5; ++i ) Elements[i] = copy.Elements[i];
161   }
162
163   int &operator[] (const int &i) {
164     return Elements[i];
165   }
166
167   void ResetElements() {
168     for ( int i=0; i<5; ++i ) 
169       Elements[i] = -1;   
170   }
171
172   void AddElement(int i, int el) {
173     ++N;
174     Elements[i] = el;
175   }
176   
177   int Elements[5];
178   int N;
179   int Label;
180 };
181
182 // class AliITSUTrackCA : public AliITSUTrackCooked {
183 // public:
184 //   AliITSUTrackCA() : AliITSUTrackCooked() {}
185 //   AliITSUTrackCA(const AliITSUTrackCA &t) : AliITSUTrackCooked((AliITSUTrackCooked)t) {}
186 //   AliITSUTrackCA(const AliESDtrack &t) : AliITSUTrackCooked(t) {}
187 //   AliITSUTrackCA &operator=(const AliITSUTrackCooked &t);
188 //   virtual ~AliITSUTrackCA();
189 //   void SetChi2(Double_t chi2) { fChi2=chi2; }
190 //   ClassDef(AliITSUTrackCA,1)
191 // };
192
193 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
194 template<> 
195 struct Comparison <AliITSUTrackCooked> {
196   Comparison(vector<AliITSUTrackCooked> *d) : fData(d) {}
197
198   bool operator()(int i1, int i2) {
199     return (fData->at(i1).GetChi2() < fData->at(i2).GetChi2());
200   }
201   vector<AliITSUTrackCooked> *fData;
202 };
203
204 // //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
205 // class Candidate : public AliKalmanTrack {
206 //   public :
207
208 //   Candidate() : AliKalmanTrack(), 
209 //                 fChi2( 0. ), 
210 //                 fPoints(), 
211 //                 fNPoints(0), 
212 //                 fInnermostLayer(-1), 
213 //                 fOutermostLayer(-1) 
214 //   {
215 //     for ( unsigned int i = 0; i < 2*AliITSUAux::kMaxLayers; ++i ) fPoints[i]=-1;
216 //   };
217
218 //   Candidate(const Candidate &copy) : AliExternalTrackParam(), 
219 //                                      fChi2(copy.fChi2), 
220 //                                      fPoints(),
221 //                                      fNPoints(copy.fNPoints), 
222 //                                      fInnermostLayer(copy.fInnermostLayer), 
223 //                                      fOutermostLayer(copy.fOutermostLayer)
224 //   {
225 //     for ( unsigned int i = 0; i < 2*AliITSUAux::kMaxLayers; ++i ) fPoints[i]=copy.fPoints[i];
226 //   };
227
228 //   Candidate(int points[7]) : AliExternalTrackParam(), 
229 //                              fChi2( 0. ), 
230 //                              fPoints(),
231 //                              fNPoints( 0 ), 
232 //                              fInnermostLayer( -1 ), 
233 //                              fOutermostLayer( -1 )
234 //   { 
235 //     bool outer=false;
236 //     ResetPoints();
237 //     for ( int i=6; i>=0; --i ) {
238 //       if (points[i]!=-1) {
239 //         if (! outer ) { 
240 //           outer = true;
241 //           fOutermostLayer = points[i];
242 //         }
243 //         fInnermostLayer = points[i];
244 //         ++fNPoints;
245 //       }
246 //       fPoints[i<<0x1] = points[i];
247 //     }
248 //   }
249
250 //   int GetClusterIndex(const int &i) const {
251 //     return ((fInnermostLayer+i)<<28)+fPoints[(fInnermostLayer+i)<<0x1];
252 //   }
253
254 //   Double_t CmpVar() const { return fChi2; }
255
256 //   void ResetPoints() { for(unsigned int i = 0; i < 2*AliITSUAux::kMaxLayers; ++i) fPoints[i]=-1; }
257 //   //
258 //   // Double_t fChi2;
259 //   // Double_t fFakeRatio;
260 //   Int_t fPoints[2*AliITSUAux::kMaxLayers];
261 //   // Int_t fNPoints;
262 //   Int_t fLabel;
263 //   Int_t fInnermostLayer;
264 //   Int_t fOutermostLayer;
265
266 // };
267
268 #endif