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.
26 #include "AliHLTMUONRecHit.h"
28 #include "mapping/AliMpDEManager.h"
34 ClassImp(AliHLTMUONRecHit);
35 ClassImp(AliHLTMUONRecHit::Channel);
38 std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit& hit)
40 // Stream operator for std::ostream classes.
42 stream << "(" << hit.X() << ", " << hit.Y() << ", " << hit.Z() << ")";
47 void AliHLTMUONRecHit::SetDebugInfo(
48 Int_t detElemId, Int_t clusterId, UInt_t nChExp, Int_t sourceDDL
51 // Sets the debugging information.
53 fSourceDDL = sourceDDL;
54 fDetElemId = detElemId;
55 fClusterId = clusterId;
60 Int_t AliHLTMUONRecHit::Chamber(bool warn) const
62 // Returns the chamber ID for this hit.
66 if (fSourceDDL < 1 or fSourceDDL > 20)
68 return ((fSourceDDL-1) / 2) + 1;
72 AliError(Form("The DDL source number: %d is out of range."
73 " Valid values are [1..20]", fSourceDDL
77 if (fDetElemId != -1) return AliMpDEManager::GetChamberId(fDetElemId, warn);
81 AliWarning("Neither the DDL source nor the detector element ID was not set,"
82 " so we do not know on which chamber this hit was reconstructed."
89 void AliHLTMUONRecHit::AddChannel(
90 Short_t manu, Short_t channel, Short_t signal,
94 // Adds a new channel to the channels list forming this hit's cluster.
96 Int_t index = fChannels.GetEntriesFast();
97 new (fChannels[index]) Channel(manu, channel, signal, rawDataWord);
101 void AliHLTMUONRecHit::Print(Option_t* option) const
103 // Prints the coordinates of this hit to standard output (screen).
105 if ( option == NULL or strcmp(option, "") == 0 or
106 strcmp(option, "compact") == 0
109 cout << *this << endl;
111 else if (strcmp(option, "detail") == 0)
113 cout << "(x = " << X() << " cm, y = " << Y()
114 << " cm, z = " << Z()
115 << " cm); source DDL = " << fSourceDDL
116 << "; DetElemID = " << fDetElemId
117 << "; cluster ID = " << fClusterId
118 << "; expected #ch = " << fNchExp << endl;
120 else if (strcmp(option, "all") == 0)
122 cout << "(x = " << X() << " cm, y = " << Y()
123 << " cm, z = " << Z()
124 << " cm); source DDL = " << fSourceDDL
125 << "; DetElemID = " << fDetElemId
126 << "; cluster ID = " << fClusterId
127 << "; expected #ch = " << fNchExp << endl;
128 if (fChannels.GetEntriesFast() == 0)
130 cout << "No channels found for this hit." << endl;
134 streamsize w = cout.width();
135 ios::fmtflags f = cout.flags();
136 cout << setw(12) << "MANU"
137 << setw(12) << "Channel"
138 << setw(12) << "Signal"
139 << setw(15) << "Raw data word" << endl;
141 for (Int_t i = 0; i < fChannels.GetEntriesFast(); i++)
143 const AliHLTMUONRecHit::Channel* c =
144 static_cast<const AliHLTMUONRecHit::Channel*>(fChannels[i]);
145 cout << dec << setw(12) << c->Manu()
146 << setw(12) << c->Address()
147 << setw(12) << c->Signal()
148 << " " << hex << setw(10) << internal;
149 ios::char_type fc = cout.fill('0');
150 cout << c->RawDataWord() << right << endl;
153 cout.width(w); // reset the field width to previous value.
154 cout.flags(f); // reset the flags to previous values.
159 AliError("Unknown option specified. Can only be one of 'compact',"
160 " 'detail' or 'all'."
166 Int_t AliHLTMUONRecHit::Compare(const TObject* obj) const
168 // We compare this object with 'obj' first by X, then Y, then Z.
170 if (obj->IsA() == AliHLTMUONRecHit::Class())
172 const AliHLTMUONRecHit* h = static_cast<const AliHLTMUONRecHit*>(obj);
173 if (X() < h->X()) return -1;
174 if (X() > h->X()) return 1;
175 if (Y() < h->Y()) return -1;
176 if (Y() > h->Y()) return 1;
177 if (Z() < h->Z()) return -1;
178 if (Z() > h->Z()) return 1;
183 AliError(Form("Do not know how to compare %s to %s.",
192 std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit::Channel& c)
194 // Stream operator for std::ostream classes.
196 stream << "Channel: " << c.fManu << " , " << c.fAddress
197 << "; ADC: " << c.fSignal;
202 void AliHLTMUONRecHit::Channel::Print(Option_t* option) const
204 // Prints the details of this channel to standard output (screen).
206 if ( option == NULL or strcmp(option, "") == 0 or
207 strcmp(option, "compact") == 0
210 cout << *this << endl;
212 else if (strcmp(option, "detail") == 0)
214 streamsize w = cout.width();
215 ios::fmtflags f = cout.flags();
216 cout << "MANU = " << fManu << ", Channel address = " << fAddress
217 << ", Signal = " << fSignal
218 << "; Raw data word = " << hex << setw(10) << internal;
219 ios::char_type fc = cout.fill('0');
220 cout << fRawDataWord << endl;
221 cout.fill(fc); // reset fill character
222 cout.width(w); // reset the field width to previous value.
223 cout.flags(f); // reset the flags to previous values.
227 AliError("Unknown option specified. Can only be one of"
228 " 'compact' or 'detail'."
234 Int_t AliHLTMUONRecHit::Channel::Compare(const TObject* obj) const
236 // We compare this object with 'obj' first by MANU number, then by MANU channel
237 // address, then ADC signal.
239 if (obj->IsA() == Channel::Class())
241 const Channel* c = static_cast<const Channel*>(obj);
242 if (fManu < c->Manu()) return -1;
243 if (fManu > c->Manu()) return 1;
244 if (fAddress < c->Address()) return -1;
245 if (fAddress > c->Address()) return 1;
246 if (fSignal < c->Signal()) return -1;
247 if (fSignal > c->Signal()) return 1;
252 AliError(Form("Do not know how to compare %s to %s.",