1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
23 ////////////////////////////////////////////////////////////////////////
25 // AliTOFDigitMap class
27 // digitmap enables fast check if the pad was already digit.
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
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.
38 // Author: F. Pierella based on AliTOFHitMap
40 // Modified by A. De Caro
42 ///////////////////////////////////////////////////////////////////////
46 #include "AliTOFDigitMap.h"
47 #include "AliTOFGeometry.h"
49 ClassImp(AliTOFDigitMap)
51 AliTOFDigitMap::AliTOFDigitMap():
52 fNSector(AliTOFGeometry::NSectors()),
53 fNplate(AliTOFGeometry::NPlates()),
54 fNstrip(AliTOFGeometry::NStripC()),
55 fNpx(AliTOFGeometry::NpadX()),
56 fNpz(AliTOFGeometry::NpadZ()),
64 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
65 fDigitMap = new Int_t*[fMaxIndex];
67 for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
71 ////////////////////////////////////////////////////////////////////////
72 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & digitMap):
74 fNSector(digitMap.fNSector),
75 fNplate(digitMap.fNplate),
76 fNstrip(digitMap.fNstrip),
79 fMaxIndex(digitMap.fMaxIndex),
83 // dummy copy constructor
86 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
87 fDigitMap = new Int_t*[fMaxIndex];
89 for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
92 ////////////////////////////////////////////////////////////////////////
94 AliTOFDigitMap::operator=(const AliTOFDigitMap & /*digitMap*/)
103 ////////////////////////////////////////////////////////////////////////
104 AliTOFDigitMap::~AliTOFDigitMap()
110 for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i];
116 ////////////////////////////////////////////////////////////////////////
117 void AliTOFDigitMap::Clear(const Option_t*)
123 for(Int_t ii=0; ii<fMaxIndex; ii++) {
124 for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
125 fDigitMap[ii][jj] = 0;
131 ////////////////////////////////////////////////////////////////////////
132 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
135 // Return checked index for vol
139 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
140 vol[1]*fNstrip*fNpx*fNpz+ // plate
141 vol[2]*fNpx*fNpz+ // strip
145 if (index >= fMaxIndex || index < 0) {
146 AliError("CheckedIndex - input outside bounds");
153 ////////////////////////////////////////////////////////////////////////
154 void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
157 // Assign digit to pad vol
159 // 0 means empty pad, we need to shift indeces by 1
161 if (fDigitMap[CheckedIndex(vol)][kMaxDigitsPerPad-1]!=0) {
162 AliWarning(Form("For this volume (Se%i, Pl%i, St%i, PadR%i, Pad%i) there are not more possibility to add digits.", vol[0], vol[1], vol[2], vol[4], vol[3]));
163 AliWarning(Form("Then, the digit number %i will be not inserted in the digit map, i.e. it will be lost.", idigit));
167 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
169 if (fDigitMap[CheckedIndex(vol)][slot]==0) {
170 fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
178 ////////////////////////////////////////////////////////////////////////
179 void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
182 // Get all contents (digitLabels) of pad volume (vol)
185 // 0 means empty pad, we need to shift indeces by 1
188 for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
189 dummy = GetDigitIndex(vol,j);
190 if (dummy>=0) digitLabels[j] = dummy;
195 ////////////////////////////////////////////////////////////////////////
196 Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
199 // Get one of the contents (label) of pad volume (vol)
202 // 0 means empty pad, we need to shift indeces by 1
204 if (!(label<kMaxDigitsPerPad)) {
205 AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
209 if (CheckedIndex(vol)==-1) return -1;
211 Int_t dummy = fDigitMap[CheckedIndex(vol)][label];
213 if (dummy>0) return dummy-1;
218 ////////////////////////////////////////////////////////////////////////
219 FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
222 // Check if hit cell is empty, used or unused
224 Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
227 } else if (inf == 0) {
234 ////////////////////////////////////////////////////////////////////////
235 Int_t AliTOFDigitMap::GetFilledCellNumber() const
238 // Returns the number of filled cells of the TOF digit map
241 Int_t volume[5] = {-1, -1, -1, -1, -1};
244 for (Int_t iSector=0; iSector<fNSector; iSector++)
245 for (Int_t iPlate=0; iPlate<fNplate; iPlate++)
246 for (Int_t iStrip=0; iStrip<fNstrip; iStrip++)
247 for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
248 for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
257 //if (CheckedIndex(volume)!=-1) counter++;
258 if (GetDigitIndex(volume, 0)>0) counter++;
265 ////////////////////////////////////////////////////////////////////////
266 Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip) const
270 // kFALSE if the strip doesn't contain digits
271 // kTRUE if the strip contains at least one digit
274 Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
275 Bool_t counter = kFALSE;
277 for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
278 for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
282 if (GetDigitIndex(volume, 0)>=0) {
292 ////////////////////////////////////////////////////////////////////////
293 Int_t AliTOFDigitMap::DigitInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const
299 Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
302 for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
303 for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
304 for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
307 if (GetDigitIndex(volume, label)<0) continue;
315 ////////////////////////////////////////////////////////////////////////
316 void AliTOFDigitMap::ResetDigitNumber(Int_t *vol, Int_t dig)
319 // Reset digit into pad vol
324 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
325 if (fDigitMap[CheckedIndex(vol)][slot]-1==dig) {
326 fDigitMap[CheckedIndex(vol)][slot] = 0;
331 if (dummy<kMaxDigitsPerPad-1) {
332 for (Int_t ii=dummy; ii<kMaxDigitsPerPad-1; ii++) {
333 fDigitMap[CheckedIndex(vol)][ii] =
334 fDigitMap[CheckedIndex(vol)][ii+1];
340 ////////////////////////////////////////////////////////////////////////
341 void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig)
344 // Reset digit into pad vol
346 // 0 means empty pad, we need to shift indeces by 1
348 //for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
349 //if (fDigitMap[CheckedIndex(vol)][slot]==dig)
350 //fDigitMap[CheckedIndex(vol)][slot] = 0;
354 fDigitMap[CheckedIndex(vol)][dig] = 0;
356 if (dig<kMaxDigitsPerPad-1) {
357 for (Int_t ii=dig; ii<kMaxDigitsPerPad-1; ii++) {
358 fDigitMap[CheckedIndex(vol)][ii] =
359 fDigitMap[CheckedIndex(vol)][ii+1];
365 void AliTOFDigitMap::ResetDigit(Int_t *vol)
368 // Reset digit into pad vol
370 // 0 means empty pad, we need to shift indices by 1
372 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
373 fDigitMap[CheckedIndex(vol)][slot] = 0;
377 Int_t AliTOFDigitMap::GetNumberOfDigits(Int_t *vol)
380 // Returns the number of digit
381 // into pad volume vol
388 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
389 if (GetDigitIndex(vol, slot)!=-1) counter++;