]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/AliHLTMUONMansoTrack.cxx
The high performance decoder is now under MUON/
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONMansoTrack.cxx
CommitLineData
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 AliHLTMUONMansoTrack.cxx
21 * @author Artur Szostak <artursz@iafrica.com>
22 * @date
23 * @brief Implementation of the AliHLTMUONMansoTrack class.
24 */
25
26#include "AliHLTMUONMansoTrack.h"
27#include "AliLog.h"
28#include "mapping/AliMpDEManager.h"
29#include <cstring>
30#include <iostream>
31#include <iomanip>
32using namespace std;
33
34ClassImp(AliHLTMUONMansoTrack);
35
36
37std::ostream& operator << (
38 std::ostream& stream,
39 const AliHLTMUONMansoTrack& track
40 )
41{
42// Stream operator.
43
44 stream << "ID: " << track.fId
45 << "; sign: " << track.fSign
46 << "; p = (" << track.Px()
47 << ", " << track.Py()
48 << ", " << track.Pz()
49 << "); chi^2: " << track.fChi2;
50 return stream;
51}
52
53
54AliHLTMUONMansoTrack::AliHLTMUONMansoTrack(
55 Int_t id, Int_t sign,
56 Float_t px, Float_t py, Float_t pz,
57 Float_t chi2,
58 const AliHLTMUONTriggerRecord* trigrec,
59 const AliHLTMUONRecHit* hit7,
60 const AliHLTMUONRecHit* hit8,
61 const AliHLTMUONRecHit* hit9,
62 const AliHLTMUONRecHit* hit10,
63 Float_t zf, Float_t qbl
64 ) :
65 fId(id), fSign(sign), fMomentum(px, py, pz),
66 fChi2(chi2), fTrigRec(trigrec), fZmiddle(zf), fQBL(qbl)
67{
68 if (sign < -1 or 1 < sign)
69 {
70 AliError(Form("Trying to set the sign to %d. This is outside the"
71 " valid range of [-1..1]", sign
72 ));
73 fSign = 0;
74 }
75
76 fHit[0] = hit7;
77 fHit[1] = hit8;
78 fHit[2] = hit9;
79 fHit[3] = hit10;
80}
81
82
83const AliHLTMUONRecHit* AliHLTMUONMansoTrack::Hit(Int_t chamber) const
84{
85// Returns the hit on the specified chamber.
86
87 if (7 <= chamber and chamber <= 10) return fHit[chamber - 7];
88
89 AliError(Form(
90 "Chamber number %d is not in the valid range [7..10].",
91 int(chamber)
92 ));
93 return NULL;
94}
95
96
97void AliHLTMUONMansoTrack::Print(Option_t* option) const
98{
99// Prints the track information to standard output (screen).
100
101 if ( option == NULL or strcmp(option, "") == 0 or
102 strcmp(option, "compact") == 0
103 )
104 {
105 cout << *this << endl;
106 }
107 else if (strcmp(option, "detail") == 0)
108 {
109 cout << "Track ID = " << fId << "; sign = ";
110 if (fSign != 0)
111 cout << fSign;
112 else
113 cout << "unknown";
114 cout << "; momentum: (px = " << Px()
115 << " GeV/c, py = " << Py()
116 << " GeV/c, pz = " << Pz()
117 << " GeV/c); chi^2 = " << fChi2 << endl;
118 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
119 << fQBL << " T.m for the momentum calculation." << endl;
120
121 streamsize w = cout.width();
122 ios::fmtflags f = cout.flags();
123 cout << setw(9) << "Chamber" << setw(0) << " Hit:"
124 << setw(8) << "X (cm)"
125 << setw(12) << "Y (cm)"
126 << setw(12) << "Z (cm)" << endl;
127 for (int i = 0; i < 4; i++)
128 {
129 cout << setw(9) << i+11;
130 if (fHit[i] != NULL)
131 {
132 cout << setw(14) << fHit[i]->X()
133 << setw(12) << fHit[i]->Y()
134 << setw(12) << fHit[i]->Z();
135 }
136 else
137 {
138 cout << setw(14) << "-"
139 << setw(12) << "-"
140 << setw(12) << "-";
141 }
142 cout << endl;
143 }
144 cout.width(w); // reset the field width to previous value.
145 cout.flags(f); // reset the flags to previous values.
146 }
147 else if (strcmp(option, "all") == 0)
148 {
149 cout << "Track ID = " << fId << "; sign = ";
150 if (fSign != 0)
151 cout << fSign;
152 else
153 cout << "unknown";
154 cout << "; momentum: (px = " << Px()
155 << " GeV/c, py = " << Py()
156 << " GeV/c, pz = " << Pz()
157 << " GeV/c); chi^2 = " << fChi2 << endl;
158 cout << "Used Zmiddle = " << fZmiddle << " cm and QBL = "
159 << fQBL << " T.m for the momentum calculation." << endl;
160
161 for (int i = 0; i < 4; i++)
162 {
163 cout << "===== Hit on chamber: " << i+7 << " =====" << endl;
164 if (fHit[i] != NULL)
165 fHit[i]->Print("all");
166 else
167 cout << "No hit found." << endl;
168 }
169
170 cout << "===== Trigger Record =====" << endl;
171 if (fTrigRec != NULL)
172 fTrigRec->Print("all");
173 else
174 cout << "No trigger record associated with track." << endl;
175 }
176 else
177 {
178 AliError("Unknown option specified. Can only be one of 'compact',"
179 " 'detail' or 'all'."
180 );
181 }
182}
183
184
185Int_t AliHLTMUONMansoTrack::Compare(const TObject* obj) const
186{
187// We compare this object with 'obj' first by track ID, then by sign, then
188// by momentum and finally by chi2.
189
190 if (obj->IsA() == AliHLTMUONMansoTrack::Class())
191 {
192 const AliHLTMUONMansoTrack* t =
193 static_cast<const AliHLTMUONMansoTrack*>(obj);
194 if (fId < t->fId) return -1;
195 if (fId > t->fId) return 1;
196 if (fSign < t->fSign) return -1;
197 if (fSign > t->fSign) return 1;
198 if (Px() < t->Px()) return -1;
199 if (Px() > t->Px()) return 1;
200 if (Py() < t->Py()) return -1;
201 if (Py() > t->Py()) return 1;
202 if (Pz() < t->Pz()) return -1;
203 if (Pz() > t->Pz()) return 1;
204 if (fChi2 < t->fChi2) return -1;
205 if (fChi2 > t->fChi2) return 1;
206 return 0;
207 }
208 else
209 {
210 AliError(Form("Do not know how to compare %s to %s.",
211 this->ClassName(),
212 obj->ClassName()
213 ));
214 return -999;
215 }
216}
217
218
219bool AliHLTMUONMansoTrack::operator == (const AliHLTMUONMansoTrack& track) const
220{
221 return fId == track.fId and fSign == track.fSign
222 and fMomentum == track.fMomentum
223 and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec
224 and fHit[0] == track.fHit[0] and fHit[1] == track.fHit[1]
225 and fHit[2] == track.fHit[2] and fHit[3] == track.fHit[3];
226}