]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFDigitMap.cxx
Get in sync with the base class
[u/mrichter/AliRoot.git] / TOF / AliTOFDigitMap.cxx
CommitLineData
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 18Revision 1.12 2007/02/20 15:57:00 decaro
19Raw 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 49ClassImp(AliTOFDigitMap)
50
655e379f 51AliTOFDigitMap::AliTOFDigitMap():
52 fNSector(-1),
53 fNplate(-1),
54 fNstrip(-1),
55 fNpx(-1),
56 fNpz(-1),
57 fMaxIndex(-1),
10056aa6 58 fDigitMap(0x0)
bf6bf84c 59{
60//
61// Default ctor
62//
d3c7bfac 63
0f4a7374 64 fNSector = AliTOFGeometry::NSectors();
65 fNplate = AliTOFGeometry::NPlates();
10056aa6 66 fNstrip = AliTOFGeometry::NStripC();
0f4a7374 67 fNpx = AliTOFGeometry::NpadX();
68 fNpz = AliTOFGeometry::NpadZ();
a06668b9 69 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
d0eb8f39 70
71 fDigitMap = new Int_t*[fMaxIndex];
72 for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
bf6bf84c 73 Clear();
74}
75
76////////////////////////////////////////////////////////////////////////
655e379f 77AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/):
78 TObject(),
79 fNSector(-1),
80 fNplate(-1),
81 fNstrip(-1),
82 fNpx(-1),
83 fNpz(-1),
84 fMaxIndex(-1),
10056aa6 85 fDigitMap(0x0)
bf6bf84c 86{
87//
88// Dummy copy constructor
89//
d3c7bfac 90 ;
91
bf6bf84c 92}
93
94
95////////////////////////////////////////////////////////////////////////
96AliTOFDigitMap::~AliTOFDigitMap()
97{
98//
99// Destructor
100//
d0eb8f39 101 if (fDigitMap) {
102 for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i];
103 }
d3c7bfac 104
d3c7bfac 105
bf6bf84c 106}
107
108////////////////////////////////////////////////////////////////////////
d0eb8f39 109void AliTOFDigitMap::Clear(const Option_t*)
bf6bf84c 110{
d0eb8f39 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
bf6bf84c 121}
122
123////////////////////////////////////////////////////////////////////////
124Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
125{
d0eb8f39 126 //
127 // Return checked index for vol
128 //
129
130 Int_t index =
d3c7bfac 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
bf6bf84c 136
d0eb8f39 137 if (index >= fMaxIndex || index < 0) {
138 AliError("CheckedIndex - input outside bounds");
139 return -1;
bf6bf84c 140 } else {
d0eb8f39 141 return index;
bf6bf84c 142 }
143}
144
145////////////////////////////////////////////////////////////////////////
d0eb8f39 146void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
bf6bf84c 147{
d0eb8f39 148 //
149 // Assign digit to pad vol
150 //
151 // 0 means empty pad, we need to shift indeces by 1
bf6bf84c 152
d0eb8f39 153 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
bf6bf84c 154
d0eb8f39 155 if (fDigitMap[CheckedIndex(vol)][slot]==0) {
156 fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
157 break;
158 }
159 //else continue;
bf6bf84c 160
d0eb8f39 161 }
bf6bf84c 162}
163
164////////////////////////////////////////////////////////////////////////
d0eb8f39 165void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
bf6bf84c 166{
d0eb8f39 167 //
168 // Get all contents (digitLabels) of pad volume (vol)
169 //
170
171 // 0 means empty pad, we need to shift indeces by 1
bf6bf84c 172
d0eb8f39 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 }
bf6bf84c 179}
180
181////////////////////////////////////////////////////////////////////////
d0eb8f39 182Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
bf6bf84c 183{
d0eb8f39 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
bf6bf84c 202}
203
204////////////////////////////////////////////////////////////////////////
d0eb8f39 205FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
bf6bf84c 206{
207//
208// Check if hit cell is empty, used or unused
209//
d0eb8f39 210 Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
0085f44e 211 if (inf > 0) {
bf6bf84c 212 return kUsed;
213 } else if (inf == 0) {
214 return kEmpty;
215 } else {
216 return kUnused;
217 }
218}
219
220////////////////////////////////////////////////////////////////////////
5c016a7b 221AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/)
bf6bf84c 222{
223// Dummy assignment operator
224 return *this;
225}
ec5fb3e4 226
15ec34b9 227////////////////////////////////////////////////////////////////////////
228Int_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}
dfa56f14 257
258////////////////////////////////////////////////////////////////////////
ec5fb3e4 259Bool_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
818b5e8c 285////////////////////////////////////////////////////////////////////////
286Int_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////////////////////////////////////////////////////////////////////////
309void 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
ec5fb3e4 333////////////////////////////////////////////////////////////////////////
334void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig)
dfa56f14 335{
336 //
337 // Reset digit into pad vol
338 //
339 // 0 means empty pad, we need to shift indeces by 1
340
ec5fb3e4 341 //for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
342 //if (fDigitMap[CheckedIndex(vol)][slot]==dig)
343 //fDigitMap[CheckedIndex(vol)][slot] = 0;
344 //}
ec5fb3e4 345
818b5e8c 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 */
ec5fb3e4 356}
357
358void 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
dfa56f14 365 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
818b5e8c 366 fDigitMap[CheckedIndex(vol)][slot] = 0;
367
368}
369
370Int_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;
dfa56f14 385
386}