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
114 const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const
116 /// Returns the hit on the specified chamber.
117 /// \param chamber The chamber to return the hit for. Must be a value in the range [7..10].
118 /// \returns A pointer to the hit object else NULL if it does not exist.
120 if (7 <= chamber and chamber <= 10) return fHit[chamber - 7];
123 "Chamber number %d is not in the valid range [7..10].",
130 void AliHLTMUONMansoTrack::Print(Option_t* option) const
132 /// Prints the track information to standard output (screen).
133 /// \param option Can be one of the following:
134 /// - "compact" - prints in a compact format.
135 /// - "detail" - prints track information in a more detailed format.
136 /// - "all" - prints a full dump of the track object.
140 if ( option == NULL or strcmp(option, "") == 0 or
141 strcmp(option, "compact") == 0
144 cout << *this << endl;
146 else if (strcmp(option, "detail") == 0)
148 cout << "Track ID = " << fId << "; sign = ";
153 cout << "; momentum: (px = " << Px()
154 << " GeV/c, py = " << Py()
155 << " GeV/c, pz = " << Pz()
156 << " GeV/c); chi^2 = " << fChi2 << endl;
157 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
158 << fQBL << " T.m for the momentum calculation." << endl;
160 streamsize w = cout.width();
161 ios::fmtflags f = cout.flags();
162 cout << setw(9) << "Chamber" << setw(0) << " Hit:"
163 << setw(8) << "X (cm)"
164 << setw(12) << "Y (cm)"
165 << setw(12) << "Z (cm)" << endl;
166 for (int i = 0; i < 4; i++)
168 cout << setw(9) << i+11;
171 cout << setw(14) << fHit[i]->X()
172 << setw(12) << fHit[i]->Y()
173 << setw(12) << fHit[i]->Z();
177 cout << setw(14) << "-"
183 cout.width(w); // reset the field width to previous value.
184 cout.flags(f); // reset the flags to previous values.
186 else if (strcmp(option, "all") == 0)
188 cout << "Track ID = " << fId << "; sign = ";
193 cout << "; momentum: (px = " << Px()
194 << " GeV/c, py = " << Py()
195 << " GeV/c, pz = " << Pz()
196 << " GeV/c); chi^2 = " << fChi2 << endl;
197 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
198 << fQBL << " T.m for the momentum calculation." << endl;
200 for (int i = 0; i < 4; i++)
202 cout << "===== Hit on chamber: " << i+7 << " =====" << endl;
204 fHit[i]->Print("all");
206 cout << "No hit found." << endl;
209 cout << "===== Trigger Record =====" << endl;
210 if (fTrigRec != NULL)
211 fTrigRec->Print("all");
213 cout << "No trigger record associated with track." << endl;
217 AliError("Unknown option specified. Can only be one of 'compact',"
218 " 'detail' or 'all'."
224 Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const
226 /// We compare this object with 'obj' first by track ID, then by sign, then
227 /// by momentum and finally by chi2.
228 /// \param obj This is the object to compare to. It must be of type AliHLTMUONMansoTrack.
229 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
230 /// objects are the same.
232 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
234 const AliHLTMUONMansoTrack* t =
235 static_cast<const AliHLTMUONMansoTrack*>(obj);
236 if (fId < t->fId) return -1;
237 if (fId > t->fId) return 1;
238 if (fSign < t->fSign) return -1;
239 if (fSign > t->fSign) return 1;
240 if (Px() < t->Px()) return -1;
241 if (Px() > t->Px()) return 1;
242 if (Py() < t->Py()) return -1;
243 if (Py() > t->Py()) return 1;
244 if (Pz() < t->Pz()) return -1;
245 if (Pz() > t->Pz()) return 1;
246 if (fChi2 < t->fChi2) return -1;
247 if (fChi2 > t->fChi2) return 1;
252 AliError(Form("Do not know how to compare %s to %s.",
261 bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const
263 /// Comparison operator.
264 /// \param track The track object to compare to.
265 /// \returns true if 'this' object is identical to 'track' else false.
267 return fId == track.fId and fSign == track.fSign
268 and fMomentum == track.fMomentum
269 and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec
270 and fHit[0] == track.fHit[0] and fHit[1] == track.fHit[1]
271 and fHit[2] == track.fHit[2] and fHit[3] == track.fHit[3];