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