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