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 **************************************************************************/
17 // $Id: AliHLTMUONTrack.cxx 37131 2009-11-23 11:08:09Z aszostak $
20 /// @file AliHLTMUONTrack.cxx
21 /// @author Indranil Das <indra.ehep@gmail.com> and Artur Szostak <artursz@iafrica.com>
22 /// @date 10 March 2010
23 /// @brief Implementation of the AliHLTMUONTrack class.
25 /// The track class is used to store converted track data from dHLT raw internal
26 /// data blocks as a ROOT object. This allows storing these in ROOT files.
29 #include "AliHLTMUONTrack.h"
30 #include "AliHLTMUONRecHit.h"
31 #include "AliHLTMUONTriggerRecord.h"
33 #include "mapping/AliMpDEManager.h"
38 ClassImp(AliHLTMUONTrack);
41 std::ostream& operator << (
43 const AliHLTMUONTrack& 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 the stream object that was written to, <i>stream</i>.
51 stream << "ID: " << track.fId
52 << "; sign: " << track.fSign
53 << "; p = (" << track.Px()
56 << "); chi^2: " << track.fChi2;
61 AliHLTMUONTrack::AliHLTMUONTrack(
63 Float_t px, Float_t py, Float_t pz,
64 Float_t invmom, Float_t thetaX, Float_t thetaY,
65 Float_t x, Float_t y, Float_t z,
67 const AliHLTMUONTriggerRecord* trigrec,
68 const AliHLTMUONRecHit* hits[16]
73 fInverseBendingMomentum(invmom),
76 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 invmom Inverse bending momentum (GeV/c).
88 /// @param thetaX The non-bending plane slope of the fitted track.
89 /// @param thetaY The bending plane slope of the fitted track.
90 /// @param x X coordinate of the particle's distance of closest
91 /// approach (DCA) position (cm).
92 /// @param y Y coordinate of the particle's DCA position (cm).
93 /// @param z Z coordinate of the particle's DCA position (cm).
94 /// @param chi2 The chi squared of the track fit.
95 /// @param trigrec Corresponding trigger record used as a seed to find
97 /// @param hits The array of 16 hit coordinates found for the track.
98 /// If NULL then then all hit coordinates are set to empty.
100 if (sign < -1 or 1 < sign)
102 AliError(Form("Trying to set the sign to %d. This is outside the"
103 " valid range of [-1..1]", sign
108 // Copy individual hit pointers if hits were set.
111 for (int i = 0; i < 16; ++i)
118 for (int i = 0; i < 16; ++i)
126 const AliHLTMUONRecHit* AliHLTMUONTrack::Hit(Int_t i) const
128 /// Returns the i'th hit.
129 /// \param i The number of the hit to return. Must be a value in the range [0..15].
130 /// \returns A pointer to the hit object else NULL if it does not exist.
132 if (0 <= i and i <= 15) return fHit[i];
133 AliError(Form("Hit index number %d is not in the valid range [0..15].", int(i)));
138 const AliHLTMUONRecHit* AliHLTMUONTrack::HitByChamber(Int_t chamber) const
140 /// Returns the first hit found for the specified chamber.
141 /// \param chamber The chamber to return the hit for. Must be a value in the range [1..14].
142 /// \returns A pointer to the hit object else NULL if it does not exist.
144 if (not (1 <= chamber and chamber <= 14))
147 "Chamber number %d is not in the valid range [1..14].",
153 const AliHLTMUONRecHit* hit = NULL;
154 for (int i = 0; i < 16; ++i)
156 if (fHit[i] == NULL) continue;
157 if (fHit[i]->Chamber(false) == chamber)
167 void AliHLTMUONTrack::Print(Option_t* option) const
169 /// Prints the track information to standard output (screen).
170 /// \param option Can be one of the following:
171 /// - "compact" - prints in a compact format.
172 /// - "detail" - prints track information in a more detailed format.
173 /// - "all" - prints a full dump of the track object.
177 if ( option == NULL or strcmp(option, "") == 0 or
178 strcmp(option, "compact") == 0
181 cout << *this << endl;
183 else if (strcmp(option, "detail") == 0)
185 cout << "Track ID = " << fId << "; sign = ";
190 cout << "; momentum: (px = " << Px()
191 << " GeV/c, py = " << Py()
192 << " GeV/c, pz = " << Pz()
193 << " GeV/c); vertex DCA: (x = " << X()
194 << " cm, y = " << Y()
195 << " cm, z = " << Z()
196 << " cm); chi^2 = " << fChi2 << endl;
198 streamsize w = cout.width();
199 ios::fmtflags f = cout.flags();
200 cout << setw(9) << "Hit no."
201 << setw(9) << "Chamber"
202 << setw(0) << " Pos:"
203 << setw(8) << "X (cm)"
204 << setw(12) << "Y (cm)"
205 << setw(12) << "Z (cm)" << endl;
206 for (int i = 0; i < 16; i++)
208 cout << setw(9) << i;
211 cout << setw(9) << fHit[i]->Chamber(false)
212 << setw(14) << fHit[i]->X()
213 << setw(12) << fHit[i]->Y()
214 << setw(12) << fHit[i]->Z();
218 cout << setw(9) << "-"
225 cout.width(w); // reset the field width to previous value.
226 cout.flags(f); // reset the flags to previous values.
228 else if (strcmp(option, "all") == 0)
230 cout << "Track ID = " << fId << "; sign = ";
235 cout << "; momentum: (px = " << Px()
236 << " GeV/c, py = " << Py()
237 << " GeV/c, pz = " << Pz()
238 << " GeV/c); vertex DCA: (x = " << X()
239 << " cm, y = " << Y()
240 << " cm, z = " << Z()
241 << " cm); chi^2 = " << fChi2 << endl;
242 cout << "Inverse bending momentum = " << fInverseBendingMomentum
243 << "; non-bending plane slope = " << fThetaX
244 << "; bending plane slope = " << fThetaY << endl;
246 streamsize w = cout.width();
247 ios::fmtflags f = cout.flags();
248 cout.width(w); // reset the field width to previous value.
249 cout.flags(f); // reset the flags to previous values.
251 for (int i = 0; i < 16; i++)
253 cout << "======== Hit " << i << " ========" << endl;
255 fHit[i]->Print("all");
257 cout << "No hit found." << endl;
260 cout << "===== Trigger Record =====" << endl;
261 if (fTrigRec != NULL)
262 fTrigRec->Print("all");
264 cout << "No trigger record associated with track." << endl;
268 AliError("Unknown option specified. Can only be one of 'compact',"
269 " 'detail' or 'all'."
275 Int_t AliHLTMUONTrack::Compare(const TObject* obj) const
277 /// We compare this object with 'obj' first by track ID, then by sign, then
278 /// by momentum, then by DCA vertex and finally by chi2.
279 /// \param obj This is the object to compare to. It must be of type AliHLTMUONTrack.
280 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
281 /// objects are the same.
283 if (obj->IsA() == AliHLTMUONTrack::Class())
285 const AliHLTMUONTrack* t =
286 static_cast<const AliHLTMUONTrack*>(obj);
287 if (fId < t->fId) return -1;
288 if (fId > t->fId) return 1;
289 if (fSign < t->fSign) return -1;
290 if (fSign > t->fSign) return 1;
291 if (Px() < t->Px()) return -1;
292 if (Px() > t->Px()) return 1;
293 if (Py() < t->Py()) return -1;
294 if (Py() > t->Py()) return 1;
295 if (Pz() < t->Pz()) return -1;
296 if (Pz() > t->Pz()) return 1;
297 if (X() < t->X()) return -1;
298 if (X() > t->X()) return 1;
299 if (Y() < t->Y()) return -1;
300 if (Y() > t->Y()) return 1;
301 if (Z() < t->Z()) return -1;
302 if (Z() > t->Z()) return 1;
303 if (fChi2 < t->fChi2) return -1;
304 if (fChi2 > t->fChi2) return 1;
309 AliError(Form("Do not know how to compare %s to %s.",
318 bool AliHLTMUONTrack::operator == (const AliHLTMUONTrack& track) const
320 /// Comparison operator.
321 /// \param track The track object to compare to.
322 /// \returns true if 'this' object is identical to 'track' else false.
324 for (int i = 0; i < 16; i++)
326 if (fHit[i] != track.fHit[i]) return false;
329 return fId == track.fId and fSign == track.fSign
330 and fInverseBendingMomentum == track.fInverseBendingMomentum
331 and fThetaX == track.fThetaX and fThetaY == track.fThetaY
332 and fMomentum == track.fMomentum and fVertexDCA == track.fVertexDCA
333 and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec;