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.
26 #include "AliHLTMUONMansoTrack.h"
28 #include "mapping/AliMpDEManager.h"
34 ClassImp(AliHLTMUONMansoTrack);
37 std::ostream& operator << (
39 const AliHLTMUONMansoTrack& track
44 stream << "ID: " << track.fId
45 << "; sign: " << track.fSign
46 << "; p = (" << track.Px()
49 << "); chi^2: " << track.fChi2;
54 AliHLTMUONMansoTrack::AliHLTMUONMansoTrack(
56 Float_t px, Float_t py, Float_t pz,
58 const AliHLTMUONTriggerRecord* trigrec,
59 const AliHLTMUONRecHit* hit7,
60 const AliHLTMUONRecHit* hit8,
61 const AliHLTMUONRecHit* hit9,
62 const AliHLTMUONRecHit* hit10,
63 Float_t zf, Float_t qbl
65 fId(id), fSign(sign), fMomentum(px, py, pz),
66 fChi2(chi2), fTrigRec(trigrec), fZmiddle(zf), fQBL(qbl)
68 if (sign < -1 or 1 < sign)
70 AliError(Form("Trying to set the sign to %d. This is outside the"
71 " valid range of [-1..1]", sign
83 const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const
85 // Returns the hit on the specified chamber.
87 if (7 <= chamber and chamber <= 10) return fHit[chamber - 7];
90 "Chamber number %d is not in the valid range [7..10].",
97 void AliHLTMUONMansoTrack::Print(Option_t* option) const
99 // Prints the track information to standard output (screen).
101 if ( option == NULL or strcmp(option, "") == 0 or
102 strcmp(option, "compact") == 0
105 cout << *this << endl;
107 else if (strcmp(option, "detail") == 0)
109 cout << "Track ID = " << fId << "; sign = ";
114 cout << "; momentum: (px = " << Px()
115 << " GeV/c, py = " << Py()
116 << " GeV/c, pz = " << Pz()
117 << " GeV/c); chi^2 = " << fChi2 << endl;
118 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
119 << fQBL << " T.m for the momentum calculation." << endl;
121 streamsize w = cout.width();
122 ios::fmtflags f = cout.flags();
123 cout << setw(9) << "Chamber" << setw(0) << " Hit:"
124 << setw(8) << "X (cm)"
125 << setw(12) << "Y (cm)"
126 << setw(12) << "Z (cm)" << endl;
127 for (int i = 0; i < 4; i++)
129 cout << setw(9) << i+11;
132 cout << setw(14) << fHit[i]->X()
133 << setw(12) << fHit[i]->Y()
134 << setw(12) << fHit[i]->Z();
138 cout << setw(14) << "-"
144 cout.width(w); // reset the field width to previous value.
145 cout.flags(f); // reset the flags to previous values.
147 else if (strcmp(option, "all") == 0)
149 cout << "Track ID = " << fId << "; sign = ";
154 cout << "; momentum: (px = " << Px()
155 << " GeV/c, py = " << Py()
156 << " GeV/c, pz = " << Pz()
157 << " GeV/c); chi^2 = " << fChi2 << endl;
158 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
159 << fQBL << " T.m for the momentum calculation." << endl;
161 for (int i = 0; i < 4; i++)
163 cout << "===== Hit on chamber: " << i+7 << " =====" << endl;
165 fHit[i]->Print("all");
167 cout << "No hit found." << endl;
170 cout << "===== Trigger Record =====" << endl;
171 if (fTrigRec != NULL)
172 fTrigRec->Print("all");
174 cout << "No trigger record associated with track." << endl;
178 AliError("Unknown option specified. Can only be one of 'compact',"
179 " 'detail' or 'all'."
185 Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const
187 // We compare this object with 'obj' first by track ID, then by sign, then
188 // by momentum and finally by chi2.
190 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
192 const AliHLTMUONMansoTrack* t =
193 static_cast<const AliHLTMUONMansoTrack*>(obj);
194 if (fId < t->fId) return -1;
195 if (fId > t->fId) return 1;
196 if (fSign < t->fSign) return -1;
197 if (fSign > t->fSign) return 1;
198 if (Px() < t->Px()) return -1;
199 if (Px() > t->Px()) return 1;
200 if (Py() < t->Py()) return -1;
201 if (Py() > t->Py()) return 1;
202 if (Pz() < t->Pz()) return -1;
203 if (Pz() > t->Pz()) return 1;
204 if (fChi2 < t->fChi2) return -1;
205 if (fChi2 > t->fChi2) return 1;
210 AliError(Form("Do not know how to compare %s to %s.",
219 bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const
221 return fId == track.fId and fSign == track.fSign
222 and fMomentum == track.fMomentum
223 and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec
224 and fHit[0] == track.fHit[0] and fHit[1] == track.fHit[1]
225 and fHit[2] == track.fHit[2] and fHit[3] == track.fHit[3];