]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/AliHLTMUONRecHit.cxx
Making important updates to the internal data structures:
[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(
53 Int_t detElemId, Int_t clusterId, UInt_t nChExp, Int_t sourceDDL
54 )
55{
450e0b36 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.
753896cd 61
62 fSourceDDL = sourceDDL;
63 fDetElemId = detElemId;
64 fClusterId = clusterId;
65 fNchExp = nChExp;
66}
67
68
69Int_t AliHLTMUONRecHit::Chamber(bool warn) const
70{
450e0b36 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.
753896cd 74
753896cd 75 if (fDetElemId != -1) return AliMpDEManager::GetChamberId(fDetElemId, warn);
76
77 if (warn)
78 {
79 AliWarning("Neither the DDL source nor the detector element ID was not set,"
80 " so we do not know on which chamber this hit was reconstructed."
81 );
82 }
83 return -1;
84}
85
86
87void AliHLTMUONRecHit::AddChannel(
88 Short_t manu, Short_t channel, Short_t signal,
89 UInt_t rawDataWord
90 )
91{
450e0b36 92/// Adds a new channel to the channels list forming this hit's cluster.
93/// @param manu The MANU number
94/// @param channel The MANU channel address.
95/// @param signal The ADC signal value measured on the channel.
96/// @param rawDataWord This is the raw data word as read from the DDL.
753896cd 97
98 Int_t index = fChannels.GetEntriesFast();
450e0b36 99 new (fChannels[index]) AliChannel(manu, channel, signal, rawDataWord);
753896cd 100}
101
102
103void AliHLTMUONRecHit::Print(Option_t* option) const
104{
450e0b36 105/// Prints the coordinates of this hit to standard output (screen).
106/// \param option Can be one of the following:
107/// - "compact" - prints in a compact format.
108/// - "detail" - prints hit information in a more detailed format.
109/// - "all" - prints a full dump of the hit object.
110
111 using namespace std;
753896cd 112
113 if ( option == NULL or strcmp(option, "") == 0 or
114 strcmp(option, "compact") == 0
115 )
116 {
117 cout << *this << endl;
118 }
119 else if (strcmp(option, "detail") == 0)
120 {
121 cout << "(x = " << X() << " cm, y = " << Y()
122 << " cm, z = " << Z()
123 << " cm); source DDL = " << fSourceDDL
124 << "; DetElemID = " << fDetElemId
125 << "; cluster ID = " << fClusterId
126 << "; expected #ch = " << fNchExp << endl;
127 }
128 else if (strcmp(option, "all") == 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
135 << "; expected #ch = " << fNchExp << endl;
136 if (fChannels.GetEntriesFast() == 0)
137 {
138 cout << "No channels found for this hit." << endl;
139 }
140 else
141 {
142 streamsize w = cout.width();
143 ios::fmtflags f = cout.flags();
144 cout << setw(12) << "MANU"
145 << setw(12) << "Channel"
146 << setw(12) << "Signal"
147 << setw(15) << "Raw data word" << endl;
148 cout << showbase;
149 for (Int_t i = 0; i < fChannels.GetEntriesFast(); i++)
150 {
450e0b36 151 const AliHLTMUONRecHit::AliChannel* c =
152 static_cast<const AliHLTMUONRecHit::AliChannel*>(fChannels[i]);
753896cd 153 cout << dec << setw(12) << c->Manu()
154 << setw(12) << c->Address()
155 << setw(12) << c->Signal()
156 << " " << hex << setw(10) << internal;
157 ios::char_type fc = cout.fill('0');
158 cout << c->RawDataWord() << right << endl;
159 cout.fill(fc);
160 }
161 cout.width(w); // reset the field width to previous value.
162 cout.flags(f); // reset the flags to previous values.
163 }
164 }
165 else
166 {
167 AliError("Unknown option specified. Can only be one of 'compact',"
168 " 'detail' or 'all'."
169 );
170 }
171}
172
173
174Int_t AliHLTMUONRecHit::Compare(const TObject* obj) const
175{
450e0b36 176/// We compare this object with 'obj' first by X, then Y, then Z.
177/// \param obj This is the object to compare to. It must be of type AliHLTMUONRecHit.
178/// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
179/// objects are the same.
753896cd 180
181 if (obj->IsA() == AliHLTMUONRecHit::Class())
182 {
183 const AliHLTMUONRecHit* h = static_cast<const AliHLTMUONRecHit*>(obj);
184 if (X() < h->X()) return -1;
185 if (X() > h->X()) return 1;
186 if (Y() < h->Y()) return -1;
187 if (Y() > h->Y()) return 1;
188 if (Z() < h->Z()) return -1;
189 if (Z() > h->Z()) return 1;
190 return 0;
191 }
192 else
193 {
194 AliError(Form("Do not know how to compare %s to %s.",
195 this->ClassName(),
196 obj->ClassName()
197 ));
198 return -999;
199 }
200}
201
202
450e0b36 203std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit::AliChannel& c)
753896cd 204{
450e0b36 205/// Stream operator for std::ostream classes.
206/// \param stream The output stream object being written to.
207/// \param c The channel object to print to the stream.
208/// \returns Returns 'stream'.
753896cd 209
210 stream << "Channel: " << c.fManu << " , " << c.fAddress
211 << "; ADC: " << c.fSignal;
212 return stream;
213}
214
215
450e0b36 216void AliHLTMUONRecHit::AliChannel::Print(Option_t* option) const
753896cd 217{
450e0b36 218/// Prints the details of this channel to standard output (screen).
219/// \param option Can be one of the following:
220/// - "compact" - prints in a compact format.
221/// - "detail" - prints channel information in a more detailed format.
753896cd 222
450e0b36 223 using namespace std;
224
753896cd 225 if ( option == NULL or strcmp(option, "") == 0 or
226 strcmp(option, "compact") == 0
227 )
228 {
229 cout << *this << endl;
230 }
231 else if (strcmp(option, "detail") == 0)
232 {
233 streamsize w = cout.width();
234 ios::fmtflags f = cout.flags();
235 cout << "MANU = " << fManu << ", Channel address = " << fAddress
236 << ", Signal = " << fSignal
237 << "; Raw data word = " << hex << setw(10) << internal;
238 ios::char_type fc = cout.fill('0');
239 cout << fRawDataWord << endl;
240 cout.fill(fc); // reset fill character
241 cout.width(w); // reset the field width to previous value.
242 cout.flags(f); // reset the flags to previous values.
243 }
244 else
245 {
246 AliError("Unknown option specified. Can only be one of"
247 " 'compact' or 'detail'."
248 );
249 }
250}
251
252
450e0b36 253Int_t AliHLTMUONRecHit::AliChannel::Compare(const TObject* obj) const
753896cd 254{
450e0b36 255/// We compare this object with 'obj' first by MANU number, then by MANU channel
256/// address, then ADC signal.
257/// \param obj This is the object to compare to. It must be of type AliHLTMUONRecHit::Channel.
258/// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
259/// objects are the same.
753896cd 260
450e0b36 261 if (obj->IsA() == AliChannel::Class())
753896cd 262 {
450e0b36 263 const AliChannel* c = static_cast<const AliChannel*>(obj);
753896cd 264 if (fManu < c->Manu()) return -1;
265 if (fManu > c->Manu()) return 1;
266 if (fAddress < c->Address()) return -1;
267 if (fAddress > c->Address()) return 1;
268 if (fSignal < c->Signal()) return -1;
269 if (fSignal > c->Signal()) return 1;
270 return 0;
271 }
272 else
273 {
274 AliError(Form("Do not know how to compare %s to %s.",
275 this->ClassName(),
276 obj->ClassName()
277 ));
278 return -999;
279 }
280}