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