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