]>
Commit | Line | Data |
---|---|---|
e0679afb | 1 | #ifndef ALIHLTMUONMANSOTRACKERFSM_H |
2 | #define ALIHLTMUONMANSOTRACKERFSM_H | |
b92524d0 | 3 | /************************************************************************** |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: * | |
8 | * Artur Szostak <artursz@iafrica.com> * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
e0679afb | 18 | |
19 | /* $Id$ */ | |
20 | ||
2b401483 | 21 | ///** |
22 | // * @file AliHLTMUONMansoTrackerFSM.h | |
23 | // * @author Artur Szostak <artursz@iafrica.com> | |
24 | // * @date | |
25 | // * @brief The AliHLTMUONMansoTrackerFSM implements the Manso tracking | |
26 | // * algorithm as a finite state machine, which partially reconstructs | |
27 | // * tracks in the muon spectrometer. | |
28 | // */ | |
e0679afb | 29 | |
30 | #include "AliHLTMUONDataTypes.h" | |
31 | #include "AliHLTMUONList.h" | |
32 | #include "AliHLTMUONCountedList.h" | |
33 | #include "AliHLTMUONRecHitsBlockStruct.h" | |
b92524d0 | 34 | #include "AliHLTMUONTriggerRecordsBlockStruct.h" |
35 | #include "AliHLTMUONMansoTracksBlockStruct.h" | |
36 | #include "AliHLTMUONMansoTrackerFSMCallback.h" | |
37 | #include <cassert> | |
e0679afb | 38 | |
39 | ||
b92524d0 | 40 | class AliHLTMUONMansoTrackerFSM |
e0679afb | 41 | { |
42 | public: | |
43 | ||
44 | AliHLTMUONMansoTrackerFSM(); | |
45 | virtual ~AliHLTMUONMansoTrackerFSM() {} | |
46 | ||
47 | ||
48 | /* This is the starting point for the tracking algorithm. The tracker is | |
49 | called at this point with the specified trigger record. It needs to figure | |
50 | out which cluster blocks it needs and request them with calls to | |
51 | RequestClusters. | |
52 | Any memory allocated at this point should be released in the Reset method. | |
53 | ||
54 | Note: Reset should be called for before calling FindTrack, for the | |
55 | second or subsequent method calls to FindTrack. | |
56 | */ | |
b92524d0 | 57 | virtual void FindTrack(const AliHLTMUONTriggerRecordStruct& trigger); |
e0679afb | 58 | |
59 | /* When requested clusters have been found by the framework they are returned | |
60 | to the tracker using this method. | |
61 | This method should implement any processing of the cluster blocks. If more | |
62 | more regions of interest are identified then appropriate request should me | |
63 | made using RequestClusters. The tag parameter will be the same one as was | |
64 | passed to RequestClusters. | |
65 | */ | |
b92524d0 | 66 | virtual void ReturnClusters( |
67 | void* tag, const AliHLTMUONRecHitStruct* clusters, | |
68 | AliHLTUInt32_t count | |
69 | ); | |
e0679afb | 70 | |
71 | /* When no more clusters are to be expected for the request with the corresponding | |
72 | tag value, then this method is called. | |
73 | Any final processing can be placed in here and when the track is found then | |
74 | the algorithm can call FoundTrack otherwise NoTrackFound to indicate end of | |
75 | processing. | |
76 | */ | |
77 | virtual void EndOfClusters(void* tag); | |
78 | ||
79 | /* Called to receive track information after receiving a FoundTrack call. | |
80 | The tracker should fill the track data block with all relevant information. | |
b92524d0 | 81 | The method will return false if the momentum could not be calculated from |
82 | the hits found. The hits in the track structure will however still be filled. | |
e0679afb | 83 | */ |
b92524d0 | 84 | virtual bool FillTrackData(AliHLTMUONMansoTrackStruct& track); |
e0679afb | 85 | |
86 | /* Called when the tracker should be reset to a initial state. | |
87 | All extra internal allocated data structured should be released. | |
88 | */ | |
89 | virtual void Reset(); | |
90 | ||
91 | /* To set the TrackerCallback callback object. | |
92 | */ | |
2b401483 | 93 | void SetCallback(AliHLTMUONMansoTrackerFSMCallback* callback) |
e0679afb | 94 | { |
95 | fCallback = callback; | |
96 | }; | |
97 | ||
98 | ||
99 | /* Get and set methods for the a and b parameters used to build the region | |
b92524d0 | 100 | of interests. Refer to AliRegionOfInterest for details about a and b parameters. |
e0679afb | 101 | */ |
102 | static AliHLTFloat32_t GetA7() { return fgA7; }; | |
103 | static void SetA7(AliHLTFloat32_t value) { fgA7 = value; }; | |
104 | static AliHLTFloat32_t GetA8() { return fgA8; }; | |
105 | static void SetA8(AliHLTFloat32_t value) { fgA8 = value; }; | |
106 | static AliHLTFloat32_t GetA9() { return fgA9; }; | |
107 | static void SetA9(AliHLTFloat32_t value) { fgA9 = value; }; | |
108 | static AliHLTFloat32_t GetA10() { return fgA10; }; | |
109 | static void SetA10(AliHLTFloat32_t value) { fgA10 = value; }; | |
110 | ||
111 | static AliHLTFloat32_t GetB7() { return fgB7; }; | |
112 | static void SetB7(AliHLTFloat32_t value) { fgB7 = value; }; | |
113 | static AliHLTFloat32_t GetB8() { return fgB8; }; | |
114 | static void SetB8(AliHLTFloat32_t value) { fgB8 = value; }; | |
115 | static AliHLTFloat32_t GetB9() { return fgB9; }; | |
116 | static void SetB9(AliHLTFloat32_t value) { fgB9 = value; }; | |
117 | static AliHLTFloat32_t GetB10() { return fgB10; }; | |
118 | static void SetB10(AliHLTFloat32_t value) { fgB10 = value; }; | |
119 | ||
120 | static AliHLTFloat32_t GetZ7() { return fgZ7; }; | |
121 | static void SetZ7(AliHLTFloat32_t value) { fgZ7 = value; }; | |
122 | static AliHLTFloat32_t GetZ8() { return fgZ8; }; | |
123 | static void SetZ8(AliHLTFloat32_t value) { fgZ8 = value; }; | |
124 | static AliHLTFloat32_t GetZ9() { return fgZ9; }; | |
125 | static void SetZ9(AliHLTFloat32_t value) { fgZ9 = value; }; | |
126 | static AliHLTFloat32_t GetZ10() { return fgZ10; }; | |
127 | static void SetZ10(AliHLTFloat32_t value) { fgZ10 = value; }; | |
128 | static AliHLTFloat32_t GetZ11() { return fgZ11; }; | |
129 | static void SetZ11(AliHLTFloat32_t value) { fgZ11 = value; }; | |
130 | static AliHLTFloat32_t GetZ13() { return fgZ13; }; | |
131 | static void SetZ13(AliHLTFloat32_t value) { fgZ13 = value; }; | |
132 | ||
133 | ||
134 | protected: | |
135 | ||
136 | class AliRegionOfInterest | |
137 | { | |
138 | public: | |
139 | ||
140 | AliRegionOfInterest() : fCentre(), fRs(0.0) {}; | |
141 | ||
b92524d0 | 142 | AliRegionOfInterest(AliHLTMUONRecHitStruct p, AliHLTFloat32_t a, AliHLTFloat32_t b) |
e0679afb | 143 | : fCentre(), fRs(0) |
144 | { | |
145 | Create(p, a, b); | |
146 | }; | |
147 | ||
148 | /* Creates a region of interest. In this implementation it is a | |
149 | circular disk. | |
150 | ||
151 | The point p is the intersecting point of the track with the chamber. | |
152 | For more details and for details about the parameters a and b refer to: | |
153 | "A first algorithm for dimuon High Level Trigger" | |
154 | Ref ID: ALICE-INT-2002-04 version 1.0 | |
155 | equation: | |
156 | Rs = a * Rp + b | |
157 | given on page 3 section 4. | |
158 | */ | |
b92524d0 | 159 | void Create(AliHLTMUONRecHitStruct p, AliHLTFloat32_t a, AliHLTFloat32_t b); |
e0679afb | 160 | |
161 | /* Returns true if the point p is within the region of interest. | |
162 | */ | |
b92524d0 | 163 | bool Contains(AliHLTMUONRecHitStruct p) const; |
e0679afb | 164 | |
165 | void GetBoundaryBox(AliHLTFloat32_t& left, AliHLTFloat32_t& right, AliHLTFloat32_t& bottom, AliHLTFloat32_t& top) const; | |
166 | ||
167 | private: | |
168 | ||
b92524d0 | 169 | AliHLTMUONRecHitStruct fCentre; // The centre point of the region of interest. |
e0679afb | 170 | AliHLTFloat32_t fRs; // The redius of the region of interest around fcentre. |
171 | }; | |
172 | ||
173 | ||
174 | class AliVertex | |
175 | { | |
176 | public: | |
177 | ||
178 | AliVertex(AliHLTFloat32_t x = 0.0, AliHLTFloat32_t y = 0.0, AliHLTFloat32_t z = 0.0); | |
b92524d0 | 179 | AliVertex(AliHLTMUONRecHitStruct xy, AliHLTFloat32_t z); |
e0679afb | 180 | |
b92524d0 | 181 | AliHLTMUONRecHitStruct AsXYPoint() const |
e0679afb | 182 | { |
b92524d0 | 183 | AliHLTMUONRecHitStruct p; |
2b401483 | 184 | p.fX = fX; p.fY = fY; p.fZ = 0; |
b92524d0 | 185 | return p; |
e0679afb | 186 | }; |
187 | ||
188 | // Get/set methods: | |
189 | AliHLTFloat32_t X() const { return fX; }; | |
190 | AliHLTFloat32_t Y() const { return fY; }; | |
191 | AliHLTFloat32_t Z() const { return fZ; }; | |
192 | AliHLTFloat32_t& X() { return fX; }; | |
193 | AliHLTFloat32_t& Y() { return fY; }; | |
194 | AliHLTFloat32_t& Z() { return fZ; }; | |
195 | void X(AliHLTFloat32_t value) { fX = value; }; | |
196 | void Y(AliHLTFloat32_t value) { fY = value; }; | |
197 | void Z(AliHLTFloat32_t value) { fZ = value; }; | |
198 | ||
199 | private: | |
200 | ||
201 | AliHLTFloat32_t fX, fY, fZ; // 3D coordinates. | |
202 | }; | |
203 | ||
204 | ||
205 | class AliLine | |
206 | { | |
207 | public: | |
208 | ||
209 | /* Creates a vector line between points A and B. | |
210 | ax, ay, az are x, y and z coordinates for space point A respectively. | |
211 | simmilarly for B. | |
212 | */ | |
213 | AliLine( | |
214 | AliHLTFloat32_t ax = 0.0, AliHLTFloat32_t ay = 0.0, AliHLTFloat32_t az = 0.0, | |
215 | AliHLTFloat32_t bx = 0.0, AliHLTFloat32_t by = 0.0, AliHLTFloat32_t bz = 0.0 | |
216 | ); | |
217 | ||
218 | /* Creates a vector line between vertices A and B. | |
219 | */ | |
220 | AliLine(AliVertex a, AliVertex b); | |
221 | ||
222 | /* Finds the intersection point with the xy plain specified by the z coordinate. | |
223 | The z coordiante would be the distance of the n'th chamber to the interaction | |
224 | vertex. | |
225 | */ | |
b92524d0 | 226 | AliHLTMUONRecHitStruct FindIntersectWithXYPlain(AliHLTFloat32_t z) const; |
e0679afb | 227 | |
228 | private: | |
229 | ||
230 | // Parameters for the vector line: L = M*t + C | |
231 | AliHLTFloat32_t fMx, fMy, fMz, fCx, fCy, fCz; // line parameters. | |
232 | }; | |
233 | ||
234 | ||
2b401483 | 235 | class AliTagData |
e0679afb | 236 | { |
2b401483 | 237 | public: |
238 | AliTagData() : fChamber(kChamber1), fRoi(), fLine() {}; | |
239 | ||
b92524d0 | 240 | AliHLTMUONChamberName fChamber; // The chamber on which the region of interest lies. |
e0679afb | 241 | AliRegionOfInterest fRoi; // Region of interest on the next station. |
242 | AliLine fLine; // line between a cluster point and the previous station. | |
e0679afb | 243 | }; |
244 | ||
2b401483 | 245 | class AliStation5Data |
e0679afb | 246 | { |
2b401483 | 247 | public: |
248 | AliStation5Data() : fClusterPoint(), fTag() {}; | |
249 | ||
b92524d0 | 250 | AliHLTMUONRecHitStruct fClusterPoint; // Cluster point found on station 5. |
e0679afb | 251 | AliTagData fTag; // Chamber, ROI and line data for station 5. |
e0679afb | 252 | }; |
253 | ||
b92524d0 | 254 | typedef AliHLTMUONCountedList<AliStation5Data> Station5List; |
e0679afb | 255 | |
2b401483 | 256 | class AliStation4Data |
e0679afb | 257 | { |
2b401483 | 258 | public: |
e0679afb | 259 | AliStation4Data() : fClusterPoint(), fSt5tag() {}; |
260 | ||
261 | AliStation4Data(const AliStation4Data& data) : | |
262 | fClusterPoint(data.fClusterPoint), fSt5tag(data.fSt5tag) | |
263 | {}; | |
264 | ||
265 | AliStation4Data& operator = (const AliStation4Data& data) | |
266 | { | |
267 | fClusterPoint = data.fClusterPoint; | |
268 | fSt5tag = data.fSt5tag; | |
269 | return *this; | |
270 | }; | |
2b401483 | 271 | |
272 | AliHLTMUONRecHitStruct fClusterPoint; // Cluster point found on station 4. | |
273 | const AliTagData* fSt5tag; // Corresponding station 5 tag. | |
e0679afb | 274 | }; |
275 | ||
b92524d0 | 276 | typedef AliHLTMUONList<AliStation4Data> Station4List; |
e0679afb | 277 | |
278 | ||
b92524d0 | 279 | void ReceiveClustersChamber7(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count, const AliTagData* data); |
280 | void ReceiveClustersChamber8(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count, const AliTagData* data); | |
281 | void ReceiveClustersChamber9(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count); | |
282 | void ReceiveClustersChamber10(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count); | |
e0679afb | 283 | void EndOfClustersChamber7(); |
284 | void EndOfClustersChamber8(); | |
285 | void EndOfClustersChamber9(); | |
286 | void EndOfClustersChamber10(); | |
287 | ||
288 | void ProjectToStation4(AliStation5Data* data, register AliHLTFloat32_t station5z); | |
289 | void ProcessClusters(); | |
290 | ||
291 | #ifdef DEBUG | |
292 | public: | |
293 | #endif | |
294 | // States for state machine 4 (SM4). | |
295 | enum StatesSM4 | |
296 | { | |
297 | kSM4Idle, | |
298 | kWaitChamber8, | |
299 | kWaitMoreChamber8, | |
300 | kWaitChamber7, | |
301 | kWaitMoreChamber7 | |
302 | }; | |
303 | ||
304 | // States for state machine 5 (SM5). | |
305 | enum StatesSM5 | |
306 | { | |
307 | kSM5Idle, | |
308 | kWaitChamber10, | |
309 | kWaitMoreChamber10, | |
310 | kWaitChamber9, | |
311 | kWaitMoreChamber9, | |
312 | kSM5Done | |
313 | }; | |
314 | ||
315 | protected: | |
316 | ||
2b401483 | 317 | AliHLTMUONMansoTrackerFSMCallback* fCallback; // Pointer to the callback interface from which we fetch reco hits and to which we publish results. |
e0679afb | 318 | |
319 | StatesSM4 fSm4state; // State of SM4 used for fetching clusters on chambers 7 and 8. | |
320 | StatesSM5 fSm5state; // State of SM5 used for fetching clusters on chambers 9 and 10. | |
b92524d0 | 321 | AliHLTUInt32_t fRequestsCompleted; // Number of requests for station 4 that have completed. |
322 | AliHLTMUONChamberName fSt4chamber; // The chamber on station 4 that data was retreived from. | |
e0679afb | 323 | |
324 | AliVertex fV1; // The impact (hit) vertex for trigger station 1. | |
325 | AliTagData fMc1; // Trigger station 1 data. | |
326 | ||
e0679afb | 327 | Station5List fSt5data; // List of found cluster points for station 5 and their tag data. |
e0679afb | 328 | Station4List fSt4points; // The found cluster points for station 4. |
329 | ||
330 | // Iterators used in the FoundTrack, FillTrackData methods. | |
331 | Station5List::Iterator fSt5rec; // current station 5 record | |
332 | Station4List::Iterator fFoundPoint; // current found point | |
b92524d0 | 333 | AliHLTInt32_t fTriggerId; // The current ID number of the trigger record being processed. |
334 | AliHLTInt32_t fTrackId; // Track ID counter for the current track. | |
e0679afb | 335 | |
336 | ||
337 | /* To request clusters from the boundary box specified by the 'left', 'right', | |
338 | 'top' and 'bottom' boundaries and on the given chamber use this method call. | |
339 | Supply a tag parameter if you want the request uniquely identified. | |
340 | This is usefull to supply a pointer to some internal state data structure | |
341 | to figure out where processing should continue in the ReturnClusters or | |
342 | EndOfClusters methods. | |
343 | */ | |
2b401483 | 344 | void RequestClusters( |
e0679afb | 345 | AliHLTFloat32_t left, AliHLTFloat32_t right, AliHLTFloat32_t bottom, AliHLTFloat32_t top, |
b92524d0 | 346 | AliHLTMUONChamberName chamber, const void* tag = NULL |
e0679afb | 347 | ) |
348 | { | |
b92524d0 | 349 | assert( fCallback != NULL ); |
e0679afb | 350 | fCallback->RequestClusters(this, left, right, bottom, top, chamber, tag); |
351 | }; | |
352 | ||
353 | /* When no more cluster requests will be generated by this tracker then this | |
354 | method should be called. | |
355 | DO NOT request more clusters after calling this method. | |
356 | */ | |
2b401483 | 357 | void EndOfClusterRequests() |
e0679afb | 358 | { |
b92524d0 | 359 | assert( fCallback != NULL ); |
e0679afb | 360 | fCallback->EndOfClusterRequests(this); |
361 | }; | |
362 | ||
363 | /* When the tracker has found a track it should call this method to inform | |
364 | the rest of the system. At this point all cluster blocks received with | |
365 | ReturnClusters are to be considered released and MUST NOT be accessed. | |
366 | */ | |
2b401483 | 367 | void FoundTrack() |
e0679afb | 368 | { |
b92524d0 | 369 | assert( fCallback != NULL ); |
e0679afb | 370 | fCallback->FoundTrack(this); |
371 | }; | |
372 | ||
373 | /* If the tracker is finished processing the trigger record but has not found | |
374 | a track it should call this method to inform the rest of the system. | |
375 | At this point all cluster blocks received with ReturnClusters are to be | |
376 | considered released and MUST NOT be accessed. | |
377 | */ | |
2b401483 | 378 | void NoTrackFound() |
e0679afb | 379 | { |
b92524d0 | 380 | assert( fCallback != NULL ); |
e0679afb | 381 | fCallback->NoTrackFound(this); |
382 | }; | |
383 | ||
384 | private: | |
385 | ||
5def1693 | 386 | bool LineFit( |
387 | const AliHLTMUONTriggerRecordStruct& trigger, | |
388 | AliHLTMUONRecHitStruct& pa, | |
389 | AliHLTMUONRecHitStruct& pb | |
390 | ); | |
391 | ||
e0679afb | 392 | // Not allowed to copy this object. |
393 | AliHLTMUONMansoTrackerFSM(const AliHLTMUONMansoTrackerFSM& tracker); | |
b92524d0 | 394 | AliHLTMUONMansoTrackerFSM& operator = (const AliHLTMUONMansoTrackerFSM& tracker); |
e0679afb | 395 | |
396 | static AliHLTFloat32_t fgA7, fgB7; // Parameters used to create a region of interest for the 7'th chamber. | |
397 | static AliHLTFloat32_t fgA8, fgB8; // Parameters used to create a region of interest for the 8'th chamber. | |
398 | static AliHLTFloat32_t fgA9, fgB9; // Parameters used to create a region of interest for the 9'th chamber. | |
399 | static AliHLTFloat32_t fgA10, fgB10; // Parameters used to create a region of interest for the 10'th chamber. | |
400 | static AliHLTFloat32_t fgZ7, fgZ8, fgZ9, fgZ10, fgZ11, fgZ13; // Z coordinates of chambers 7 to 10. | |
401 | ||
402 | }; | |
403 | ||
404 | ||
e0679afb | 405 | #endif // ALIHLTMUONMANSOTRACKERFSM_H |