]>
Commit | Line | Data |
---|---|---|
753896cd | 1 | /************************************************************************** |
8e0220c2 | 2 | * This file is property of and copyright by the ALICE HLT Project * |
753896cd | 3 | * All rights reserved. * |
4 | * * | |
5 | * Primary Authors: * | |
6 | * Artur Szostak <artursz@iafrica.com> * | |
7 | * * | |
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 * | |
8e0220c2 | 13 | * about the suitability of this software for any purpose. It is * |
753896cd | 14 | * provided "as is" without express or implied warranty. * |
15 | **************************************************************************/ | |
16 | ||
17 | /* $Id$ */ | |
18 | ||
450e0b36 | 19 | /// |
20 | /// @file AliHLTMUONMansoTrack.cxx | |
21 | /// @author Artur Szostak <artursz@iafrica.com> | |
22 | /// @date 29 Sep 2007 | |
23 | /// @brief Implementation of the AliHLTMUONMansoTrack class. | |
24 | /// | |
25 | /// The Manso track class is used to store converted track data from dHLT raw | |
26 | /// internal data blocks. | |
27 | /// | |
753896cd | 28 | |
29 | #include "AliHLTMUONMansoTrack.h" | |
450e0b36 | 30 | #include "AliHLTMUONRecHit.h" |
31 | #include "AliHLTMUONTriggerRecord.h" | |
753896cd | 32 | #include "AliLog.h" |
33 | #include "mapping/AliMpDEManager.h" | |
34 | #include <cstring> | |
35 | #include <iostream> | |
36 | #include <iomanip> | |
753896cd | 37 | |
38 | ClassImp(AliHLTMUONMansoTrack); | |
39 | ||
40 | ||
41 | std::ostream& operator << ( | |
42 | std::ostream& stream, | |
43 | const AliHLTMUONMansoTrack& track | |
44 | ) | |
45 | { | |
450e0b36 | 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'. | |
753896cd | 50 | |
51 | stream << "ID: " << track.fId | |
52 | << "; sign: " << track.fSign | |
53 | << "; p = (" << track.Px() | |
54 | << ", " << track.Py() | |
55 | << ", " << track.Pz() | |
56 | << "); chi^2: " << track.fChi2; | |
57 | return stream; | |
58 | } | |
59 | ||
60 | ||
61 | AliHLTMUONMansoTrack::AliHLTMUONMansoTrack( | |
62 | Int_t id, Int_t sign, | |
63 | Float_t px, Float_t py, Float_t pz, | |
64 | Float_t chi2, | |
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 | |
71 | ) : | |
92aebaf3 | 72 | TObject(), |
73 | fId(id), | |
74 | fSign(sign), | |
75 | fMomentum(px, py, pz), | |
76 | fChi2(chi2), | |
77 | fTrigRec(trigrec), | |
78 | fZmiddle(zf), | |
79 | fQBL(qbl) | |
753896cd | 80 | { |
450e0b36 | 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 | |
89 | /// this track. | |
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 | |
97 | /// calculation. | |
98 | ||
753896cd | 99 | if (sign < -1 or 1 < sign) |
100 | { | |
101 | AliError(Form("Trying to set the sign to %d. This is outside the" | |
102 | " valid range of [-1..1]", sign | |
103 | )); | |
104 | fSign = 0; | |
105 | } | |
106 | ||
107 | fHit[0] = hit7; | |
108 | fHit[1] = hit8; | |
109 | fHit[2] = hit9; | |
110 | fHit[3] = hit10; | |
111 | } | |
112 | ||
113 | ||
114 | const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const | |
115 | { | |
450e0b36 | 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. | |
753896cd | 119 | |
120 | if (7 <= chamber and chamber <= 10) return fHit[chamber - 7]; | |
121 | ||
122 | AliError(Form( | |
123 | "Chamber number %d is not in the valid range [7..10].", | |
124 | int(chamber) | |
125 | )); | |
126 | return NULL; | |
127 | } | |
128 | ||
129 | ||
130 | void AliHLTMUONMansoTrack::Print(Option_t* option) const | |
131 | { | |
450e0b36 | 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. | |
753896cd | 137 | |
450e0b36 | 138 | using namespace std; |
139 | ||
753896cd | 140 | if ( option == NULL or strcmp(option, "") == 0 or |
141 | strcmp(option, "compact") == 0 | |
142 | ) | |
143 | { | |
144 | cout << *this << endl; | |
145 | } | |
146 | else if (strcmp(option, "detail") == 0) | |
147 | { | |
148 | cout << "Track ID = " << fId << "; sign = "; | |
149 | if (fSign != 0) | |
150 | cout << fSign; | |
151 | else | |
152 | cout << "unknown"; | |
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; | |
159 | ||
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++) | |
167 | { | |
168 | cout << setw(9) << i+11; | |
169 | if (fHit[i] != NULL) | |
170 | { | |
171 | cout << setw(14) << fHit[i]->X() | |
172 | << setw(12) << fHit[i]->Y() | |
173 | << setw(12) << fHit[i]->Z(); | |
174 | } | |
175 | else | |
176 | { | |
177 | cout << setw(14) << "-" | |
178 | << setw(12) << "-" | |
179 | << setw(12) << "-"; | |
180 | } | |
181 | cout << endl; | |
182 | } | |
183 | cout.width(w); // reset the field width to previous value. | |
184 | cout.flags(f); // reset the flags to previous values. | |
185 | } | |
186 | else if (strcmp(option, "all") == 0) | |
187 | { | |
188 | cout << "Track ID = " << fId << "; sign = "; | |
189 | if (fSign != 0) | |
190 | cout << fSign; | |
191 | else | |
192 | cout << "unknown"; | |
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; | |
199 | ||
200 | for (int i = 0; i < 4; i++) | |
201 | { | |
202 | cout << "===== Hit on chamber: " << i+7 << " =====" << endl; | |
203 | if (fHit[i] != NULL) | |
204 | fHit[i]->Print("all"); | |
205 | else | |
206 | cout << "No hit found." << endl; | |
207 | } | |
208 | ||
209 | cout << "===== Trigger Record =====" << endl; | |
210 | if (fTrigRec != NULL) | |
211 | fTrigRec->Print("all"); | |
212 | else | |
213 | cout << "No trigger record associated with track." << endl; | |
214 | } | |
215 | else | |
216 | { | |
217 | AliError("Unknown option specified. Can only be one of 'compact'," | |
218 | " 'detail' or 'all'." | |
219 | ); | |
220 | } | |
221 | } | |
222 | ||
223 | ||
224 | Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const | |
225 | { | |
450e0b36 | 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. | |
753896cd | 231 | |
232 | if (obj->IsA() == AliHLTMUONMansoTrack::Class()) | |
233 | { | |
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; | |
248 | return 0; | |
249 | } | |
250 | else | |
251 | { | |
252 | AliError(Form("Do not know how to compare %s to %s.", | |
253 | this->ClassName(), | |
254 | obj->ClassName() | |
255 | )); | |
256 | return -999; | |
257 | } | |
258 | } | |
259 | ||
260 | ||
261 | bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const | |
262 | { | |
450e0b36 | 263 | /// Comparison operator. |
264 | /// \param track The track object to compare to. | |
265 | /// \returns true if 'this' object is identical to 'track' else false. | |
266 | ||
753896cd | 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]; | |
272 | } |