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 AliHLTMUONTriggerRecord.cxx
21 /// @author Artur Szostak <artursz@iafrica.com>
23 /// @brief Implementation of the AliHLTMUONTriggerRecord class.
25 /// Code for the trigger record structure containing data corresponding to the
26 /// L0 trigger local board output.
29 #include "AliHLTMUONTriggerRecord.h"
31 #include "mapping/AliMpDEManager.h"
37 ClassImp(AliHLTMUONTriggerRecord);
40 std::ostream& operator << (
42 const AliHLTMUONTriggerRecord& trigrec
45 /// Stream operator for std::ostream classes.
46 /// \param stream The output stream object being written to.
47 /// \param trigrec The trigger record object to print to the stream.
48 /// \returns Returns 'stream'.
50 stream << "ID: " << trigrec.fId
51 << "; sign: " << trigrec.fSign
52 << "; p = (" << trigrec.Px()
53 << ", " << trigrec.Py()
54 << ", " << trigrec.Pz()
60 AliHLTMUONTriggerRecord::AliHLTMUONTriggerRecord(
62 Float_t px, Float_t py, Float_t pz,
63 Int_t sourceDDL, Float_t zf, Float_t qbl
65 fId(id), fSign(sign), fMomentum(px, py, pz), fSourceDDL(sourceDDL),
66 fZmiddle(zf), fQBL(qbl)
68 /// Constructor for creating a new trigger record.
69 /// @param id The trigger record ID number unique for an event.
70 /// @param sign The particle's sign. Must be -1, 1 or 0 if the sign is unknown.
71 /// @param px X component of the particle's momentum.
72 /// @param py Y component of the particle's momentum.
73 /// @param pz Z component of the particle's momentum.
74 /// @param sourceDDL The DDL from which this trigger record originates.
75 /// @param zf The Z coordinate of the middle of the magnetic field assumed
76 /// during momentum calculation.
77 /// @param qbl The integrated magnetic field strength assumed during momentum
80 if (sign < -1 or 1 < sign)
82 AliError(Form("Trying to set the sign to %d. This is outside the"
83 " valid range of [-1..1]", sign
88 // Fill the debugging information to invalid values by default.
89 for (int i = 0; i < 4; i++)
98 const TVector3& AliHLTMUONTriggerRecord::Hit(Int_t chamber) const
100 /// Returns the hit on the specified chamber.
101 /// \param chamber The chamber for which to fetch the hit. Valid values
102 /// are in the range [11..14].
103 /// \returns The 3D corrdinate of the hit.
105 if (11 <= chamber and chamber <= 14) return fHit[chamber - 11];
108 "Chamber number %d is not in the valid range [11..14].",
115 Int_t AliHLTMUONTriggerRecord::DetElemId(Int_t chamber) const
117 /// Returns the detector element ID for the specified chamber associated
118 /// to the hit on that chamber.
119 /// @param chamber The chamber for which to fetch the detector element ID.
120 /// Valid values are in the range [11..14].
121 /// \returns The detector element ID or -1 if not known.
123 if (11 <= chamber and chamber <= 14) return fDetElemId[chamber - 11];
126 "Chamber number %d is not in the valid range [11..14].",
129 return fDetElemId[0];
133 Int_t AliHLTMUONTriggerRecord::PatternX(Int_t chamber) const
135 /// Returns the raw data X pattern of the hit on the specified chamber.
136 /// \param chamber The chamber for which to fetch the bit pattern.
137 /// Valid values are in the range [11..14].
138 /// \returns X bit pattern of the hit.
140 if (11 <= chamber and chamber <= 14) return fPatternX[chamber - 11];
143 "Chamber number %d is not in the valid range [11..14].",
150 Int_t AliHLTMUONTriggerRecord::PatternY(Int_t chamber) const
152 /// Returns the raw data Y pattern of the hit on the specified chamber.
153 /// \param chamber The chamber for which to fetch the bit pattern.
154 /// Valid values are in the range [11..14].
155 /// \returns Y bit pattern of the hit.
157 if (11 <= chamber and chamber <= 14) return fPatternY[chamber - 11];
160 "Chamber number %d is not in the valid range [11..14].",
167 void AliHLTMUONTriggerRecord::SetHit(Int_t chamber, Float_t x, Float_t y, Float_t z)
169 /// Fills the hit coordinate on the specified chamber.
170 /// @param chamber The chamber for which to set the hit. Valid values
171 /// are in the range [11..14].
172 /// @param x The X coordinate of the hit in centimetres.
173 /// @param y The Y coordinate of the hit in centimetres.
174 /// @param z The Z coordinate of the hit in centimetres.
176 if (11 <= chamber and chamber <= 14)
178 fHit[chamber - 11].SetXYZ(x, y, z);
183 "Chamber number %d is not in the valid range [11..14].",
190 void AliHLTMUONTriggerRecord::SetHitDebugInfo(
192 Int_t detElemId, UShort_t patternX, UShort_t patternY
195 /// Fills the debugging information corresponding to the hit on the specified chamber.
196 /// Sets the debugging information for the hit on the specified chamber.
197 /// @param chamber The chamber for which to set the debugging information.
198 /// Valid values are in the range [11..14].
199 /// @param detElemId The detector element ID.
200 /// @param patterX The X bit pattern from the local board.
201 /// @param patterY The Y bit pattern from the local board.
203 if (11 <= chamber and chamber <= 14)
205 fDetElemId[chamber - 11] = detElemId;
206 fPatternX[chamber - 11] = patternX;
207 fPatternY[chamber - 11] = patternY;
212 "Chamber number %d is not in the valid range [11..14].",
219 void AliHLTMUONTriggerRecord::Print(Option_t* option) const
221 /// Prints the trigger record to standard output (screen).
222 /// \param option Can be one of the following:
223 /// - "compact" - prints in a compact format.
224 /// - "detail" - prints track information in a more detailed format.
225 /// - "all" - prints a full dump of the track object.
229 if ( option == NULL or strcmp(option, "") == 0 or
230 strcmp(option, "compact") == 0
233 cout << *this << endl;
235 else if (strcmp(option, "detail") == 0)
237 cout << "Trigger record ID = " << fId << "; sign = ";
242 cout << "; momentum: (px = " << Px()
243 << " GeV/c, py = " << Py()
244 << " GeV/c, pz = " << Pz()
245 << " GeV/c)" << endl;
246 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
247 << fQBL << " T.m for the momentum calculation." << endl;
249 else if (strcmp(option, "all") == 0)
251 cout << "Trigger record ID = " << fId << "; sign = ";
256 cout << "; momentum: (px = " << Px()
257 << " GeV/c, py = " << Py()
258 << " GeV/c, pz = " << Pz()
259 << " GeV/c)" << endl;
260 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
261 << fQBL << " T.m for the momentum calculation." << endl;
263 streamsize w = cout.width();
264 ios::fmtflags f = cout.flags();
265 cout << setw(9) << "Chamber" << setw(0) << " Hit:"
266 << setw(8) << "X (cm)"
267 << setw(12) << "Y (cm)"
268 << setw(12) << "Z (cm)"
269 << setw(12) << "DetElemID"
270 << setw(18) << "X bit pattern"
271 << setw(18) << "Y bit pattern" << endl;
272 for (int i = 0; i < 4; i++)
274 cout << setw(9) << i+11
275 << setw(14) << fHit[i].X()
276 << setw(12) << fHit[i].Y()
277 << setw(12) << fHit[i].Z()
278 << setw(12) << fDetElemId[i];
279 if (fPatternX[i] != -1)
281 // Print the X pattern as a bit pattern.
283 for (Int_t j = 15; j >= 0; j--)
284 cout << (((fPatternX[i] & (1 << j)) > 0) ? "1" : "0");
288 cout << " ----------------";
290 if (fPatternY[i] != -1)
292 // Print the Y pattern as a bit pattern.
294 for (Int_t j = 15; j >= 0; j--)
295 cout << (((fPatternY[i] & (1 << j)) > 0) ? "1" : "0");
299 cout << " ----------------";
303 cout.width(w); // reset the field width to previous value.
304 cout.flags(f); // reset the flags to previous values.
308 AliError("Unknown option specified. Can only be one of 'compact',"
309 " 'detail' or 'all'."
315 Int_t AliHLTMUONTriggerRecord::Compare(const TObject* obj) const
317 /// We compare this object with 'obj' first by trigger record ID, then
318 /// by sign and finally by momentum.
319 /// \param obj This is the object to compare to. It must be of type AliHLTMUONTriggerRecord.
320 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
321 /// objects are the same.
323 if (obj->IsA() == AliHLTMUONTriggerRecord::Class())
325 const AliHLTMUONTriggerRecord* tr =
326 static_cast<const AliHLTMUONTriggerRecord*>(obj);
327 if (fId < tr->fId) return -1;
328 if (fId > tr->fId) return 1;
329 if (fSign < tr->fSign) return -1;
330 if (fSign > tr->fSign) return 1;
331 if (Px() < tr->Px()) return -1;
332 if (Px() > tr->Px()) return 1;
333 if (Py() < tr->Py()) return -1;
334 if (Py() > tr->Py()) return 1;
335 if (Pz() < tr->Pz()) return -1;
336 if (Pz() > tr->Pz()) return 1;
341 AliError(Form("Do not know how to compare %s to %s.",
350 bool AliHLTMUONTriggerRecord::operator == (const AliHLTMUONTriggerRecord& trigrec) const
352 /// Compares the trigger record 'trigrec' to this one.
353 /// \param trigrec The trigger record object to compare to.
354 /// \returns true if 'this' object is identical to 'trigrec' else false.
356 return fId == trigrec.fId and fSign == trigrec.fSign
357 and fMomentum == trigrec.fMomentum
358 and fHit[0] == trigrec.fHit[0] and fHit[1] == trigrec.fHit[1]
359 and fHit[2] == trigrec.fHit[2] and fHit[3] == trigrec.fHit[3];