]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | ||
17 | //////////////////////////////////////////////////////////////////////// | |
18 | // | |
19 | // AliTOFDigitMap class | |
20 | // | |
d0eb8f39 | 21 | // digitmap enables fast check if the pad was already digit. |
22 | ||
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 | |
25 | // means empty cell). | |
bf6bf84c | 26 | // In TOF, number of strips varies according plate type, the highest |
d0eb8f39 | 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. | |
bf6bf84c | 30 | // |
31 | // | |
32 | // Author: F. Pierella based on AliTOFHitMap | |
33 | // | |
d0eb8f39 | 34 | // Modified by A. De Caro |
35 | // | |
36 | /////////////////////////////////////////////////////////////////////// | |
bf6bf84c | 37 | |
d0eb8f39 | 38 | #include "AliLog.h" |
bf6bf84c | 39 | |
40 | #include "AliTOFDigitMap.h" | |
0f4a7374 | 41 | #include "AliTOFGeometry.h" |
bf6bf84c | 42 | |
bf6bf84c | 43 | ClassImp(AliTOFDigitMap) |
44 | ||
655e379f | 45 | AliTOFDigitMap::AliTOFDigitMap(): |
46 | fNSector(-1), | |
47 | fNplate(-1), | |
48 | fNstrip(-1), | |
49 | fNpx(-1), | |
50 | fNpz(-1), | |
51 | fMaxIndex(-1), | |
52 | fDigitMap(0x0), | |
53 | fTOFGeometry(new AliTOFGeometry()) | |
bf6bf84c | 54 | { |
55 | // | |
56 | // Default ctor | |
57 | // | |
d3c7bfac | 58 | |
0f4a7374 | 59 | fNSector = AliTOFGeometry::NSectors(); |
60 | fNplate = AliTOFGeometry::NPlates(); | |
d0eb8f39 | 61 | fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip(); |
0f4a7374 | 62 | fNpx = AliTOFGeometry::NpadX(); |
63 | fNpz = AliTOFGeometry::NpadZ(); | |
a06668b9 | 64 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; |
d0eb8f39 | 65 | |
66 | fDigitMap = new Int_t*[fMaxIndex]; | |
67 | for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad]; | |
bf6bf84c | 68 | Clear(); |
69 | } | |
70 | ||
71 | //////////////////////////////////////////////////////////////////////// | |
655e379f | 72 | AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/): |
73 | TObject(), | |
74 | fNSector(-1), | |
75 | fNplate(-1), | |
76 | fNstrip(-1), | |
77 | fNpx(-1), | |
78 | fNpz(-1), | |
79 | fMaxIndex(-1), | |
80 | fDigitMap(0x0), | |
81 | fTOFGeometry(new AliTOFGeometry()) | |
bf6bf84c | 82 | { |
83 | // | |
84 | // Dummy copy constructor | |
85 | // | |
d3c7bfac | 86 | ; |
87 | ||
bf6bf84c | 88 | } |
89 | ||
90 | ||
91 | //////////////////////////////////////////////////////////////////////// | |
92 | AliTOFDigitMap::~AliTOFDigitMap() | |
93 | { | |
94 | // | |
95 | // Destructor | |
96 | // | |
d0eb8f39 | 97 | if (fDigitMap) { |
98 | for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i]; | |
99 | } | |
d3c7bfac | 100 | |
afd804a3 | 101 | fTOFGeometry = 0; |
d3c7bfac | 102 | |
bf6bf84c | 103 | } |
104 | ||
105 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 106 | void AliTOFDigitMap::Clear(const Option_t*) |
bf6bf84c | 107 | { |
d0eb8f39 | 108 | // |
109 | // Clear digitmap | |
110 | // | |
111 | ||
112 | for(Int_t ii=0; ii<fMaxIndex; ii++) { | |
113 | for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) { | |
114 | fDigitMap[ii][jj] = 0; | |
115 | } | |
116 | } | |
117 | ||
bf6bf84c | 118 | } |
119 | ||
120 | //////////////////////////////////////////////////////////////////////// | |
121 | Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const | |
122 | { | |
d0eb8f39 | 123 | // |
124 | // Return checked index for vol | |
125 | // | |
126 | ||
127 | Int_t index = | |
d3c7bfac | 128 | vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector |
129 | vol[1]*fNstrip*fNpx*fNpz+ // plate | |
130 | vol[2]*fNpx*fNpz+ // strip | |
131 | vol[3]*fNpz+ // padx | |
132 | vol[4]; // padz | |
bf6bf84c | 133 | |
d0eb8f39 | 134 | if (index >= fMaxIndex || index < 0) { |
135 | AliError("CheckedIndex - input outside bounds"); | |
136 | return -1; | |
bf6bf84c | 137 | } else { |
d0eb8f39 | 138 | return index; |
bf6bf84c | 139 | } |
140 | } | |
141 | ||
142 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 143 | void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit) |
bf6bf84c | 144 | { |
d0eb8f39 | 145 | // |
146 | // Assign digit to pad vol | |
147 | // | |
148 | // 0 means empty pad, we need to shift indeces by 1 | |
bf6bf84c | 149 | |
d0eb8f39 | 150 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) { |
bf6bf84c | 151 | |
d0eb8f39 | 152 | if (fDigitMap[CheckedIndex(vol)][slot]==0) { |
153 | fDigitMap[CheckedIndex(vol)][slot]=idigit+1; | |
154 | break; | |
155 | } | |
156 | //else continue; | |
bf6bf84c | 157 | |
d0eb8f39 | 158 | } |
bf6bf84c | 159 | } |
160 | ||
161 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 162 | void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const |
bf6bf84c | 163 | { |
d0eb8f39 | 164 | // |
165 | // Get all contents (digitLabels) of pad volume (vol) | |
166 | // | |
167 | ||
168 | // 0 means empty pad, we need to shift indeces by 1 | |
bf6bf84c | 169 | |
d0eb8f39 | 170 | Int_t dummy; |
171 | for (Int_t j=0; j<kMaxDigitsPerPad; j++) { | |
172 | dummy = GetDigitIndex(vol,j); | |
173 | if (dummy>=0) digitLabels[j] = dummy; | |
174 | else break; | |
175 | } | |
bf6bf84c | 176 | } |
177 | ||
178 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 179 | Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const |
bf6bf84c | 180 | { |
d0eb8f39 | 181 | // |
182 | // Get one of the contents (label) of pad volume (vol) | |
183 | // | |
184 | ||
185 | // 0 means empty pad, we need to shift indeces by 1 | |
186 | ||
187 | if (!(label<kMaxDigitsPerPad)) { | |
188 | AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad)); | |
189 | return -1; | |
190 | } | |
191 | ||
192 | if (CheckedIndex(vol)==-1) return -1; | |
193 | ||
194 | Int_t dummy = fDigitMap[CheckedIndex(vol)][label]; | |
195 | ||
196 | if (dummy>0) return dummy-1; | |
197 | else return -1; | |
198 | ||
bf6bf84c | 199 | } |
200 | ||
201 | //////////////////////////////////////////////////////////////////////// | |
d0eb8f39 | 202 | FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const |
bf6bf84c | 203 | { |
204 | // | |
205 | // Check if hit cell is empty, used or unused | |
206 | // | |
d0eb8f39 | 207 | Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified |
0085f44e | 208 | if (inf > 0) { |
bf6bf84c | 209 | return kUsed; |
210 | } else if (inf == 0) { | |
211 | return kEmpty; | |
212 | } else { | |
213 | return kUnused; | |
214 | } | |
215 | } | |
216 | ||
217 | //////////////////////////////////////////////////////////////////////// | |
5c016a7b | 218 | AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) |
bf6bf84c | 219 | { |
220 | // Dummy assignment operator | |
221 | return *this; | |
222 | } |