]>
Commit | Line | Data |
---|---|---|
8356cc1d | 1 | //////////////////////////////////////////////////////////////////////////////// |
2 | // | |
3 | // Author: Artur Szostak | |
4 | // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com | |
5 | // | |
6 | //////////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | #include "AliRoot/Track.hpp" | |
98af1577 | 9 | #include <TMath.h> |
26538635 | 10 | #include "AliHLTMUONUtils.h" |
8356cc1d | 11 | |
69d7cf2e | 12 | ClassImp(AliHLTMUONTrack) |
8356cc1d | 13 | |
14 | ||
77650318 | 15 | AliHLTMUONTrack::AliHLTMUONTrack() : |
16 | TObject(), fTriggerID(-1), fParticleSign(0), fP(0), fPt(0) | |
8356cc1d | 17 | { |
4175c31c | 18 | // Default constructor initialises everything to zero and fTriggerID to -1. |
19 | ||
8356cc1d | 20 | Init(); |
cbee67e7 | 21 | } |
8356cc1d | 22 | |
23 | ||
69d7cf2e | 24 | AliHLTMUONTrack::AliHLTMUONTrack( |
e33f3609 | 25 | Int_t triggerid, Int_t sign, Float_t momentum, Float_t pt, |
69d7cf2e | 26 | const AliHLTMUONPoint hits[10], const AliHLTMUONRegion regions[10] |
77650318 | 27 | ) : |
28 | TObject(), fTriggerID(-1), fParticleSign(0), fP(0), fPt(0) | |
8356cc1d | 29 | { |
4175c31c | 30 | // Create a track object from the given parameters. |
31 | // This constructor checks that momentum >= pt and sign is one of the | |
32 | // following values: -1, 0 or +1. If these conditions are violated then | |
33 | // the internal data is initialised as in the default constructor and an | |
34 | // error message is displayed. | |
35 | ||
f086c81b | 36 | if (sign < -1 || +1 < sign) |
8356cc1d | 37 | { |
38 | Init(); | |
69d7cf2e | 39 | Error("AliHLTMUONTrack", "The particle sign was not one of -1, 0 or +1. Got %d", sign); |
8356cc1d | 40 | } |
41 | else if (momentum < pt) | |
42 | { | |
43 | Init(); | |
69d7cf2e | 44 | Error("AliHLTMUONTrack", "The momentum (%f) must be larger or equal to the pt (%f).", |
8356cc1d | 45 | momentum, pt |
46 | ); | |
47 | } | |
48 | else if (pt < 0.0) | |
49 | { | |
50 | Init(); | |
69d7cf2e | 51 | Error("AliHLTMUONTrack", "The pt must be a positive number. Got: %f", pt); |
8356cc1d | 52 | } |
53 | else | |
54 | { | |
55 | fTriggerID = triggerid; | |
56 | fParticleSign = sign; | |
57 | fP = momentum; | |
58 | fPt = pt; | |
59 | for (Int_t i = 0; i < 10; i++) | |
60 | { | |
61 | fHit[i] = hits[i]; | |
62 | fRegionOfInterest[i] = regions[i]; | |
cbee67e7 | 63 | } |
64 | } | |
65 | } | |
8356cc1d | 66 | |
67 | ||
69d7cf2e | 68 | void AliHLTMUONTrack::Init() |
8356cc1d | 69 | { |
4175c31c | 70 | // Internal initialisation routine used by the constructors. |
71 | ||
8356cc1d | 72 | fTriggerID = -1; |
73 | fParticleSign = 0; | |
74 | fP = fPt = 0.0; | |
cbee67e7 | 75 | } |
8356cc1d | 76 | |
77 | ||
69d7cf2e | 78 | void AliHLTMUONTrack::ParticleSign(Int_t value) |
8356cc1d | 79 | { |
4175c31c | 80 | // Set method for the particle sign. The particle sign must be one |
81 | // of the following values: -1, 0 or +1 | |
82 | // If the new value is not in this range then an error message is | |
83 | // displayed and the internal value remain unchanged. | |
84 | ||
f086c81b | 85 | if (-1 <= value && value <= +1) |
8356cc1d | 86 | fParticleSign = value; |
87 | else | |
88 | Error("ParticleSign", | |
89 | "The particle sign must be a value of -1, 0 or +1, but got %d", | |
90 | value | |
91 | ); | |
cbee67e7 | 92 | } |
8356cc1d | 93 | |
94 | ||
69d7cf2e | 95 | void AliHLTMUONTrack::P(Float_t value) |
8356cc1d | 96 | { |
4175c31c | 97 | // The set method for the momentum. |
98 | // This method checks that the momentum is always equal or larger than | |
99 | // the pt. If not then the internal values are left unchanged and an | |
100 | // error message is displayed. The numbers must also be positive. | |
101 | ||
8356cc1d | 102 | if (value >= fPt) |
103 | fP = value; | |
104 | else | |
105 | Error("P", | |
106 | "Trying to assing momentum (%f) which is smaller than the pt value (%f).", | |
107 | value, fPt | |
108 | ); | |
cbee67e7 | 109 | } |
8356cc1d | 110 | |
69d7cf2e | 111 | void AliHLTMUONTrack::Pt(Float_t value) |
8356cc1d | 112 | { |
4175c31c | 113 | // The set method for the pt. |
114 | // This method checks that the momentum is always equal or larger than | |
115 | // the pt. If not then the internal values are left unchanged and an | |
116 | // error message is displayed. The numbers must also be positive. | |
117 | ||
8356cc1d | 118 | if (value >= 0.0) |
119 | { | |
120 | if (value <= fP) | |
121 | fPt = value; | |
122 | else | |
123 | Error("Pt", | |
124 | "Trying to assign pt (%f) which is larger than the momentum value (%f).", | |
125 | value, fP | |
126 | ); | |
127 | } | |
128 | else | |
129 | Error("Pt", "Cannot have a negative value pt. Got: %f", value); | |
130 | }; | |
131 | ||
132 | ||
69d7cf2e | 133 | AliHLTMUONPoint& AliHLTMUONTrack::Hit(UInt_t chamber) |
8356cc1d | 134 | { |
4175c31c | 135 | // Returns the hit point for the specified chamber. |
136 | // If the chamber number in out of bounds the point on the first | |
137 | // chamber is returned and an error message displayed. | |
138 | ||
e33f3609 | 139 | if (chamber < 10) |
8356cc1d | 140 | return fHit[chamber]; |
141 | else | |
142 | { | |
143 | Error("Hit", | |
144 | "The chamber is out of range. Got: %d, but should be in [0..9].", | |
145 | chamber | |
146 | ); | |
147 | return fHit[0]; | |
cbee67e7 | 148 | } |
149 | } | |
8356cc1d | 150 | |
151 | ||
69d7cf2e | 152 | const AliHLTMUONPoint& AliHLTMUONTrack::Hit(UInt_t chamber) const |
8356cc1d | 153 | { |
4175c31c | 154 | // Returns a constant hit object for the specified chamber. |
155 | // If the chamber number in out of bounds the point on the first | |
156 | // chamber is returned and an error message displayed. | |
157 | ||
e33f3609 | 158 | if (chamber < 10) |
8356cc1d | 159 | return fHit[chamber]; |
160 | else | |
161 | { | |
162 | Error("Hit", | |
163 | "The chamber is out of range. Got: %d, but should be in [0..9].", | |
164 | chamber | |
165 | ); | |
166 | return fHit[0]; | |
167 | }; | |
168 | }; | |
169 | ||
170 | ||
69d7cf2e | 171 | void AliHLTMUONTrack::Hit(UInt_t chamber, const AliHLTMUONPoint& value) |
8356cc1d | 172 | { |
4175c31c | 173 | // Set method for hits. The chamber must be in the range [0..9] |
174 | ||
e33f3609 | 175 | if (chamber < 10) |
8356cc1d | 176 | fHit[chamber] = value; |
177 | else | |
178 | Error("Hit", | |
179 | "The chamber is out of range. Got: %d, but should be in [0..9].", | |
180 | chamber | |
181 | ); | |
cbee67e7 | 182 | } |
8356cc1d | 183 | |
184 | ||
69d7cf2e | 185 | AliHLTMUONRegion& AliHLTMUONTrack::RegionOfInterest(UInt_t chamber) |
8356cc1d | 186 | { |
4175c31c | 187 | // Returns the region of interest for the specified chamber. |
188 | // If the chamber number in out of bounds the region on the first | |
189 | // chamber is returned and an error message displayed. | |
190 | ||
e33f3609 | 191 | if (chamber < 10) |
8356cc1d | 192 | return fRegionOfInterest[chamber]; |
193 | else | |
194 | { | |
195 | Error("RegionOfInterest", | |
196 | "The chamber is out of range. Got: %d, but should be in [0..9].", | |
197 | chamber | |
198 | ); | |
199 | return fRegionOfInterest[0]; | |
cbee67e7 | 200 | } |
201 | } | |
8356cc1d | 202 | |
203 | ||
69d7cf2e | 204 | const AliHLTMUONRegion& AliHLTMUONTrack::RegionOfInterest(UInt_t chamber) const |
8356cc1d | 205 | { |
4175c31c | 206 | // Returns the constatn region of interest object for the specified chamber. |
207 | // If the chamber number in out of bounds the region on the first | |
208 | // chamber is returned and an error message displayed. | |
209 | ||
e33f3609 | 210 | if (chamber < 10) |
8356cc1d | 211 | return fRegionOfInterest[chamber]; |
212 | else | |
213 | { | |
214 | Error("RegionOfInterest", | |
215 | "The chamber is out of range. Got: %d, but should be in [0..9].", | |
216 | chamber | |
217 | ); | |
218 | return fRegionOfInterest[0]; | |
cbee67e7 | 219 | } |
220 | } | |
8356cc1d | 221 | |
222 | ||
69d7cf2e | 223 | void AliHLTMUONTrack::RegionOfInterest(UInt_t chamber, const AliHLTMUONRegion& value) |
8356cc1d | 224 | { |
4175c31c | 225 | // Set method for regions. The chamber must be in the range [0..9] |
226 | ||
e33f3609 | 227 | if (chamber < 10) |
8356cc1d | 228 | fRegionOfInterest[chamber] = value; |
229 | else | |
230 | Error("RegionOfInterest", | |
231 | "The chamber is out of range. Got: %d, but should be in [0..9].", | |
232 | chamber | |
233 | ); | |
cbee67e7 | 234 | } |
8356cc1d | 235 | |
236 | ||
69d7cf2e | 237 | Bool_t AliHLTMUONTrack::HitsInRegions() const |
8356cc1d | 238 | { |
4175c31c | 239 | // Checks to see if the all the hits are within their respective regions |
240 | // of interest for each chamber. kTRUE is returned if they are and kFALSE | |
241 | // otherwise. | |
242 | ||
8356cc1d | 243 | for (Int_t i = 0; i < 10; i++) |
244 | { | |
f086c81b | 245 | if ( ! fRegionOfInterest[i].Contains(fHit[i]) ) |
8356cc1d | 246 | return kFALSE; |
cbee67e7 | 247 | } |
8356cc1d | 248 | return kTRUE; |
cbee67e7 | 249 | } |
8356cc1d | 250 | |
251 | ||
69d7cf2e | 252 | ostream& operator << (ostream& os, const AliHLTMUONTrack& t) |
8356cc1d | 253 | { |
254 | os << "{trigid: " << t.fTriggerID << ", sign: " << t.fParticleSign | |
255 | << ", p: " << t.fP << ", pt: " << t.fPt << "}"; | |
256 | return os; | |
cbee67e7 | 257 | } |
8356cc1d | 258 |