ALIROOT-5433 Transition to CDHv3 in HLT
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONMansoTrack.cxx
CommitLineData
753896cd 1/**************************************************************************
8e0220c2 2 * This file is property of and copyright by the ALICE HLT Project *
753896cd 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 *
8e0220c2 13 * about the suitability of this software for any purpose. It is *
753896cd 14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
1d8ae082 17// $Id$
753896cd 18
450e0b36 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///
753896cd 28
29#include "AliHLTMUONMansoTrack.h"
450e0b36 30#include "AliHLTMUONRecHit.h"
31#include "AliHLTMUONTriggerRecord.h"
753896cd 32#include "AliLog.h"
33#include "mapping/AliMpDEManager.h"
34#include <cstring>
35#include <iostream>
36#include <iomanip>
753896cd 37
38ClassImp(AliHLTMUONMansoTrack);
39
40
41std::ostream& operator << (
42 std::ostream& stream,
43 const AliHLTMUONMansoTrack& track
44 )
45{
450e0b36 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'.
753896cd 50
51 stream << "ID: " << track.fId
52 << "; sign: " << track.fSign
53 << "; p = (" << track.Px()
54 << ", " << track.Py()
55 << ", " << track.Pz()
56 << "); chi^2: " << track.fChi2;
57 return stream;
58}
59
60
61AliHLTMUONMansoTrack::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 ) :
92aebaf3 72 TObject(),
73 fId(id),
74 fSign(sign),
75 fMomentum(px, py, pz),
76 fChi2(chi2),
77 fTrigRec(trigrec),
78 fZmiddle(zf),
79 fQBL(qbl)
753896cd 80{
450e0b36 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
753896cd 99 if (sign < -1 or 1 < sign)
100 {
101 AliError(Form("Trying to set the sign to %d. This is outside the"
102 " valid range of [-1..1]", sign
103 ));
104 fSign = 0;
105 }
106
107 fHit[0] = hit7;
108 fHit[1] = hit8;
109 fHit[2] = hit9;
110 fHit[3] = hit10;
bc5cb6d6 111 for (int i = 0; i < 4; i++)
112 {
113 fRoICentre[i] = TVector3(0, 0, 0);
114 fRoIRadius[i] = -1;
115 }
753896cd 116}
117
118
119const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const
120{
450e0b36 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.
753896cd 124
125 if (7 <= chamber and chamber <= 10) return fHit[chamber - 7];
126
127 AliError(Form(
128 "Chamber number %d is not in the valid range [7..10].",
129 int(chamber)
130 ));
131 return NULL;
132}
133
134
135void AliHLTMUONMansoTrack::Print(Option_t* option) const
136{
450e0b36 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.
753896cd 142
450e0b36 143 using namespace std;
144
753896cd 145 if ( option == NULL or strcmp(option, "") == 0 or
146 strcmp(option, "compact") == 0
147 )
148 {
149 cout << *this << endl;
150 }
151 else if (strcmp(option, "detail") == 0)
152 {
153 cout << "Track ID = " << fId << "; sign = ";
154 if (fSign != 0)
155 cout << fSign;
156 else
157 cout << "unknown";
158 cout << "; momentum: (px = " << Px()
159 << " GeV/c, py = " << Py()
160 << " GeV/c, pz = " << Pz()
161 << " GeV/c); chi^2 = " << fChi2 << endl;
162 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
163 << fQBL << " T.m for the momentum calculation." << endl;
164
165 streamsize w = cout.width();
166 ios::fmtflags f = cout.flags();
167 cout << setw(9) << "Chamber" << setw(0) << " Hit:"
168 << setw(8) << "X (cm)"
169 << setw(12) << "Y (cm)"
170 << setw(12) << "Z (cm)" << endl;
171 for (int i = 0; i < 4; i++)
172 {
173 cout << setw(9) << i+11;
174 if (fHit[i] != NULL)
175 {
176 cout << setw(14) << fHit[i]->X()
177 << setw(12) << fHit[i]->Y()
178 << setw(12) << fHit[i]->Z();
179 }
180 else
181 {
182 cout << setw(14) << "-"
183 << setw(12) << "-"
184 << setw(12) << "-";
185 }
186 cout << endl;
187 }
188 cout.width(w); // reset the field width to previous value.
189 cout.flags(f); // reset the flags to previous values.
190 }
191 else if (strcmp(option, "all") == 0)
192 {
193 cout << "Track ID = " << fId << "; sign = ";
194 if (fSign != 0)
195 cout << fSign;
196 else
197 cout << "unknown";
198 cout << "; momentum: (px = " << Px()
199 << " GeV/c, py = " << Py()
200 << " GeV/c, pz = " << Pz()
201 << " GeV/c); chi^2 = " << fChi2 << endl;
202 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
203 << fQBL << " T.m for the momentum calculation." << endl;
204
bc5cb6d6 205 cout << "Region of interest information:" << endl;
206 streamsize w = cout.width();
207 ios::fmtflags f = cout.flags();
208 cout << setw(9) << "Chamber"
209 << setw(12) << "X (cm)"
210 << setw(12) << "Y (cm)"
211 << setw(12) << "Z (cm)"
212 << setw(12) << "Radius (cm)" << endl;
213 for (int i = 0; i < 4; i++)
214 {
215 cout << setw(9) << i+11;
216 if (fRoIRadius[i] != -1)
217 {
218 cout << setw(12) << fRoICentre[i].X()
219 << setw(12) << fRoICentre[i].Y()
220 << setw(12) << fRoICentre[i].Z()
221 << setw(12) << fRoIRadius[i];
222 }
223 else
224 {
225 cout << setw(12) << "-"
226 << setw(12) << "-"
227 << setw(12) << "-"
228 << setw(12) << "-";
229 }
230 cout << endl;
231 }
232 cout.width(w); // reset the field width to previous value.
233 cout.flags(f); // reset the flags to previous values.
234
753896cd 235 for (int i = 0; i < 4; i++)
236 {
237 cout << "===== Hit on chamber: " << i+7 << " =====" << endl;
238 if (fHit[i] != NULL)
239 fHit[i]->Print("all");
240 else
241 cout << "No hit found." << endl;
242 }
243
244 cout << "===== Trigger Record =====" << endl;
245 if (fTrigRec != NULL)
246 fTrigRec->Print("all");
247 else
248 cout << "No trigger record associated with track." << endl;
249 }
250 else
251 {
252 AliError("Unknown option specified. Can only be one of 'compact',"
253 " 'detail' or 'all'."
254 );
255 }
256}
257
258
259Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const
260{
450e0b36 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.
753896cd 266
267 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
268 {
269 const AliHLTMUONMansoTrack* t =
270 static_cast<const AliHLTMUONMansoTrack*>(obj);
271 if (fId < t->fId) return -1;
272 if (fId > t->fId) return 1;
273 if (fSign < t->fSign) return -1;
274 if (fSign > t->fSign) return 1;
275 if (Px() < t->Px()) return -1;
276 if (Px() > t->Px()) return 1;
277 if (Py() < t->Py()) return -1;
278 if (Py() > t->Py()) return 1;
279 if (Pz() < t->Pz()) return -1;
280 if (Pz() > t->Pz()) return 1;
281 if (fChi2 < t->fChi2) return -1;
282 if (fChi2 > t->fChi2) return 1;
283 return 0;
284 }
285 else
286 {
287 AliError(Form("Do not know how to compare %s to %s.",
288 this->ClassName(),
289 obj->ClassName()
290 ));
291 return -999;
292 }
293}
294
295
296bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const
297{
450e0b36 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
753896cd 302 return fId == track.fId and fSign == track.fSign
303 and fMomentum == track.fMomentum
304 and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec
305 and fHit[0] == track.fHit[0] and fHit[1] == track.fHit[1]
306 and fHit[2] == track.fHit[2] and fHit[3] == track.fHit[3];
307}
bc5cb6d6 308
309
310void AliHLTMUONMansoTrack::SetDebugData(Float_t zmiddle, Float_t bfieldintegral)
311{
312 // Sets the extra debugging information.
313
314 fZmiddle = zmiddle;
315 fQBL = bfieldintegral;
316}
317
318
319const TVector3& AliHLTMUONMansoTrack::RoICentre(Int_t chamber) const
320{
321 // Returns the ragion of interest centre point for a given chamber.
322
323 if (7 <= chamber and chamber <= 10) return fRoICentre[chamber - 7];
324
325 AliError(Form(
326 "Chamber number %d is not in the valid range [7..10].",
327 int(chamber)
328 ));
329 static TVector3 zeroVector(0, 0, 0);
330 return zeroVector;
331}
332
333
334Float_t AliHLTMUONMansoTrack::RoIRadius(Int_t chamber) const
335{
336 // Returns the ragion of interest radius for a given chamber.
337
338 if (7 <= chamber and chamber <= 10) return fRoIRadius[chamber - 7];
339
340 AliError(Form(
341 "Chamber number %d is not in the valid range [7..10].",
342 int(chamber)
343 ));
344 return -1;
345}
346
347
348void 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 if (7 <= chamber and chamber <= 10)
353 {
354 fRoICentre[chamber - 7] = TVector3(x, y, z);
355 fRoIRadius[chamber - 7] = r;
356 }
357 else
358 {
359 AliError(Form(
360 "Chamber number %d is not in the valid range [7..10].",
361 int(chamber)
362 ));
363 }
364}