1 #ifndef ALIHLTMUONMANSOTRACKERFSM_H
2 #define ALIHLTMUONMANSOTRACKERFSM_H
3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
8 * Artur Szostak <artursz@iafrica.com> *
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 **************************************************************************/
22 /// @file AliHLTMUONMansoTrackerFSM.h
23 /// @author Artur Szostak <artursz@iafrica.com>
25 /// @brief Declaration of the AliHLTMUONMansoTrackerFSM class which implements the Manso tracking algorithm.
28 #include "AliHLTLogging.h"
29 #include "AliHLTMUONDataTypes.h"
30 #include "AliHLTMUONList.h"
31 #include "AliHLTMUONCountedList.h"
32 #include "AliHLTMUONRecHitsBlockStruct.h"
33 #include "AliHLTMUONMansoTrackerFSMCallback.h"
36 extern "C" struct AliHLTMUONTriggerRecordStruct;
37 extern "C" struct AliHLTMUONMansoTrackStruct;
38 extern "C" struct AliHLTMUONMansoCandidateStruct;
41 * The AliHLTMUONMansoTrackerFSM implements the Manso tracking
42 * algorithm as a finite state machine, which partially reconstructs
43 * tracks in the muon spectrometer.
45 class AliHLTMUONMansoTrackerFSM : public AliHLTLogging
49 AliHLTMUONMansoTrackerFSM();
50 virtual ~AliHLTMUONMansoTrackerFSM();
53 /* This is the starting point for the tracking algorithm. The tracker is
54 called at this point with the specified trigger record. It needs to figure
55 out which cluster blocks it needs and request them with calls to
57 Any memory allocated at this point should be released in the Reset method.
59 Note: Reset should be called for before calling FindTrack, for the
60 second or subsequent method calls to FindTrack.
62 virtual void FindTrack(const AliHLTMUONTriggerRecordStruct& trigger);
64 /* When requested clusters have been found by the framework they are returned
65 to the tracker using this method.
66 This method should implement any processing of the cluster blocks. If more
67 more regions of interest are identified then appropriate request should me
68 made using RequestClusters. The tag parameter will be the same one as was
69 passed to RequestClusters.
71 virtual void ReturnClusters(
72 void* tag, const AliHLTMUONRecHitStruct* clusters,
76 /* When no more clusters are to be expected for the request with the corresponding
77 tag value, then this method is called.
78 Any final processing can be placed in here and when the track is found then
79 the algorithm can call FoundTrack otherwise NoTrackFound to indicate end of
82 virtual void EndOfClusters(void* tag);
84 /* Called to receive track information after receiving a FoundTrack call.
85 The tracker should fill the track data block with all relevant information.
86 The method will return false if the momentum could not be calculated from
87 the hits found. The hits in the track structure will however still be filled.
89 virtual bool FillTrackData(AliHLTMUONMansoTrackStruct& track);
91 /* Called when the tracker should be reset to a initial state.
92 All extra internal allocated data structured should be released.
96 /* To set the TrackerCallback callback object.
98 void SetCallback(AliHLTMUONMansoTrackerFSMCallback* callback)
100 fCallback = callback;
103 /// Returns the flag indicating if track candidates are stored.
104 bool MakeCandidates() const { return fMakeCandidates; }
106 /// Sets the flag to indicate if track candidates are stored or not.
107 void MakeCandidates(bool value) { fMakeCandidates = value; }
109 /// Returns the number of track candidates found in the list returned by TrackCandidates().
110 AliHLTUInt32_t TrackCandidatesCount() const { return fCandidatesCount; }
112 /// Returns the array of track candidates.
113 const AliHLTMUONMansoCandidateStruct* TrackCandidates() const { return fCandidates; }
115 /// Removes all the elements in the track candidates array.
116 void ZeroTrackCandidatesList() { fCandidatesCount = 0; }
118 /* Get and set methods for the a and b parameters used to build the region
119 of interests. Refer to AliRegionOfInterest for details about a and b parameters.
121 static AliHLTFloat32_t GetA7() { return fgA7; };
122 static void SetA7(AliHLTFloat32_t value) { fgA7 = value; };
123 static AliHLTFloat32_t GetA8() { return fgA8; };
124 static void SetA8(AliHLTFloat32_t value) { fgA8 = value; };
125 static AliHLTFloat32_t GetA9() { return fgA9; };
126 static void SetA9(AliHLTFloat32_t value) { fgA9 = value; };
127 static AliHLTFloat32_t GetA10() { return fgA10; };
128 static void SetA10(AliHLTFloat32_t value) { fgA10 = value; };
130 static AliHLTFloat32_t GetB7() { return fgB7; };
131 static void SetB7(AliHLTFloat32_t value) { fgB7 = value; };
132 static AliHLTFloat32_t GetB8() { return fgB8; };
133 static void SetB8(AliHLTFloat32_t value) { fgB8 = value; };
134 static AliHLTFloat32_t GetB9() { return fgB9; };
135 static void SetB9(AliHLTFloat32_t value) { fgB9 = value; };
136 static AliHLTFloat32_t GetB10() { return fgB10; };
137 static void SetB10(AliHLTFloat32_t value) { fgB10 = value; };
139 static AliHLTFloat32_t GetZ7() { return fgZ7; };
140 static void SetZ7(AliHLTFloat32_t value) { fgZ7 = value; };
141 static AliHLTFloat32_t GetZ8() { return fgZ8; };
142 static void SetZ8(AliHLTFloat32_t value) { fgZ8 = value; };
143 static AliHLTFloat32_t GetZ9() { return fgZ9; };
144 static void SetZ9(AliHLTFloat32_t value) { fgZ9 = value; };
145 static AliHLTFloat32_t GetZ10() { return fgZ10; };
146 static void SetZ10(AliHLTFloat32_t value) { fgZ10 = value; };
147 static AliHLTFloat32_t GetZ11() { return fgZ11; };
148 static void SetZ11(AliHLTFloat32_t value) { fgZ11 = value; };
149 static AliHLTFloat32_t GetZ13() { return fgZ13; };
150 static void SetZ13(AliHLTFloat32_t value) { fgZ13 = value; };
155 class AliRegionOfInterest
159 AliRegionOfInterest() : fCentre(), fRs(0.0) {};
161 AliRegionOfInterest(AliHLTMUONRecHitStruct p, AliHLTFloat32_t a, AliHLTFloat32_t b)
167 /* Creates a region of interest. In this implementation it is a
170 The point p is the intersecting point of the track with the chamber.
171 For more details and for details about the parameters a and b refer to:
172 "A first algorithm for dimuon High Level Trigger"
173 Ref ID: ALICE-INT-2002-04 version 1.0
176 given on page 3 section 4.
178 void Create(AliHLTMUONRecHitStruct p, AliHLTFloat32_t a, AliHLTFloat32_t b);
180 /* Returns true if the point p is within the region of interest.
182 bool Contains(AliHLTMUONRecHitStruct p) const;
184 void GetBoundaryBox(AliHLTFloat32_t& left, AliHLTFloat32_t& right, AliHLTFloat32_t& bottom, AliHLTFloat32_t& top) const;
186 /// Returns the centre point of the region of interest.
187 const AliHLTMUONRecHitStruct& Centre() const { return fCentre; }
189 /// Returns the radius of the region of interest disk.
190 AliHLTFloat32_t Radius() const { return fRs; }
194 AliHLTMUONRecHitStruct fCentre; // The centre point of the region of interest.
195 AliHLTFloat32_t fRs; // The redius of the region of interest around fcentre.
203 AliVertex(AliHLTFloat32_t x = 0.0, AliHLTFloat32_t y = 0.0, AliHLTFloat32_t z = 0.0);
204 AliVertex(AliHLTMUONRecHitStruct xy, AliHLTFloat32_t z);
206 AliHLTMUONRecHitStruct AsXYPoint() const
208 AliHLTMUONRecHitStruct p;
209 p.fX = fX; p.fY = fY; p.fZ = 0;
214 AliHLTFloat32_t X() const { return fX; };
215 AliHLTFloat32_t Y() const { return fY; };
216 AliHLTFloat32_t Z() const { return fZ; };
217 AliHLTFloat32_t& X() { return fX; };
218 AliHLTFloat32_t& Y() { return fY; };
219 AliHLTFloat32_t& Z() { return fZ; };
220 void X(AliHLTFloat32_t value) { fX = value; };
221 void Y(AliHLTFloat32_t value) { fY = value; };
222 void Z(AliHLTFloat32_t value) { fZ = value; };
226 AliHLTFloat32_t fX, fY, fZ; // 3D coordinates.
234 /* Creates a vector line between points A and B.
235 ax, ay, az are x, y and z coordinates for space point A respectively.
239 AliHLTFloat32_t ax = 0.0, AliHLTFloat32_t ay = 0.0, AliHLTFloat32_t az = 0.0,
240 AliHLTFloat32_t bx = 0.0, AliHLTFloat32_t by = 0.0, AliHLTFloat32_t bz = 0.0
243 /* Creates a vector line between vertices A and B.
245 AliLine(AliVertex a, AliVertex b);
247 /* Finds the intersection point with the xy plain specified by the z coordinate.
248 The z coordiante would be the distance of the n'th chamber to the interaction
251 AliHLTMUONRecHitStruct FindIntersectWithXYPlain(AliHLTFloat32_t z) const;
255 // Parameters for the vector line: L = M*t + C
256 AliHLTFloat32_t fMx, fMy, fMz, fCx, fCy, fCz; // line parameters.
263 AliTagData() : fChamber(kChamber1), fRoi(), fLine(), fCandidate(NULL) {};
265 AliHLTMUONChamberName fChamber; // The chamber on which the region of interest lies.
266 AliRegionOfInterest fRoi; // Region of interest on the next station.
267 AliLine fLine; // line between a cluster point and the previous station.
268 AliHLTMUONMansoCandidateStruct* fCandidate; // Track candidate related to the RoI.
271 class AliStation5Data
274 AliStation5Data() : fClusterPoint(), fTag() {};
276 AliHLTMUONRecHitStruct fClusterPoint; // Cluster point found on station 5.
277 AliTagData fTag; // Chamber, ROI and line data for station 5.
280 typedef AliHLTMUONCountedList<AliStation5Data> Station5List;
282 class AliStation4Data
285 AliStation4Data() : fClusterPoint(), fSt5tag() {};
287 AliStation4Data(const AliStation4Data& data) :
288 fClusterPoint(data.fClusterPoint), fSt5tag(data.fSt5tag)
291 AliStation4Data& operator = (const AliStation4Data& data)
293 fClusterPoint = data.fClusterPoint;
294 fSt5tag = data.fSt5tag;
298 AliHLTMUONRecHitStruct fClusterPoint; // Cluster point found on station 4.
299 const AliTagData* fSt5tag; // Corresponding station 5 tag.
302 typedef AliHLTMUONList<AliStation4Data> Station4List;
305 void ReceiveClustersChamber7(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count, const AliTagData* data);
306 void ReceiveClustersChamber8(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count, const AliTagData* data);
307 void ReceiveClustersChamber9(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count);
308 void ReceiveClustersChamber10(const AliHLTMUONRecHitStruct* clusters, AliHLTUInt32_t count);
309 void EndOfClustersChamber7();
310 void EndOfClustersChamber8();
311 void EndOfClustersChamber9();
312 void EndOfClustersChamber10();
314 void ProjectToStation4(AliStation5Data* data, AliHLTFloat32_t station5z, AliHLTUInt32_t chamberSt5);
315 void ProcessClusters();
320 // States for state machine 4 (SM4).
330 // States for state machine 5 (SM5).
343 AliHLTMUONMansoTrackerFSMCallback* fCallback; // Pointer to the callback interface from which we fetch reco hits and to which we publish results.
345 StatesSM4 fSm4state; // State of SM4 used for fetching clusters on chambers 7 and 8.
346 StatesSM5 fSm5state; // State of SM5 used for fetching clusters on chambers 9 and 10.
347 AliHLTUInt32_t fRequestsCompleted; // Number of requests for station 4 that have completed.
348 AliHLTMUONChamberName fSt4chamber; // The chamber on station 4 that data was retreived from.
350 AliVertex fV1; // The impact (hit) vertex for trigger station 1.
351 AliTagData fMc1; // Trigger station 1 data.
353 Station5List fSt5data; // List of found cluster points for station 5 and their tag data.
354 Station4List fSt4points; // The found cluster points for station 4.
356 // Iterators used in the FoundTrack, FillTrackData methods.
357 Station5List::Iterator fSt5rec; // current station 5 record
358 Station4List::Iterator fFoundPoint; // current found point
359 AliHLTInt32_t fTriggerId; // The current ID number of the trigger record being processed.
360 AliHLTInt32_t fTrackId; // Track ID counter for the current track.
362 bool fMakeCandidates; // Indicates if the track candidates should be recorded.
363 AliHLTUInt32_t fCandidatesCount; // The number of track candidates in the fCandidates list.
364 AliHLTUInt32_t fCandidatesSize; // Number of elements that the fCandidates list can store.
365 AliHLTMUONMansoCandidateStruct* fCandidates; // The track candidates buffer.
367 /* To request clusters from the boundary box specified by the 'left', 'right',
368 'top' and 'bottom' boundaries and on the given chamber use this method call.
369 Supply a tag parameter if you want the request uniquely identified.
370 This is usefull to supply a pointer to some internal state data structure
371 to figure out where processing should continue in the ReturnClusters or
372 EndOfClusters methods.
374 void RequestClusters(
375 AliHLTFloat32_t left, AliHLTFloat32_t right, AliHLTFloat32_t bottom, AliHLTFloat32_t top,
376 AliHLTMUONChamberName chamber, const void* tag = NULL
379 assert( fCallback != NULL );
380 fCallback->RequestClusters(this, left, right, bottom, top, chamber, tag);
383 /* When no more cluster requests will be generated by this tracker then this
384 method should be called.
385 DO NOT request more clusters after calling this method.
387 void EndOfClusterRequests()
389 assert( fCallback != NULL );
390 fCallback->EndOfClusterRequests(this);
393 /* When the tracker has found a track it should call this method to inform
394 the rest of the system. At this point all cluster blocks received with
395 ReturnClusters are to be considered released and MUST NOT be accessed.
399 assert( fCallback != NULL );
400 fCallback->FoundTrack(this);
403 /* If the tracker is finished processing the trigger record but has not found
404 a track it should call this method to inform the rest of the system.
405 At this point all cluster blocks received with ReturnClusters are to be
406 considered released and MUST NOT be accessed.
410 assert( fCallback != NULL );
411 fCallback->NoTrackFound(this);
415 * Adds a new track candidate to the fCandidates list and returns the pointer
416 * to the new structure to be filled.
417 * \returns a pointer to the new structure and NULL if we ran out of space.
419 AliHLTMUONMansoCandidateStruct* AddTrackCandidate();
423 // Not allowed to copy this object.
424 AliHLTMUONMansoTrackerFSM(const AliHLTMUONMansoTrackerFSM& tracker);
425 AliHLTMUONMansoTrackerFSM& operator = (const AliHLTMUONMansoTrackerFSM& tracker);
427 static AliHLTFloat32_t fgA7, fgB7; // Parameters used to create a region of interest for the 7'th chamber.
428 static AliHLTFloat32_t fgA8, fgB8; // Parameters used to create a region of interest for the 8'th chamber.
429 static AliHLTFloat32_t fgA9, fgB9; // Parameters used to create a region of interest for the 9'th chamber.
430 static AliHLTFloat32_t fgA10, fgB10; // Parameters used to create a region of interest for the 10'th chamber.
431 static AliHLTFloat32_t fgZ7, fgZ8, fgZ9, fgZ10, fgZ11, fgZ13; // Z coordinates of chambers 7 to 10.
436 #endif // ALIHLTMUONMANSOTRACKERFSM_H