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 The AliHLTMUONMansoTrackerFSM implements the Manso tracking
26 // * algorithm as a finite state machine, which partially reconstructs
27 // * tracks in the muon spectrometer.
30 #include "AliHLTMUONDataTypes.h"
31 #include "AliHLTMUONList.h"
32 #include "AliHLTMUONCountedList.h"
33 #include "AliHLTMUONRecHitsBlockStruct.h"
34 #include "AliHLTMUONTriggerRecordsBlockStruct.h"
35 #include "AliHLTMUONMansoTracksBlockStruct.h"
36 #include "AliHLTMUONMansoTrackerFSMCallback.h"
40 class AliHLTMUONMansoTrackerFSM
44 AliHLTMUONMansoTrackerFSM();
45 virtual ~AliHLTMUONMansoTrackerFSM() {}
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
52 Any memory allocated at this point should be released in the Reset method.
54 Note: Reset should be called for before calling FindTrack, for the
55 second or subsequent method calls to FindTrack.
57 virtual void FindTrack(const AliHLTMUONTriggerRecordStruct& trigger);
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.
66 virtual void ReturnClusters(
67 void* tag, const AliHLTMUONRecHitStruct* clusters,
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
77 virtual void EndOfClusters(void* tag);
79 /* Called to receive track information after receiving a FoundTrack call.
80 The tracker should fill the track data block with all relevant information.
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.
84 virtual bool FillTrackData(AliHLTMUONMansoTrackStruct& track);
86 /* Called when the tracker should be reset to a initial state.
87 All extra internal allocated data structured should be released.
91 /* To set the TrackerCallback callback object.
93 void SetCallback(AliHLTMUONMansoTrackerFSMCallback* callback)
99 /* Get and set methods for the a and b parameters used to build the region
100 of interests. Refer to AliRegionOfInterest for details about a and b parameters.
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; };
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; };
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; };
136 class AliRegionOfInterest
140 AliRegionOfInterest() : fCentre(), fRs(0.0) {};
142 AliRegionOfInterest(AliHLTMUONRecHitStruct p, AliHLTFloat32_t a, AliHLTFloat32_t b)
148 /* Creates a region of interest. In this implementation it is a
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
157 given on page 3 section 4.
159 void Create(AliHLTMUONRecHitStruct p, AliHLTFloat32_t a, AliHLTFloat32_t b);
161 /* Returns true if the point p is within the region of interest.
163 bool Contains(AliHLTMUONRecHitStruct p) const;
165 void GetBoundaryBox(AliHLTFloat32_t& left, AliHLTFloat32_t& right, AliHLTFloat32_t& bottom, AliHLTFloat32_t& top) const;
169 AliHLTMUONRecHitStruct fCentre; // The centre point of the region of interest.
170 AliHLTFloat32_t fRs; // The redius of the region of interest around fcentre.
178 AliVertex(AliHLTFloat32_t x = 0.0, AliHLTFloat32_t y = 0.0, AliHLTFloat32_t z = 0.0);
179 AliVertex(AliHLTMUONRecHitStruct xy, AliHLTFloat32_t z);
181 AliHLTMUONRecHitStruct AsXYPoint() const
183 AliHLTMUONRecHitStruct p;
184 p.fX = fX; p.fY = fY; p.fZ = 0;
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; };
201 AliHLTFloat32_t fX, fY, fZ; // 3D coordinates.
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.
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
218 /* Creates a vector line between vertices A and B.
220 AliLine(AliVertex a, AliVertex b);
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
226 AliHLTMUONRecHitStruct FindIntersectWithXYPlain(AliHLTFloat32_t z) const;
230 // Parameters for the vector line: L = M*t + C
231 AliHLTFloat32_t fMx, fMy, fMz, fCx, fCy, fCz; // line parameters.
238 AliTagData() : fChamber(kChamber1), fRoi(), fLine() {};
240 AliHLTMUONChamberName fChamber; // The chamber on which the region of interest lies.
241 AliRegionOfInterest fRoi; // Region of interest on the next station.
242 AliLine fLine; // line between a cluster point and the previous station.
245 class AliStation5Data
248 AliStation5Data() : fClusterPoint(), fTag() {};
250 AliHLTMUONRecHitStruct fClusterPoint; // Cluster point found on station 5.
251 AliTagData fTag; // Chamber, ROI and line data for station 5.
254 typedef AliHLTMUONCountedList<AliStation5Data> Station5List;
256 class AliStation4Data
259 AliStation4Data() : fClusterPoint(), fSt5tag() {};
261 AliStation4Data(const AliStation4Data& data) :
262 fClusterPoint(data.fClusterPoint), fSt5tag(data.fSt5tag)
265 AliStation4Data& operator = (const AliStation4Data& data)
267 fClusterPoint = data.fClusterPoint;
268 fSt5tag = data.fSt5tag;
272 AliHLTMUONRecHitStruct fClusterPoint; // Cluster point found on station 4.
273 const AliTagData* fSt5tag; // Corresponding station 5 tag.
276 typedef AliHLTMUONList<AliStation4Data> Station4List;
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);
283 void EndOfClustersChamber7();
284 void EndOfClustersChamber8();
285 void EndOfClustersChamber9();
286 void EndOfClustersChamber10();
288 void ProjectToStation4(AliStation5Data* data, register AliHLTFloat32_t station5z);
289 void ProcessClusters();
294 // States for state machine 4 (SM4).
304 // States for state machine 5 (SM5).
317 AliHLTMUONMansoTrackerFSMCallback* fCallback; // Pointer to the callback interface from which we fetch reco hits and to which we publish results.
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.
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.
324 AliVertex fV1; // The impact (hit) vertex for trigger station 1.
325 AliTagData fMc1; // Trigger station 1 data.
327 Station5List fSt5data; // List of found cluster points for station 5 and their tag data.
328 Station4List fSt4points; // The found cluster points for station 4.
330 // Iterators used in the FoundTrack, FillTrackData methods.
331 Station5List::Iterator fSt5rec; // current station 5 record
332 Station4List::Iterator fFoundPoint; // current found point
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.
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.
344 void RequestClusters(
345 AliHLTFloat32_t left, AliHLTFloat32_t right, AliHLTFloat32_t bottom, AliHLTFloat32_t top,
346 AliHLTMUONChamberName chamber, const void* tag = NULL
349 assert( fCallback != NULL );
350 fCallback->RequestClusters(this, left, right, bottom, top, chamber, tag);
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.
357 void EndOfClusterRequests()
359 assert( fCallback != NULL );
360 fCallback->EndOfClusterRequests(this);
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.
369 assert( fCallback != NULL );
370 fCallback->FoundTrack(this);
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.
380 assert( fCallback != NULL );
381 fCallback->NoTrackFound(this);
387 const AliHLTMUONTriggerRecordStruct& trigger,
388 AliHLTMUONRecHitStruct& pa,
389 AliHLTMUONRecHitStruct& pb
392 // Not allowed to copy this object.
393 AliHLTMUONMansoTrackerFSM(const AliHLTMUONMansoTrackerFSM& tracker);
394 AliHLTMUONMansoTrackerFSM& operator = (const AliHLTMUONMansoTrackerFSM& tracker);
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.
405 #endif // ALIHLTMUONMANSOTRACKERFSM_H