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 AliHLTMUONRecHit.cxx
21 /// @author Artur Szostak <artursz@iafrica.com>
23 /// @brief Implementation of the AliHLTMUONRecHit class.
25 /// The AliHLTMUONRecHit object is used to store 3D hit coordinates translated
26 /// from dHLT raw data.
29 #include "AliHLTMUONRecHit.h"
31 #include "mapping/AliMpDEManager.h"
36 ClassImp(AliHLTMUONRecHit);
37 ClassImp(AliHLTMUONRecHit::AliChannel);
40 std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit& hit)
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'.
47 stream << "(" << hit.X() << ", " << hit.Y() << ", " << hit.Z() << ")";
52 void AliHLTMUONRecHit::SetDebugInfo(
53 Int_t detElemId, Int_t clusterId, UInt_t nChExp, Int_t sourceDDL
56 /// Sets the debugging information.
57 /// @param detElemId The detector element ID.
58 /// @param clusterId Cluster ID of the hit's cluster.
59 /// @param nChExp Number of expected channels forming the cluster.
60 /// @param sourceDDL The source DDL of this hit.
62 fSourceDDL = sourceDDL;
63 fDetElemId = detElemId;
64 fClusterId = clusterId;
69 Int_t AliHLTMUONRecHit::Chamber(bool warn) const
71 /// Returns the chamber ID for this hit.
72 /// \param warn Indicates if any warning should be printed in case of problems.
73 /// \returns The chamber number of this hit in the range [1..14] or -1 if not known.
77 if (fSourceDDL < 1 or fSourceDDL > 20)
79 return ((fSourceDDL-1) / 2) + 1;
83 AliError(Form("The DDL source number: %d is out of range."
84 " Valid values are [1..20]", fSourceDDL
88 if (fDetElemId != -1) return AliMpDEManager::GetChamberId(fDetElemId, warn);
92 AliWarning("Neither the DDL source nor the detector element ID was not set,"
93 " so we do not know on which chamber this hit was reconstructed."
100 void AliHLTMUONRecHit::AddChannel(
101 Short_t manu, Short_t channel, Short_t signal,
105 /// Adds a new channel to the channels list forming this hit's cluster.
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.
111 Int_t index = fChannels.GetEntriesFast();
112 new (fChannels[index]) AliChannel(manu, channel, signal, rawDataWord);
116 void AliHLTMUONRecHit::Print(Option_t* option) const
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.
126 if ( option == NULL or strcmp(option, "") == 0 or
127 strcmp(option, "compact") == 0
130 cout << *this << endl;
132 else if (strcmp(option, "detail") == 0)
134 cout << "(x = " << X() << " cm, y = " << Y()
135 << " cm, z = " << Z()
136 << " cm); source DDL = " << fSourceDDL
137 << "; DetElemID = " << fDetElemId
138 << "; cluster ID = " << fClusterId
139 << "; expected #ch = " << fNchExp << endl;
141 else if (strcmp(option, "all") == 0)
143 cout << "(x = " << X() << " cm, y = " << Y()
144 << " cm, z = " << Z()
145 << " cm); source DDL = " << fSourceDDL
146 << "; DetElemID = " << fDetElemId
147 << "; cluster ID = " << fClusterId
148 << "; expected #ch = " << fNchExp << endl;
149 if (fChannels.GetEntriesFast() == 0)
151 cout << "No channels found for this hit." << endl;
155 streamsize w = cout.width();
156 ios::fmtflags f = cout.flags();
157 cout << setw(12) << "MANU"
158 << setw(12) << "Channel"
159 << setw(12) << "Signal"
160 << setw(15) << "Raw data word" << endl;
162 for (Int_t i = 0; i < fChannels.GetEntriesFast(); i++)
164 const AliHLTMUONRecHit::AliChannel* c =
165 static_cast<const AliHLTMUONRecHit::AliChannel*>(fChannels[i]);
166 cout << dec << setw(12) << c->Manu()
167 << setw(12) << c->Address()
168 << setw(12) << c->Signal()
169 << " " << hex << setw(10) << internal;
170 ios::char_type fc = cout.fill('0');
171 cout << c->RawDataWord() << right << endl;
174 cout.width(w); // reset the field width to previous value.
175 cout.flags(f); // reset the flags to previous values.
180 AliError("Unknown option specified. Can only be one of 'compact',"
181 " 'detail' or 'all'."
187 Int_t AliHLTMUONRecHit::Compare(const TObject* obj) const
189 /// We compare this object with 'obj' first by X, then Y, then Z.
190 /// \param obj This is the object to compare to. It must be of type AliHLTMUONRecHit.
191 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
192 /// objects are the same.
194 if (obj->IsA() == AliHLTMUONRecHit::Class())
196 const AliHLTMUONRecHit* h = static_cast<const AliHLTMUONRecHit*>(obj);
197 if (X() < h->X()) return -1;
198 if (X() > h->X()) return 1;
199 if (Y() < h->Y()) return -1;
200 if (Y() > h->Y()) return 1;
201 if (Z() < h->Z()) return -1;
202 if (Z() > h->Z()) return 1;
207 AliError(Form("Do not know how to compare %s to %s.",
216 std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit::AliChannel& c)
218 /// Stream operator for std::ostream classes.
219 /// \param stream The output stream object being written to.
220 /// \param c The channel object to print to the stream.
221 /// \returns Returns 'stream'.
223 stream << "Channel: " << c.fManu << " , " << c.fAddress
224 << "; ADC: " << c.fSignal;
229 void AliHLTMUONRecHit::AliChannel::Print(Option_t* option) const
231 /// Prints the details of this channel to standard output (screen).
232 /// \param option Can be one of the following:
233 /// - "compact" - prints in a compact format.
234 /// - "detail" - prints channel information in a more detailed format.
238 if ( option == NULL or strcmp(option, "") == 0 or
239 strcmp(option, "compact") == 0
242 cout << *this << endl;
244 else if (strcmp(option, "detail") == 0)
246 streamsize w = cout.width();
247 ios::fmtflags f = cout.flags();
248 cout << "MANU = " << fManu << ", Channel address = " << fAddress
249 << ", Signal = " << fSignal
250 << "; Raw data word = " << hex << setw(10) << internal;
251 ios::char_type fc = cout.fill('0');
252 cout << fRawDataWord << endl;
253 cout.fill(fc); // reset fill character
254 cout.width(w); // reset the field width to previous value.
255 cout.flags(f); // reset the flags to previous values.
259 AliError("Unknown option specified. Can only be one of"
260 " 'compact' or 'detail'."
266 Int_t AliHLTMUONRecHit::AliChannel::Compare(const TObject* obj) const
268 /// We compare this object with 'obj' first by MANU number, then by MANU channel
269 /// address, then ADC signal.
270 /// \param obj This is the object to compare to. It must be of type AliHLTMUONRecHit::Channel.
271 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
272 /// objects are the same.
274 if (obj->IsA() == AliChannel::Class())
276 const AliChannel* c = static_cast<const AliChannel*>(obj);
277 if (fManu < c->Manu()) return -1;
278 if (fManu > c->Manu()) return 1;
279 if (fAddress < c->Address()) return -1;
280 if (fAddress > c->Address()) return 1;
281 if (fSignal < c->Signal()) return -1;
282 if (fSignal > c->Signal()) return 1;
287 AliError(Form("Do not know how to compare %s to %s.",