71cff663a43aad174c93128dfb120d25833ff1ac
[u/mrichter/AliRoot.git] / HLT / MUON / src / AliRoot / Tracker.hpp
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Author: Artur Szostak
4 // Email:  artur@alice.phy.uct.ac.za | artursz@iafrica.com
5 //
6 ////////////////////////////////////////////////////////////////////////////////
7
8 #ifndef dHLT_ALIROOT_TRACKER_HPP
9 #define dHLT_ALIROOT_TRACKER_HPP
10
11 #ifndef __CINT__
12 #include "AliRoot/Point.hpp"
13 #include "AliRoot/TriggerRecord.hpp"
14 #include "AliRoot/Track.hpp"
15 #include "AliRoot/TrackerCallback.hpp"
16 #endif // __CINT__
17
18
19 namespace AliMUONHLT
20 {
21
22
23 class Tracker
24 {
25 public:
26
27         Tracker() : fInterface(this)
28         {
29                 fCallback = NULL;
30         };
31
32         /* Methods required to be implemented by the tracker.
33            These correspond to the dHLT::Tracker specification, refer to that
34            class for more information.
35          */
36         virtual void FindTrack(const TriggerRecord& trigger) = 0;
37         virtual void ReturnClusters(void* tag, const Point* clusters, const UInt_t count) = 0;
38         virtual void EndOfClusters(void* tag) = 0;
39         virtual void FillTrackData(Track& track) = 0;
40         virtual void Reset() = 0;
41
42         /* Set the callback for the tracker, so that the tracker can communicate
43            with the framework.
44          */
45         void SetCallback(TrackerCallback* callback)
46         {
47                 fCallback = callback;
48         };
49         
50         /* Returns the TrackerInterface object to this tracker.
51            This is required by the MicrodHLT object.
52          */
53         TrackerInterface* Interface() const
54         {
55                 return &fInterface;
56         };
57
58
59 protected:
60
61         void RequestClusters(
62                         const Float_t left, const Float_t right, const Float_t bottom, const Float_t top,
63                         const Int_t chamber, const void* tag
64                 )
65         {
66                 if (left > right)
67                         Error("RequestClusters", "The parameter left (%f) is larger than right (%f).",
68                                 left, right
69                         );
70                 else if (bottom > top)
71                         Error("RequestClusters", "The parameter bottom (%f) is larger than top (%f).",
72                                 bottom, top
73                         );
74                 else if (chamber < 0 or 9 < chamber)
75                         Error("RequestClusters", "The chamber parameter is out of range. Got: %d, expected a value in [0..9]",
76                                 chamber
77                         );
78                 else if (fCallback != NULL)
79                         fCallback->RequestClusters(left, right, bottom, top, chamber, tag);
80                 else
81                         Error("RequestClusters", "Callback not set.");
82         };
83
84
85         void EndOfClusterRequests()
86         {
87                 if (fCallback != NULL)
88                         fCallback->EndOfClusterRequests();
89                 else
90                         Error("EndOfClusterRequests", "Callback not set.");
91         };
92
93
94         void FoundTrack()
95         {
96                 if (fCallback != NULL)
97                         fCallback->FoundTrack();
98                 else
99                         Error("FoundTrack", "Callback not set.");
100         };
101
102
103         void NoTrackFound()
104         {
105                 if (fCallback != NULL)
106                         fCallback->NoTrackFound();
107                 else
108                         Error("NoTrackFound", "Callback not set.");
109         };
110
111
112 private:
113
114         TrackerInterface fInterface;  // The interface via which compiled code communicates with this object.
115         TrackerCallback* fCallback;   // Callback interface to framework.
116 };
117
118
119 // Implementation of the TrackerInterface:
120 // This must come here so that it gets interpreted together with the rest
121 // of the AliMUONHLT::Tracker.
122
123 void TrackerInterface::FindTrack(const TriggerRecord& trigger)
124 {
125         fTracker->FindTrack(trigger);
126 };
127
128 void TrackerInterface::ReturnClusters(void* tag, const Point* clusters, const UInt_t count)
129 {
130         fTracker->ReturnClusters(tag, clusters, count);
131 };
132
133 void TrackerInterface::EndOfClusters(void* tag)
134 {
135         fTracker->EndOfClusters(tag);
136 };
137
138 void TrackerInterface::FillTrackData(Track& track)
139 {
140         fTracker->FillTrackData(track);
141 };
142
143 void TrackerInterface::Reset()
144 {
145         fTracker->Reset();
146 };
147
148 void TrackerInterface::SetCallback(TrackerCallback* callback)
149 {
150         fTracker->SetCallback(callback);
151 };
152
153
154 // Implementation of the SetTracker method which is undefined in MicrodHLT.
155 void MicrodHLT::SetTracker(Tracker* tracker)
156 {
157         SetTracker(tracker->Interface());
158 };
159
160
161 }; // AliMUONHLT
162
163 #endif // dHLT_ALIROOT_TRACKER_HPP