Line data Source code
1 : /**************************************************************************
2 : * This file is property of and copyright by the ALICE HLT Project *
3 : * All rights reserved. *
4 : * *
5 : * Primary Authors: *
6 : * Artur Szostak <artursz@iafrica.com> *
7 : * *
8 : * Permission to use, copy, modify and distribute this software and its *
9 : * documentation strictly for non-commercial purposes is hereby granted *
10 : * without fee, provided that the above copyright notice appears in all *
11 : * copies and that both the copyright notice and this permission notice *
12 : * appear in the supporting documentation. The authors make no claims *
13 : * about the suitability of this software for any purpose. It is *
14 : * provided "as is" without express or implied warranty. *
15 : **************************************************************************/
16 :
17 : // $Id$
18 :
19 : ///
20 : /// @file AliHLTMUONMansoTrack.cxx
21 : /// @author Artur Szostak <artursz@iafrica.com>
22 : /// @date 29 Sep 2007
23 : /// @brief Implementation of the AliHLTMUONMansoTrack class.
24 : ///
25 : /// The Manso track class is used to store converted track data from dHLT raw
26 : /// internal data blocks.
27 : ///
28 :
29 : #include "AliHLTMUONMansoTrack.h"
30 : #include "AliHLTMUONRecHit.h"
31 : #include "AliHLTMUONTriggerRecord.h"
32 : #include "AliLog.h"
33 : #include "AliMpDEManager.h"
34 : #include <cstring>
35 : #include <iostream>
36 : #include <iomanip>
37 :
38 6 : ClassImp(AliHLTMUONMansoTrack);
39 :
40 :
41 : std::ostream& operator << (
42 : std::ostream& stream,
43 : const AliHLTMUONMansoTrack& track
44 : )
45 : {
46 : /// Stream operator for std::ostream classes.
47 : /// \param stream The output stream object being written to.
48 : /// \param track The track object to print to the stream.
49 : /// \returns Returns 'stream'.
50 :
51 0 : stream << "ID: " << track.fId
52 0 : << "; sign: " << track.fSign
53 0 : << "; p = (" << track.Px()
54 0 : << ", " << track.Py()
55 0 : << ", " << track.Pz()
56 0 : << "); chi^2: " << track.fChi2;
57 0 : return stream;
58 : }
59 :
60 :
61 0 : AliHLTMUONMansoTrack::AliHLTMUONMansoTrack(
62 : Int_t id, Int_t sign,
63 : Float_t px, Float_t py, Float_t pz,
64 : Float_t chi2,
65 : const AliHLTMUONTriggerRecord* trigrec,
66 : const AliHLTMUONRecHit* hit7,
67 : const AliHLTMUONRecHit* hit8,
68 : const AliHLTMUONRecHit* hit9,
69 : const AliHLTMUONRecHit* hit10,
70 : Float_t zf, Float_t qbl
71 : ) :
72 0 : TObject(),
73 0 : fId(id),
74 0 : fSign(sign),
75 0 : fMomentum(px, py, pz),
76 0 : fChi2(chi2),
77 0 : fTrigRec(trigrec),
78 0 : fZmiddle(zf),
79 0 : fQBL(qbl)
80 0 : {
81 : /// Default constructor.
82 : /// @param id The track ID number which must be unique for any event.
83 : /// @param sign The particle's sign: -1, 1 or 0 if unknown.
84 : /// @param px X component of the particle's momentum (GeV/c).
85 : /// @param py Y component of the particle's momentum (GeV/c).
86 : /// @param pz Z component of the particle's momentum (GeV/c).
87 : /// @param chi2 The chi squared of the track fit.
88 : /// @param trigrec Corresponding trigger record used as a seed to find
89 : /// this track.
90 : /// @param hit7 Hit on chamber 7, tracking station 4.
91 : /// @param hit8 Hit on chamber 8, tracking station 4.
92 : /// @param hit9 Hit on chamber 9, tracking station 5.
93 : /// @param hit10 Hit on chamber 10, tracking station 5.
94 : /// @param zf The Z coordinate of the middle of the magnetic field assumed
95 : /// during momentum calculation.
96 : /// @param qbl The integrated magnetic field strength assumed during momentum
97 : /// calculation.
98 :
99 0 : if (sign < -1 or 1 < sign)
100 : {
101 0 : AliError(Form("Trying to set the sign to %d. This is outside the"
102 : " valid range of [-1..1]", sign
103 : ));
104 0 : fSign = 0;
105 0 : }
106 :
107 0 : fHit[0] = hit7;
108 0 : fHit[1] = hit8;
109 0 : fHit[2] = hit9;
110 0 : fHit[3] = hit10;
111 0 : for (int i = 0; i < 4; i++)
112 : {
113 0 : fRoICentre[i] = TVector3(0, 0, 0);
114 0 : fRoIRadius[i] = -1;
115 : }
116 0 : }
117 :
118 :
119 : const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const
120 : {
121 : /// Returns the hit on the specified chamber.
122 : /// \param chamber The chamber to return the hit for. Must be a value in the range [7..10].
123 : /// \returns A pointer to the hit object else NULL if it does not exist.
124 :
125 0 : if (7 <= chamber and chamber <= 10) return fHit[chamber - 7];
126 :
127 0 : AliError(Form(
128 : "Chamber number %d is not in the valid range [7..10].",
129 : int(chamber)
130 : ));
131 0 : return NULL;
132 0 : }
133 :
134 :
135 : void AliHLTMUONMansoTrack::Print(Option_t* option) const
136 : {
137 : /// Prints the track information to standard output (screen).
138 : /// \param option Can be one of the following:
139 : /// - "compact" - prints in a compact format.
140 : /// - "detail" - prints track information in a more detailed format.
141 : /// - "all" - prints a full dump of the track object.
142 :
143 : using namespace std;
144 :
145 0 : if ( option == NULL or strcmp(option, "") == 0 or
146 0 : strcmp(option, "compact") == 0
147 : )
148 : {
149 0 : cout << *this << endl;
150 0 : }
151 0 : else if (strcmp(option, "detail") == 0)
152 : {
153 0 : cout << "Track ID = " << fId << "; sign = ";
154 0 : if (fSign != 0)
155 0 : cout << fSign;
156 : else
157 0 : cout << "unknown";
158 0 : cout << "; momentum: (px = " << Px()
159 0 : << " GeV/c, py = " << Py()
160 0 : << " GeV/c, pz = " << Pz()
161 0 : << " GeV/c); chi^2 = " << fChi2 << endl;
162 0 : cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
163 0 : << fQBL << " T.m for the momentum calculation." << endl;
164 :
165 0 : streamsize w = cout.width();
166 0 : ios::fmtflags f = cout.flags();
167 0 : cout << setw(9) << "Chamber" << setw(0) << " Hit:"
168 0 : << setw(8) << "X (cm)"
169 0 : << setw(12) << "Y (cm)"
170 0 : << setw(12) << "Z (cm)" << endl;
171 0 : for (int i = 0; i < 4; i++)
172 : {
173 0 : cout << setw(9) << i+11;
174 0 : if (fHit[i] != NULL)
175 : {
176 0 : cout << setw(14) << fHit[i]->X()
177 0 : << setw(12) << fHit[i]->Y()
178 0 : << setw(12) << fHit[i]->Z();
179 0 : }
180 : else
181 : {
182 0 : cout << setw(14) << "-"
183 0 : << setw(12) << "-"
184 0 : << setw(12) << "-";
185 : }
186 0 : cout << endl;
187 : }
188 0 : cout.width(w); // reset the field width to previous value.
189 0 : cout.flags(f); // reset the flags to previous values.
190 0 : }
191 0 : else if (strcmp(option, "all") == 0)
192 : {
193 0 : cout << "Track ID = " << fId << "; sign = ";
194 0 : if (fSign != 0)
195 0 : cout << fSign;
196 : else
197 0 : cout << "unknown";
198 0 : cout << "; momentum: (px = " << Px()
199 0 : << " GeV/c, py = " << Py()
200 0 : << " GeV/c, pz = " << Pz()
201 0 : << " GeV/c); chi^2 = " << fChi2 << endl;
202 0 : cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
203 0 : << fQBL << " T.m for the momentum calculation." << endl;
204 :
205 0 : cout << "Region of interest information:" << endl;
206 0 : streamsize w = cout.width();
207 0 : ios::fmtflags f = cout.flags();
208 0 : cout << setw(9) << "Chamber"
209 0 : << setw(12) << "X (cm)"
210 0 : << setw(12) << "Y (cm)"
211 0 : << setw(12) << "Z (cm)"
212 0 : << setw(12) << "Radius (cm)" << endl;
213 0 : for (int i = 0; i < 4; i++)
214 : {
215 0 : cout << setw(9) << i+11;
216 0 : if (fRoIRadius[i] != -1)
217 : {
218 0 : cout << setw(12) << fRoICentre[i].X()
219 0 : << setw(12) << fRoICentre[i].Y()
220 0 : << setw(12) << fRoICentre[i].Z()
221 0 : << setw(12) << fRoIRadius[i];
222 0 : }
223 : else
224 : {
225 0 : cout << setw(12) << "-"
226 0 : << setw(12) << "-"
227 0 : << setw(12) << "-"
228 0 : << setw(12) << "-";
229 : }
230 0 : cout << endl;
231 : }
232 0 : cout.width(w); // reset the field width to previous value.
233 0 : cout.flags(f); // reset the flags to previous values.
234 :
235 0 : for (int i = 0; i < 4; i++)
236 : {
237 0 : cout << "===== Hit on chamber: " << i+7 << " =====" << endl;
238 0 : if (fHit[i] != NULL)
239 0 : fHit[i]->Print("all");
240 : else
241 0 : cout << "No hit found." << endl;
242 : }
243 :
244 0 : cout << "===== Trigger Record =====" << endl;
245 0 : if (fTrigRec != NULL)
246 0 : fTrigRec->Print("all");
247 : else
248 0 : cout << "No trigger record associated with track." << endl;
249 0 : }
250 : else
251 : {
252 0 : AliError("Unknown option specified. Can only be one of 'compact',"
253 : " 'detail' or 'all'."
254 : );
255 : }
256 0 : }
257 :
258 :
259 : Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const
260 : {
261 : /// We compare this object with 'obj' first by track ID, then by sign, then
262 : /// by momentum and finally by chi2.
263 : /// \param obj This is the object to compare to. It must be of type AliHLTMUONMansoTrack.
264 : /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
265 : /// objects are the same.
266 :
267 0 : if (obj->IsA() == AliHLTMUONMansoTrack::Class())
268 : {
269 : const AliHLTMUONMansoTrack* t =
270 0 : static_cast<const AliHLTMUONMansoTrack*>(obj);
271 0 : if (fId < t->fId) return -1;
272 0 : if (fId > t->fId) return 1;
273 0 : if (fSign < t->fSign) return -1;
274 0 : if (fSign > t->fSign) return 1;
275 0 : if (Px() < t->Px()) return -1;
276 0 : if (Px() > t->Px()) return 1;
277 0 : if (Py() < t->Py()) return -1;
278 0 : if (Py() > t->Py()) return 1;
279 0 : if (Pz() < t->Pz()) return -1;
280 0 : if (Pz() > t->Pz()) return 1;
281 0 : if (fChi2 < t->fChi2) return -1;
282 0 : if (fChi2 > t->fChi2) return 1;
283 0 : return 0;
284 : }
285 : else
286 : {
287 0 : AliError(Form("Do not know how to compare %s to %s.",
288 : this->ClassName(),
289 : obj->ClassName()
290 : ));
291 0 : return -999;
292 : }
293 0 : }
294 :
295 :
296 : bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const
297 : {
298 : /// Comparison operator.
299 : /// \param track The track object to compare to.
300 : /// \returns true if 'this' object is identical to 'track' else false.
301 :
302 0 : return fId == track.fId and fSign == track.fSign
303 0 : and fMomentum == track.fMomentum
304 0 : and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec
305 0 : and fHit[0] == track.fHit[0] and fHit[1] == track.fHit[1]
306 0 : and fHit[2] == track.fHit[2] and fHit[3] == track.fHit[3];
307 : }
308 :
309 :
310 : void AliHLTMUONMansoTrack::SetDebugData(Float_t zmiddle, Float_t bfieldintegral)
311 : {
312 : // Sets the extra debugging information.
313 :
314 0 : fZmiddle = zmiddle;
315 0 : fQBL = bfieldintegral;
316 0 : }
317 :
318 :
319 : const TVector3& AliHLTMUONMansoTrack::RoICentre(Int_t chamber) const
320 : {
321 : // Returns the ragion of interest centre point for a given chamber.
322 :
323 0 : if (7 <= chamber and chamber <= 10) return fRoICentre[chamber - 7];
324 :
325 0 : AliError(Form(
326 : "Chamber number %d is not in the valid range [7..10].",
327 : int(chamber)
328 : ));
329 0 : static TVector3 zeroVector(0, 0, 0);
330 0 : return zeroVector;
331 0 : }
332 :
333 :
334 : Float_t AliHLTMUONMansoTrack::RoIRadius(Int_t chamber) const
335 : {
336 : // Returns the ragion of interest radius for a given chamber.
337 :
338 0 : if (7 <= chamber and chamber <= 10) return fRoIRadius[chamber - 7];
339 :
340 0 : AliError(Form(
341 : "Chamber number %d is not in the valid range [7..10].",
342 : int(chamber)
343 : ));
344 0 : return -1;
345 0 : }
346 :
347 :
348 : void AliHLTMUONMansoTrack::SetRoI(Int_t chamber, Float_t x, Float_t y, Float_t z, Float_t r)
349 : {
350 : // Returns the ragion of interest radius for a given chamber.
351 :
352 0 : if (7 <= chamber and chamber <= 10)
353 : {
354 0 : fRoICentre[chamber - 7] = TVector3(x, y, z);
355 0 : fRoIRadius[chamber - 7] = r;
356 0 : }
357 : else
358 : {
359 0 : AliError(Form(
360 : "Chamber number %d is not in the valid range [7..10].",
361 : int(chamber)
362 : ));
363 : }
364 0 : }
|