]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/MUON/AliHLTMUONRecHit.cxx
Adding ROOT classes to be able to store dHLT internal data in ROOT files.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONRecHit.cxx
... / ...
CommitLineData
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
23 * @brief Implementation of the AliHLTMUONRecHit class.
24 */
25
26#include "AliHLTMUONRecHit.h"
27#include "AliLog.h"
28#include "mapping/AliMpDEManager.h"
29#include <cstring>
30#include <iostream>
31#include <iomanip>
32using namespace std;
33
34ClassImp(AliHLTMUONRecHit);
35ClassImp(AliHLTMUONRecHit::Channel);
36
37
38std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit& hit)
39{
40// Stream operator for std::ostream classes.
41
42 stream << "(" << hit.X() << ", " << hit.Y() << ", " << hit.Z() << ")";
43 return stream;
44}
45
46
47void AliHLTMUONRecHit::SetDebugInfo(
48 Int_t detElemId, Int_t clusterId, UInt_t nChExp, Int_t sourceDDL
49 )
50{
51// Sets the debugging information.
52
53 fSourceDDL = sourceDDL;
54 fDetElemId = detElemId;
55 fClusterId = clusterId;
56 fNchExp = nChExp;
57}
58
59
60Int_t AliHLTMUONRecHit::Chamber(bool warn) const
61{
62// Returns the chamber ID for this hit.
63
64 if (fSourceDDL != -1)
65 {
66 if (fSourceDDL < 1 or fSourceDDL > 20)
67 {
68 return ((fSourceDDL-1) / 2) + 1;
69 }
70 else if (warn)
71 {
72 AliError(Form("The DDL source number: %d is out of range."
73 " Valid values are [1..20]", fSourceDDL
74 ));
75 }
76 }
77 if (fDetElemId != -1) return AliMpDEManager::GetChamberId(fDetElemId, warn);
78
79 if (warn)
80 {
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."
83 );
84 }
85 return -1;
86}
87
88
89void AliHLTMUONRecHit::AddChannel(
90 Short_t manu, Short_t channel, Short_t signal,
91 UInt_t rawDataWord
92 )
93{
94// Adds a new channel to the channels list forming this hit's cluster.
95
96 Int_t index = fChannels.GetEntriesFast();
97 new (fChannels[index]) Channel(manu, channel, signal, rawDataWord);
98}
99
100
101void AliHLTMUONRecHit::Print(Option_t* option) const
102{
103// Prints the coordinates of this hit to standard output (screen).
104
105 if ( option == NULL or strcmp(option, "") == 0 or
106 strcmp(option, "compact") == 0
107 )
108 {
109 cout << *this << endl;
110 }
111 else if (strcmp(option, "detail") == 0)
112 {
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;
119 }
120 else if (strcmp(option, "all") == 0)
121 {
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)
129 {
130 cout << "No channels found for this hit." << endl;
131 }
132 else
133 {
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;
140 cout << showbase;
141 for (Int_t i = 0; i < fChannels.GetEntriesFast(); i++)
142 {
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;
151 cout.fill(fc);
152 }
153 cout.width(w); // reset the field width to previous value.
154 cout.flags(f); // reset the flags to previous values.
155 }
156 }
157 else
158 {
159 AliError("Unknown option specified. Can only be one of 'compact',"
160 " 'detail' or 'all'."
161 );
162 }
163}
164
165
166Int_t AliHLTMUONRecHit::Compare(const TObject* obj) const
167{
168// We compare this object with 'obj' first by X, then Y, then Z.
169
170 if (obj->IsA() == AliHLTMUONRecHit::Class())
171 {
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;
179 return 0;
180 }
181 else
182 {
183 AliError(Form("Do not know how to compare %s to %s.",
184 this->ClassName(),
185 obj->ClassName()
186 ));
187 return -999;
188 }
189}
190
191
192std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit::Channel& c)
193{
194// Stream operator for std::ostream classes.
195
196 stream << "Channel: " << c.fManu << " , " << c.fAddress
197 << "; ADC: " << c.fSignal;
198 return stream;
199}
200
201
202void AliHLTMUONRecHit::Channel::Print(Option_t* option) const
203{
204// Prints the details of this channel to standard output (screen).
205
206 if ( option == NULL or strcmp(option, "") == 0 or
207 strcmp(option, "compact") == 0
208 )
209 {
210 cout << *this << endl;
211 }
212 else if (strcmp(option, "detail") == 0)
213 {
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.
224 }
225 else
226 {
227 AliError("Unknown option specified. Can only be one of"
228 " 'compact' or 'detail'."
229 );
230 }
231}
232
233
234Int_t AliHLTMUONRecHit::Channel::Compare(const TObject* obj) const
235{
236// We compare this object with 'obj' first by MANU number, then by MANU channel
237// address, then ADC signal.
238
239 if (obj->IsA() == Channel::Class())
240 {
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;
248 return 0;
249 }
250 else
251 {
252 AliError(Form("Do not know how to compare %s to %s.",
253 this->ClassName(),
254 obj->ClassName()
255 ));
256 return -999;
257 }
258}