Line data Source code
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 AliHLTMUONRecHit.cxx
21 : /// @author Artur Szostak <artursz@iafrica.com>
22 : /// @date 29 Sep 2007
23 : /// @brief Implementation of the AliHLTMUONRecHit class.
24 : ///
25 : /// The AliHLTMUONRecHit object is used to store 3D hit coordinates translated
26 : /// from dHLT raw data.
27 : ///
28 :
29 : #include "AliHLTMUONRecHit.h"
30 : #include "AliLog.h"
31 : #include "AliMpDEManager.h"
32 : #include <cstring>
33 : #include <iostream>
34 : #include <iomanip>
35 :
36 6 : ClassImp(AliHLTMUONRecHit);
37 6 : ClassImp(AliHLTMUONRecHit::AliChannel);
38 :
39 :
40 : std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit& hit)
41 : {
42 : /// Stream operator for std::ostream classes.
43 : /// \param stream The output stream object being written to.
44 : /// \param track The hit object to print to the stream.
45 : /// \returns Returns 'stream'.
46 :
47 0 : stream << "(" << hit.X() << ", " << hit.Y() << ", " << hit.Z() << ")";
48 0 : return stream;
49 : }
50 :
51 :
52 : void AliHLTMUONRecHit::SetDebugInfo(
53 : Int_t detElemId, Int_t clusterId,
54 : UShort_t nChExpB, UShort_t nChExpNB,
55 : Float_t chargeB, Float_t chargeNB,
56 : Int_t sourceDDL
57 : )
58 : {
59 : /// Sets the extra debugging information.
60 : /// @param detElemId The detector element ID.
61 : /// @param clusterId Cluster ID of the hit's cluster.
62 : /// @param nChExpB Number of expected channels in the bending plane forming the cluster.
63 : /// @param nChExpNB Number of expected channels in the non-bending plane forming the cluster.
64 : /// @param chargeB The charge of the cluster in the bending plane.
65 : /// @param chargeNB The charge of the cluster in the non-bending plane.
66 : /// @param sourceDDL The source DDL of this hit.
67 :
68 0 : fSourceDDL = sourceDDL;
69 0 : fDetElemId = detElemId;
70 0 : fClusterId = clusterId;
71 0 : fNchExpB = nChExpB;
72 0 : fNchExpNB = nChExpNB;
73 0 : fChargeB = chargeB;
74 0 : fChargeNB = chargeNB;
75 0 : }
76 :
77 :
78 : Int_t AliHLTMUONRecHit::Chamber(bool warn) const
79 : {
80 : /// Returns the chamber ID for this hit.
81 : /// \param warn Indicates if any warning should be printed in case of problems.
82 : /// \returns The chamber number of this hit in the range [1..14] or -1 if not known.
83 :
84 : //FIXME: 16 March 2010 AliMpDEManager::GetChamberId is not behaving as the
85 : // documentation indicates anymore and now causes a segfault.
86 : //if (fDetElemId != -1) return AliMpDEManager::GetChamberId(fDetElemId, warn);
87 0 : if (fDetElemId != -1) return fDetElemId/100;
88 :
89 0 : if (warn)
90 : {
91 0 : AliWarning("Neither the DDL source nor the detector element ID was not set,"
92 : " so we do not know on which chamber this hit was reconstructed."
93 : );
94 0 : }
95 0 : return -1;
96 0 : }
97 :
98 :
99 : void AliHLTMUONRecHit::AddChannel(
100 : Short_t buspatch, Short_t manu, Short_t channel, Short_t signal,
101 : UInt_t rawDataWord
102 : )
103 : {
104 : /// Adds a new channel to the channels list forming this hit's cluster.
105 : /// @param buspatch The bus patch ID of the channel.
106 : /// @param manu The MANU number
107 : /// @param channel The MANU channel address.
108 : /// @param signal The ADC signal value measured on the channel.
109 : /// @param rawDataWord This is the raw data word as read from the DDL.
110 :
111 0 : Int_t index = fChannels.GetEntriesFast();
112 0 : new (fChannels[index]) AliChannel(buspatch, manu, channel, signal, rawDataWord);
113 0 : }
114 :
115 :
116 : void AliHLTMUONRecHit::Print(Option_t* option) const
117 : {
118 : /// Prints the coordinates of this hit to standard output (screen).
119 : /// \param option Can be one of the following:
120 : /// - "compact" - prints in a compact format.
121 : /// - "detail" - prints hit information in a more detailed format.
122 : /// - "all" - prints a full dump of the hit object.
123 :
124 : using namespace std;
125 :
126 0 : if ( option == NULL or strcmp(option, "") == 0 or
127 0 : strcmp(option, "compact") == 0
128 : )
129 : {
130 0 : cout << *this << endl;
131 0 : }
132 0 : else if (strcmp(option, "detail") == 0)
133 : {
134 0 : cout << "(x = " << X() << " cm, y = " << Y()
135 0 : << " cm, z = " << Z()
136 0 : << " cm); source DDL = " << fSourceDDL
137 0 : << "; DetElemID = " << fDetElemId
138 0 : << "; cluster ID = " << fClusterId
139 0 : << "; total charge = " << fChargeB + fChargeNB
140 0 : << "; expected #ch = " << fNchExpB + fNchExpNB << endl;
141 0 : }
142 0 : else if (strcmp(option, "all") == 0)
143 : {
144 0 : streamsize w = cout.width();
145 0 : ios::fmtflags f = cout.flags();
146 0 : cout << "RecHit: (x = " << X() << " cm, y = " << Y()
147 0 : << " cm, z = " << Z()
148 0 : << " cm); source DDL = " << fSourceDDL
149 0 : << "; DetElemID = " << fDetElemId
150 0 : << "; cluster ID = " << fClusterId
151 0 : << endl;
152 0 : cout << setw(0) << " Plane:" << setw(14) << "Bending" << setw(14) << "Non-bending" << endl;
153 0 : cout << setw(0) << " Charge:" << setw(14) << fChargeB << setw(14) << fChargeNB << endl;
154 0 : cout << setw(0) << "Expected channels #:" << setw(14) << fNchExpB << setw(14) << fNchExpNB << setw(0) << endl;
155 0 : if (fChannels.GetEntriesFast() == 0)
156 : {
157 0 : cout << "No channels found for this hit." << endl;
158 0 : }
159 : else
160 : {
161 0 : cout << setw(12) << "MANU"
162 0 : << setw(12) << "Channel"
163 0 : << setw(12) << "Signal"
164 0 : << setw(15) << "Raw data word" << endl;
165 0 : cout << showbase;
166 0 : for (Int_t i = 0; i < fChannels.GetEntriesFast(); i++)
167 : {
168 : const AliHLTMUONRecHit::AliChannel* c =
169 0 : static_cast<const AliHLTMUONRecHit::AliChannel*>(fChannels[i]);
170 0 : cout << dec << setw(12) << c->Manu()
171 0 : << setw(12) << c->Address()
172 0 : << setw(12) << c->Signal()
173 0 : << " " << hex << setw(10) << internal;
174 0 : ios::char_type fc = cout.fill('0');
175 0 : cout << c->RawDataWord() << right << endl;
176 0 : cout.fill(fc);
177 : }
178 : }
179 0 : cout.width(w); // reset the field width to previous value.
180 0 : cout.flags(f); // reset the flags to previous values.
181 0 : }
182 : else
183 : {
184 0 : AliError("Unknown option specified. Can only be one of 'compact',"
185 : " 'detail' or 'all'."
186 : );
187 : }
188 0 : }
189 :
190 :
191 : Int_t AliHLTMUONRecHit::Compare(const TObject* obj) const
192 : {
193 : /// We compare this object with 'obj' first by X, then Y, then Z.
194 : /// \param obj This is the object to compare to. It must be of type AliHLTMUONRecHit.
195 : /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
196 : /// objects are the same.
197 :
198 0 : if (obj->IsA() == AliHLTMUONRecHit::Class())
199 : {
200 0 : const AliHLTMUONRecHit* h = static_cast<const AliHLTMUONRecHit*>(obj);
201 0 : if (X() < h->X()) return -1;
202 0 : if (X() > h->X()) return 1;
203 0 : if (Y() < h->Y()) return -1;
204 0 : if (Y() > h->Y()) return 1;
205 0 : if (Z() < h->Z()) return -1;
206 0 : if (Z() > h->Z()) return 1;
207 0 : return 0;
208 : }
209 : else
210 : {
211 0 : AliError(Form("Do not know how to compare %s to %s.",
212 : this->ClassName(),
213 : obj->ClassName()
214 : ));
215 0 : return -999;
216 : }
217 0 : }
218 :
219 :
220 : std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit::AliChannel& c)
221 : {
222 : /// Stream operator for std::ostream classes.
223 : /// \param stream The output stream object being written to.
224 : /// \param c The channel object to print to the stream.
225 : /// \returns Returns 'stream'.
226 :
227 0 : stream << "Channel: " << c.fManu << " , " << c.fAddress
228 0 : << "; ADC: " << c.fSignal;
229 0 : return stream;
230 : }
231 :
232 :
233 : void AliHLTMUONRecHit::AliChannel::Print(Option_t* option) const
234 : {
235 : /// Prints the details of this channel to standard output (screen).
236 : /// \param option Can be one of the following:
237 : /// - "compact" - prints in a compact format.
238 : /// - "detail" - prints channel information in a more detailed format.
239 :
240 : using namespace std;
241 :
242 0 : if ( option == NULL or strcmp(option, "") == 0 or
243 0 : strcmp(option, "compact") == 0
244 : )
245 : {
246 0 : cout << *this << endl;
247 0 : }
248 0 : else if (strcmp(option, "detail") == 0)
249 : {
250 0 : streamsize w = cout.width();
251 0 : ios::fmtflags f = cout.flags();
252 0 : cout << "MANU = " << fManu << ", Channel address = " << fAddress
253 0 : << ", Signal = " << fSignal
254 0 : << "; Raw data word = " << hex << setw(10) << internal;
255 0 : ios::char_type fc = cout.fill('0');
256 0 : cout << fRawDataWord << endl;
257 0 : cout.fill(fc); // reset fill character
258 0 : cout.width(w); // reset the field width to previous value.
259 0 : cout.flags(f); // reset the flags to previous values.
260 0 : }
261 : else
262 : {
263 0 : AliError("Unknown option specified. Can only be one of"
264 : " 'compact' or 'detail'."
265 : );
266 : }
267 0 : }
268 :
269 :
270 : Int_t AliHLTMUONRecHit::AliChannel::Compare(const TObject* obj) const
271 : {
272 : /// We compare this object with 'obj' first by MANU number, then by MANU channel
273 : /// address, then ADC signal.
274 : /// \param obj This is the object to compare to. It must be of type AliHLTMUONRecHit::Channel.
275 : /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
276 : /// objects are the same.
277 :
278 0 : if (obj->IsA() == AliChannel::Class())
279 : {
280 0 : const AliChannel* c = static_cast<const AliChannel*>(obj);
281 0 : if (fManu < c->Manu()) return -1;
282 0 : if (fManu > c->Manu()) return 1;
283 0 : if (fAddress < c->Address()) return -1;
284 0 : if (fAddress > c->Address()) return 1;
285 0 : if (fSignal < c->Signal()) return -1;
286 0 : if (fSignal > c->Signal()) return 1;
287 0 : return 0;
288 : }
289 : else
290 : {
291 0 : AliError(Form("Do not know how to compare %s to %s.",
292 : this->ClassName(),
293 : obj->ClassName()
294 : ));
295 0 : return -999;
296 : }
297 0 : }
|