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