]>
Commit | Line | Data |
---|---|---|
753896cd | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
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 * | |
13 | * about the suitability of this software for any purpose. It is * | |
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 | ) : | |
72 | fId(id), fSign(sign), fMomentum(px, py, pz), | |
73 | fChi2(chi2), fTrigRec(trigrec), fZmiddle(zf), fQBL(qbl) | |
74 | { | |
450e0b36 | 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 | |
83 | /// this track. | |
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 | |
91 | /// calculation. | |
92 | ||
753896cd | 93 | if (sign < -1 or 1 < sign) |
94 | { | |
95 | AliError(Form("Trying to set the sign to %d. This is outside the" | |
96 | " valid range of [-1..1]", sign | |
97 | )); | |
98 | fSign = 0; | |
99 | } | |
100 | ||
101 | fHit[0] = hit7; | |
102 | fHit[1] = hit8; | |
103 | fHit[2] = hit9; | |
104 | fHit[3] = hit10; | |
105 | } | |
106 | ||
107 | ||
108 | const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const | |
109 | { | |
450e0b36 | 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. | |
753896cd | 113 | |
114 | if (7 <= chamber and chamber <= 10) return fHit[chamber - 7]; | |
115 | ||
116 | AliError(Form( | |
117 | "Chamber number %d is not in the valid range [7..10].", | |
118 | int(chamber) | |
119 | )); | |
120 | return NULL; | |
121 | } | |
122 | ||
123 | ||
124 | void AliHLTMUONMansoTrack::Print(Option_t* option) const | |
125 | { | |
450e0b36 | 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. | |
753896cd | 131 | |
450e0b36 | 132 | using namespace std; |
133 | ||
753896cd | 134 | if ( option == NULL or strcmp(option, "") == 0 or |
135 | strcmp(option, "compact") == 0 | |
136 | ) | |
137 | { | |
138 | cout << *this << endl; | |
139 | } | |
140 | else if (strcmp(option, "detail") == 0) | |
141 | { | |
142 | cout << "Track ID = " << fId << "; sign = "; | |
143 | if (fSign != 0) | |
144 | cout << fSign; | |
145 | else | |
146 | cout << "unknown"; | |
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; | |
153 | ||
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++) | |
161 | { | |
162 | cout << setw(9) << i+11; | |
163 | if (fHit[i] != NULL) | |
164 | { | |
165 | cout << setw(14) << fHit[i]->X() | |
166 | << setw(12) << fHit[i]->Y() | |
167 | << setw(12) << fHit[i]->Z(); | |
168 | } | |
169 | else | |
170 | { | |
171 | cout << setw(14) << "-" | |
172 | << setw(12) << "-" | |
173 | << setw(12) << "-"; | |
174 | } | |
175 | cout << endl; | |
176 | } | |
177 | cout.width(w); // reset the field width to previous value. | |
178 | cout.flags(f); // reset the flags to previous values. | |
179 | } | |
180 | else if (strcmp(option, "all") == 0) | |
181 | { | |
182 | cout << "Track ID = " << fId << "; sign = "; | |
183 | if (fSign != 0) | |
184 | cout << fSign; | |
185 | else | |
186 | cout << "unknown"; | |
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; | |
193 | ||
194 | for (int i = 0; i < 4; i++) | |
195 | { | |
196 | cout << "===== Hit on chamber: " << i+7 << " =====" << endl; | |
197 | if (fHit[i] != NULL) | |
198 | fHit[i]->Print("all"); | |
199 | else | |
200 | cout << "No hit found." << endl; | |
201 | } | |
202 | ||
203 | cout << "===== Trigger Record =====" << endl; | |
204 | if (fTrigRec != NULL) | |
205 | fTrigRec->Print("all"); | |
206 | else | |
207 | cout << "No trigger record associated with track." << endl; | |
208 | } | |
209 | else | |
210 | { | |
211 | AliError("Unknown option specified. Can only be one of 'compact'," | |
212 | " 'detail' or 'all'." | |
213 | ); | |
214 | } | |
215 | } | |
216 | ||
217 | ||
218 | Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const | |
219 | { | |
450e0b36 | 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. | |
753896cd | 225 | |
226 | if (obj->IsA() == AliHLTMUONMansoTrack::Class()) | |
227 | { | |
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; | |
242 | return 0; | |
243 | } | |
244 | else | |
245 | { | |
246 | AliError(Form("Do not know how to compare %s to %s.", | |
247 | this->ClassName(), | |
248 | obj->ClassName() | |
249 | )); | |
250 | return -999; | |
251 | } | |
252 | } | |
253 | ||
254 | ||
255 | bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const | |
256 | { | |
450e0b36 | 257 | /// Comparison operator. |
258 | /// \param track The track object to compare to. | |
259 | /// \returns true if 'this' object is identical to 'track' else false. | |
260 | ||
753896cd | 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]; | |
266 | } |