New virtual interface for digits (Laurent)
[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//_____________________________________________________________________________
73UInt_t
74AliMUONVDigit::BuildUniqueID(Int_t detElemId, Int_t manuId,
75 Int_t manuChannel, Int_t cathode)
76{
77 /// Build a single integer with id information
78 return ( ( detElemId ) | ( manuId << 12 ) | ( manuChannel << 24 )
79 | ( cathode << 30 ) );
80}
81
82//_____________________________________________________________________________
83Int_t
84AliMUONVDigit::DetElemId(UInt_t uniqueID)
85{
86 /// Return detection element id part of the uniqueID
87 return uniqueID & 0xFFF;
88}
89
90//_____________________________________________________________________________
91Int_t
92AliMUONVDigit::ManuChannel(UInt_t uniqueID)
93{
94 /// Return manuChannel part of the uniqueID
95 return ( uniqueID & 0x3F000000 ) >> 24;
96}
97
98//_____________________________________________________________________________
99Int_t
100AliMUONVDigit::ManuId(UInt_t uniqueID)
101{
102 /// Return manuId part of the uniqueID
103 return ( uniqueID & 0xFFF000 ) >> 12;
104}
105
106//_____________________________________________________________________________
107Int_t
108AliMUONVDigit::Cathode(UInt_t uniqueID)
109{
110 /// Return the cathode part of the uniqueID
111 return ( uniqueID & 0x40000000 ) >> 30;
112}
113
114//_____________________________________________________________________________
115void
116AliMUONVDigit::DecodeUniqueID(UInt_t uniqueID,
117 Int_t& detElemId, Int_t& manuId,
118 Int_t& manuChannel, Int_t& cathode)
119{
120 /// Unpack uniqueID into 4 elements
121 detElemId = DetElemId(uniqueID);
122 manuId = ManuId(uniqueID);
123 manuChannel = ManuChannel(uniqueID);
124 cathode = Cathode(uniqueID);
125}
126
127//_____________________________________________________________________________
128const char*
129AliMUONVDigit::GetName() const
130{
131 /// Return the name of this digit, composed of its id parts.
132 return Form("DE%04d-%04d-%02d-%d",
133 DetElemId(),ManuId(),ManuChannel(),Cathode());
134}
135
136//_____________________________________________________________________________
137void
138AliMUONVDigit::Print(Option_t* opt) const
139{
140 /// Dump to screen.
141 /// If opt=="tracks", info on tracks are printed too.
142
143 cout << Form("<%s>: ID %12u DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
144 ", Charge=%7.2f",
145 ClassName(),GetUniqueID(),
146 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Charge());
147 if ( IsSaturated() )
148 {
149 cout << "(S)";
150 }
151 else
152 {
153 cout << " ";
154 }
155
156 if ( IsCalibrated() )
157 {
158 cout << "(C)";
159 }
160 else
161 {
162 cout << " ";
163 }
164
165 if ( IsUsed() )
166 {
167 cout << "(U)";
168 }
169 else
170 {
171 cout << " ";
172 }
173
174 cout << Form(" ADC=%4d StatusMap=%04x",ADC(),StatusMap());
175
176 TString options(opt);
177 options.ToLower();
178 if ( options.Contains("tracks") && HasMCInformation() )
179 {
180 cout << " Hit " << setw(3) << Hit();
181 Int_t ntracks = Ntracks();
182 if (ntracks)
183 {
184 cout << " Tracks : " << setw(2) << ntracks;
185 for ( Int_t i = 0; i < ntracks; ++i )
186 {
187 cout << " Track(" << i << ")=" << setw(3) << Track(i)
188 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
189 }
190 }
191 else
192 {
193 cout << " no track info.";
194 }
195 }
196 cout << endl;
197}