]>
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), | |
a3b608e8 | 79 | fMaxIndex(-1), |
10056aa6 | 80 | fDigitMap(0x0) |
bf6bf84c | 81 | { |
cab4eeb0 | 82 | // |
83 | // Copy constructor | |
84 | // | |
8a190ba2 | 85 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; |
86 | fDigitMap = new Int_t*[fMaxIndex]; | |
cab4eeb0 | 87 | for (Int_t i=0; i<fMaxIndex; i++) { |
88 | fDigitMap[i] = new Int_t[kMaxDigitsPerPad]; | |
a3b608e8 | 89 | for (Int_t j=0; j<kMaxDigitsPerPad; j++) |
90 | fDigitMap[i][j]=digitMap.fDigitMap[i][j]; | |
cab4eeb0 | 91 | } |
8a190ba2 | 92 | } |
93 | ||
94 | //////////////////////////////////////////////////////////////////////// | |
a3b608e8 | 95 | AliTOFDigitMap & AliTOFDigitMap::operator=(const AliTOFDigitMap & digitMap) |
8a190ba2 | 96 | { |
cab4eeb0 | 97 | // |
98 | // Assignment operator | |
99 | // | |
100 | ||
101 | if (this != &digitMap) { | |
102 | TObject::operator=(digitMap); | |
103 | fNSector=digitMap.fNSector; | |
104 | fNplate=digitMap.fNplate; | |
105 | fNstrip=digitMap.fNstrip; | |
106 | fNpx=digitMap.fNpx; | |
107 | fNpz=digitMap.fNpz; | |
108 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; | |
109 | for (Int_t i=0; i<fMaxIndex; ++i) delete [] fDigitMap[i]; | |
110 | delete [] fDigitMap; | |
111 | fDigitMap = new Int_t*[fMaxIndex]; | |
112 | for (Int_t i=0; i<fMaxIndex; i++) { | |
113 | fDigitMap[i] = new Int_t[kMaxDigitsPerPad]; | |
114 | for (Int_t j=0; j<kMaxDigitsPerPad; j++) | |
115 | fDigitMap[i][j]=digitMap.fDigitMap[i][j]; | |
116 | } | |
117 | } | |
a44583b8 | 118 | return *this; |
bf6bf84c | 119 | } |
120 | ||
121 | ||
122 | //////////////////////////////////////////////////////////////////////// | |
123 | AliTOFDigitMap::~AliTOFDigitMap() | |
124 | { | |
125 | // | |
126 | // Destructor | |
127 | // | |
d0eb8f39 | 128 | if (fDigitMap) { |
129 | for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i]; | |
a30ca649 | 130 | delete [] fDigitMap; |
d0eb8f39 | 131 | } |
d3c7bfac | 132 | |
d3c7bfac | 133 | |
bf6bf84c | 134 | } |
135 | ||
136 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 137 | void AliTOFDigitMap::Clear(const Option_t*) |
bf6bf84c | 138 | { |
d0eb8f39 | 139 | // |
140 | // Clear digitmap | |
141 | // | |
142 | ||
143 | for(Int_t ii=0; ii<fMaxIndex; ii++) { | |
144 | for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) { | |
145 | fDigitMap[ii][jj] = 0; | |
146 | } | |
147 | } | |
148 | ||
bf6bf84c | 149 | } |
150 | ||
151 | //////////////////////////////////////////////////////////////////////// | |
0e74c396 | 152 | Int_t AliTOFDigitMap::CheckedIndex(Int_t * const vol) const |
bf6bf84c | 153 | { |
d0eb8f39 | 154 | // |
155 | // Return checked index for vol | |
156 | // | |
157 | ||
158 | Int_t index = | |
d3c7bfac | 159 | vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector |
160 | vol[1]*fNstrip*fNpx*fNpz+ // plate | |
161 | vol[2]*fNpx*fNpz+ // strip | |
162 | vol[3]*fNpz+ // padx | |
163 | vol[4]; // padz | |
bf6bf84c | 164 | |
d0eb8f39 | 165 | if (index >= fMaxIndex || index < 0) { |
166 | AliError("CheckedIndex - input outside bounds"); | |
167 | return -1; | |
bf6bf84c | 168 | } else { |
d0eb8f39 | 169 | return index; |
bf6bf84c | 170 | } |
171 | } | |
172 | ||
173 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 174 | void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit) |
bf6bf84c | 175 | { |
d0eb8f39 | 176 | // |
177 | // Assign digit to pad vol | |
178 | // | |
179 | // 0 means empty pad, we need to shift indeces by 1 | |
bf6bf84c | 180 | |
6e4ef37b | 181 | if (fDigitMap[CheckedIndex(vol)][kMaxDigitsPerPad-1]!=0) { |
fda219f1 | 182 | AliDebug(1,Form("In the volume (Se%i, Pl%i, St%i, PadR%i, Pad%i) there is not more possibility to add other digits.", vol[0], vol[1], vol[2], vol[4], vol[3])); |
183 | AliDebug(1,Form("Then, the digit number %i will be not inserted in the digit map, i.e. it will be lost.", idigit)); | |
184 | AliDebug(1,Form("Please, check the possibility to increase the digit map size (succently set to %i)", kMaxDigitsPerPad)); | |
6e4ef37b | 185 | return; |
186 | } | |
187 | ||
d0eb8f39 | 188 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) { |
bf6bf84c | 189 | |
d0eb8f39 | 190 | if (fDigitMap[CheckedIndex(vol)][slot]==0) { |
191 | fDigitMap[CheckedIndex(vol)][slot]=idigit+1; | |
192 | break; | |
193 | } | |
194 | //else continue; | |
bf6bf84c | 195 | |
d0eb8f39 | 196 | } |
c630773f | 197 | |
bf6bf84c | 198 | } |
199 | ||
200 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 201 | void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const |
bf6bf84c | 202 | { |
d0eb8f39 | 203 | // |
204 | // Get all contents (digitLabels) of pad volume (vol) | |
205 | // | |
206 | ||
207 | // 0 means empty pad, we need to shift indeces by 1 | |
bf6bf84c | 208 | |
d0eb8f39 | 209 | Int_t dummy; |
210 | for (Int_t j=0; j<kMaxDigitsPerPad; j++) { | |
211 | dummy = GetDigitIndex(vol,j); | |
212 | if (dummy>=0) digitLabels[j] = dummy; | |
213 | else break; | |
214 | } | |
bf6bf84c | 215 | } |
216 | ||
217 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 218 | Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const |
bf6bf84c | 219 | { |
d0eb8f39 | 220 | // |
221 | // Get one of the contents (label) of pad volume (vol) | |
222 | // | |
223 | ||
224 | // 0 means empty pad, we need to shift indeces by 1 | |
225 | ||
226 | if (!(label<kMaxDigitsPerPad)) { | |
227 | AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad)); | |
228 | return -1; | |
229 | } | |
230 | ||
86040d7c | 231 | Int_t ci = CheckedIndex(vol); |
232 | if (ci==-1) return -1; | |
d0eb8f39 | 233 | |
86040d7c | 234 | Int_t dummy = fDigitMap[ci][label]; |
d0eb8f39 | 235 | |
236 | if (dummy>0) return dummy-1; | |
237 | else return -1; | |
238 | ||
bf6bf84c | 239 | } |
240 | ||
241 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 242 | FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const |
bf6bf84c | 243 | { |
244 | // | |
245 | // Check if hit cell is empty, used or unused | |
246 | // | |
d0eb8f39 | 247 | Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified |
0085f44e | 248 | if (inf > 0) { |
bf6bf84c | 249 | return kUsed; |
250 | } else if (inf == 0) { | |
251 | return kEmpty; | |
252 | } else { | |
253 | return kUnused; | |
254 | } | |
255 | } | |
256 | ||
15ec34b9 | 257 | //////////////////////////////////////////////////////////////////////// |
258 | Int_t AliTOFDigitMap::GetFilledCellNumber() const | |
259 | { | |
260 | // | |
261 | // Returns the number of filled cells of the TOF digit map | |
262 | // | |
263 | ||
15ec34b9 | 264 | Int_t counter = 0; |
265 | ||
86040d7c | 266 | for (Int_t index = 0; index < fMaxIndex; ++index) |
267 | { | |
268 | for (Int_t label = 0; label < kMaxDigitsPerPad; ++label) | |
269 | { | |
270 | if (fDigitMap[index][label] > 0) | |
271 | { | |
272 | ++counter; | |
273 | break; | |
274 | } | |
275 | } | |
276 | } | |
15ec34b9 | 277 | |
278 | return counter; | |
15ec34b9 | 279 | } |
dfa56f14 | 280 | |
281 | //////////////////////////////////////////////////////////////////////// | |
ec5fb3e4 | 282 | Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip) const |
283 | { | |
284 | // | |
285 | // Returns: | |
286 | // kFALSE if the strip doesn't contain digits | |
287 | // kTRUE if the strip contains at least one digit | |
288 | // | |
289 | ||
290 | Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1}; | |
291 | Bool_t counter = kFALSE; | |
292 | ||
293 | for (Int_t iPadX=0; iPadX<fNpx; iPadX++) | |
294 | for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) | |
295 | { | |
296 | volume[3] = iPadX; | |
297 | volume[4] = iPadZ; | |
1a0fcc34 | 298 | for (Int_t label=0; label<kMaxDigitsPerPad; label++) { |
299 | if (GetDigitIndex(volume, label)>=0) { | |
300 | counter = kTRUE; | |
301 | break; | |
302 | } | |
ec5fb3e4 | 303 | } |
304 | } | |
305 | ||
306 | return counter; | |
307 | ||
308 | } | |
309 | ||
818b5e8c | 310 | //////////////////////////////////////////////////////////////////////// |
311 | Int_t AliTOFDigitMap::DigitInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const | |
312 | { | |
313 | // | |
1a0fcc34 | 314 | // Returns number of digits in the strip iStrip, |
315 | // in the plate iPlate of the sector iSector | |
818b5e8c | 316 | // |
317 | ||
318 | Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1}; | |
319 | Int_t counter = 0; | |
320 | ||
321 | for (Int_t iPadX=0; iPadX<fNpx; iPadX++) | |
322 | for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) | |
323 | for (Int_t label=0; label<kMaxDigitsPerPad; label++) { | |
324 | volume[3] = iPadX; | |
325 | volume[4] = iPadZ; | |
1a0fcc34 | 326 | if (GetDigitIndex(volume, label)>=0) |
327 | counter++; | |
818b5e8c | 328 | } |
329 | ||
330 | return counter; | |
331 | ||
332 | } | |
333 | ||
d7ed6a6d | 334 | //////////////////////////////////////////////////////////////////////// |
335 | Int_t AliTOFDigitMap::FilledCellsInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const | |
336 | { | |
337 | // | |
338 | // Returns number of digits in the strip iStrip, | |
339 | // in the plate iPlate of the sector iSector | |
340 | // | |
341 | ||
342 | Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1}; | |
343 | Int_t counter = 0; | |
344 | ||
345 | for (Int_t iPadX=0; iPadX<fNpx; iPadX++) | |
346 | for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) { | |
347 | volume[3] = iPadX; | |
348 | volume[4] = iPadZ; | |
349 | if (GetDigitIndex(volume, 0)>=0) | |
350 | counter++; | |
351 | } | |
352 | ||
353 | return counter; | |
354 | ||
355 | } | |
356 | ||
818b5e8c | 357 | //////////////////////////////////////////////////////////////////////// |
358 | void AliTOFDigitMap::ResetDigitNumber(Int_t *vol, Int_t dig) | |
359 | { | |
360 | // | |
361 | // Reset digit into pad vol | |
362 | // | |
363 | ||
818b5e8c | 364 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) { |
365 | if (fDigitMap[CheckedIndex(vol)][slot]-1==dig) { | |
366 | fDigitMap[CheckedIndex(vol)][slot] = 0; | |
818b5e8c | 367 | } |
368 | } | |
1a0fcc34 | 369 | |
818b5e8c | 370 | } |
371 | ||
ec5fb3e4 | 372 | //////////////////////////////////////////////////////////////////////// |
373 | void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig) | |
dfa56f14 | 374 | { |
375 | // | |
376 | // Reset digit into pad vol | |
377 | // | |
378 | // 0 means empty pad, we need to shift indeces by 1 | |
379 | ||
818b5e8c | 380 | fDigitMap[CheckedIndex(vol)][dig] = 0; |
1a0fcc34 | 381 | |
ec5fb3e4 | 382 | } |
383 | ||
1a0fcc34 | 384 | //////////////////////////////////////////////////////////////////////// |
ec5fb3e4 | 385 | void AliTOFDigitMap::ResetDigit(Int_t *vol) |
386 | { | |
387 | // | |
388 | // Reset digit into pad vol | |
389 | // | |
390 | // 0 means empty pad, we need to shift indices by 1 | |
391 | ||
dfa56f14 | 392 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) |
818b5e8c | 393 | fDigitMap[CheckedIndex(vol)][slot] = 0; |
394 | ||
395 | } | |
396 | ||
1a0fcc34 | 397 | //////////////////////////////////////////////////////////////////////// |
818b5e8c | 398 | Int_t AliTOFDigitMap::GetNumberOfDigits(Int_t *vol) |
399 | { | |
400 | // | |
401 | // Returns the number of digit | |
402 | // into pad volume vol | |
403 | // | |
404 | // 0 means empty pad | |
405 | // | |
406 | ||
407 | Int_t counter = 0; | |
408 | ||
409 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) | |
1a0fcc34 | 410 | if (GetDigitIndex(vol, slot)>=0) counter++; |
818b5e8c | 411 | |
412 | return counter; | |
dfa56f14 | 413 | |
414 | } |