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 /////////////////////////////////////////////////////////
29 #include "AliTRDarraySignal.h"
30 #include "AliTRDfeeParam.h"
32 ClassImp(AliTRDarraySignal)
34 Short_t *AliTRDarraySignal::fgLutPadNumbering = 0x0;
36 //_______________________________________________________________________
37 AliTRDarraySignal::AliTRDarraySignal()
49 // AliTRDarraySignal default constructor
56 //_______________________________________________________________________
57 AliTRDarraySignal::AliTRDarraySignal(Int_t nrow, Int_t ncol,Int_t ntime)
68 // AliTRDarraySignal constructor
72 Allocate(nrow,ncol,ntime);
76 //_______________________________________________________________________
77 AliTRDarraySignal::AliTRDarraySignal(const AliTRDarraySignal &d)
82 ,fNumberOfChannels(d.fNumberOfChannels)
88 // AliTRDarraySignal copy constructor
91 fSignal = new Float_t[fNdim];
92 memcpy(fSignal, d.fSignal, fNdim*sizeof(Float_t));
96 //_______________________________________________________________________
97 AliTRDarraySignal::~AliTRDarraySignal()
100 // AliTRDarraySignal destructor
108 //_______________________________________________________________________
109 AliTRDarraySignal &AliTRDarraySignal::operator=(const AliTRDarraySignal &d)
112 // Assignment operator
127 fNumberOfChannels = d.fNumberOfChannels;
130 fSignal = new Float_t[fNdim];
131 memcpy(fSignal,d.fSignal, fNdim*sizeof(Float_t));
137 //_______________________________________________________________________
138 void AliTRDarraySignal::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
141 // Allocates memory for an AliTRDarraySignal object with dimensions
142 // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time
143 // To be consistent with AliTRDarrayADC
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;
158 fSignal = new Float_t[fNdim];
159 memset(fSignal,0,sizeof(Float_t)*fNdim);
163 //_______________________________________________________________________
164 Int_t AliTRDarraySignal::GetOverThreshold(Float_t threshold) const
167 // Get the number of entries over the threshold
171 for(Int_t i=0; i<fNdim; i++)
173 if(fSignal[i]>threshold)
182 //_______________________________________________________________________
183 void AliTRDarraySignal::Compress(Float_t minval)
186 // Compress the array, setting values equal or
187 // below minval to zero (minval>=0)
196 Int_t *longArr = new Int_t[fNdim];
201 //Initialize the array
202 memset(longArr,0,sizeof(Int_t)*fNdim);
204 for(Int_t i=0;i<fNdim; i++)
207 if(fSignal[i]<=minval)
211 if(fSignal[k]<=minval)
226 //Calculate the size of the compressed array
227 for(Int_t i=0; i<fNdim;i++)
231 counter=counter+longArr[i]-1;
234 newDim=fNdim-counter; //New dimension
236 //Fill the buffer of the compressed array
237 Float_t* buffer = new Float_t[newDim];
243 //Write the new array
245 for(Int_t i=0; i<newDim; i++)
249 if(fSignal[counterTwo]>minval)
251 buffer[i]=fSignal[counterTwo];
253 if(fSignal[counterTwo]<=minval)
255 buffer[i]=-(longArr[g]);
256 counterTwo=counterTwo+longArr[g]-1;
269 fSignal = new Float_t[newDim];
271 for(Int_t i=0; i<newDim; i++)
273 fSignal[i] = buffer[i];
288 //_______________________________________________________________________
289 void AliTRDarraySignal::Expand()
298 //Check if the array has not been already expanded
300 for(Int_t i=0; i<fNdim; i++)
314 Int_t *longArr = new Int_t[fNdim];
319 memset(longArr,0,sizeof(Int_t)*fNdim);
322 for(Int_t i=0; i<fNdim;i++)
326 longArr[r2]=(Int_t)(-fSignal[i]);
331 //Calculate new dimensions
332 for(Int_t i=0; i<fNdim;i++)
336 dimexp=dimexp+longArr[i]-1;
339 dimexp=dimexp+fNdim; //Dimension of the expanded array
341 //Write in the buffer the new array
344 Float_t* bufferE = new Float_t[dimexp];
349 for(Int_t i=0; i<dimexp; i++)
351 if(fSignal[contaexp]>0)
353 bufferE[i]=fSignal[contaexp];
355 if(fSignal[contaexp]<0)
357 for(Int_t j=0; j<longArr[h];j++)
370 fSignal = new Float_t[dimexp];
372 for(Int_t i=0; i<dimexp; i++)
374 fSignal[i] = bufferE[i];
388 //________________________________________________________________________________
389 void AliTRDarraySignal::Reset()
392 // Reset the array, the old contents are deleted
393 // The array keeps the same dimensions as before
396 memset(fSignal,0,sizeof(Float_t)*fNdim);
399 //________________________________________________________________________________
400 Float_t AliTRDarraySignal::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
403 // Get the data using the pad numbering.
404 // To access data using the mcm scheme use instead
405 // the method GetDataByAdcCol
408 Int_t corrcolumn = fgLutPadNumbering[ncol];
410 return fSignal[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
413 //________________________________________________________________________________
414 void AliTRDarraySignal::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Float_t value)
417 // Set the data using the pad numbering.
418 // To write data using the mcm scheme use instead
419 // the method SetDataByAdcCol
422 Int_t colnumb = fgLutPadNumbering[ncol];
424 fSignal[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;
428 //________________________________________________________________________________
429 void AliTRDarraySignal::CreateLut()
432 // Initializes the Look Up Table to relate
433 // pad numbering and mcm channel numbering
436 if(fgLutPadNumbering) return;
438 fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
439 memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());
441 for(Int_t mcm=0; mcm<8; mcm++)
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++)
448 fgLutPadNumbering[index]=index+shiftposition;