]>
Commit | Line | Data |
---|---|---|
b65e5048 | 1 | /************************************************************************* |
2 | * Copyright(c) 1998-2008, 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 | /* $Id: AliTRDarrayDictionary.cxx 25392 2008-04-23 19:40:29Z cblume $ */ | |
17 | ||
18 | ///////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Container Class for Dictionary Info // | |
21 | // // | |
22 | // Author: // | |
23 | // Hermes Leon Vargas (hleon@ikf.uni-frankfurt.de) // | |
24 | // // | |
25 | ///////////////////////////////////////////////////////// | |
26 | ||
27 | #include "AliTRDarrayDictionary.h" | |
acf20e8f | 28 | #include "AliTRDfeeParam.h" |
b65e5048 | 29 | |
30 | ClassImp(AliTRDarrayDictionary) | |
31 | ||
f41a4d6a | 32 | Short_t *AliTRDarrayDictionary::fgLutPadNumbering = 0x0; |
acf20e8f | 33 | |
b65e5048 | 34 | //________________________________________________________________________________ |
35 | AliTRDarrayDictionary::AliTRDarrayDictionary() | |
36 | :TObject() | |
37 | ,fNdet(0) | |
38 | ,fNrow(0) | |
39 | ,fNcol(0) | |
acf20e8f | 40 | ,fNumberOfChannels(0) |
b65e5048 | 41 | ,fNtime(0) |
42 | ,fNDdim(0) | |
43 | ,fDictionary(0) | |
44 | { | |
45 | // | |
46 | // AliTRDarrayDictionary default contructor | |
47 | // | |
48 | ||
acf20e8f | 49 | CreateLut(); |
50 | ||
b65e5048 | 51 | } |
52 | ||
53 | //________________________________________________________________________________ | |
54 | AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime) | |
55 | :TObject() | |
56 | ,fNdet(0) | |
57 | ,fNrow(0) | |
58 | ,fNcol(0) | |
acf20e8f | 59 | ,fNumberOfChannels(0) |
b65e5048 | 60 | ,fNtime(0) |
61 | ,fNDdim(0) | |
62 | ,fDictionary(0) | |
63 | ||
64 | { | |
65 | // | |
66 | // AliTRDarrayDictionary contructor | |
67 | // | |
68 | ||
acf20e8f | 69 | CreateLut(); |
b65e5048 | 70 | Allocate(nrow,ncol,ntime); |
71 | ||
72 | } | |
73 | ||
74 | //________________________________________________________________________________ | |
75 | AliTRDarrayDictionary::AliTRDarrayDictionary(const AliTRDarrayDictionary &a) | |
76 | :TObject() | |
77 | ,fNdet(a.fNdet) | |
78 | ,fNrow(a.fNrow) | |
79 | ,fNcol(a.fNcol) | |
acf20e8f | 80 | ,fNumberOfChannels(a.fNumberOfChannels) |
b65e5048 | 81 | ,fNtime(a.fNtime) |
82 | ,fNDdim(a.fNDdim) | |
83 | ,fDictionary(0) | |
84 | { | |
85 | // | |
86 | // AliTRDarrayDictionary copy constructor | |
87 | // | |
88 | ||
89 | fDictionary = new Int_t[fNDdim]; | |
90 | for(Int_t i=0; i<fNDdim; i++) | |
91 | { | |
92 | fDictionary[i]=a.fDictionary[i]; | |
93 | } | |
94 | ||
95 | } | |
96 | ||
97 | //________________________________________________________________________________ | |
98 | AliTRDarrayDictionary::~AliTRDarrayDictionary() | |
99 | { | |
100 | // | |
101 | // AliTRDarrayDictionary destructor | |
102 | // | |
103 | ||
104 | if(fDictionary) | |
105 | { | |
106 | delete [] fDictionary; | |
107 | fDictionary=0; | |
108 | } | |
109 | ||
110 | } | |
111 | ||
112 | //________________________________________________________________________________ | |
113 | AliTRDarrayDictionary &AliTRDarrayDictionary::operator=(const AliTRDarrayDictionary &a) | |
114 | { | |
115 | // | |
116 | // Assignment operator | |
117 | // | |
118 | ||
119 | if(this==&a) | |
120 | { | |
121 | return *this; | |
122 | } | |
123 | ||
124 | if(fDictionary) | |
125 | { | |
126 | delete [] fDictionary; | |
127 | } | |
128 | fNdet=a.fNdet; | |
129 | fNDdim=a.fNDdim; | |
130 | fNrow=a.fNrow; | |
131 | fNcol=a.fNcol; | |
acf20e8f | 132 | fNumberOfChannels = a.fNumberOfChannels; |
b65e5048 | 133 | fNtime=a.fNtime; |
134 | fDictionary = new Int_t[fNDdim]; | |
135 | for(Int_t i=0; i<fNDdim; i++) | |
136 | { | |
137 | fDictionary[i]=a.fDictionary[i]; | |
138 | } | |
139 | return *this; | |
140 | ||
141 | } | |
142 | ||
143 | //________________________________________________________________________________ | |
144 | void AliTRDarrayDictionary::Allocate(Int_t nrow, Int_t ncol, Int_t ntime) | |
145 | { | |
146 | // | |
147 | // Allocates memory for the dictionary array with dimensions | |
acf20e8f | 148 | // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time |
149 | // To be consistent with AliTRDarrayADC | |
b65e5048 | 150 | // Object initialized to -1 |
151 | // | |
152 | ||
153 | fNrow=nrow; | |
154 | fNcol=ncol; | |
155 | fNtime=ntime; | |
acf20e8f | 156 | Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm(); |
157 | Int_t padspermcm = AliTRDfeeParam::GetNcolMcm(); | |
158 | Int_t numberofmcms = fNcol/padspermcm; | |
159 | fNumberOfChannels = numberofmcms*adcchannelspermcm; | |
160 | fNDdim=nrow*fNumberOfChannels*ntime; | |
b65e5048 | 161 | if(fDictionary) |
162 | { | |
163 | delete [] fDictionary; | |
164 | fDictionary=0; | |
165 | } | |
166 | fDictionary = new Int_t[fNDdim]; | |
167 | for(Int_t i=0; i<fNDdim; i++) | |
168 | { | |
169 | fDictionary[i] = -1; | |
170 | } | |
171 | ||
172 | } | |
173 | ||
174 | //________________________________________________________________________________ | |
175 | void AliTRDarrayDictionary::Compress() | |
176 | { | |
177 | // | |
178 | // Compress the array | |
179 | // | |
180 | ||
181 | ||
182 | // AliDebug(1,"Compressing"); | |
183 | Int_t counter=0; | |
184 | Int_t newDim=0; | |
185 | Int_t j; | |
186 | Int_t r=0; | |
187 | Int_t *longArr; | |
188 | longArr = new Int_t[fNDdim]; | |
189 | Int_t k=0; | |
190 | for(Int_t i=0; i<fNDdim;i++) | |
191 | { | |
192 | longArr[i]=0; | |
193 | } | |
194 | for(Int_t i=0;i<fNDdim; i++) | |
195 | { | |
196 | j=0; | |
197 | if(fDictionary[i]==-1) | |
198 | { | |
199 | for(k=i;k<fNDdim;k++) | |
200 | { | |
201 | if(fDictionary[k]==-1) | |
202 | { | |
203 | j=j+1; | |
204 | longArr[r]=j; | |
205 | } | |
206 | else | |
207 | { | |
208 | break; | |
209 | } | |
210 | } | |
211 | r=r+1; | |
212 | } | |
213 | i=i+j; | |
214 | } | |
215 | //Calculate the size of the compressed array | |
216 | for(Int_t i=0; i<fNDdim;i++) | |
217 | { | |
218 | if(longArr[i]!=0) | |
219 | { | |
220 | counter=counter+longArr[i]-1; | |
221 | } | |
222 | } | |
223 | newDim=fNDdim-counter; //Size of the compressed array | |
224 | //Fill the buffer of the compressed array | |
225 | Int_t* buffer; | |
226 | buffer = new Int_t[newDim]; | |
227 | Int_t counterTwo=0; | |
228 | Int_t g=0; | |
229 | for(Int_t i=0; i<newDim; i++) | |
230 | { | |
231 | if(counterTwo<fNDdim) | |
232 | { | |
233 | if(fDictionary[counterTwo]!=-1) | |
234 | { | |
235 | buffer[i]=fDictionary[counterTwo]; | |
236 | } | |
237 | if(fDictionary[counterTwo]==-1) | |
238 | { | |
239 | buffer[i]=-(longArr[g]); | |
240 | counterTwo=counterTwo+longArr[g]-1; | |
241 | g++; | |
242 | } | |
243 | counterTwo++; | |
244 | } | |
245 | } | |
246 | ||
247 | //Copy the buffer | |
248 | if(fDictionary) | |
249 | { | |
250 | delete [] fDictionary; | |
251 | fDictionary=0; | |
252 | } | |
253 | fDictionary = new Int_t[newDim]; | |
254 | fNDdim = newDim; | |
255 | for(Int_t i=0; i<newDim; i++) | |
256 | { | |
257 | fDictionary[i] = buffer[i]; | |
258 | } | |
259 | if(buffer) | |
260 | { | |
261 | delete [] buffer; | |
262 | buffer=0; | |
263 | } | |
264 | if(longArr) | |
265 | { | |
266 | delete [] longArr; | |
267 | longArr=0; | |
268 | } | |
269 | ||
270 | } | |
271 | ||
272 | //________________________________________________________________________________ | |
273 | void AliTRDarrayDictionary::Expand() | |
274 | { | |
275 | // | |
276 | // Expand the array | |
277 | // | |
278 | ||
279 | Int_t *longArr; | |
280 | longArr = new Int_t[fNDdim]; | |
281 | Int_t dimexp=0; | |
282 | for(Int_t i=0; i<fNDdim;i++) | |
283 | { | |
284 | longArr[i]=0; | |
285 | } | |
286 | Int_t r2=0; | |
287 | for(Int_t i=0; i<fNDdim;i++) | |
288 | { | |
289 | if((fDictionary[i]<0)&&(fDictionary[i]!=-1)) | |
290 | { | |
291 | longArr[r2]=-fDictionary[i]; | |
292 | r2++; | |
293 | } | |
294 | } | |
295 | ||
296 | //Calculate new dimensions | |
297 | for(Int_t i=0; i<fNDdim;i++) | |
298 | { | |
299 | if(longArr[i]!=0) | |
300 | { | |
301 | dimexp=dimexp+longArr[i]-1; | |
302 | } | |
303 | } | |
304 | dimexp=dimexp+fNDdim; | |
305 | ||
306 | //Write in the buffer the new array | |
307 | Int_t* bufferE; | |
308 | bufferE = new Int_t[dimexp]; | |
309 | Int_t contaexp =0; | |
310 | Int_t h=0; | |
311 | for(Int_t i=0; i<dimexp; i++) | |
312 | { | |
313 | if(fDictionary[contaexp]>=-1) | |
314 | { | |
315 | bufferE[i]=fDictionary[contaexp]; | |
316 | } | |
317 | if(fDictionary[contaexp]<-1) | |
318 | { | |
319 | for(Int_t j=0; j<longArr[h];j++) | |
320 | { | |
321 | bufferE[i+j]=-1; | |
322 | } | |
323 | i=i+longArr[h]-1; | |
324 | h++; | |
325 | } | |
326 | contaexp++; | |
327 | } | |
328 | ||
329 | //Copy the buffer | |
330 | if(fDictionary) | |
331 | { | |
332 | delete [] fDictionary; | |
333 | fDictionary=0; | |
334 | } | |
335 | ||
336 | fDictionary = new Int_t[dimexp]; | |
337 | fNDdim = dimexp; | |
338 | for(Int_t i=0; i<dimexp; i++) | |
339 | { | |
340 | fDictionary[i] = bufferE[i]; | |
341 | } | |
342 | if(bufferE) delete [] bufferE; | |
343 | if(longArr) delete [] longArr; | |
344 | ||
345 | } | |
705d9e7b | 346 | //________________________________________________________________________________ |
347 | void AliTRDarrayDictionary::Reset() | |
348 | { | |
349 | // | |
350 | // Reset the array, the old contents are deleted | |
351 | // and the data array elements are set to zero. | |
352 | // | |
353 | ||
354 | memset(fDictionary,0,sizeof(Int_t)*fNDdim); | |
355 | ||
356 | } | |
acf20e8f | 357 | //________________________________________________________________________________ |
358 | Int_t AliTRDarrayDictionary::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const | |
359 | { | |
360 | // | |
361 | // Get the data using the pad numbering. | |
362 | // To access data using the mcm scheme use instead | |
363 | // the method GetDataByAdcCol | |
364 | // | |
365 | ||
f41a4d6a | 366 | Int_t corrcolumn = fgLutPadNumbering[ncol]; |
acf20e8f | 367 | |
368 | return fDictionary[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime]; | |
369 | ||
370 | } | |
371 | //________________________________________________________________________________ | |
372 | void AliTRDarrayDictionary::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Int_t value) | |
373 | { | |
374 | // | |
375 | // Set the data using the pad numbering. | |
376 | // To write data using the mcm scheme use instead | |
377 | // the method SetDataByAdcCol | |
378 | // | |
379 | ||
f41a4d6a | 380 | Int_t colnumb = fgLutPadNumbering[ncol]; |
acf20e8f | 381 | |
382 | fDictionary[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value; | |
383 | ||
384 | } | |
385 | ||
386 | //________________________________________________________________________________ | |
387 | void AliTRDarrayDictionary::CreateLut() | |
388 | { | |
389 | // | |
390 | // Initializes the Look Up Table to relate | |
391 | // pad numbering and mcm channel numbering | |
392 | // | |
393 | ||
f41a4d6a | 394 | if(fgLutPadNumbering) return; |
acf20e8f | 395 | |
f41a4d6a | 396 | fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()]; |
397 | memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol()); | |
acf20e8f | 398 | |
399 | for(Int_t mcm=0; mcm<8; mcm++) | |
400 | { | |
401 | Int_t lowerlimit=0+mcm*18; | |
402 | Int_t upperlimit=18+mcm*18; | |
403 | Int_t shiftposition = 1+3*mcm; | |
404 | for(Int_t index=lowerlimit;index<upperlimit;index++) | |
405 | { | |
f41a4d6a | 406 | fgLutPadNumbering[index]=index+shiftposition; |
acf20e8f | 407 | } |
408 | } | |
409 | } |