1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
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 **************************************************************************/
20 /// @file AliHLTMUONMansoTrack.cxx
21 /// @author Artur Szostak <artursz@iafrica.com>
23 /// @brief Implementation of the AliHLTMUONMansoTrack class.
25 /// The Manso track class is used to store converted track data from dHLT raw
26 /// internal data blocks.
29 #include "AliHLTMUONMansoTrack.h"
30 #include "AliHLTMUONRecHit.h"
31 #include "AliHLTMUONTriggerRecord.h"
33 #include "mapping/AliMpDEManager.h"
38 ClassImp(AliHLTMUONMansoTrack);
41 std::ostream& operator << (
43 const AliHLTMUONMansoTrack& track
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'.
51 stream << "ID: " << track.fId
52 << "; sign: " << track.fSign
53 << "; p = (" << track.Px()
56 << "); chi^2: " << track.fChi2;
61 AliHLTMUONMansoTrack::AliHLTMUONMansoTrack(
63 Float_t px, Float_t py, Float_t pz,
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
75 fMomentum(px, py, pz),
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
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
99 if (sign < -1 or 1 < sign)
101 AliError(Form("Trying to set the sign to %d. This is outside the"
102 " valid range of [-1..1]", sign
111 for (int i = 0; i < 4; i++)
113 fRoICentre[i] = TVector3(0, 0, 0);
119 const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const
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.
125 if (7 <= chamber and chamber <= 10) return fHit[chamber - 7];
128 "Chamber number %d is not in the valid range [7..10].",
135 void AliHLTMUONMansoTrack::Print(Option_t* option) const
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.
145 if ( option == NULL or strcmp(option, "") == 0 or
146 strcmp(option, "compact") == 0
149 cout << *this << endl;
151 else if (strcmp(option, "detail") == 0)
153 cout << "Track ID = " << fId << "; sign = ";
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;
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++)
173 cout << setw(9) << i+11;
176 cout << setw(14) << fHit[i]->X()
177 << setw(12) << fHit[i]->Y()
178 << setw(12) << fHit[i]->Z();
182 cout << setw(14) << "-"
188 cout.width(w); // reset the field width to previous value.
189 cout.flags(f); // reset the flags to previous values.
191 else if (strcmp(option, "all") == 0)
193 cout << "Track ID = " << fId << "; sign = ";
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;
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++)
215 cout << setw(9) << i+11;
216 if (fRoIRadius[i] != -1)
218 cout << setw(12) << fRoICentre[i].X()
219 << setw(12) << fRoICentre[i].Y()
220 << setw(12) << fRoICentre[i].Z()
221 << setw(12) << fRoIRadius[i];
225 cout << setw(12) << "-"
232 cout.width(w); // reset the field width to previous value.
233 cout.flags(f); // reset the flags to previous values.
235 for (int i = 0; i < 4; i++)
237 cout << "===== Hit on chamber: " << i+7 << " =====" << endl;
239 fHit[i]->Print("all");
241 cout << "No hit found." << endl;
244 cout << "===== Trigger Record =====" << endl;
245 if (fTrigRec != NULL)
246 fTrigRec->Print("all");
248 cout << "No trigger record associated with track." << endl;
252 AliError("Unknown option specified. Can only be one of 'compact',"
253 " 'detail' or 'all'."
259 Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const
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.
267 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
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;
287 AliError(Form("Do not know how to compare %s to %s.",
296 bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const
298 /// Comparison operator.
299 /// \param track The track object to compare to.
300 /// \returns true if 'this' object is identical to 'track' else false.
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];
310 void AliHLTMUONMansoTrack::SetDebugData(Float_t zmiddle, Float_t bfieldintegral)
312 // Sets the extra debugging information.
315 fQBL = bfieldintegral;
319 const TVector3& AliHLTMUONMansoTrack::RoICentre(Int_t chamber) const
321 // Returns the ragion of interest centre point for a given chamber.
323 if (7 <= chamber and chamber <= 10) return fRoICentre[chamber - 7];
326 "Chamber number %d is not in the valid range [7..10].",
329 static TVector3 zeroVector(0, 0, 0);
334 Float_t AliHLTMUONMansoTrack::RoIRadius(Int_t chamber) const
336 // Returns the ragion of interest radius for a given chamber.
338 if (7 <= chamber and chamber <= 10) return fRoIRadius[chamber - 7];
341 "Chamber number %d is not in the valid range [7..10].",
348 void AliHLTMUONMansoTrack::SetRoI(Int_t chamber, Float_t x, Float_t y, Float_t z, Float_t r)
350 // Returns the ragion of interest radius for a given chamber.
352 if (7 <= chamber and chamber <= 10)
354 fRoICentre[chamber - 7] = TVector3(x, y, z);
355 fRoIRadius[chamber - 7] = r;
360 "Chamber number %d is not in the valid range [7..10].",