]>
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 | ||
19 | /** | |
20 | * @file AliHLTMUONTriggerRecord.cxx | |
21 | * @author Artur Szostak <artursz@iafrica.com> | |
22 | * @date | |
23 | * @brief Implementation of the AliHLTMUONTriggerRecord class. | |
24 | */ | |
25 | ||
26 | #include "AliHLTMUONTriggerRecord.h" | |
27 | #include "AliLog.h" | |
28 | #include "mapping/AliMpDEManager.h" | |
29 | #include <cstring> | |
30 | #include <iostream> | |
31 | #include <iomanip> | |
32 | using namespace std; | |
33 | ||
34 | ClassImp(AliHLTMUONTriggerRecord); | |
35 | ||
36 | ||
37 | std::ostream& operator << ( | |
38 | std::ostream& stream, | |
39 | const AliHLTMUONTriggerRecord& trigrec | |
40 | ) | |
41 | { | |
42 | // Stream operator. | |
43 | ||
44 | stream << "ID: " << trigrec.fId | |
45 | << "; sign: " << trigrec.fSign | |
46 | << "; p = (" << trigrec.Px() | |
47 | << ", " << trigrec.Py() | |
48 | << ", " << trigrec.Pz() | |
49 | << ")"; | |
50 | return stream; | |
51 | } | |
52 | ||
53 | ||
54 | AliHLTMUONTriggerRecord::AliHLTMUONTriggerRecord( | |
55 | Int_t id, Int_t sign, | |
56 | Float_t px, Float_t py, Float_t pz, | |
57 | Int_t sourceDDL, Float_t zf, Float_t qbl | |
58 | ) : | |
59 | fId(id), fSign(sign), fMomentum(px, py, pz), fSourceDDL(sourceDDL), | |
60 | fZmiddle(zf), fQBL(qbl) | |
61 | { | |
62 | if (sign < -1 or 1 < sign) | |
63 | { | |
64 | AliError(Form("Trying to set the sign to %d. This is outside the" | |
65 | " valid range of [-1..1]", sign | |
66 | )); | |
67 | fSign = 0; | |
68 | } | |
69 | ||
70 | // Fill the debugging information to invalid values by default. | |
71 | for (int i = 0; i < 4; i++) | |
72 | { | |
73 | fDetElemId[i] = -1; | |
74 | fPatternX[i] = -1; | |
75 | fPatternY[i] = -1; | |
76 | } | |
77 | } | |
78 | ||
79 | ||
80 | const TVector3& AliHLTMUONTriggerRecord::Hit(Int_t chamber) const | |
81 | { | |
82 | // Returns the hit on the specified chamber. | |
83 | ||
84 | if (11 <= chamber and chamber <= 14) return fHit[chamber - 11]; | |
85 | ||
86 | AliError(Form( | |
87 | "Chamber number %d is not in the valid range [11..14].", | |
88 | int(chamber) | |
89 | )); | |
90 | return fHit[0]; | |
91 | } | |
92 | ||
93 | ||
94 | Int_t AliHLTMUONTriggerRecord::DetElemId(Int_t chamber) const | |
95 | { | |
96 | // Returns the detector element ID for the specified chamber associated | |
97 | // to the hit on that chamber. | |
98 | ||
99 | if (11 <= chamber and chamber <= 14) return fDetElemId[chamber - 11]; | |
100 | ||
101 | AliError(Form( | |
102 | "Chamber number %d is not in the valid range [11..14].", | |
103 | int(chamber) | |
104 | )); | |
105 | return fDetElemId[0]; | |
106 | } | |
107 | ||
108 | ||
109 | Int_t AliHLTMUONTriggerRecord::PatternX(Int_t chamber) const | |
110 | { | |
111 | // Returns the raw data X pattern of the hit on the specified chamber. | |
112 | ||
113 | if (11 <= chamber and chamber <= 14) return fPatternX[chamber - 11]; | |
114 | ||
115 | AliError(Form( | |
116 | "Chamber number %d is not in the valid range [11..14].", | |
117 | int(chamber) | |
118 | )); | |
119 | return fPatternX[0]; | |
120 | } | |
121 | ||
122 | ||
123 | Int_t AliHLTMUONTriggerRecord::PatternY(Int_t chamber) const | |
124 | { | |
125 | // Returns the raw data Y pattern of the hit on the specified chamber. | |
126 | ||
127 | if (11 <= chamber and chamber <= 14) return fPatternY[chamber - 11]; | |
128 | ||
129 | AliError(Form( | |
130 | "Chamber number %d is not in the valid range [11..14].", | |
131 | int(chamber) | |
132 | )); | |
133 | return fPatternY[0]; | |
134 | } | |
135 | ||
136 | ||
137 | void AliHLTMUONTriggerRecord::SetHit(Int_t chamber, Float_t x, Float_t y, Float_t z) | |
138 | { | |
139 | // Fills the hit coordinate on the specified chamber. | |
140 | ||
141 | if (11 <= chamber and chamber <= 14) | |
142 | { | |
143 | fHit[chamber - 11].SetXYZ(x, y, z); | |
144 | } | |
145 | else | |
146 | { | |
147 | AliError(Form( | |
148 | "Chamber number %d is not in the valid range [11..14].", | |
149 | int(chamber) | |
150 | )); | |
151 | } | |
152 | } | |
153 | ||
154 | ||
155 | void AliHLTMUONTriggerRecord::SetHitDebugInfo( | |
156 | Int_t chamber, | |
157 | Int_t detElemId, UShort_t patternX, UShort_t patternY | |
158 | ) | |
159 | { | |
160 | // Fills the debugging information corresponding to the hit on the specified chamber. | |
161 | ||
162 | if (11 <= chamber and chamber <= 14) | |
163 | { | |
164 | fDetElemId[chamber - 11] = detElemId; | |
165 | fPatternX[chamber - 11] = patternX; | |
166 | fPatternY[chamber - 11] = patternY; | |
167 | } | |
168 | else | |
169 | { | |
170 | AliError(Form( | |
171 | "Chamber number %d is not in the valid range [11..14].", | |
172 | int(chamber) | |
173 | )); | |
174 | } | |
175 | } | |
176 | ||
177 | ||
178 | void AliHLTMUONTriggerRecord::Print(Option_t* option) const | |
179 | { | |
180 | // Prints the trigger record to standard output (screen). | |
181 | ||
182 | if ( option == NULL or strcmp(option, "") == 0 or | |
183 | strcmp(option, "compact") == 0 | |
184 | ) | |
185 | { | |
186 | cout << *this << endl; | |
187 | } | |
188 | else if (strcmp(option, "detail") == 0) | |
189 | { | |
190 | cout << "Trigger record ID = " << fId << "; sign = "; | |
191 | if (fSign != 0) | |
192 | cout << fSign; | |
193 | else | |
194 | cout << "unknown"; | |
195 | cout << "; momentum: (px = " << Px() | |
196 | << " GeV/c, py = " << Py() | |
197 | << " GeV/c, pz = " << Pz() | |
198 | << " GeV/c)" << endl; | |
199 | cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = " | |
200 | << fQBL << " T.m for the momentum calculation." << endl; | |
201 | } | |
202 | else if (strcmp(option, "all") == 0) | |
203 | { | |
204 | cout << "Trigger record ID = " << fId << "; sign = "; | |
205 | if (fSign != 0) | |
206 | cout << fSign; | |
207 | else | |
208 | cout << "unknown"; | |
209 | cout << "; momentum: (px = " << Px() | |
210 | << " GeV/c, py = " << Py() | |
211 | << " GeV/c, pz = " << Pz() | |
212 | << " GeV/c)" << endl; | |
213 | cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = " | |
214 | << fQBL << " T.m for the momentum calculation." << endl; | |
215 | ||
216 | streamsize w = cout.width(); | |
217 | ios::fmtflags f = cout.flags(); | |
218 | cout << setw(9) << "Chamber" << setw(0) << " Hit:" | |
219 | << setw(8) << "X (cm)" | |
220 | << setw(12) << "Y (cm)" | |
221 | << setw(12) << "Z (cm)" | |
222 | << setw(12) << "DetElemID" | |
223 | << setw(18) << "X bit pattern" | |
224 | << setw(18) << "Y bit pattern" << endl; | |
225 | for (int i = 0; i < 4; i++) | |
226 | { | |
227 | cout << setw(9) << i+11 | |
228 | << setw(14) << fHit[i].X() | |
229 | << setw(12) << fHit[i].Y() | |
230 | << setw(12) << fHit[i].Z() | |
231 | << setw(12) << fDetElemId[i]; | |
232 | if (fPatternX[i] != -1) | |
233 | { | |
234 | // Print the X pattern as a bit pattern. | |
235 | cout << " "; | |
236 | for (Int_t j = 15; j >= 0; j--) | |
237 | cout << (((fPatternX[i] & (1 << j)) > 0) ? "1" : "0"); | |
238 | } | |
239 | else | |
240 | { | |
241 | cout << " ----------------"; | |
242 | } | |
243 | if (fPatternY[i] != -1) | |
244 | { | |
245 | // Print the Y pattern as a bit pattern. | |
246 | cout << " "; | |
247 | for (Int_t j = 15; j >= 0; j--) | |
248 | cout << (((fPatternY[i] & (1 << j)) > 0) ? "1" : "0"); | |
249 | } | |
250 | else | |
251 | { | |
252 | cout << " ----------------"; | |
253 | } | |
254 | cout << endl; | |
255 | } | |
256 | cout.width(w); // reset the field width to previous value. | |
257 | cout.flags(f); // reset the flags to previous values. | |
258 | } | |
259 | else | |
260 | { | |
261 | AliError("Unknown option specified. Can only be one of 'compact'," | |
262 | " 'detail' or 'all'." | |
263 | ); | |
264 | } | |
265 | } | |
266 | ||
267 | ||
268 | Int_t AliHLTMUONTriggerRecord::Compare(const TObject* obj) const | |
269 | { | |
270 | // We compare this object with 'obj' first by trigger record ID, then | |
271 | // by sign and finally by momentum. | |
272 | ||
273 | if (obj->IsA() == AliHLTMUONTriggerRecord::Class()) | |
274 | { | |
275 | const AliHLTMUONTriggerRecord* tr = | |
276 | static_cast<const AliHLTMUONTriggerRecord*>(obj); | |
277 | if (fId < tr->fId) return -1; | |
278 | if (fId > tr->fId) return 1; | |
279 | if (fSign < tr->fSign) return -1; | |
280 | if (fSign > tr->fSign) return 1; | |
281 | if (Px() < tr->Px()) return -1; | |
282 | if (Px() > tr->Px()) return 1; | |
283 | if (Py() < tr->Py()) return -1; | |
284 | if (Py() > tr->Py()) return 1; | |
285 | if (Pz() < tr->Pz()) return -1; | |
286 | if (Pz() > tr->Pz()) return 1; | |
287 | return 0; | |
288 | } | |
289 | else | |
290 | { | |
291 | AliError(Form("Do not know how to compare %s to %s.", | |
292 | this->ClassName(), | |
293 | obj->ClassName() | |
294 | )); | |
295 | return -999; | |
296 | } | |
297 | } | |
298 | ||
299 | ||
300 | bool AliHLTMUONTriggerRecord::operator == (const AliHLTMUONTriggerRecord& trigrec) const | |
301 | { | |
302 | // Compares the trigger record 'trigrec' to this one. | |
303 | ||
304 | return fId == trigrec.fId and fSign == trigrec.fSign | |
305 | and fMomentum == trigrec.fMomentum | |
306 | and fHit[0] == trigrec.fHit[0] and fHit[1] == trigrec.fHit[1] | |
307 | and fHit[2] == trigrec.fHit[2] and fHit[3] == trigrec.fHit[3]; | |
308 | } |