1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliTRDarraySignal.cxx 25392 2008-04-23 19:40:29Z cblume $ */
18 /////////////////////////////////////////////////////////
20 // Container Class for Signals //
23 // Hermes Leon Vargas (hleon@ikf.uni-frankfurt.de) //
25 /////////////////////////////////////////////////////////
27 #include "AliTRDarraySignal.h"
29 #include "AliTRDfeeParam.h"
31 ClassImp(AliTRDarraySignal)
33 Short_t *AliTRDarraySignal::fgLutPadNumbering = 0x0;
35 //_______________________________________________________________________
36 AliTRDarraySignal::AliTRDarraySignal()
48 // AliTRDarraySignal default constructor
55 //_______________________________________________________________________
56 AliTRDarraySignal::AliTRDarraySignal(Int_t nrow, Int_t ncol,Int_t ntime)
67 // AliTRDarraySignal constructor
71 Allocate(nrow,ncol,ntime);
75 //_______________________________________________________________________
76 AliTRDarraySignal::AliTRDarraySignal(const AliTRDarraySignal &d)
81 ,fNumberOfChannels(d.fNumberOfChannels)
87 // AliTRDarraySignal copy constructor
90 fSignal = new Float_t[fNdim];
91 memcpy(fSignal, d.fSignal, fNdim*sizeof(Float_t));
95 //_______________________________________________________________________
96 AliTRDarraySignal::~AliTRDarraySignal()
99 // AliTRDarraySignal destructor
110 //_______________________________________________________________________
111 AliTRDarraySignal &AliTRDarraySignal::operator=(const AliTRDarraySignal &d)
114 // Assignment operator
129 fNumberOfChannels = d.fNumberOfChannels;
132 fSignal = new Float_t[fNdim];
133 memcpy(fSignal,d.fSignal, fNdim*sizeof(Float_t));
139 //_______________________________________________________________________
140 void AliTRDarraySignal::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
143 // Allocates memory for an AliTRDarraySignal object with dimensions
144 // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time
145 // To be consistent with AliTRDarrayADC
151 Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm();
152 Int_t padspermcm = AliTRDfeeParam::GetNcolMcm();
153 Int_t numberofmcms = fNcol/padspermcm;
154 fNumberOfChannels = numberofmcms*adcchannelspermcm;
155 fNdim = nrow*fNumberOfChannels*ntime;
160 fSignal = new Float_t[fNdim];
161 memset(fSignal,0,sizeof(Float_t)*fNdim);
165 //_______________________________________________________________________
166 Int_t AliTRDarraySignal::GetOverThreshold(Float_t threshold) const
169 // Get the number of entries over the threshold
173 for(Int_t i=0; i<fNdim; i++)
175 if(fSignal[i]>threshold)
184 //_______________________________________________________________________
185 void AliTRDarraySignal::Compress(Float_t minval)
188 // Compress the array, setting values equal or
189 // below minval to zero (minval>=0)
197 longArr = new Int_t[fNdim];
200 //Initialize the array
201 memset(longArr,0,sizeof(Int_t)*fNdim);
203 for(Int_t i=0;i<fNdim; i++)
206 if(fSignal[i]<=minval)
210 if(fSignal[k]<=minval)
225 //Calculate the size of the compressed array
226 for(Int_t i=0; i<fNdim;i++)
230 counter=counter+longArr[i]-1;
233 newDim=fNdim-counter; //New dimension
235 //Fill the buffer of the compressed array
237 buffer = new Float_t[newDim];
240 //Write the new array
242 for(Int_t i=0; i<newDim; i++)
246 if(fSignal[counterTwo]>minval)
248 buffer[i]=fSignal[counterTwo];
250 if(fSignal[counterTwo]<=minval)
252 buffer[i]=-(longArr[g]);
253 counterTwo=counterTwo+longArr[g]-1;
266 fSignal = new Float_t[newDim];
268 for(Int_t i=0; i<newDim; i++)
270 fSignal[i] = buffer[i];
285 //_______________________________________________________________________
286 void AliTRDarraySignal::Expand()
292 //Check if the array has not been already expanded
294 for(Int_t i=0; i<fNdim; i++)
308 longArr = new Int_t[fNdim];
310 memset(longArr,0,sizeof(Int_t)*fNdim);
313 for(Int_t i=0; i<fNdim;i++)
317 longArr[r2]=(Int_t)(-fSignal[i]);
322 //Calculate new dimensions
323 for(Int_t i=0; i<fNdim;i++)
327 dimexp=dimexp+longArr[i]-1;
330 dimexp=dimexp+fNdim; //Dimension of the expanded array
332 //Write in the buffer the new array
334 bufferE = new Float_t[dimexp];
337 for(Int_t i=0; i<dimexp; i++)
339 if(fSignal[contaexp]>0)
341 bufferE[i]=fSignal[contaexp];
343 if(fSignal[contaexp]<0)
345 for(Int_t j=0; j<longArr[h];j++)
362 fSignal = new Float_t[dimexp];
364 for(Int_t i=0; i<dimexp; i++)
366 fSignal[i] = bufferE[i];
369 if(bufferE) delete [] bufferE;
370 if(longArr) delete [] longArr;
373 //________________________________________________________________________________
374 void AliTRDarraySignal::Reset()
377 // Reset the array, the old contents are deleted
378 // The array keeps the same dimensions as before
381 memset(fSignal,0,sizeof(Float_t)*fNdim);
384 //________________________________________________________________________________
385 Float_t AliTRDarraySignal::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
388 // Get the data using the pad numbering.
389 // To access data using the mcm scheme use instead
390 // the method GetDataByAdcCol
393 Int_t corrcolumn = fgLutPadNumbering[ncol];
395 return fSignal[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
398 //________________________________________________________________________________
399 void AliTRDarraySignal::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Float_t value)
402 // Set the data using the pad numbering.
403 // To write data using the mcm scheme use instead
404 // the method SetDataByAdcCol
407 Int_t colnumb = fgLutPadNumbering[ncol];
409 fSignal[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;
413 //________________________________________________________________________________
414 void AliTRDarraySignal::CreateLut()
417 // Initializes the Look Up Table to relate
418 // pad numbering and mcm channel numbering
421 if(fgLutPadNumbering) return;
423 fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
424 memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());
426 for(Int_t mcm=0; mcm<8; mcm++)
428 Int_t lowerlimit=0+mcm*18;
429 Int_t upperlimit=18+mcm*18;
430 Int_t shiftposition = 1+3*mcm;
431 for(Int_t index=lowerlimit;index<upperlimit;index++)
433 fgLutPadNumbering[index]=index+shiftposition;