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