]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDarraySignal.cxx
- set the time stamp for the correct application of the calibration values
[u/mrichter/AliRoot.git] / TRD / AliTRDarraySignal.cxx
CommitLineData
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
32ClassImp(AliTRDarraySignal)
33
f41a4d6a 34Short_t *AliTRDarraySignal::fgLutPadNumbering = 0x0;
acf20e8f 35
b65e5048 36//_______________________________________________________________________
37AliTRDarraySignal::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//_______________________________________________________________________
57AliTRDarraySignal::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//_______________________________________________________________________
77AliTRDarraySignal::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//_______________________________________________________________________
97AliTRDarraySignal::~AliTRDarraySignal()
98{
99 //
100 // AliTRDarraySignal destructor
101 //
102
103 if (fSignal)
104 {
105 delete [] fSignal;
106 fSignal=0;
107 }
108
109}
110
111//_______________________________________________________________________
112AliTRDarraySignal &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//_______________________________________________________________________
141void 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 167Int_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//_______________________________________________________________________
186void 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;
b65e5048 197 Int_t k=0;
198
024c0422 199 Int_t *longArr = new Int_t[fNdim];
b65e5048 200
024c0422 201 if(longArr)
b65e5048 202 {
b65e5048 203
024c0422 204 //Initialize the array
205 memset(longArr,0,sizeof(Int_t)*fNdim);
b65e5048 206
024c0422 207 for(Int_t i=0;i<fNdim; i++)
208 {
209 j=0;
210 if(fSignal[i]<=minval)
b65e5048 211 {
024c0422 212 for(k=i;k<fNdim;k++)
213 {
214 if(fSignal[k]<=minval)
215 {
216 j=j+1;
217 longArr[r]=j;
218 }
219 else
220 {
221 break;
222 }
223 }
224 r=r+1;
b65e5048 225 }
024c0422 226 i=i+j;
227 }
228
229 //Calculate the size of the compressed array
230 for(Int_t i=0; i<fNdim;i++)
231 {
232 if(longArr[i]!=0)
b65e5048 233 {
024c0422 234 counter=counter+longArr[i]-1;
235 }
236 }
237 newDim=fNdim-counter; //New dimension
238
239 //Fill the buffer of the compressed array
240 Float_t* buffer = new Float_t[newDim];
241 Int_t counterTwo=0;
242
243 if(buffer)
244 {
245
246 //Write the new array
247 Int_t g=0;
248 for(Int_t i=0; i<newDim; i++)
249 {
250 if(counterTwo<fNdim)
251 {
252 if(fSignal[counterTwo]>minval)
253 {
254 buffer[i]=fSignal[counterTwo];
255 }
256 if(fSignal[counterTwo]<=minval)
257 {
258 buffer[i]=-(longArr[g]);
259 counterTwo=counterTwo+longArr[g]-1;
260 g++;
261 }
262 counterTwo++;
263 }
264 }
265
266 //Copy the buffer
267 if(fSignal)
268 {
269 delete [] fSignal;
270 fSignal=0;
271 }
272 fSignal = new Float_t[newDim];
273 fNdim = newDim;
274 for(Int_t i=0; i<newDim; i++)
275 {
276 fSignal[i] = buffer[i];
277 }
278
279 delete [] buffer;
280 buffer=0;
281
282 }
b65e5048 283
b65e5048 284 delete [] longArr;
285 longArr=0;
024c0422 286
b65e5048 287 }
288
289}
290
291//_______________________________________________________________________
292void AliTRDarraySignal::Expand()
293{
294 //
295 // Expand the array
296 //
297
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 }
307
308 if(verif==0)
309 {
310 return;
311 }
312
313 Int_t *longArr;
314 longArr = new Int_t[fNdim];
315 Int_t dimexp=0;
064d808d 316 memset(longArr,0,sizeof(Int_t)*fNdim);
b65e5048 317
318 Int_t r2=0;
319 for(Int_t i=0; i<fNdim;i++)
320 {
321 if(fSignal[i]<0)
322 {
323 longArr[r2]=(Int_t)(-fSignal[i]);
324 r2++;
325 }
326 }
327
328 //Calculate new dimensions
329 for(Int_t i=0; i<fNdim;i++)
330 {
331 if(longArr[i]!=0)
332 {
333 dimexp=dimexp+longArr[i]-1;
334 }
335 }
336 dimexp=dimexp+fNdim; //Dimension of the expanded array
337
338 //Write in the buffer the new array
339 Float_t* bufferE;
340 bufferE = new Float_t[dimexp];
341 Int_t contaexp =0;
342 Int_t h=0;
343 for(Int_t i=0; i<dimexp; i++)
344 {
345 if(fSignal[contaexp]>0)
346 {
347 bufferE[i]=fSignal[contaexp];
348 }
349 if(fSignal[contaexp]<0)
350 {
351 for(Int_t j=0; j<longArr[h];j++)
352 {
353 bufferE[i+j]=0;
354 }
355 i=i+longArr[h]-1;
356 h++;
357 }
358 contaexp++;
359 }
360
361 //Copy the buffer
362 if(fSignal)
363 {
364 delete [] fSignal;
365 fSignal=0;
366 }
367
368 fSignal = new Float_t[dimexp];
369 fNdim = dimexp;
370 for(Int_t i=0; i<dimexp; i++)
371 {
372 fSignal[i] = bufferE[i];
373 }
374
375 if(bufferE) delete [] bufferE;
376 if(longArr) delete [] longArr;
377
378}
705d9e7b 379//________________________________________________________________________________
380void AliTRDarraySignal::Reset()
381{
382 //
383 // Reset the array, the old contents are deleted
384 // The array keeps the same dimensions as before
385 //
386
387 memset(fSignal,0,sizeof(Float_t)*fNdim);
388
389}
acf20e8f 390//________________________________________________________________________________
391Float_t AliTRDarraySignal::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
392{
393 //
394 // Get the data using the pad numbering.
395 // To access data using the mcm scheme use instead
396 // the method GetDataByAdcCol
397 //
398
f41a4d6a 399 Int_t corrcolumn = fgLutPadNumbering[ncol];
acf20e8f 400
401 return fSignal[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
402
403}
404//________________________________________________________________________________
405void AliTRDarraySignal::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Float_t value)
406{
407 //
408 // Set the data using the pad numbering.
409 // To write data using the mcm scheme use instead
410 // the method SetDataByAdcCol
411 //
412
f41a4d6a 413 Int_t colnumb = fgLutPadNumbering[ncol];
acf20e8f 414
415 fSignal[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;
416
417}
418
419//________________________________________________________________________________
420void AliTRDarraySignal::CreateLut()
421{
422 //
423 // Initializes the Look Up Table to relate
424 // pad numbering and mcm channel numbering
425 //
426
f41a4d6a 427 if(fgLutPadNumbering) return;
acf20e8f 428
f41a4d6a 429 fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
430 memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());
acf20e8f 431
432 for(Int_t mcm=0; mcm<8; mcm++)
433 {
434 Int_t lowerlimit=0+mcm*18;
435 Int_t upperlimit=18+mcm*18;
436 Int_t shiftposition = 1+3*mcm;
437 for(Int_t index=lowerlimit;index<upperlimit;index++)
438 {
f41a4d6a 439 fgLutPadNumbering[index]=index+shiftposition;
acf20e8f 440 }
441 }
442}