]>
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 | ||
103 | if (fSignal) | |
104 | { | |
105 | delete [] fSignal; | |
106 | fSignal=0; | |
107 | } | |
108 | ||
109 | } | |
110 | ||
111 | //_______________________________________________________________________ | |
112 | AliTRDarraySignal &AliTRDarraySignal::operator=(const AliTRDarraySignal &d) | |
113 | { | |
114 | // | |
115 | // Assignment operator | |
116 | // | |
117 | ||
118 | if (this==&d) | |
119 | { | |
120 | return *this; | |
121 | } | |
122 | ||
123 | if (fSignal) | |
124 | { | |
125 | delete [] fSignal; | |
126 | } | |
127 | fNdet=d.fNdet; | |
128 | fNrow=d.fNrow; | |
129 | fNcol=d.fNcol; | |
acf20e8f | 130 | fNumberOfChannels = d.fNumberOfChannels; |
b65e5048 | 131 | fNtime=d.fNtime; |
132 | fNdim=d.fNdim; | |
133 | fSignal = new Float_t[fNdim]; | |
064d808d | 134 | memcpy(fSignal,d.fSignal, fNdim*sizeof(Float_t)); |
b65e5048 | 135 | |
136 | return *this; | |
137 | ||
138 | } | |
139 | ||
140 | //_______________________________________________________________________ | |
141 | void AliTRDarraySignal::Allocate(Int_t nrow, Int_t ncol, Int_t ntime) | |
142 | { | |
143 | // | |
144 | // Allocates memory for an AliTRDarraySignal object with dimensions | |
acf20e8f | 145 | // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time |
146 | // To be consistent with AliTRDarrayADC | |
b65e5048 | 147 | // |
148 | ||
149 | fNrow=nrow; | |
150 | fNcol=ncol; | |
151 | fNtime=ntime; | |
acf20e8f | 152 | Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm(); |
153 | Int_t padspermcm = AliTRDfeeParam::GetNcolMcm(); | |
154 | Int_t numberofmcms = fNcol/padspermcm; | |
155 | fNumberOfChannels = numberofmcms*adcchannelspermcm; | |
156 | fNdim = nrow*fNumberOfChannels*ntime; | |
b65e5048 | 157 | if (fSignal) |
158 | { | |
159 | delete [] fSignal; | |
160 | } | |
161 | fSignal = new Float_t[fNdim]; | |
064d808d | 162 | memset(fSignal,0,sizeof(Float_t)*fNdim); |
b65e5048 | 163 | |
164 | } | |
165 | ||
166 | //_______________________________________________________________________ | |
f41a4d6a | 167 | Int_t AliTRDarraySignal::GetOverThreshold(Float_t threshold) const |
b65e5048 | 168 | { |
169 | // | |
170 | // Get the number of entries over the threshold | |
171 | // | |
172 | ||
173 | Int_t counter=0; | |
174 | for(Int_t i=0; i<fNdim; i++) | |
175 | { | |
176 | if(fSignal[i]>threshold) | |
177 | { | |
178 | counter++; | |
179 | } | |
180 | } | |
181 | return counter; | |
182 | ||
183 | } | |
184 | ||
185 | //_______________________________________________________________________ | |
186 | void AliTRDarraySignal::Compress(Float_t minval) | |
187 | { | |
188 | // | |
189 | // Compress the array, setting values equal or | |
190 | // below minval to zero (minval>=0) | |
191 | // | |
192 | ||
193 | Int_t counter=0; | |
194 | Int_t newDim=0; | |
195 | Int_t j; | |
196 | Int_t r=0; | |
197 | Int_t *longArr; | |
198 | longArr = new Int_t[fNdim]; | |
199 | Int_t k=0; | |
200 | ||
201 | //Initialize the array | |
064d808d | 202 | memset(longArr,0,sizeof(Int_t)*fNdim); |
b65e5048 | 203 | |
204 | for(Int_t i=0;i<fNdim; i++) | |
205 | { | |
206 | j=0; | |
207 | if(fSignal[i]<=minval) | |
208 | { | |
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; | |
222 | } | |
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) | |
230 | { | |
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; | |
238 | buffer = new Float_t[newDim]; | |
239 | Int_t counterTwo=0; | |
240 | ||
241 | //Write the new array | |
242 | Int_t g=0; | |
243 | for(Int_t i=0; i<newDim; i++) | |
244 | { | |
245 | if(counterTwo<fNdim) | |
246 | { | |
247 | if(fSignal[counterTwo]>minval) | |
248 | { | |
249 | buffer[i]=fSignal[counterTwo]; | |
250 | } | |
251 | if(fSignal[counterTwo]<=minval) | |
252 | { | |
253 | buffer[i]=-(longArr[g]); | |
254 | counterTwo=counterTwo+longArr[g]-1; | |
255 | g++; | |
256 | } | |
257 | counterTwo++; | |
258 | } | |
259 | } | |
260 | ||
261 | //Copy the buffer | |
262 | if(fSignal) | |
263 | { | |
264 | delete [] fSignal; | |
265 | fSignal=0; | |
266 | } | |
267 | fSignal = new Float_t[newDim]; | |
268 | fNdim = newDim; | |
269 | for(Int_t i=0; i<newDim; i++) | |
270 | { | |
271 | fSignal[i] = buffer[i]; | |
272 | } | |
273 | if(buffer) | |
274 | { | |
275 | delete [] buffer; | |
276 | buffer=0; | |
277 | } | |
278 | if(longArr) | |
279 | { | |
280 | delete [] longArr; | |
281 | longArr=0; | |
282 | } | |
283 | ||
284 | } | |
285 | ||
286 | //_______________________________________________________________________ | |
287 | void AliTRDarraySignal::Expand() | |
288 | { | |
289 | // | |
290 | // Expand the array | |
291 | // | |
292 | ||
293 | //Check if the array has not been already expanded | |
294 | Int_t verif=0; | |
295 | for(Int_t i=0; i<fNdim; i++) | |
296 | { | |
297 | if(fSignal[i]<0) | |
298 | { | |
299 | verif++; | |
300 | } | |
301 | } | |
302 | ||
303 | if(verif==0) | |
304 | { | |
305 | return; | |
306 | } | |
307 | ||
308 | Int_t *longArr; | |
309 | longArr = new Int_t[fNdim]; | |
310 | Int_t dimexp=0; | |
064d808d | 311 | memset(longArr,0,sizeof(Int_t)*fNdim); |
b65e5048 | 312 | |
313 | Int_t r2=0; | |
314 | for(Int_t i=0; i<fNdim;i++) | |
315 | { | |
316 | if(fSignal[i]<0) | |
317 | { | |
318 | longArr[r2]=(Int_t)(-fSignal[i]); | |
319 | r2++; | |
320 | } | |
321 | } | |
322 | ||
323 | //Calculate new dimensions | |
324 | for(Int_t i=0; i<fNdim;i++) | |
325 | { | |
326 | if(longArr[i]!=0) | |
327 | { | |
328 | dimexp=dimexp+longArr[i]-1; | |
329 | } | |
330 | } | |
331 | dimexp=dimexp+fNdim; //Dimension of the expanded array | |
332 | ||
333 | //Write in the buffer the new array | |
334 | Float_t* bufferE; | |
335 | bufferE = new Float_t[dimexp]; | |
336 | Int_t contaexp =0; | |
337 | Int_t h=0; | |
338 | for(Int_t i=0; i<dimexp; i++) | |
339 | { | |
340 | if(fSignal[contaexp]>0) | |
341 | { | |
342 | bufferE[i]=fSignal[contaexp]; | |
343 | } | |
344 | if(fSignal[contaexp]<0) | |
345 | { | |
346 | for(Int_t j=0; j<longArr[h];j++) | |
347 | { | |
348 | bufferE[i+j]=0; | |
349 | } | |
350 | i=i+longArr[h]-1; | |
351 | h++; | |
352 | } | |
353 | contaexp++; | |
354 | } | |
355 | ||
356 | //Copy the buffer | |
357 | if(fSignal) | |
358 | { | |
359 | delete [] fSignal; | |
360 | fSignal=0; | |
361 | } | |
362 | ||
363 | fSignal = new Float_t[dimexp]; | |
364 | fNdim = dimexp; | |
365 | for(Int_t i=0; i<dimexp; i++) | |
366 | { | |
367 | fSignal[i] = bufferE[i]; | |
368 | } | |
369 | ||
370 | if(bufferE) delete [] bufferE; | |
371 | if(longArr) delete [] longArr; | |
372 | ||
373 | } | |
705d9e7b | 374 | //________________________________________________________________________________ |
375 | void AliTRDarraySignal::Reset() | |
376 | { | |
377 | // | |
378 | // Reset the array, the old contents are deleted | |
379 | // The array keeps the same dimensions as before | |
380 | // | |
381 | ||
382 | memset(fSignal,0,sizeof(Float_t)*fNdim); | |
383 | ||
384 | } | |
acf20e8f | 385 | //________________________________________________________________________________ |
386 | Float_t AliTRDarraySignal::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const | |
387 | { | |
388 | // | |
389 | // Get the data using the pad numbering. | |
390 | // To access data using the mcm scheme use instead | |
391 | // the method GetDataByAdcCol | |
392 | // | |
393 | ||
f41a4d6a | 394 | Int_t corrcolumn = fgLutPadNumbering[ncol]; |
acf20e8f | 395 | |
396 | return fSignal[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime]; | |
397 | ||
398 | } | |
399 | //________________________________________________________________________________ | |
400 | void AliTRDarraySignal::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Float_t value) | |
401 | { | |
402 | // | |
403 | // Set the data using the pad numbering. | |
404 | // To write data using the mcm scheme use instead | |
405 | // the method SetDataByAdcCol | |
406 | // | |
407 | ||
f41a4d6a | 408 | Int_t colnumb = fgLutPadNumbering[ncol]; |
acf20e8f | 409 | |
410 | fSignal[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value; | |
411 | ||
412 | } | |
413 | ||
414 | //________________________________________________________________________________ | |
415 | void AliTRDarraySignal::CreateLut() | |
416 | { | |
417 | // | |
418 | // Initializes the Look Up Table to relate | |
419 | // pad numbering and mcm channel numbering | |
420 | // | |
421 | ||
f41a4d6a | 422 | if(fgLutPadNumbering) return; |
acf20e8f | 423 | |
f41a4d6a | 424 | fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()]; |
425 | memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol()); | |
acf20e8f | 426 | |
427 | for(Int_t mcm=0; mcm<8; mcm++) | |
428 | { | |
429 | Int_t lowerlimit=0+mcm*18; | |
430 | Int_t upperlimit=18+mcm*18; | |
431 | Int_t shiftposition = 1+3*mcm; | |
432 | for(Int_t index=lowerlimit;index<upperlimit;index++) | |
433 | { | |
f41a4d6a | 434 | fgLutPadNumbering[index]=index+shiftposition; |
acf20e8f | 435 | } |
436 | } | |
437 | } |