]>
Commit | Line | Data |
---|---|---|
e0679afb | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // Author: Artur Szostak | |
21 | // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com | |
22 | // | |
23 | //////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include "AliHLTMUONMansoTrackerFSM.h" | |
26 | #include "AliHLTMUONCalculations.h" | |
27 | #include "AliHLTMUONUtils.h" | |
28 | #include <cmath> | |
29 | ||
30 | ||
31 | #ifdef DEBUG | |
32 | #include <ostream> | |
33 | namespace | |
34 | { | |
35 | ||
36 | std::ostream& operator << (std::ostream& os, AliHLTMUONMansoTrackerFSM::StatesSM4 state) | |
37 | { | |
38 | switch (state) | |
39 | { | |
40 | case AliHLTMUONMansoTrackerFSM::kSM4Idle: os << "kSM4Idle"; break; | |
41 | case AliHLTMUONMansoTrackerFSM::kWaitChamber8: os << "kWaitChamber8"; break; | |
42 | case AliHLTMUONMansoTrackerFSM::kWaitMoreChamber8: os << "kWaitMoreChamber8"; break; | |
43 | case AliHLTMUONMansoTrackerFSM::kWaitChamber7: os << "kWaitChamber7"; break; | |
44 | case AliHLTMUONMansoTrackerFSM::kWaitMoreChamber7: os << "kWaitMoreChamber7"; break; | |
45 | default: os << "FAULT!!"; | |
46 | } | |
47 | return os; | |
48 | } | |
49 | ||
50 | std::ostream& operator << (std::ostream& os, AliHLTMUONMansoTrackerFSM::StatesSM5 state) | |
51 | { | |
52 | switch (state) | |
53 | { | |
54 | case AliHLTMUONMansoTrackerFSM::kSM5Idle: os << "kSM5Idle"; break; | |
55 | case AliHLTMUONMansoTrackerFSM::kWaitChamber10: os << "kWaitChamber10"; break; | |
56 | case AliHLTMUONMansoTrackerFSM::kWaitMoreChamber10: os << "kWaitMoreChamber10"; break; | |
57 | case AliHLTMUONMansoTrackerFSM::kWaitChamber9: os << "kWaitChamber9"; break; | |
58 | case AliHLTMUONMansoTrackerFSM::kWaitMoreChamber9: os << "kWaitMoreChamber9"; break; | |
59 | case AliHLTMUONMansoTrackerFSM::kSM5Done: os << "kSM5Done"; break; | |
60 | default: os << "FAULT!!"; | |
61 | } | |
62 | return os; | |
63 | } | |
64 | ||
65 | } // end of namespace | |
66 | #endif // DEBUG | |
67 | ||
68 | ||
69 | // Deviate from the Manso implementation by allowing a and b | |
70 | // parameters per chamber and not just per station. | |
71 | // The default values are derived from the work done in | |
72 | // "A first algorithm for dimuon High Level Trigger" | |
73 | // Ref ID: ALICE-INT-2002-04 version 1.0 | |
74 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgA7 = 0.016f; | |
75 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgB7 = 2.0f; | |
76 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgA8 = 0.016f; | |
77 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgB8 = 2.0f; | |
78 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgA9 = 0.020f; | |
79 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgB9 = 3.0f; | |
80 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgA10 = 0.020f; | |
81 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgB10 = 3.0f; | |
82 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgZ7 = 1274.5f; | |
83 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgZ8 = 1305.5f; | |
84 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgZ9 = 1408.6f; | |
85 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgZ10 = 1439.6f; | |
86 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgZ11 = 1603.5f; | |
87 | AliHLTFloat32_t AliHLTMUONMansoTrackerFSM::fgZ13 = 1703.5f; | |
88 | ||
89 | ||
90 | void AliHLTMUONMansoTrackerFSM::AliRegionOfInterest::Create(AliHLTMUONCorePoint p, AliHLTFloat32_t a, AliHLTFloat32_t b) | |
91 | { | |
92 | // Creates a region of interest specific to the Manso algorithm from a point and | |
93 | // two Manso specific parameters. | |
94 | ||
95 | fCentre = p; | |
96 | // Compute the radius Rp | |
97 | AliHLTFloat32_t rp = (AliHLTFloat32_t) sqrt( p.X() * p.X() + p.Y() * p.Y() ); | |
98 | ||
99 | // The radius Rs for the region of interest is computed from the | |
100 | // specification given in the document: | |
101 | // "A first algorithm for dimuon High Level Trigger" | |
102 | // Ref ID: ALICE-INT-2002-04 version 1.0 | |
103 | // equation: | |
104 | // Rs = a * Rp + b | |
105 | // given on page 3 section 4. | |
106 | fRs = a * rp + b; | |
107 | } | |
108 | ||
109 | ||
110 | bool AliHLTMUONMansoTrackerFSM::AliRegionOfInterest::Contains(AliHLTMUONCorePoint p) const | |
111 | { | |
112 | // Compute the distance between the centre of the region of interest and | |
113 | // the point p. This distance must be less than the radius of the region | |
114 | // of interest for p to be contained in the region of interest. | |
115 | register AliHLTFloat32_t lx = fCentre.X() - p.X(); | |
116 | register AliHLTFloat32_t ly = fCentre.Y() - p.Y(); | |
117 | register AliHLTFloat32_t r = (AliHLTFloat32_t) sqrt( lx * lx + ly * ly ); | |
118 | DebugTrace("\tAliRegionOfInterest::Contains : p = " << p | |
119 | << " , centre = " << fCentre << " , r = " << r << " , Rs = " << fRs | |
120 | ); | |
121 | return r <= fRs; | |
122 | } | |
123 | ||
124 | ||
125 | void AliHLTMUONMansoTrackerFSM::AliRegionOfInterest::GetBoundaryBox( | |
126 | AliHLTFloat32_t& left, AliHLTFloat32_t& right, AliHLTFloat32_t& bottom, AliHLTFloat32_t& top | |
127 | ) const | |
128 | { | |
129 | // Works out the smallest boundary box that will contain the region of interest. | |
130 | ||
131 | left = fCentre.X() - fRs; | |
132 | right = fCentre.X() + fRs; | |
133 | bottom = fCentre.Y() - fRs; | |
134 | top = fCentre.Y() + fRs; | |
135 | } | |
136 | ||
137 | ||
138 | AliHLTMUONMansoTrackerFSM::AliVertex::AliVertex(AliHLTFloat32_t x, AliHLTFloat32_t y, AliHLTFloat32_t z) | |
139 | : fX(x), fY(y), fZ(z) | |
140 | { | |
141 | // Constructor for vertex. | |
142 | ||
143 | fX = x; | |
144 | fY = y; | |
145 | fZ = z; | |
146 | } | |
147 | ||
148 | ||
149 | AliHLTMUONMansoTrackerFSM::AliVertex::AliVertex(AliHLTMUONCorePoint xy, AliHLTFloat32_t z) | |
150 | : fX(xy.X()), fY(xy.Y()), fZ(z) | |
151 | { | |
152 | // Construct vertex from a point on the XY plane and z coordinate. | |
153 | ||
154 | fX = xy.X(); | |
155 | fY = xy.Y(); | |
156 | fZ = z; | |
157 | } | |
158 | ||
159 | ||
160 | AliHLTMUONMansoTrackerFSM::AliLine::AliLine( | |
161 | AliHLTFloat32_t ax, AliHLTFloat32_t ay, AliHLTFloat32_t az, | |
162 | AliHLTFloat32_t bx, AliHLTFloat32_t by, AliHLTFloat32_t bz | |
163 | ) : | |
164 | fMx(ax - bx), fMy(ay - by), fMz(az - bz), | |
165 | fCx(bx), fCy(by), fCz(bz) | |
166 | { | |
167 | // Construct a line defined by L = M*t + C = (A-B)*t + B | |
168 | // where M and C are 3D vectors and t is a free parameter. | |
169 | // A = (ax, ay, az) and B = (bx, by, bz) | |
170 | ||
171 | fMx = ax - bx; | |
172 | fMy = ay - by; | |
173 | fMz = az - bz; | |
174 | fCx = bx; | |
175 | fCy = by; | |
176 | fCz = bz; | |
177 | } | |
178 | ||
179 | ||
180 | AliHLTMUONMansoTrackerFSM::AliLine::AliLine(AliVertex a, AliVertex b) : | |
181 | fMx(a.X() - b.X()), fMy(a.Y() - b.Y()), fMz(a.Z() - b.Z()), | |
182 | fCx(b.X()), fCy(b.Y()), fCz(b.Z()) | |
183 | { | |
184 | // Contruct a line to go through two vertices a and b. | |
185 | ||
186 | fMx = a.X() - b.X(); | |
187 | fMy = a.Y() - b.Y(); | |
188 | fMz = a.Z() - b.Z(); | |
189 | fCx = b.X(); | |
190 | fCy = b.Y(); | |
191 | fCz = b.Z(); | |
192 | } | |
193 | ||
194 | ||
195 | AliHLTMUONCorePoint AliHLTMUONMansoTrackerFSM::AliLine::FindIntersectWithXYPlain(AliHLTFloat32_t z) const | |
196 | { | |
197 | // Find the point of intersection of the line and the XY plane at z. | |
198 | ||
199 | Assert( fMz != 0.0 ); // Should not have a ray perpendicular to the beam axis. | |
200 | AliHLTFloat32_t t = (z - fCz) / fMz; | |
201 | AliHLTFloat32_t lx = fMx*t + fCx; | |
202 | AliHLTFloat32_t ly = fMy*t + fCy; | |
203 | ||
204 | return AliHLTMUONCorePoint(lx, ly); | |
205 | } | |
206 | ||
207 | ||
208 | AliHLTMUONMansoTrackerFSM::AliHLTMUONMansoTrackerFSM() : | |
209 | fCallback(NULL), | |
210 | fSm4state(kSM4Idle), | |
211 | fSm5state(kSM5Idle), | |
212 | fRequestsCompleted(0), | |
213 | fSt4chamber(kChamber1), | |
214 | fV1(), | |
215 | fMc1(), | |
216 | fSt5z(0), | |
217 | fSt5data(), | |
218 | fSt4z(0), | |
219 | fSt4points(), | |
220 | fSt5rec(), | |
221 | fFoundPoint() | |
222 | { | |
223 | // Default constructor | |
224 | } | |
225 | ||
226 | ||
227 | void AliHLTMUONMansoTrackerFSM::FindTrack(const AliHLTMUONCoreTriggerRecord& trigger) | |
228 | { | |
229 | // Tries to find the track from the trigger seed. | |
230 | ||
231 | DebugTrace("SM5 state = " << fSm5state << " , SM4 state = " << fSm4state); | |
232 | DebugTrace("Processing trigger with pt = " << trigger.fPt); | |
233 | fV1 = AliVertex( trigger.fStation1impact, fgZ11 ); | |
234 | AliVertex v2 = AliVertex( trigger.fStation2impact, fgZ13 ); | |
235 | ||
236 | // Form the vector line between the above two impact points and | |
237 | // find the crossing point of the line with chamber 10 (i.e. station 5). | |
238 | fMc1.fLine = AliLine(fV1, v2); | |
239 | AliHLTMUONCorePoint p10 = fMc1.fLine.FindIntersectWithXYPlain( fgZ10 ); | |
240 | ||
241 | // Build a region of interest for tracking station 5 (chamber 10). | |
242 | // Remember the parameters a and b are station specific. | |
243 | fMc1.fChamber = kChamber10; | |
244 | fMc1.fRoi.Create(p10, fgA10, fgB10); | |
245 | ||
246 | // Make SM5 state transition before the call to RequestClusters since | |
247 | // that method could call one of our methods again, so we need to be | |
248 | // in a consistant internal state. | |
249 | fSm5state = kWaitChamber10; | |
250 | ||
251 | AliHLTFloat32_t left, right, bottom, top; | |
252 | fMc1.fRoi.GetBoundaryBox(left, right, bottom, top); | |
253 | RequestClusters(left, right, bottom, top, kChamber10, &fMc1); | |
254 | } | |
255 | ||
256 | ||
257 | void AliHLTMUONMansoTrackerFSM::ReturnClusters(void* tag, const AliHLTMUONCoreClusterPoint* clusters, UInt count) | |
258 | { | |
259 | // Implementation of AliHLTMUONCoreTracker::ReturnClusters. | |
260 | ||
261 | Assert( count > 0 ); | |
262 | Assert( clusters != NULL ); | |
263 | ||
264 | AliTagData* data = (AliTagData*)tag; | |
265 | DebugTrace("Got AliHLTMUONMansoTrackerFSM::ReturnClusters(tag = " << tag | |
266 | << ", chamber = " << data->fChamber | |
267 | << ", clusters = " << clusters << ", count = " << count << ")" | |
268 | ); | |
269 | DebugTrace("SM5 state = " << fSm5state << " , SM4 state = " << fSm4state); | |
270 | ||
271 | switch (data->fChamber) | |
272 | { | |
273 | case kChamber7: ReceiveClustersChamber7(clusters, count, data); break; | |
274 | case kChamber8: ReceiveClustersChamber8(clusters, count, data); break; | |
275 | case kChamber9: ReceiveClustersChamber9(clusters, count); break; | |
276 | case kChamber10: ReceiveClustersChamber10(clusters, count); break; | |
277 | default: | |
278 | // Error | |
279 | DebugTrace("ERROR: Got tag with an invalid value: " << data->fChamber); | |
280 | } | |
281 | } | |
282 | ||
283 | ||
284 | void AliHLTMUONMansoTrackerFSM::EndOfClusters(void* tag) | |
285 | { | |
286 | // Implementation of AliHLTMUONCoreTracker::EndOfClusters. | |
287 | ||
288 | AliTagData* data = (AliTagData*)tag; | |
289 | DebugTrace("Got AliHLTMUONMansoTrackerFSM::EndOfClusters(chamber = " << data->fChamber << ")"); | |
290 | DebugTrace("SM5 state = " << fSm5state << " , SM4 state = " << fSm4state); | |
291 | ||
292 | switch (data->fChamber) | |
293 | { | |
294 | case kChamber7: EndOfClustersChamber7(); break; | |
295 | case kChamber8: EndOfClustersChamber8(); break; | |
296 | case kChamber9: EndOfClustersChamber9(); break; | |
297 | case kChamber10: EndOfClustersChamber10(); break; | |
298 | default: | |
299 | // Error | |
300 | DebugTrace("ERROR: Got tag with an invalid value: " << data->fChamber); | |
301 | } | |
302 | } | |
303 | ||
304 | ||
305 | void AliHLTMUONMansoTrackerFSM::FillTrackData(AliHLTMUONCoreTrack& track) | |
306 | { | |
307 | // Implementation of AliHLTMUONCoreTracker::FillTrackData | |
308 | ||
309 | DebugTrace("FillTrack: st5 = " << fSt5rec->fClusterPoint << ", st4 = " << fFoundPoint->fClusterPoint); | |
310 | ||
311 | AliHLTFloat32_t x1 = fFoundPoint->fClusterPoint.X(); | |
312 | AliHLTFloat32_t y1 = fFoundPoint->fClusterPoint.Y(); | |
313 | AliHLTFloat32_t y2 = fSt5rec->fClusterPoint.Y(); | |
314 | AliHLTFloat32_t momentum; | |
315 | AliHLTFloat32_t pt = AliHLTMUONCoreCalculateSignedPt(x1, y1, y2, fSt4z, fSt5z, momentum); | |
316 | DebugTrace("Calculated Pt = " << pt); | |
317 | DebugTrace("\tusing x1 = " << x1 << " , y1 = " << y1 << " , y2 = " << y2 | |
318 | << " , z1 = " << fSt4z << " , z2 = " << fSt5z | |
319 | ); | |
320 | ||
321 | if (pt < 0) | |
322 | track.fSign = kSignMinus; | |
323 | else if (pt > 0) | |
324 | track.fSign = kSignPlus; | |
325 | else | |
326 | track.fSign = kUnknownSign; | |
327 | ||
328 | track.fP = momentum; | |
329 | track.fPt = (AliHLTFloat32_t) fabs(pt); | |
330 | for (UInt i = 0; i < 6; i++) | |
331 | { | |
332 | track.fPoint[i] = AliHLTMUONCorePoint(0.0, 0.0); | |
333 | track.fRegion[i] = kInvalidROI; | |
334 | } | |
335 | ||
336 | AliHLTFloat32_t left, right, bottom, top; | |
337 | ||
338 | // Have to create the ROI numbers from the internal region of interest structures. | |
339 | fSt5rec->fTag.fRoi.GetBoundaryBox(left, right, bottom, top); | |
340 | AliHLTMUONCoreRegionOfInterest region4(left, right, bottom, top, fSt4chamber); | |
341 | fMc1.fRoi.GetBoundaryBox(left, right, bottom, top); | |
342 | AliHLTMUONCoreRegionOfInterest region5(left, right, bottom, top, fMc1.fChamber); | |
343 | ||
344 | // Depending on the chamber we received cluster points from, fill the appropriate | |
345 | // point and ROI number. This is done for station 4 then 5. | |
346 | if (fSt4chamber == kChamber8) | |
347 | { | |
348 | track.fPoint[6] = AliHLTMUONCorePoint(0.0, 0.0); | |
349 | track.fRegion[6] = kInvalidROI; | |
350 | track.fPoint[7] = fFoundPoint->fClusterPoint; | |
351 | track.fRegion[7] = region4; | |
352 | } | |
353 | else | |
354 | { | |
355 | track.fPoint[6] = fFoundPoint->fClusterPoint; | |
356 | track.fRegion[6] = region4; | |
357 | track.fPoint[7] = AliHLTMUONCorePoint(0.0, 0.0); | |
358 | track.fRegion[7] = kInvalidROI; | |
359 | } | |
360 | if (fMc1.fChamber == kChamber10) | |
361 | { | |
362 | track.fPoint[8] = AliHLTMUONCorePoint(0.0, 0.0); | |
363 | track.fRegion[8] = kInvalidROI; | |
364 | track.fPoint[9] = fSt5rec->fClusterPoint; | |
365 | track.fRegion[9] = region5; | |
366 | } | |
367 | else | |
368 | { | |
369 | track.fPoint[8] = fSt5rec->fClusterPoint; | |
370 | track.fRegion[8] = region5; | |
371 | track.fPoint[9] = AliHLTMUONCorePoint(0.0, 0.0); | |
372 | track.fRegion[9] = kInvalidROI; | |
373 | } | |
374 | } | |
375 | ||
376 | ||
377 | void AliHLTMUONMansoTrackerFSM::Reset() | |
378 | { | |
379 | // Implementation of AliHLTMUONCoreTracker::Reset | |
380 | ||
381 | DebugTrace("SM5 state = " << fSm5state << " , SM4 state = " << fSm4state); | |
382 | fSt5data.Clear(); | |
383 | fSt4points.Clear(); | |
384 | fSm4state = kSM4Idle; | |
385 | fSm5state = kSM5Idle; | |
386 | fRequestsCompleted = 0; | |
387 | } | |
388 | ||
389 | ||
390 | // Note: In the following ReceiveClustersXXX and EndOfClustersXXX methods we make | |
391 | // the state machine transitions before calls to RequestClusters, FoundTrack, | |
392 | // NoTrackFound or EndOfClusterRequests. This is important since the callback | |
393 | // object will make recursive calls to the tracker's methods so we need to maintain | |
394 | // a consistant internal state. | |
395 | // The same would go for updating internal variables. | |
396 | // In general one should only call the callback methods at the end of any of the | |
397 | // following routines. | |
398 | ||
399 | void AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber7( | |
400 | const AliHLTMUONCoreClusterPoint* clusters, UInt count, const AliTagData* data | |
401 | ) | |
402 | { | |
403 | // State change method for Station 4 state machine. | |
404 | ||
405 | switch (fSm4state) | |
406 | { | |
407 | case kWaitChamber7: | |
408 | fSm4state = kWaitMoreChamber7; | |
409 | ||
410 | case kWaitMoreChamber7: | |
411 | for (UInt j = 0; j < count; j++) | |
412 | { | |
413 | AliHLTMUONCoreClusterPoint cluster = clusters[j]; | |
414 | // Check that the cluster actually is in our region of interest on station 4. | |
415 | if ( data->fRoi.Contains(cluster) ) | |
416 | { | |
417 | DebugTrace("Adding cluster [" << cluster.X() << ", " << cluster.Y() << "] from chamber 7."); | |
418 | AliStation4Data* newdata = fSt4points.New(); | |
419 | newdata->fClusterPoint = cluster; | |
420 | newdata->fSt5tag = data; | |
421 | } | |
422 | } | |
423 | break; | |
424 | ||
425 | default: | |
426 | DebugTrace("ERROR: Unexpected state for SM4 in AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber7!"); | |
427 | } | |
428 | } | |
429 | ||
430 | ||
431 | void AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber8( | |
432 | const AliHLTMUONCoreClusterPoint* clusters, UInt count, const AliTagData* data | |
433 | ) | |
434 | { | |
435 | // State change method for Station 4 state machine. | |
436 | ||
437 | switch (fSm4state) | |
438 | { | |
439 | case kWaitChamber8: | |
440 | fSm4state = kWaitMoreChamber8; | |
441 | fSt4z = fgZ8; | |
442 | fSt4chamber = kChamber8; | |
443 | ||
444 | case kWaitMoreChamber8: | |
445 | for (UInt j = 0; j < count; j++) | |
446 | { | |
447 | AliHLTMUONCoreClusterPoint cluster = clusters[j]; | |
448 | // Check that the cluster actually is in our region of interest on station 4. | |
449 | if ( data->fRoi.Contains(cluster) ) | |
450 | { | |
451 | DebugTrace("Adding cluster [" << cluster.X() << ", " << cluster.Y() << "] from chamber 8."); | |
452 | AliStation4Data* newdata = fSt4points.New(); | |
453 | newdata->fClusterPoint = cluster; | |
454 | newdata->fSt5tag = data; | |
455 | } | |
456 | } | |
457 | break; | |
458 | ||
459 | default: | |
460 | DebugTrace("ERROR: Unexpected state for SM4 in AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber8!"); | |
461 | } | |
462 | } | |
463 | ||
464 | ||
465 | void AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber9(const AliHLTMUONCoreClusterPoint* clusters, UInt count) | |
466 | { | |
467 | // State change method for Station 5 state machine. | |
468 | ||
469 | switch (fSm5state) | |
470 | { | |
471 | case kWaitChamber9: | |
472 | fSm5state = kWaitMoreChamber9; | |
473 | fSm4state = kWaitChamber8; // Start SM4. | |
474 | ||
475 | case kWaitMoreChamber9: | |
476 | for (UInt j = 0; j < count; j++) | |
477 | { | |
478 | AliHLTMUONCoreClusterPoint cluster = clusters[j]; | |
479 | // Check that the cluster actually is in our region of interest on station 5. | |
480 | if ( fMc1.fRoi.Contains(cluster) ) | |
481 | { | |
482 | DebugTrace("Adding cluster [" << cluster.X() << ", " << cluster.Y() << "] from chamber 9."); | |
483 | AliStation5Data* data = fSt5data.New(); | |
484 | data->fClusterPoint = cluster; | |
485 | ProjectToStation4(data, fgZ9); // This adds a new request for station 4. | |
486 | } | |
487 | } | |
488 | break; | |
489 | ||
490 | default: | |
491 | DebugTrace("ERROR: Unexpected state for SM5 in AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber9!"); | |
492 | } | |
493 | } | |
494 | ||
495 | ||
496 | void AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber10(const AliHLTMUONCoreClusterPoint* clusters, UInt count) | |
497 | { | |
498 | // State change method for Station 5 state machine. | |
499 | ||
500 | switch (fSm5state) | |
501 | { | |
502 | case kWaitChamber10: | |
503 | fSm5state = kWaitMoreChamber10; | |
504 | fSt5z = fgZ10; | |
505 | fSm4state = kWaitChamber8; // Start SM4. | |
506 | ||
507 | case kWaitMoreChamber10: | |
508 | for (UInt j = 0; j < count; j++) | |
509 | { | |
510 | AliHLTMUONCoreClusterPoint cluster = clusters[j]; | |
511 | // Check that the cluster actually is in our region of interest on station 5. | |
512 | if ( fMc1.fRoi.Contains(cluster) ) | |
513 | { | |
514 | DebugTrace(4, "Adding cluster [" << cluster.X() << ", " << cluster.Y() << "] from chamber 10."); | |
515 | AliStation5Data* data = fSt5data.New(); | |
516 | data->fClusterPoint = cluster; | |
517 | ProjectToStation4(data, fgZ10); // This adds a new request for station 4. | |
518 | } | |
519 | } | |
520 | break; | |
521 | ||
522 | default: | |
523 | DebugTrace("ERROR: Unexpected state for SM5 in AliHLTMUONMansoTrackerFSM::ReceiveClustersChamber10!"); | |
524 | } | |
525 | } | |
526 | ||
527 | ||
528 | void AliHLTMUONMansoTrackerFSM::EndOfClustersChamber7() | |
529 | { | |
530 | // State change method for Station 4 state machine. | |
531 | ||
532 | fRequestsCompleted++; // Increment the number of requests completed for station 4. | |
533 | DebugTrace("fRequestsCompleted = " << fRequestsCompleted ); | |
534 | ||
535 | switch (fSm4state) | |
536 | { | |
537 | case kWaitChamber7: | |
538 | // If all data from station 5 is received and no data found on | |
539 | // chambers 7 or 8 then we can not find a track. | |
540 | if (fSm5state == kSM5Done) NoTrackFound(); | |
541 | break; | |
542 | ||
543 | case kWaitMoreChamber7: | |
544 | if (fRequestsCompleted == fSt5data.Count() && fSm5state == kSM5Done) | |
545 | ProcessClusters(); | |
546 | break; | |
547 | ||
548 | default: | |
549 | DebugTrace("ERROR: Unexpected state for SM4 in AliHLTMUONMansoTrackerFSM::EndOfClustersChamber7!"); | |
550 | } | |
551 | } | |
552 | ||
553 | ||
554 | void AliHLTMUONMansoTrackerFSM::EndOfClustersChamber8() | |
555 | { | |
556 | // State change method for Station 4 state machine. | |
557 | ||
558 | fRequestsCompleted++; // Increment the number of requests completed for station 4. | |
559 | DebugTrace("fRequestsCompleted = " << fRequestsCompleted ); | |
560 | ||
561 | switch (fSm4state) | |
562 | { | |
563 | case kWaitChamber7: | |
564 | // Ignore. The requests for chamber 8 are already re-requested below. | |
565 | break; | |
566 | ||
567 | case kWaitChamber8: | |
568 | { | |
569 | fSm4state = kWaitChamber7; | |
570 | fSt4z = fgZ7; | |
571 | fSt4chamber = kChamber7; | |
572 | ||
573 | // We need to resend the requests for chamber 8, but change the request | |
574 | // to get data for chamber 7 instead: | |
575 | UInt reqlistsize = fSt5data.Count(); | |
576 | DebugTrace("Re-requesting clusters from chamber 7... reqlistsize = " << reqlistsize); | |
577 | ||
578 | Station5List::Iterator rec = fSt5data.First(); | |
579 | for (UInt i = 0; i < reqlistsize; i++, rec++) | |
580 | { | |
581 | // Need to create a new st5 data block for the request. | |
582 | AliStation5Data* data = fSt5data.New(); | |
583 | data->fClusterPoint = rec->fClusterPoint; | |
584 | data->fTag.fLine = rec->fTag.fLine; | |
585 | ||
586 | // Rebuild a region of interest for chamber 7. | |
587 | // Remember the parameters a and b are station specific. | |
588 | AliHLTMUONCorePoint p7 = data->fTag.fLine.FindIntersectWithXYPlain( fgZ7 ); | |
589 | data->fTag.fChamber = kChamber7; | |
590 | data->fTag.fRoi.Create(p7, fgA7, fgB7); | |
591 | ||
592 | AliHLTFloat32_t left, right, bottom, top; | |
593 | data->fTag.fRoi.GetBoundaryBox(left, right, bottom, top); | |
594 | // Make request for chamber 7 data. | |
595 | RequestClusters(left, right, bottom, top, kChamber7, &data->fTag); | |
596 | } | |
597 | } | |
598 | break; | |
599 | ||
600 | case kWaitMoreChamber8: | |
601 | if (fRequestsCompleted == fSt5data.Count() && fSm5state == kSM5Done) | |
602 | ProcessClusters(); | |
603 | break; | |
604 | ||
605 | default: | |
606 | DebugTrace("ERROR: Unexpected state for SM4 in AliHLTMUONMansoTrackerFSM::EndOfClustersChamber8!"); | |
607 | } | |
608 | } | |
609 | ||
610 | ||
611 | void AliHLTMUONMansoTrackerFSM::EndOfClustersChamber9() | |
612 | { | |
613 | // State change method for Station 5 state machine. | |
614 | ||
615 | switch (fSm5state) | |
616 | { | |
617 | case kWaitChamber9: | |
618 | fSm5state = kSM5Done; | |
619 | EndOfClusterRequests(); | |
620 | NoTrackFound(); | |
621 | break; | |
622 | ||
623 | case kWaitMoreChamber9: | |
624 | fSm5state = kSM5Done; | |
625 | EndOfClusterRequests(); | |
626 | if (fRequestsCompleted == fSt5data.Count()) | |
627 | ProcessClusters(); | |
628 | break; | |
629 | ||
630 | default: | |
631 | DebugTrace("ERROR: Unexpected state for SM5 in AliHLTMUONMansoTrackerFSM::EndOfClustersChamber9!"); | |
632 | } | |
633 | } | |
634 | ||
635 | ||
636 | void AliHLTMUONMansoTrackerFSM::EndOfClustersChamber10() | |
637 | { | |
638 | // State change method for Station 5 state machine. | |
639 | ||
640 | switch (fSm5state) | |
641 | { | |
642 | case kWaitChamber10: | |
643 | { | |
644 | fSm5state = kWaitChamber9; | |
645 | fSt5z = fgZ9; | |
646 | ||
647 | // No clusters found on chamber 10 so we need to make a request for | |
648 | // clusters from chamber 9: | |
649 | AliHLTMUONCorePoint p9 = fMc1.fLine.FindIntersectWithXYPlain( fgZ9 ); | |
650 | ||
651 | // Build a region of interest for tracking station 5 (chamber 9). | |
652 | // Remember the parameters a and b are station specific. | |
653 | fMc1.fChamber = kChamber9; | |
654 | fMc1.fRoi.Create(p9, fgA9, fgB9); | |
655 | ||
656 | AliHLTFloat32_t left, right, bottom, top; | |
657 | fMc1.fRoi.GetBoundaryBox(left, right, bottom, top); | |
658 | RequestClusters(left, right, bottom, top, kChamber9, &fMc1); | |
659 | } | |
660 | break; | |
661 | ||
662 | case kWaitMoreChamber10: | |
663 | fSm5state = kSM5Done; | |
664 | EndOfClusterRequests(); | |
665 | if (fRequestsCompleted == fSt5data.Count()) | |
666 | ProcessClusters(); | |
667 | break; | |
668 | ||
669 | default: | |
670 | DebugTrace("ERROR: Unexpected state for SM5 in AliHLTMUONMansoTrackerFSM::EndOfClustersChamber10!"); | |
671 | } | |
672 | } | |
673 | ||
674 | ||
675 | void AliHLTMUONMansoTrackerFSM::ProjectToStation4(AliStation5Data* data, register AliHLTFloat32_t station5z) | |
676 | { | |
677 | // Perform chamber specific operations: | |
678 | // Since certain states of SM4 means that it is fetching for Chamber8 | |
679 | // and other states are for fetching from Chamber7. We need to make | |
680 | // requests for the correct chamber. | |
681 | Assert( fSm4state == kWaitChamber8 | |
682 | || fSm4state == kWaitMoreChamber8 | |
683 | || fSm4state == kWaitChamber7 | |
684 | || fSm4state == kWaitMoreChamber7 | |
685 | ); | |
686 | AliTagData* tag = &data->fTag; | |
687 | if (fSm4state == kWaitChamber8 || fSm4state == kWaitMoreChamber8) | |
688 | { | |
689 | // Form the vector line between trigger station 1 and tracking station 5, | |
690 | // and find the intersection point of the line with station 4 (chamber8). | |
691 | AliLine line51( AliVertex(data->fClusterPoint, station5z), fV1 ); | |
692 | AliHLTMUONCorePoint intercept = line51.FindIntersectWithXYPlain( fgZ8 ); | |
693 | tag->fLine = line51; | |
694 | ||
695 | // Build a region of interest for tracking station 4. | |
696 | tag->fChamber = kChamber8; | |
697 | tag->fRoi.Create(intercept, fgA8, fgB8); | |
698 | } | |
699 | else | |
700 | { | |
701 | // Form the vector line between trigger station 1 and tracking station 5, | |
702 | // and find the intersection point of the line with station 4 (chamber7). | |
703 | AliLine line51( AliVertex(data->fClusterPoint, station5z), fV1 ); | |
704 | AliHLTMUONCorePoint intercept = line51.FindIntersectWithXYPlain( fgZ7 ); | |
705 | tag->fLine = line51; | |
706 | ||
707 | // Build a region of interest for tracking station 4. | |
708 | tag->fChamber = kChamber7; | |
709 | tag->fRoi.Create(intercept, fgA7, fgB7); | |
710 | } | |
711 | ||
712 | // Make the request for clusters from station 4. | |
713 | AliHLTFloat32_t left, right, bottom, top; | |
714 | tag->fRoi.GetBoundaryBox(left, right, bottom, top); | |
715 | RequestClusters(left, right, bottom, top, tag->fChamber, tag); | |
716 | } | |
717 | ||
718 | ||
719 | void AliHLTMUONMansoTrackerFSM::ProcessClusters() | |
720 | { | |
721 | // Process clusters that have been received. | |
722 | // This is called once all clusters have been found. | |
723 | ||
724 | DebugTrace("ProcessClusters..."); | |
725 | ||
726 | // Check if the cluster point list on station 4 is empty. | |
727 | // If it is then we have not found any tracks. | |
728 | fFoundPoint = fSt4points.First(); | |
729 | if (fFoundPoint == fSt4points.End()) | |
730 | { | |
731 | NoTrackFound(); | |
732 | return; | |
733 | } | |
734 | ||
735 | fSt5rec = fSt5data.First(); | |
736 | if (fSt5rec != fSt5data.End()) | |
737 | { | |
738 | // Only look at station 5 data records that are for the found chamber number. | |
739 | // Note: either we only have chamber 8 data or we have chamber 7 data followed | |
740 | // by chamber 8 data. | |
741 | // Thus if we hit records that we are not interested in already then the list | |
742 | // contains no interesting data and we can signal no track found. | |
743 | if (fSt5rec->fTag.fChamber != fSt4chamber) | |
744 | { | |
745 | NoTrackFound(); | |
746 | return; | |
747 | } | |
748 | ||
749 | // For all combinations of cluster point pairs from station 4 and 5 | |
750 | // signal a found track: | |
751 | do | |
752 | { | |
753 | DebugTrace("\tfSt5rec->fTag.chamber = " << fSt5rec->fTag.fChamber | |
754 | << " , fSt4chamber = " << fSt4chamber | |
755 | ); | |
756 | ||
757 | for (fFoundPoint = fSt4points.First(); fFoundPoint != fSt4points.End(); fFoundPoint++) | |
758 | { | |
759 | if (fFoundPoint->fSt5tag == &fSt5rec->fTag) | |
760 | FoundTrack(); | |
761 | } | |
762 | ||
763 | fSt5rec++; // Get next station 5 cluster point. | |
764 | } while (fSt5rec != fSt5data.End() && fSt5rec->fTag.fChamber == fSt4chamber); | |
765 | } | |
766 | else | |
767 | NoTrackFound(); | |
768 | } | |
769 |