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
72 fId(id), fSign(sign), fMomentum(px, py, pz),
73 fChi2(chi2), fTrigRec(trigrec), fZmiddle(zf), fQBL(qbl)
75 /// Default constructor.
76 /// @param id The track ID number which must be unique for any event.
77 /// @param sign The particle's sign: -1, 1 or 0 if unknown.
78 /// @param px X component of the particle's momentum (GeV/c).
79 /// @param py Y component of the particle's momentum (GeV/c).
80 /// @param pz Z component of the particle's momentum (GeV/c).
81 /// @param chi2 The chi squared of the track fit.
82 /// @param trigrec Corresponding trigger record used as a seed to find
84 /// @param hit7 Hit on chamber 7, tracking station 4.
85 /// @param hit8 Hit on chamber 8, tracking station 4.
86 /// @param hit9 Hit on chamber 9, tracking station 5.
87 /// @param hit10 Hit on chamber 10, tracking station 5.
88 /// @param zf The Z coordinate of the middle of the magnetic field assumed
89 /// during momentum calculation.
90 /// @param qbl The integrated magnetic field strength assumed during momentum
93 if (sign < -1 or 1 < sign)
95 AliError(Form("Trying to set the sign to %d. This is outside the"
96 " valid range of [-1..1]", sign
108 const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const
110 /// Returns the hit on the specified chamber.
111 /// \param chamber The chamber to return the hit for. Must be a value in the range [7..10].
112 /// \returns A pointer to the hit object else NULL if it does not exist.
114 if (7 <= chamber and chamber <= 10) return fHit[chamber - 7];
117 "Chamber number %d is not in the valid range [7..10].",
124 void AliHLTMUONMansoTrack::Print(Option_t* option) const
126 /// Prints the track information to standard output (screen).
127 /// \param option Can be one of the following:
128 /// - "compact" - prints in a compact format.
129 /// - "detail" - prints track information in a more detailed format.
130 /// - "all" - prints a full dump of the track object.
134 if ( option == NULL or strcmp(option, "") == 0 or
135 strcmp(option, "compact") == 0
138 cout << *this << endl;
140 else if (strcmp(option, "detail") == 0)
142 cout << "Track ID = " << fId << "; sign = ";
147 cout << "; momentum: (px = " << Px()
148 << " GeV/c, py = " << Py()
149 << " GeV/c, pz = " << Pz()
150 << " GeV/c); chi^2 = " << fChi2 << endl;
151 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
152 << fQBL << " T.m for the momentum calculation." << endl;
154 streamsize w = cout.width();
155 ios::fmtflags f = cout.flags();
156 cout << setw(9) << "Chamber" << setw(0) << " Hit:"
157 << setw(8) << "X (cm)"
158 << setw(12) << "Y (cm)"
159 << setw(12) << "Z (cm)" << endl;
160 for (int i = 0; i < 4; i++)
162 cout << setw(9) << i+11;
165 cout << setw(14) << fHit[i]->X()
166 << setw(12) << fHit[i]->Y()
167 << setw(12) << fHit[i]->Z();
171 cout << setw(14) << "-"
177 cout.width(w); // reset the field width to previous value.
178 cout.flags(f); // reset the flags to previous values.
180 else if (strcmp(option, "all") == 0)
182 cout << "Track ID = " << fId << "; sign = ";
187 cout << "; momentum: (px = " << Px()
188 << " GeV/c, py = " << Py()
189 << " GeV/c, pz = " << Pz()
190 << " GeV/c); chi^2 = " << fChi2 << endl;
191 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
192 << fQBL << " T.m for the momentum calculation." << endl;
194 for (int i = 0; i < 4; i++)
196 cout << "===== Hit on chamber: " << i+7 << " =====" << endl;
198 fHit[i]->Print("all");
200 cout << "No hit found." << endl;
203 cout << "===== Trigger Record =====" << endl;
204 if (fTrigRec != NULL)
205 fTrigRec->Print("all");
207 cout << "No trigger record associated with track." << endl;
211 AliError("Unknown option specified. Can only be one of 'compact',"
212 " 'detail' or 'all'."
218 Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const
220 /// We compare this object with 'obj' first by track ID, then by sign, then
221 /// by momentum and finally by chi2.
222 /// \param obj This is the object to compare to. It must be of type AliHLTMUONMansoTrack.
223 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
224 /// objects are the same.
226 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
228 const AliHLTMUONMansoTrack* t =
229 static_cast<const AliHLTMUONMansoTrack*>(obj);
230 if (fId < t->fId) return -1;
231 if (fId > t->fId) return 1;
232 if (fSign < t->fSign) return -1;
233 if (fSign > t->fSign) return 1;
234 if (Px() < t->Px()) return -1;
235 if (Px() > t->Px()) return 1;
236 if (Py() < t->Py()) return -1;
237 if (Py() > t->Py()) return 1;
238 if (Pz() < t->Pz()) return -1;
239 if (Pz() > t->Pz()) return 1;
240 if (fChi2 < t->fChi2) return -1;
241 if (fChi2 > t->fChi2) return 1;
246 AliError(Form("Do not know how to compare %s to %s.",
255 bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const
257 /// Comparison operator.
258 /// \param track The track object to compare to.
259 /// \returns true if 'this' object is identical to 'track' else false.
261 return fId == track.fId and fSign == track.fSign
262 and fMomentum == track.fMomentum
263 and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec
264 and fHit[0] == track.fHit[0] and fHit[1] == track.fHit[1]
265 and fHit[2] == track.fHit[2] and fHit[3] == track.fHit[3];