]>
Commit | Line | Data |
---|---|---|
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 | $Log$ | |
18 | */ | |
19 | ||
20 | //////////////////////////////////////////////////////////////////////// | |
21 | // | |
22 | // AliTOFDigitMap class | |
23 | // | |
24 | // digitmap enables fast check if the pad was already digit. | |
25 | ||
26 | // The index of a AliTOFdigit is saved in the each digitmap "cell" | |
27 | // (there is an offset +1, because the index can be zero and zero | |
28 | // means empty cell). | |
29 | // In TOF, number of strips varies according plate type, the highest | |
30 | // number is in plate C. For all plates is used this number, so the | |
31 | // size of the digitmap is a little bit greater than necessary, but it | |
32 | // simplifies the access algorithm. | |
33 | // | |
34 | // | |
35 | // Author: F. Pierella based on AliTOFHitMap | |
36 | // | |
37 | // Modified by A. De Caro | |
38 | // | |
39 | /////////////////////////////////////////////////////////////////////// | |
40 | ||
41 | #include "AliLog.h" | |
42 | ||
43 | #include "AliTOFDigitMap.h" | |
44 | #include "AliTOFGeometry.h" | |
45 | ||
46 | ClassImp(AliTOFDigitMap) | |
47 | ||
48 | AliTOFDigitMap::AliTOFDigitMap(): | |
49 | fNSector(-1), | |
50 | fNplate(-1), | |
51 | fNstrip(-1), | |
52 | fNpx(-1), | |
53 | fNpz(-1), | |
54 | fMaxIndex(-1), | |
55 | fDigitMap(0x0), | |
56 | fTOFGeometry(new AliTOFGeometry()) | |
57 | { | |
58 | // | |
59 | // Default ctor | |
60 | // | |
61 | ||
62 | fNSector = AliTOFGeometry::NSectors(); | |
63 | fNplate = AliTOFGeometry::NPlates(); | |
64 | fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip(); | |
65 | fNpx = AliTOFGeometry::NpadX(); | |
66 | fNpz = AliTOFGeometry::NpadZ(); | |
67 | fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz; | |
68 | ||
69 | fDigitMap = new Int_t*[fMaxIndex]; | |
70 | for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad]; | |
71 | Clear(); | |
72 | } | |
73 | ||
74 | //////////////////////////////////////////////////////////////////////// | |
75 | AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/): | |
76 | TObject(), | |
77 | fNSector(-1), | |
78 | fNplate(-1), | |
79 | fNstrip(-1), | |
80 | fNpx(-1), | |
81 | fNpz(-1), | |
82 | fMaxIndex(-1), | |
83 | fDigitMap(0x0), | |
84 | fTOFGeometry(new AliTOFGeometry()) | |
85 | { | |
86 | // | |
87 | // Dummy copy constructor | |
88 | // | |
89 | ; | |
90 | ||
91 | } | |
92 | ||
93 | ||
94 | //////////////////////////////////////////////////////////////////////// | |
95 | AliTOFDigitMap::~AliTOFDigitMap() | |
96 | { | |
97 | // | |
98 | // Destructor | |
99 | // | |
100 | if (fDigitMap) { | |
101 | for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i]; | |
102 | } | |
103 | ||
104 | fTOFGeometry = 0; | |
105 | ||
106 | } | |
107 | ||
108 | //////////////////////////////////////////////////////////////////////// | |
109 | void AliTOFDigitMap::Clear(const Option_t*) | |
110 | { | |
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 | ||
121 | } | |
122 | ||
123 | //////////////////////////////////////////////////////////////////////// | |
124 | Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const | |
125 | { | |
126 | // | |
127 | // Return checked index for vol | |
128 | // | |
129 | ||
130 | Int_t index = | |
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 | |
136 | ||
137 | if (index >= fMaxIndex || index < 0) { | |
138 | AliError("CheckedIndex - input outside bounds"); | |
139 | return -1; | |
140 | } else { | |
141 | return index; | |
142 | } | |
143 | } | |
144 | ||
145 | //////////////////////////////////////////////////////////////////////// | |
146 | void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit) | |
147 | { | |
148 | // | |
149 | // Assign digit to pad vol | |
150 | // | |
151 | // 0 means empty pad, we need to shift indeces by 1 | |
152 | ||
153 | for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) { | |
154 | ||
155 | if (fDigitMap[CheckedIndex(vol)][slot]==0) { | |
156 | fDigitMap[CheckedIndex(vol)][slot]=idigit+1; | |
157 | break; | |
158 | } | |
159 | //else continue; | |
160 | ||
161 | } | |
162 | } | |
163 | ||
164 | //////////////////////////////////////////////////////////////////////// | |
165 | void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const | |
166 | { | |
167 | // | |
168 | // Get all contents (digitLabels) of pad volume (vol) | |
169 | // | |
170 | ||
171 | // 0 means empty pad, we need to shift indeces by 1 | |
172 | ||
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 | } | |
179 | } | |
180 | ||
181 | //////////////////////////////////////////////////////////////////////// | |
182 | Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const | |
183 | { | |
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 | ||
202 | } | |
203 | ||
204 | //////////////////////////////////////////////////////////////////////// | |
205 | FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const | |
206 | { | |
207 | // | |
208 | // Check if hit cell is empty, used or unused | |
209 | // | |
210 | Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified | |
211 | if (inf > 0) { | |
212 | return kUsed; | |
213 | } else if (inf == 0) { | |
214 | return kEmpty; | |
215 | } else { | |
216 | return kUnused; | |
217 | } | |
218 | } | |
219 | ||
220 | //////////////////////////////////////////////////////////////////////// | |
221 | AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) | |
222 | { | |
223 | // Dummy assignment operator | |
224 | return *this; | |
225 | } | |
226 | //////////////////////////////////////////////////////////////////////// | |
227 | Int_t AliTOFDigitMap::GetFilledCellNumber() const | |
228 | { | |
229 | // | |
230 | // Returns the number of filled cells of the TOF digit map | |
231 | // | |
232 | ||
233 | Int_t volume[5] = {-1, -1, -1, -1, -1}; | |
234 | Int_t counter = 0; | |
235 | ||
236 | for (Int_t iSector=0; iSector<fNSector; iSector++) | |
237 | for (Int_t iPlate=0; iPlate<fNplate; iPlate++) | |
238 | for (Int_t iStrip=0; iStrip<fNstrip; iStrip++) | |
239 | for (Int_t iPadX=0; iPadX<fNpx; iPadX++) | |
240 | for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) | |
241 | { | |
242 | ||
243 | volume[0] = iSector; | |
244 | volume[1] = iPlate; | |
245 | volume[2] = iStrip; | |
246 | volume[3] = iPadX; | |
247 | volume[4] = iPadZ; | |
248 | ||
249 | //if (CheckedIndex(volume)!=-1) counter++; | |
250 | if (GetDigitIndex(volume, 0)>0) counter++; | |
251 | } | |
252 | ||
253 | return counter; | |
254 | ||
255 | } |