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