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