--- Access to bad channel map implemented in reconstruction chain.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONRecHit.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
450e0b36 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///
753896cd 28
29#include "AliHLTMUONRecHit.h"
30#include "AliLog.h"
31#include "mapping/AliMpDEManager.h"
32#include <cstring>
33#include <iostream>
34#include <iomanip>
753896cd 35
36ClassImp(AliHLTMUONRecHit);
450e0b36 37ClassImp(AliHLTMUONRecHit::AliChannel);
753896cd 38
39
40std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit& hit)
41{
450e0b36 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'.
753896cd 46
47 stream << "(" << hit.X() << ", " << hit.Y() << ", " << hit.Z() << ")";
48 return stream;
49}
50
51
52void AliHLTMUONRecHit::SetDebugInfo(
66622a82 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
753896cd 57 )
58{
66622a82 59/// Sets the extra debugging information.
450e0b36 60/// @param detElemId The detector element ID.
61/// @param clusterId Cluster ID of the hit's cluster.
66622a82 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.
450e0b36 66/// @param sourceDDL The source DDL of this hit.
753896cd 67
68 fSourceDDL = sourceDDL;
69 fDetElemId = detElemId;
70 fClusterId = clusterId;
66622a82 71 fNchExpB = nChExpB;
72 fNchExpNB = nChExpNB;
73 fChargeB = chargeB;
74 fChargeNB = chargeNB;
753896cd 75}
76
77
78Int_t AliHLTMUONRecHit::Chamber(bool warn) const
79{
450e0b36 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.
753896cd 83
753896cd 84 if (fDetElemId != -1) return AliMpDEManager::GetChamberId(fDetElemId, warn);
85
86 if (warn)
87 {
88 AliWarning("Neither the DDL source nor the detector element ID was not set,"
89 " so we do not know on which chamber this hit was reconstructed."
90 );
91 }
92 return -1;
93}
94
95
96void AliHLTMUONRecHit::AddChannel(
97 Short_t manu, Short_t channel, Short_t signal,
98 UInt_t rawDataWord
99 )
100{
450e0b36 101/// Adds a new channel to the channels list forming this hit's cluster.
102/// @param manu The MANU number
103/// @param channel The MANU channel address.
104/// @param signal The ADC signal value measured on the channel.
105/// @param rawDataWord This is the raw data word as read from the DDL.
753896cd 106
107 Int_t index = fChannels.GetEntriesFast();
450e0b36 108 new (fChannels[index]) AliChannel(manu, channel, signal, rawDataWord);
753896cd 109}
110
111
112void AliHLTMUONRecHit::Print(Option_t* option) const
113{
450e0b36 114/// Prints the coordinates of this hit to standard output (screen).
115/// \param option Can be one of the following:
116/// - "compact" - prints in a compact format.
117/// - "detail" - prints hit information in a more detailed format.
118/// - "all" - prints a full dump of the hit object.
119
120 using namespace std;
753896cd 121
122 if ( option == NULL or strcmp(option, "") == 0 or
123 strcmp(option, "compact") == 0
124 )
125 {
126 cout << *this << endl;
127 }
128 else if (strcmp(option, "detail") == 0)
129 {
130 cout << "(x = " << X() << " cm, y = " << Y()
131 << " cm, z = " << Z()
132 << " cm); source DDL = " << fSourceDDL
133 << "; DetElemID = " << fDetElemId
134 << "; cluster ID = " << fClusterId
66622a82 135 << "; total charge = " << fChargeB + fChargeNB
136 << "; expected #ch = " << fNchExpB + fNchExpNB << endl;
753896cd 137 }
138 else if (strcmp(option, "all") == 0)
139 {
140 cout << "(x = " << X() << " cm, y = " << Y()
141 << " cm, z = " << Z()
142 << " cm); source DDL = " << fSourceDDL
143 << "; DetElemID = " << fDetElemId
144 << "; cluster ID = " << fClusterId
66622a82 145 << "; charge (Bending, Non-bending) = (" << fChargeB
146 << ", " << fChargeNB
147 << "); expected #ch (Bending, Non-bending) = ("
148 << fNchExpB << ", " << fNchExpNB << ")" << endl;
753896cd 149 if (fChannels.GetEntriesFast() == 0)
150 {
151 cout << "No channels found for this hit." << endl;
152 }
153 else
154 {
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;
161 cout << showbase;
162 for (Int_t i = 0; i < fChannels.GetEntriesFast(); i++)
163 {
450e0b36 164 const AliHLTMUONRecHit::AliChannel* c =
165 static_cast<const AliHLTMUONRecHit::AliChannel*>(fChannels[i]);
753896cd 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;
172 cout.fill(fc);
173 }
174 cout.width(w); // reset the field width to previous value.
175 cout.flags(f); // reset the flags to previous values.
176 }
177 }
178 else
179 {
180 AliError("Unknown option specified. Can only be one of 'compact',"
181 " 'detail' or 'all'."
182 );
183 }
184}
185
186
187Int_t AliHLTMUONRecHit::Compare(const TObject* obj) const
188{
450e0b36 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.
753896cd 193
194 if (obj->IsA() == AliHLTMUONRecHit::Class())
195 {
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;
203 return 0;
204 }
205 else
206 {
207 AliError(Form("Do not know how to compare %s to %s.",
208 this->ClassName(),
209 obj->ClassName()
210 ));
211 return -999;
212 }
213}
214
215
450e0b36 216std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit::AliChannel& c)
753896cd 217{
450e0b36 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'.
753896cd 222
223 stream << "Channel: " << c.fManu << " , " << c.fAddress
224 << "; ADC: " << c.fSignal;
225 return stream;
226}
227
228
450e0b36 229void AliHLTMUONRecHit::AliChannel::Print(Option_t* option) const
753896cd 230{
450e0b36 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.
753896cd 235
450e0b36 236 using namespace std;
237
753896cd 238 if ( option == NULL or strcmp(option, "") == 0 or
239 strcmp(option, "compact") == 0
240 )
241 {
242 cout << *this << endl;
243 }
244 else if (strcmp(option, "detail") == 0)
245 {
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.
256 }
257 else
258 {
259 AliError("Unknown option specified. Can only be one of"
260 " 'compact' or 'detail'."
261 );
262 }
263}
264
265
450e0b36 266Int_t AliHLTMUONRecHit::AliChannel::Compare(const TObject* obj) const
753896cd 267{
450e0b36 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.
753896cd 273
450e0b36 274 if (obj->IsA() == AliChannel::Class())
753896cd 275 {
450e0b36 276 const AliChannel* c = static_cast<const AliChannel*>(obj);
753896cd 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;
283 return 0;
284 }
285 else
286 {
287 AliError(Form("Do not know how to compare %s to %s.",
288 this->ClassName(),
289 obj->ClassName()
290 ));
291 return -999;
292 }
293}