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 **************************************************************************/
17 ////////////////////////////////////////////////////////////////////////
19 // AliTOFDigitMap class
21 // digitmap enables fast check if the pad was already digit.
23 // The index of a AliTOFdigit is saved in the each digitmap "cell"
24 // (there is an offset +1, because the index can be zero and zero
26 // In TOF, number of strips varies according plate type, the highest
27 // number is in plate C. For all plates is used this number, so the
28 // size of the digitmap is a little bit greater than necessary, but it
29 // simplifies the access algorithm.
32 // Author: F. Pierella based on AliTOFHitMap
34 // Modified by A. De Caro
36 ///////////////////////////////////////////////////////////////////////
40 #include "AliTOFDigitMap.h"
41 #include "AliTOFGeometry.h"
43 ClassImp(AliTOFDigitMap)
45 AliTOFDigitMap::AliTOFDigitMap()
52 fTOFGeometry = new AliTOFGeometry();
54 fNSector = AliTOFGeometry::NSectors();
55 fNplate = AliTOFGeometry::NPlates();
56 fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip();
57 fNpx = AliTOFGeometry::NpadX();
58 fNpz = AliTOFGeometry::NpadZ();
59 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
61 fDigitMap = new Int_t*[fMaxIndex];
62 for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
66 ////////////////////////////////////////////////////////////////////////
67 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/)
71 // Dummy copy constructor
78 ////////////////////////////////////////////////////////////////////////
79 AliTOFDigitMap::~AliTOFDigitMap()
85 for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i];
92 ////////////////////////////////////////////////////////////////////////
93 void AliTOFDigitMap::Clear(const Option_t*)
99 for(Int_t ii=0; ii<fMaxIndex; ii++) {
100 for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
101 fDigitMap[ii][jj] = 0;
107 ////////////////////////////////////////////////////////////////////////
108 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
111 // Return checked index for vol
115 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
116 vol[1]*fNstrip*fNpx*fNpz+ // plate
117 vol[2]*fNpx*fNpz+ // strip
121 if (index >= fMaxIndex || index < 0) {
122 AliError("CheckedIndex - input outside bounds");
129 ////////////////////////////////////////////////////////////////////////
130 void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
133 // Assign digit to pad vol
135 // 0 means empty pad, we need to shift indeces by 1
137 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
139 if (fDigitMap[CheckedIndex(vol)][slot]==0) {
140 fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
148 ////////////////////////////////////////////////////////////////////////
149 void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
152 // Get all contents (digitLabels) of pad volume (vol)
155 // 0 means empty pad, we need to shift indeces by 1
158 for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
159 dummy = GetDigitIndex(vol,j);
160 if (dummy>=0) digitLabels[j] = dummy;
165 ////////////////////////////////////////////////////////////////////////
166 Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
169 // Get one of the contents (label) of pad volume (vol)
172 // 0 means empty pad, we need to shift indeces by 1
174 if (!(label<kMaxDigitsPerPad)) {
175 AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
179 if (CheckedIndex(vol)==-1) return -1;
181 Int_t dummy = fDigitMap[CheckedIndex(vol)][label];
183 if (dummy>0) return dummy-1;
188 ////////////////////////////////////////////////////////////////////////
189 FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
192 // Check if hit cell is empty, used or unused
194 Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
197 } else if (inf == 0) {
204 ////////////////////////////////////////////////////////////////////////
205 AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/)
207 // Dummy assignment operator