]>
Commit | Line | Data |
---|---|---|
bf6bf84c | 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 | ||
15ec34b9 | 16 | /* |
17 | $Log$ | |
10056aa6 | 18 | Revision 1.12 2007/02/20 15:57:00 decaro |
19 | Raw data update: to read the TOF raw data defined in UNPACKED mode | |
20 | ||
15ec34b9 | 21 | */ |
bf6bf84c | 22 | |
23 | //////////////////////////////////////////////////////////////////////// | |
24 | // | |
25 | // AliTOFDigitMap class | |
26 | // | |
d0eb8f39 | 27 | // digitmap enables fast check if the pad was already digit. |
28 | ||
29 | // The index of a AliTOFdigit is saved in the each digitmap "cell" | |
30 | // (there is an offset +1, because the index can be zero and zero | |
31 | // means empty cell). | |
bf6bf84c | 32 | // In TOF, number of strips varies according plate type, the highest |
d0eb8f39 | 33 | // number is in plate C. For all plates is used this number, so the |
34 | // size of the digitmap is a little bit greater than necessary, but it | |
35 | // simplifies the access algorithm. | |
bf6bf84c | 36 | // |
37 | // | |
38 | // Author: F. Pierella based on AliTOFHitMap | |
39 | // | |
d0eb8f39 | 40 | // Modified by A. De Caro |
41 | // | |
42 | /////////////////////////////////////////////////////////////////////// | |
bf6bf84c | 43 | |
d0eb8f39 | 44 | #include "AliLog.h" |
bf6bf84c | 45 | |
46 | #include "AliTOFDigitMap.h" | |
0f4a7374 | 47 | #include "AliTOFGeometry.h" |
bf6bf84c | 48 | |
bf6bf84c | 49 | ClassImp(AliTOFDigitMap) |
50 | ||
655e379f | 51 | AliTOFDigitMap::AliTOFDigitMap(): |
8a190ba2 | 52 | fNSector(AliTOFGeometry::NSectors()), |
53 | fNplate(AliTOFGeometry::NPlates()), | |
54 | fNstrip(AliTOFGeometry::NStripC()), | |
55 | fNpx(AliTOFGeometry::NpadX()), | |
56 | fNpz(AliTOFGeometry::NpadZ()), | |
655e379f | 57 | fMaxIndex(-1), |
10056aa6 | 58 | fDigitMap(0x0) |
bf6bf84c | 59 | { |
60 | // | |
61 | // Default ctor | |
62 | // | |
d3c7bfac | 63 | |
a06668b9 | 64 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; |
d0eb8f39 | 65 | fDigitMap = new Int_t*[fMaxIndex]; |
8a190ba2 | 66 | |
d0eb8f39 | 67 | for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad]; |
bf6bf84c | 68 | Clear(); |
69 | } | |
70 | ||
71 | //////////////////////////////////////////////////////////////////////// | |
8a190ba2 | 72 | AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & digitMap): |
73 | TObject(digitMap), | |
74 | fNSector(digitMap.fNSector), | |
75 | fNplate(digitMap.fNplate), | |
76 | fNstrip(digitMap.fNstrip), | |
77 | fNpx(digitMap.fNpx), | |
78 | fNpz(digitMap.fNpz), | |
79 | fMaxIndex(digitMap.fMaxIndex), | |
10056aa6 | 80 | fDigitMap(0x0) |
bf6bf84c | 81 | { |
82 | // | |
8a190ba2 | 83 | // dummy copy constructor |
bf6bf84c | 84 | // |
8a190ba2 | 85 | |
86 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; | |
87 | fDigitMap = new Int_t*[fMaxIndex]; | |
d3c7bfac | 88 | |
8a190ba2 | 89 | for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad]; |
90 | } | |
91 | ||
92 | //////////////////////////////////////////////////////////////////////// | |
93 | AliTOFDigitMap & | |
94 | AliTOFDigitMap::operator=(const AliTOFDigitMap & /*digitMap*/) | |
95 | { | |
96 | // | |
97 | // dummy copy const | |
98 | // | |
99 | return *this; | |
bf6bf84c | 100 | } |
101 | ||
102 | ||
103 | //////////////////////////////////////////////////////////////////////// | |
104 | AliTOFDigitMap::~AliTOFDigitMap() | |
105 | { | |
106 | // | |
107 | // Destructor | |
108 | // | |
d0eb8f39 | 109 | if (fDigitMap) { |
110 | for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i]; | |
111 | } | |
d3c7bfac | 112 | |
d3c7bfac | 113 | |
bf6bf84c | 114 | } |
115 | ||
116 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 117 | void AliTOFDigitMap::Clear(const Option_t*) |
bf6bf84c | 118 | { |
d0eb8f39 | 119 | // |
120 | // Clear digitmap | |
121 | // | |
122 | ||
123 | for(Int_t ii=0; ii<fMaxIndex; ii++) { | |
124 | for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) { | |
125 | fDigitMap[ii][jj] = 0; | |
126 | } | |
127 | } | |
128 | ||
bf6bf84c | 129 | } |
130 | ||
131 | //////////////////////////////////////////////////////////////////////// | |
132 | Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const | |
133 | { | |
d0eb8f39 | 134 | // |
135 | // Return checked index for vol | |
136 | // | |
137 | ||
138 | Int_t index = | |
d3c7bfac | 139 | vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector |
140 | vol[1]*fNstrip*fNpx*fNpz+ // plate | |
141 | vol[2]*fNpx*fNpz+ // strip | |
142 | vol[3]*fNpz+ // padx | |
143 | vol[4]; // padz | |
bf6bf84c | 144 | |
d0eb8f39 | 145 | if (index >= fMaxIndex || index < 0) { |
146 | AliError("CheckedIndex - input outside bounds"); | |
147 | return -1; | |
bf6bf84c | 148 | } else { |
d0eb8f39 | 149 | return index; |
bf6bf84c | 150 | } |
151 | } | |
152 | ||
153 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 154 | void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit) |
bf6bf84c | 155 | { |
d0eb8f39 | 156 | // |
157 | // Assign digit to pad vol | |
158 | // | |
159 | // 0 means empty pad, we need to shift indeces by 1 | |
bf6bf84c | 160 | |
6e4ef37b | 161 | if (fDigitMap[CheckedIndex(vol)][kMaxDigitsPerPad-1]!=0) { |
162 | AliWarning(Form("For this volume (Se%i, Pl%i, St%i, PadR%i, Pad%i) there are not more possibility to add digits.", vol[0], vol[1], vol[2], vol[4], vol[3])); | |
163 | AliWarning(Form("Then, the digit number %i will be not inserted in the digit map, i.e. it will be lost.", idigit)); | |
164 | return; | |
165 | } | |
166 | ||
d0eb8f39 | 167 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) { |
bf6bf84c | 168 | |
d0eb8f39 | 169 | if (fDigitMap[CheckedIndex(vol)][slot]==0) { |
170 | fDigitMap[CheckedIndex(vol)][slot]=idigit+1; | |
171 | break; | |
172 | } | |
173 | //else continue; | |
bf6bf84c | 174 | |
d0eb8f39 | 175 | } |
bf6bf84c | 176 | } |
177 | ||
178 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 179 | void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const |
bf6bf84c | 180 | { |
d0eb8f39 | 181 | // |
182 | // Get all contents (digitLabels) of pad volume (vol) | |
183 | // | |
184 | ||
185 | // 0 means empty pad, we need to shift indeces by 1 | |
bf6bf84c | 186 | |
d0eb8f39 | 187 | Int_t dummy; |
188 | for (Int_t j=0; j<kMaxDigitsPerPad; j++) { | |
189 | dummy = GetDigitIndex(vol,j); | |
190 | if (dummy>=0) digitLabels[j] = dummy; | |
191 | else break; | |
192 | } | |
bf6bf84c | 193 | } |
194 | ||
195 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 196 | Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const |
bf6bf84c | 197 | { |
d0eb8f39 | 198 | // |
199 | // Get one of the contents (label) of pad volume (vol) | |
200 | // | |
201 | ||
202 | // 0 means empty pad, we need to shift indeces by 1 | |
203 | ||
204 | if (!(label<kMaxDigitsPerPad)) { | |
205 | AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad)); | |
206 | return -1; | |
207 | } | |
208 | ||
209 | if (CheckedIndex(vol)==-1) return -1; | |
210 | ||
211 | Int_t dummy = fDigitMap[CheckedIndex(vol)][label]; | |
212 | ||
213 | if (dummy>0) return dummy-1; | |
214 | else return -1; | |
215 | ||
bf6bf84c | 216 | } |
217 | ||
218 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 219 | FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const |
bf6bf84c | 220 | { |
221 | // | |
222 | // Check if hit cell is empty, used or unused | |
223 | // | |
d0eb8f39 | 224 | Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified |
0085f44e | 225 | if (inf > 0) { |
bf6bf84c | 226 | return kUsed; |
227 | } else if (inf == 0) { | |
228 | return kEmpty; | |
229 | } else { | |
230 | return kUnused; | |
231 | } | |
232 | } | |
233 | ||
15ec34b9 | 234 | //////////////////////////////////////////////////////////////////////// |
235 | Int_t AliTOFDigitMap::GetFilledCellNumber() const | |
236 | { | |
237 | // | |
238 | // Returns the number of filled cells of the TOF digit map | |
239 | // | |
240 | ||
241 | Int_t volume[5] = {-1, -1, -1, -1, -1}; | |
242 | Int_t counter = 0; | |
243 | ||
244 | for (Int_t iSector=0; iSector<fNSector; iSector++) | |
245 | for (Int_t iPlate=0; iPlate<fNplate; iPlate++) | |
246 | for (Int_t iStrip=0; iStrip<fNstrip; iStrip++) | |
247 | for (Int_t iPadX=0; iPadX<fNpx; iPadX++) | |
248 | for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) | |
249 | { | |
250 | ||
251 | volume[0] = iSector; | |
252 | volume[1] = iPlate; | |
253 | volume[2] = iStrip; | |
254 | volume[3] = iPadX; | |
255 | volume[4] = iPadZ; | |
256 | ||
257 | //if (CheckedIndex(volume)!=-1) counter++; | |
258 | if (GetDigitIndex(volume, 0)>0) counter++; | |
259 | } | |
260 | ||
261 | return counter; | |
262 | ||
263 | } | |
dfa56f14 | 264 | |
265 | //////////////////////////////////////////////////////////////////////// | |
ec5fb3e4 | 266 | Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip) const |
267 | { | |
268 | // | |
269 | // Returns: | |
270 | // kFALSE if the strip doesn't contain digits | |
271 | // kTRUE if the strip contains at least one digit | |
272 | // | |
273 | ||
274 | Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1}; | |
275 | Bool_t counter = kFALSE; | |
276 | ||
277 | for (Int_t iPadX=0; iPadX<fNpx; iPadX++) | |
278 | for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) | |
279 | { | |
280 | volume[3] = iPadX; | |
281 | volume[4] = iPadZ; | |
282 | if (GetDigitIndex(volume, 0)>=0) { | |
283 | counter = kTRUE; | |
284 | break; | |
285 | } | |
286 | } | |
287 | ||
288 | return counter; | |
289 | ||
290 | } | |
291 | ||
818b5e8c | 292 | //////////////////////////////////////////////////////////////////////// |
293 | Int_t AliTOFDigitMap::DigitInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const | |
294 | { | |
295 | // | |
296 | // Returns: | |
297 | // | |
298 | ||
299 | Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1}; | |
300 | Int_t counter = 0; | |
301 | ||
302 | for (Int_t iPadX=0; iPadX<fNpx; iPadX++) | |
303 | for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) | |
304 | for (Int_t label=0; label<kMaxDigitsPerPad; label++) { | |
305 | volume[3] = iPadX; | |
306 | volume[4] = iPadZ; | |
307 | if (GetDigitIndex(volume, label)<0) continue; | |
308 | counter++; | |
309 | } | |
310 | ||
311 | return counter; | |
312 | ||
313 | } | |
314 | ||
315 | //////////////////////////////////////////////////////////////////////// | |
316 | void AliTOFDigitMap::ResetDigitNumber(Int_t *vol, Int_t dig) | |
317 | { | |
318 | // | |
319 | // Reset digit into pad vol | |
320 | // | |
321 | ||
322 | Int_t dummy = -1; | |
323 | ||
324 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) { | |
325 | if (fDigitMap[CheckedIndex(vol)][slot]-1==dig) { | |
326 | fDigitMap[CheckedIndex(vol)][slot] = 0; | |
327 | dummy = slot; | |
328 | } | |
329 | } | |
330 | /* | |
331 | if (dummy<kMaxDigitsPerPad-1) { | |
332 | for (Int_t ii=dummy; ii<kMaxDigitsPerPad-1; ii++) { | |
333 | fDigitMap[CheckedIndex(vol)][ii] = | |
334 | fDigitMap[CheckedIndex(vol)][ii+1]; | |
335 | } | |
336 | } | |
337 | */ | |
338 | } | |
339 | ||
ec5fb3e4 | 340 | //////////////////////////////////////////////////////////////////////// |
341 | void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig) | |
dfa56f14 | 342 | { |
343 | // | |
344 | // Reset digit into pad vol | |
345 | // | |
346 | // 0 means empty pad, we need to shift indeces by 1 | |
347 | ||
ec5fb3e4 | 348 | //for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) { |
349 | //if (fDigitMap[CheckedIndex(vol)][slot]==dig) | |
350 | //fDigitMap[CheckedIndex(vol)][slot] = 0; | |
351 | //} | |
ec5fb3e4 | 352 | |
818b5e8c | 353 | |
354 | fDigitMap[CheckedIndex(vol)][dig] = 0; | |
355 | /* | |
356 | if (dig<kMaxDigitsPerPad-1) { | |
357 | for (Int_t ii=dig; ii<kMaxDigitsPerPad-1; ii++) { | |
358 | fDigitMap[CheckedIndex(vol)][ii] = | |
359 | fDigitMap[CheckedIndex(vol)][ii+1]; | |
360 | } | |
361 | } | |
362 | */ | |
ec5fb3e4 | 363 | } |
364 | ||
365 | void AliTOFDigitMap::ResetDigit(Int_t *vol) | |
366 | { | |
367 | // | |
368 | // Reset digit into pad vol | |
369 | // | |
370 | // 0 means empty pad, we need to shift indices by 1 | |
371 | ||
dfa56f14 | 372 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) |
818b5e8c | 373 | fDigitMap[CheckedIndex(vol)][slot] = 0; |
374 | ||
375 | } | |
376 | ||
377 | Int_t AliTOFDigitMap::GetNumberOfDigits(Int_t *vol) | |
378 | { | |
379 | // | |
380 | // Returns the number of digit | |
381 | // into pad volume vol | |
382 | // | |
383 | // 0 means empty pad | |
384 | // | |
385 | ||
386 | Int_t counter = 0; | |
387 | ||
388 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) | |
389 | if (GetDigitIndex(vol, slot)!=-1) counter++; | |
390 | ||
391 | return counter; | |
dfa56f14 | 392 | |
393 | } |