Interface with new trigger mapping (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONVDigit.cxx
CommitLineData
d6c3334d 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// $Id$
17
18/// \class AliMUONVDigit
19///
20/// This is the base class of a MUON digit that most client code should deal with.
21/// There should be no reason to have to use a concrete class in most cases.
22///
23/// All digits have basic features, like :
24///
25/// - a way to identify it : detection element, electronics card and
26/// channel, cathode. Note that some static methods exists to compact
27/// those 4 informations into a single 4 bytes integer (stored in the
28/// fUniqueID data member present in all TObjects).
29///
30/// - its charge
31///
32/// - a set of boolean methods to indicate whether the digit has been calibrated, etc...
33///
34/// In addition, if HasMCInformation is true, the digit store also the list
35/// of MC tracks that contributed to its charge
36///
37/// Also, if HasGeometryInformation is true, the digit knows the position and
38/// the (half) dimensions (in cm) of the pad it corresponds to.
39///
40/// \author Laurent Aphecetche, Subatech
41
42#include "AliMUONVDigit.h"
43
44#include <Riostream.h>
45#include <TClass.h>
46
47/// \cond CLASSIMP
48ClassImp(AliMUONVDigit)
49/// \endcond
50
51//_____________________________________________________________________________
52AliMUONVDigit::AliMUONVDigit(Int_t detElemId, Int_t eCardId,
53 Int_t eCardChannel, Int_t cathode)
54: TObject()
55{
56 /// Normal constructor for trigger digits
57 SetUniqueID(BuildUniqueID(detElemId,eCardId,eCardChannel,cathode));
58}
59
60//_____________________________________________________________________________
61AliMUONVDigit::AliMUONVDigit()
62{
63 /// Default ctor
64}
65
66//_____________________________________________________________________________
67AliMUONVDigit::~AliMUONVDigit()
68{
69 /// dtor
70}
71
72//_____________________________________________________________________________
36a01415 73Bool_t
74AliMUONVDigit::IsEqual(const TObject* object) const
75{
76 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
77
78 return ( DetElemId() == d->DetElemId() &&
79 Cathode() == d->Cathode() &&
80 ManuId() == d->ManuId() &&
81 ManuChannel() == d->ManuChannel() );
82}
83
84//_____________________________________________________________________________
85Int_t
86AliMUONVDigit::Compare(const TObject* object) const
87{
88 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
89
90 if ( DetElemId() > d->DetElemId() )
91 {
92 return 1;
93 }
94 else if ( DetElemId() < d->DetElemId() )
95 {
96 return -1;
97 }
98 else
99 {
100 if ( Charge() > d->Charge() )
101 {
102 return 1;
103 }
104 else if ( Charge() < d->Charge() )
105 {
106 return -1;
107 }
108 else
109 {
110 if ( ManuId() < d->ManuId() )
111 {
112 return 1;
113 }
114 else if ( ManuId() > d->ManuId() )
115 {
116 return -1;
117 }
118 else
119 {
120 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
121 }
122 }
123 }
124 return 0;
125}
126
127//_____________________________________________________________________________
d6c3334d 128UInt_t
129AliMUONVDigit::BuildUniqueID(Int_t detElemId, Int_t manuId,
130 Int_t manuChannel, Int_t cathode)
131{
132 /// Build a single integer with id information
133 return ( ( detElemId ) | ( manuId << 12 ) | ( manuChannel << 24 )
134 | ( cathode << 30 ) );
135}
136
137//_____________________________________________________________________________
138Int_t
139AliMUONVDigit::DetElemId(UInt_t uniqueID)
140{
141 /// Return detection element id part of the uniqueID
142 return uniqueID & 0xFFF;
143}
144
145//_____________________________________________________________________________
146Int_t
147AliMUONVDigit::ManuChannel(UInt_t uniqueID)
148{
149 /// Return manuChannel part of the uniqueID
150 return ( uniqueID & 0x3F000000 ) >> 24;
151}
152
153//_____________________________________________________________________________
154Int_t
155AliMUONVDigit::ManuId(UInt_t uniqueID)
156{
157 /// Return manuId part of the uniqueID
158 return ( uniqueID & 0xFFF000 ) >> 12;
159}
160
161//_____________________________________________________________________________
162Int_t
163AliMUONVDigit::Cathode(UInt_t uniqueID)
164{
165 /// Return the cathode part of the uniqueID
166 return ( uniqueID & 0x40000000 ) >> 30;
167}
168
169//_____________________________________________________________________________
170void
171AliMUONVDigit::DecodeUniqueID(UInt_t uniqueID,
172 Int_t& detElemId, Int_t& manuId,
173 Int_t& manuChannel, Int_t& cathode)
174{
175 /// Unpack uniqueID into 4 elements
176 detElemId = DetElemId(uniqueID);
177 manuId = ManuId(uniqueID);
178 manuChannel = ManuChannel(uniqueID);
179 cathode = Cathode(uniqueID);
180}
181
182//_____________________________________________________________________________
183const char*
184AliMUONVDigit::GetName() const
185{
186 /// Return the name of this digit, composed of its id parts.
187 return Form("DE%04d-%04d-%02d-%d",
188 DetElemId(),ManuId(),ManuChannel(),Cathode());
189}
190
191//_____________________________________________________________________________
192void
193AliMUONVDigit::Print(Option_t* opt) const
194{
195 /// Dump to screen.
196 /// If opt=="tracks", info on tracks are printed too.
197
198 cout << Form("<%s>: ID %12u DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
199 ", Charge=%7.2f",
200 ClassName(),GetUniqueID(),
201 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Charge());
202 if ( IsSaturated() )
203 {
204 cout << "(S)";
205 }
206 else
207 {
208 cout << " ";
209 }
210
211 if ( IsCalibrated() )
212 {
213 cout << "(C)";
214 }
215 else
216 {
217 cout << " ";
218 }
219
220 if ( IsUsed() )
221 {
222 cout << "(U)";
223 }
224 else
225 {
226 cout << " ";
227 }
228
229 cout << Form(" ADC=%4d StatusMap=%04x",ADC(),StatusMap());
230
231 TString options(opt);
232 options.ToLower();
233 if ( options.Contains("tracks") && HasMCInformation() )
234 {
235 cout << " Hit " << setw(3) << Hit();
236 Int_t ntracks = Ntracks();
237 if (ntracks)
238 {
239 cout << " Tracks : " << setw(2) << ntracks;
240 for ( Int_t i = 0; i < ntracks; ++i )
241 {
242 cout << " Track(" << i << ")=" << setw(3) << Track(i)
243 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
244 }
245 }
246 else
247 {
248 cout << " no track info.";
249 }
250 }
251 cout << endl;
252}