]>
Commit | Line | Data |
---|---|---|
09b6c804 | 1 | /************************************************************************* |
02a27b50 | 2 | * Copyright(c) 2004, 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. * | |
09b6c804 | 14 | ************************************************************************* |
15 | * $Id$ */ | |
16 | /** | |
17 | * @file AliFMDBaseDigit.cxx | |
18 | * @author Christian Holm Christensen <cholm@nbi.dk> | |
19 | * @date Mon Mar 27 12:37:41 2006 | |
20 | * @brief Digits for the FMD | |
21 | * @ingroup FMD_base | |
22 | */ | |
02a27b50 | 23 | ////////////////////////////////////////////////////////////////////// |
24 | // | |
25 | // Digits classes for the FMD | |
26 | // | |
27 | // Digits consists of | |
28 | // - Detector # | |
29 | // - Ring ID | |
30 | // - Sector # | |
31 | // - Strip # | |
32 | // - ADC count in this channel | |
33 | // | |
34 | // Digits consists of | |
35 | // - Detector # | |
36 | // - Ring ID | |
37 | // - Sector # | |
38 | // - Strip # | |
39 | // - Total energy deposited in the strip | |
40 | // - ADC count in this channel | |
41 | // | |
42 | // As the Digits and SDigits have so much in common, the classes | |
43 | // AliFMDDigit and AliFMDSDigit are implemented via a base | |
44 | // class AliFMDBaseDigit. | |
45 | /// | |
46 | // +-----------------+ | |
47 | // | AliFMDBaseDigit | | |
48 | // +-----------------+ | |
49 | // ^ | |
50 | // | | |
51 | // +------------+ | |
52 | // | | | |
53 | // +-------------+ +--------------+ | |
54 | // | AliFMDDigit | | AliFMDSDigit | | |
55 | // +-------------+ +--------------+ | |
56 | // | |
57 | // (Note, that I'd really would have liked to implement AliFMDHit as a | |
58 | // derived class from some base class - say AliFMDStrip, and the Digit | |
59 | // classes would (eventually) have derived from that as well. | |
60 | // However, ROOT doesn't do well with multiple inheritance, so I chose | |
61 | // not to anyway). | |
62 | // | |
63 | // Latest changes by Christian Holm Christensen | |
64 | // | |
65 | ////////////////////////////////////////////////////////////////////// | |
66 | ||
67 | #include "AliFMDBaseDigit.h" // ALIFMDDIGIT_H | |
faf80567 | 68 | #include "AliFMDStripIndex.h" |
02a27b50 | 69 | #include "Riostream.h" // ROOT_Riostream |
97e94238 | 70 | // #include <TString.h> |
f95a63c4 | 71 | // #include <AliLog.h> |
72 | #include "AliFMDDebug.h" // Better debug macros | |
02a27b50 | 73 | |
74 | //==================================================================== | |
cdd730d0 | 75 | using std::cout; |
76 | using std::flush; | |
02a27b50 | 77 | ClassImp(AliFMDBaseDigit) |
78 | #if 0 | |
79 | ; // This is here to keep Emacs from indenting the next line | |
80 | #endif | |
81 | ||
82 | //____________________________________________________________________ | |
83 | AliFMDBaseDigit::AliFMDBaseDigit() | |
84 | : fDetector(0), | |
85 | fRing('\0'), | |
86 | fSector(0), | |
b5ee4425 | 87 | fStrip(0), |
88 | fName("") | |
09b6c804 | 89 | { |
90 | // | |
91 | // CTOR | |
92 | // | |
93 | } | |
02a27b50 | 94 | |
95 | //____________________________________________________________________ | |
96 | AliFMDBaseDigit::AliFMDBaseDigit(UShort_t detector, | |
b5ee4425 | 97 | Char_t ring, |
98 | UShort_t sector, | |
99 | UShort_t strip) | |
faf80567 | 100 | : AliDigit(), |
101 | fDetector(detector), | |
02a27b50 | 102 | fRing(ring), |
103 | fSector(sector), | |
b5ee4425 | 104 | fStrip(strip), |
105 | fName("") | |
02a27b50 | 106 | { |
107 | // | |
108 | // Creates a base data digit object | |
109 | // | |
110 | // Parameters | |
111 | // | |
112 | // detector Detector # (1, 2, or 3) | |
113 | // ring Ring ID ('I' or 'O') | |
114 | // sector Sector # (For inner/outer rings: 0-19/0-39) | |
115 | // strip Strip # (For inner/outer rings: 0-511/0-255) | |
116 | } | |
117 | ||
faf80567 | 118 | //____________________________________________________________________ |
119 | AliFMDBaseDigit::AliFMDBaseDigit(Int_t* tracks, | |
120 | UShort_t detector, | |
121 | Char_t ring, | |
122 | UShort_t sector, | |
123 | UShort_t strip) | |
124 | : AliDigit(tracks), | |
125 | fDetector(detector), | |
126 | fRing(ring), | |
127 | fSector(sector), | |
128 | fStrip(strip), | |
129 | fName("") | |
130 | { | |
131 | // | |
132 | // Creates a base data digit object | |
133 | // | |
134 | // Parameters | |
135 | // | |
136 | // tracks Array of 3 track labels | |
137 | // detector Detector # (1, 2, or 3) | |
138 | // ring Ring ID ('I' or 'O') | |
139 | // sector Sector # (For inner/outer rings: 0-19/0-39) | |
140 | // strip Strip # (For inner/outer rings: 0-511/0-255) | |
141 | } | |
142 | ||
02a27b50 | 143 | //____________________________________________________________________ |
144 | void | |
145 | AliFMDBaseDigit::Print(Option_t* /* option*/) const | |
146 | { | |
147 | // Print digit to standard out | |
ca20eb4a | 148 | cout << ClassName() << ": FMD" << fDetector << fRing |
149 | << '[' << std::setw(2) << fSector | |
150 | << ',' << std::setw(3) << fStrip << ']' << flush; | |
02a27b50 | 151 | } |
152 | ||
153 | //____________________________________________________________________ | |
154 | const char* | |
155 | AliFMDBaseDigit::GetName() const | |
156 | { | |
157 | // Get the name of a FMD digit. | |
158 | if (fName.IsNull()) | |
159 | fName = Form("FMD%d%c[%2d,%3d]", fDetector, fRing, fSector, fStrip); | |
160 | return fName.Data(); | |
161 | } | |
162 | #define fMaxStrips 512 | |
163 | #define fMaxSectors 40 | |
164 | #define fMaxRings 2 | |
165 | ||
166 | //____________________________________________________________________ | |
167 | ULong_t | |
168 | AliFMDBaseDigit::Hash() const | |
169 | { | |
6169f936 | 170 | // Calculate a hash value based on the detector coordinates. |
faf80567 | 171 | #if 1 |
172 | return AliFMDStripIndex::Pack(fDetector, fRing, fSector, fStrip); | |
173 | #else | |
02a27b50 | 174 | size_t ringi = (fRing == 'I' || fRing == 'i' ? 0 : 1); |
175 | return fStrip + fMaxStrips * | |
176 | (fSector + fMaxSectors * (ringi + fMaxRings * (fDetector - 1))); | |
faf80567 | 177 | #endif |
02a27b50 | 178 | } |
179 | ||
180 | ||
181 | //____________________________________________________________________ | |
182 | Int_t | |
183 | AliFMDBaseDigit::Compare(const TObject* o) const | |
184 | { | |
6169f936 | 185 | // Compare to other digit. If the passed pointer to TObject does |
186 | // not point to an object of class AliFMDBaseDigit (or one of it's | |
187 | // derived classes), then a fatal exception is made. | |
188 | // | |
189 | // Returns -1, if this object's detector coordinates are smaller | |
190 | // than passed object's detector coordinates. | |
191 | // | |
192 | // Returns 0, if this object's detector coordinates is the same as | |
193 | // passed object's detector coordinates. | |
194 | // | |
195 | // Returns 1, if this object's detector coordinates are larger | |
196 | // than passed object's detector coordinates. | |
02a27b50 | 197 | if (!o) |
198 | AliFatal("Can not compare to NULL!"); | |
199 | if (o->IsA() != AliFMDBaseDigit::Class()) | |
200 | AliFatal(Form("Cannot compare to a %s object", o->ClassName())); | |
201 | // AliFMDBaseDigit* of = static_cast<AliFMDBaseDigit*>(o); | |
202 | if (Hash() == o->Hash()) return 0; | |
203 | if (Hash() < o->Hash()) return -1; | |
204 | return 1; | |
205 | } | |
206 | ||
faf80567 | 207 | //____________________________________________________________________ |
208 | void | |
209 | AliFMDBaseDigit::AddTrack(Int_t track) | |
210 | { | |
09b6c804 | 211 | // |
212 | // Add a track referenc | |
213 | // | |
214 | // Parameters: | |
215 | // trackno The track number | |
216 | // | |
faf80567 | 217 | if (fTracks[0] == -1) fTracks[0] = track; |
218 | else if (fTracks[1] == -1) fTracks[1] = track; | |
219 | else if (fTracks[2] == -1) fTracks[2] = track; | |
220 | else | |
2180cab3 | 221 | AliFMDDebug(1, ("While adding track label to %s for %s: " |
222 | "All 3 track labels used, can't add " | |
223 | "reference to track %d", | |
faf80567 | 224 | ClassName(), GetName(), track)); |
225 | } | |
226 | ||
227 | //____________________________________________________________________ | |
228 | UShort_t | |
229 | AliFMDBaseDigit::GetNTrack() const | |
230 | { | |
09b6c804 | 231 | // |
232 | // Get the number of track references (max 3) | |
233 | // | |
234 | // | |
235 | // Return: | |
236 | // Number of valid track references. | |
237 | // | |
faf80567 | 238 | for (Int_t i = 3; i > 0; i--) |
239 | if (fTracks[i-1] != -1) return i; | |
240 | return 0; | |
241 | } | |
242 | ||
02a27b50 | 243 | |
244 | //____________________________________________________________________ | |
245 | // | |
246 | // EOF | |
247 | // |