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