]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUTrackerSAaux.h
Little coverity fix
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUTrackerSAaux.h
CommitLineData
2cbb5f31 1#ifndef ALIITSUTRACKERSAAUX_H
2#define ALIITSUTRACKERSAAUX_H
3
4#include <vector>
5using std::vector;
df380774 6#include <algorithm>
7using std::sort;
a0c47fdb 8#include "AliExternalTrackParam.h"
df380774 9#include "AliITSUTrackCooked.h"
a0c47fdb 10#include "AliITSUAux.h"
2cbb5f31 11
df380774 12#include <TMath.h>
13
14#include <Riostream.h>
15using std::cout;
16using std::endl;
17
18//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
19template <typename T>
20struct 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();
a0c47fdb 25 }
df380774 26 vector<T> *fData;
27};
28
29//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
30struct 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//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
74struct 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//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
113struct 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;
2cbb5f31 145};
146
df380774 147//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
57a336dd 148struct Road {
df380774 149
150 Road() : Elements(), N(0), Label(-1) {
57a336dd 151 ResetElements();
152 }
df380774 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];
57a336dd 165 }
166
167 void ResetElements() {
df380774 168 for ( int i=0; i<5; ++i )
169 Elements[i] = -1;
57a336dd 170 }
171
172 void AddElement(int i, int el) {
df380774 173 ++N;
174 Elements[i] = el;
57a336dd 175 }
176
df380774 177 int Elements[5];
178 int N;
179 int Label;
57a336dd 180};
181
df380774 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//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
194template<>
195struct 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());
a0c47fdb 200 }
df380774 201 vector<AliITSUTrackCooked> *fData;
2cbb5f31 202};
203
df380774 204// //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
205// class Candidate : public AliKalmanTrack {
206// public :
57a336dd 207
df380774 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// };
a0c47fdb 217
df380774 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// };
a0c47fdb 227
df380774 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// }
57a336dd 249
df380774 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// };
a0c47fdb 267
2cbb5f31 268#endif