]>
Commit | Line | Data |
---|---|---|
4ae5bbc4 | 1 | #include <Riostream.h> |
2 | #include <Riostream.h> | |
1f26c323 | 3 | #include <stdlib.h> |
4 | ||
5 | #include <TObject.h> | |
6 | #include <TROOT.h> | |
7 | #include <TMath.h> | |
8 | #include <TString.h> | |
9 | ||
10 | #include "AliITSglobalRecPoint.h" | |
11 | #include "AliITSneuralTracker.h" | |
12 | ||
13 | #include "AliITSneuralTrack.h" | |
14 | ||
15 | ||
16 | ||
17 | ClassImp(AliITSneuralTrack) | |
18 | // | |
19 | // | |
20 | // | |
21 | AliITSneuralTrack::AliITSneuralTrack() | |
22 | { | |
23 | Int_t i; | |
24 | for (i = 0; i < 6; i++) fPoint[i] = 0; | |
25 | } | |
26 | // | |
27 | // | |
28 | // | |
29 | AliITSneuralTrack::~AliITSneuralTrack() | |
30 | { | |
31 | Int_t i; | |
32 | for (i = 0; i < 6; i++) delete fPoint[i]; | |
33 | } | |
34 | // | |
35 | // | |
36 | // | |
37 | Int_t AliITSneuralTrack::CheckMe(Bool_t verbose) | |
38 | { | |
39 | Int_t l, stored = 0; | |
40 | TString empty("Not filled slots: "); | |
41 | for (l = 0; l < 6; l++) { | |
42 | if (fPoint[l]) | |
43 | stored++; | |
44 | else { | |
45 | empty += l; | |
46 | empty += ' '; | |
47 | } | |
48 | } | |
49 | ||
50 | if (stored < 6 && verbose) Warning("", empty); | |
51 | return stored; | |
52 | } | |
53 | // | |
54 | // | |
55 | // | |
56 | Int_t AliITSneuralTrack::EvaluateTrack(Bool_t verbose, Int_t min, Int_t* &good) | |
57 | { | |
58 | Int_t i, j, k = 0, count[18], id[18]; | |
59 | for (i = 0; i < 6; i++) { | |
60 | for (j = 0; j < 3; j++) { | |
61 | if (fPoint[i]) | |
62 | id[k] = fPoint[i]->fLabel[j]; | |
63 | else | |
64 | id[k] = -1; | |
65 | count[k] = 0; | |
66 | k++; | |
67 | } | |
68 | } | |
69 | for (i = 0; i < 18; i++) { | |
70 | for (j = i+1; j < 18; j++) { | |
71 | if (id[i] == id[j] || id[j] < 0) id[j] = -1; | |
72 | } | |
73 | } | |
74 | for (i = 0; i < 18; i++) { | |
75 | if (id[i] < 0) continue; | |
76 | for (j = 0; j < 6; j++) { | |
77 | if (fPoint[j] && fPoint[j]->HasID(id[i])) count[i]++; | |
78 | } | |
79 | } | |
80 | Int_t index[18], best; | |
81 | TMath::Sort(18, count, index); | |
82 | best = id[index[0]]; | |
83 | if (verbose) { | |
84 | if (count[index[0]]<min) cout << "\t"; | |
85 | cout << best << " " << count[index[0]] << endl; | |
86 | } | |
87 | ||
88 | if (good) delete [] good; | |
89 | good = new Int_t[6]; | |
90 | for (i = 0; i < 6; i++) { | |
91 | good[i] = 0; | |
92 | if (!fPoint[i]) | |
93 | good[i] = -1; | |
94 | else if (fPoint[i] && fPoint[i]->HasID(best)) | |
95 | good[i] = 1; | |
96 | else if (fPoint[i]->fLabel[0] < 0 && fPoint[i]->fLabel[1] < 0 && fPoint[i]->fLabel[2] < 0) | |
97 | good[i] = -1; | |
98 | } | |
99 | ||
100 | if (count[index[0]] < min) best = -best; | |
101 | ||
102 | return best; | |
103 | ||
104 | ||
105 | ||
106 | /* | |
107 | if (good) delete [] good; | |
108 | good = new Int_t[6]; | |
109 | Int_t count = CheckMe(verbose); | |
110 | ||
111 | if (count < min) return -9999999; | |
112 | ||
113 | Int_t i, l, max = 0, best = 0; | |
114 | for (l = 0; l < 6; l++) { | |
115 | for (i = 0; i < 3; i++) { | |
116 | if (fPoint[l].fLabel[i] > max) max = fPoint[l].fLabel[i]; | |
117 | } | |
118 | } | |
119 | ||
120 | count = max + 1; | |
121 | Int_t *counter = new Int_t[count]; | |
122 | for (i = 0; i < count; i++) counter[i] = 0; | |
123 | ||
124 | for (l = 0; l < 6; l++) { | |
125 | for (i = 0; i < 3; i++) { | |
126 | if (fPoint[l].fLabel[i] >= 0) | |
127 | counter[fPoint[l].fLabel[i]]++; | |
128 | } | |
129 | } | |
130 | ||
131 | for (i = 0; i < count; i++) { | |
132 | if (counter[i] > counter[best]) best = i; | |
133 | } | |
134 | ||
135 | for (l = 0; l < 6; l++) { | |
136 | good[l] = 0; | |
137 | if (fPoint[l].fLabel[0] == best || fPoint[l].fLabel[1] == best || fPoint[l].fLabel[2] == best) | |
138 | good[l] = 1; | |
139 | else if (fPoint[l].fLabel[0] < 0 && fPoint[l].fLabel[1] < 0 && fPoint[l].fLabel[2] < 0) | |
140 | good[l] = -1; | |
141 | } | |
142 | ||
143 | if (counter[best] < min) best = -best; | |
144 | delete counter; | |
145 | return best; | |
146 | */ | |
147 | } | |
148 | // | |
149 | // | |
150 | // | |
151 | void AliITSneuralTrack::GetCoords(Double_t* &x, Double_t* &y, Double_t* &z) | |
152 | { | |
153 | if (x) delete [] x; x = new Double_t[6]; | |
154 | if (y) delete [] y; y = new Double_t[6]; | |
155 | if (z) delete [] z; z = new Double_t[6]; | |
156 | ||
157 | Int_t i; | |
158 | ||
159 | for (i = 0; i < 6; i++) { | |
160 | x[i] = y[i] = z[i] = 0.0; | |
161 | if (!fPoint[i]) continue; | |
162 | x[i] = fPoint[i]->fGX; | |
163 | y[i] = fPoint[i]->fGY; | |
164 | z[i] = fPoint[i]->fGZ; | |
165 | } | |
166 | } | |
167 | // | |
168 | // | |
169 | // | |
170 | void AliITSneuralTrack::CopyPoint(AliITSglobalRecPoint *p) | |
171 | { | |
172 | Int_t layer = p->fLayer; | |
173 | if (layer < 0 || layer > 6) { | |
174 | Error("", Form("Wrong layer [%d]", layer)); | |
175 | return; | |
176 | } | |
177 | ||
178 | fPoint[layer] = new AliITSglobalRecPoint; | |
179 | fPoint[layer]->fGX = p->fGX; | |
180 | fPoint[layer]->fGY = p->fGY; | |
181 | fPoint[layer]->fGZ = p->fGZ; | |
182 | fPoint[layer]->fGSX = p->fGSX; | |
183 | fPoint[layer]->fGSY = p->fGSY; | |
184 | fPoint[layer]->fGSZ = p->fGSZ; | |
185 | fPoint[layer]->fLayer = layer; | |
186 | fPoint[layer]->fLabel[0] = p->fLabel[0]; | |
187 | fPoint[layer]->fLabel[1] = p->fLabel[1]; | |
188 | fPoint[layer]->fLabel[2] = p->fLabel[2]; | |
189 | } | |
190 | // | |
191 | // | |
192 | // | |
193 | void AliITSneuralTrack::Print(Option_t *option, Int_t min) | |
194 | { | |
195 | Int_t *vuoto = 0; | |
196 | TString opt(option); | |
197 | opt.ToUpper(); | |
198 | Int_t id = EvaluateTrack(0, min, vuoto); | |
199 | if (opt.Contains("A")) { | |
200 | cout << "\nEvaluated ID for this track: "; | |
201 | cout.width(8); | |
202 | if (id >= 0) { | |
203 | cout << id; | |
204 | cout << " [good]"; | |
205 | } | |
206 | else { | |
207 | cout << -id; | |
208 | cout << " [fake]"; | |
209 | } | |
210 | } | |
211 | cout << endl << endl; | |
212 | } | |
213 | // | |
214 | // | |
215 | // | |
216 | void AliITSneuralTrack::Kinks(Int_t &pos, Int_t &neg, Int_t &incr, Int_t &decr) | |
217 | { | |
218 | Int_t i; | |
219 | Double_t dphi, dphi_old = 0.0; | |
220 | pos = neg = incr = decr = 0; | |
221 | for (i = 1; i < 6; i++) { | |
222 | dphi = fPoint[i]->fPhi - fPoint[i-1]->fPhi; | |
223 | if (dphi > 0.0) pos++; else neg++; | |
224 | if (TMath::Abs(dphi) > dphi_old) incr++; else decr++; | |
225 | dphi_old = TMath::Abs(dphi); | |
226 | } | |
227 | } | |
228 | // | |
229 | // | |
230 | // | |
231 | Double_t AliITSneuralTrack::FitXY(Double_t VX, Double_t VY) | |
232 | { | |
233 | Int_t i; | |
234 | Double_t X, Y, D, R; | |
235 | Double_t rx(0.0), ry(0.0), x2(0.0), y2(0.0), xy(0.0); | |
236 | for (i = 0; i < 6; i++) { | |
237 | X = fPoint[i]->fGX - VX; | |
238 | Y = fPoint[i]->fGY - VY; | |
239 | R = X * X + Y * Y; | |
240 | rx += R * X; | |
241 | ry += R * Y; | |
242 | x2 += X * X; | |
243 | y2 += Y * Y; | |
244 | xy += X * Y; | |
245 | } | |
246 | ||
247 | D = 2 * (x2 * y2 - xy * xy); | |
248 | if (D == 0.0) | |
249 | return 1000.0; | |
250 | else { | |
251 | X = (rx * y2 - ry * xy) / D; | |
252 | Y = (ry * x2 - rx * xy) / D; | |
253 | fFitRadius = TMath::Sqrt(X * X + Y * Y); | |
254 | fFitXC = X + VX; | |
255 | fFitYC = Y + VY; | |
256 | } | |
257 | ||
258 | fSqChi = 0.0; | |
259 | for (i = 0; i < 6; i++) { | |
260 | X = fPoint[i]->fGX - fFitXC; | |
261 | Y = fPoint[i]->fGY - fFitYC; | |
262 | fSqChi += ((X * X + Y * Y) / (fFitRadius * fFitRadius)) * ((X * X + Y * Y) / (fFitRadius * fFitRadius)); | |
263 | } | |
264 | fSqChi /= 6.0; | |
265 | fSqChi = TMath::Sqrt(fSqChi); | |
266 | return fSqChi; | |
267 | } |