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
111 //_______________________________________________________________________
112 AliTRDarraySignal &AliTRDarraySignal::operator=(const AliTRDarraySignal &d)
115 // Assignment operator
130 fNumberOfChannels = d.fNumberOfChannels;
133 fSignal = new Float_t[fNdim];
134 memcpy(fSignal,d.fSignal, fNdim*sizeof(Float_t));
140 //_______________________________________________________________________
141 void AliTRDarraySignal::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
144 // Allocates memory for an AliTRDarraySignal object with dimensions
145 // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time
146 // To be consistent with AliTRDarrayADC
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;
161 fSignal = new Float_t[fNdim];
162 memset(fSignal,0,sizeof(Float_t)*fNdim);
166 //_______________________________________________________________________
167 Int_t AliTRDarraySignal::GetOverThreshold(Float_t threshold) const
170 // Get the number of entries over the threshold
174 for(Int_t i=0; i<fNdim; i++)
176 if(fSignal[i]>threshold)
185 //_______________________________________________________________________
186 void AliTRDarraySignal::Compress(Float_t minval)
189 // Compress the array, setting values equal or
190 // below minval to zero (minval>=0)
199 Int_t *longArr = new Int_t[fNdim];
204 //Initialize the array
205 memset(longArr,0,sizeof(Int_t)*fNdim);
207 for(Int_t i=0;i<fNdim; i++)
210 if(fSignal[i]<=minval)
214 if(fSignal[k]<=minval)
229 //Calculate the size of the compressed array
230 for(Int_t i=0; i<fNdim;i++)
234 counter=counter+longArr[i]-1;
237 newDim=fNdim-counter; //New dimension
239 //Fill the buffer of the compressed array
240 Float_t* buffer = new Float_t[newDim];
246 //Write the new array
248 for(Int_t i=0; i<newDim; i++)
252 if(fSignal[counterTwo]>minval)
254 buffer[i]=fSignal[counterTwo];
256 if(fSignal[counterTwo]<=minval)
258 buffer[i]=-(longArr[g]);
259 counterTwo=counterTwo+longArr[g]-1;
272 fSignal = new Float_t[newDim];
274 for(Int_t i=0; i<newDim; i++)
276 fSignal[i] = buffer[i];
291 //_______________________________________________________________________
292 void AliTRDarraySignal::Expand()
301 //Check if the array has not been already expanded
303 for(Int_t i=0; i<fNdim; i++)
317 Int_t *longArr = new Int_t[fNdim];
322 memset(longArr,0,sizeof(Int_t)*fNdim);
325 for(Int_t i=0; i<fNdim;i++)
329 longArr[r2]=(Int_t)(-fSignal[i]);
334 //Calculate new dimensions
335 for(Int_t i=0; i<fNdim;i++)
339 dimexp=dimexp+longArr[i]-1;
342 dimexp=dimexp+fNdim; //Dimension of the expanded array
344 //Write in the buffer the new array
347 Float_t* bufferE = new Float_t[dimexp];
352 for(Int_t i=0; i<dimexp; i++)
354 if(fSignal[contaexp]>0)
356 bufferE[i]=fSignal[contaexp];
358 if(fSignal[contaexp]<0)
360 for(Int_t j=0; j<longArr[h];j++)
373 fSignal = new Float_t[dimexp];
375 for(Int_t i=0; i<dimexp; i++)
377 fSignal[i] = bufferE[i];
391 //________________________________________________________________________________
392 void AliTRDarraySignal::Reset()
395 // Reset the array, the old contents are deleted
396 // The array keeps the same dimensions as before
399 memset(fSignal,0,sizeof(Float_t)*fNdim);
402 //________________________________________________________________________________
403 Float_t AliTRDarraySignal::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
406 // Get the data using the pad numbering.
407 // To access data using the mcm scheme use instead
408 // the method GetDataByAdcCol
411 Int_t corrcolumn = fgLutPadNumbering[ncol];
413 return fSignal[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
416 //________________________________________________________________________________
417 void AliTRDarraySignal::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Float_t value)
420 // Set the data using the pad numbering.
421 // To write data using the mcm scheme use instead
422 // the method SetDataByAdcCol
425 Int_t colnumb = fgLutPadNumbering[ncol];
427 fSignal[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;
431 //________________________________________________________________________________
432 void AliTRDarraySignal::CreateLut()
435 // Initializes the Look Up Table to relate
436 // pad numbering and mcm channel numbering
439 if(fgLutPadNumbering) return;
441 fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
442 memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());
444 for(Int_t mcm=0; mcm<8; mcm++)
446 Int_t lowerlimit=0+mcm*18;
447 Int_t upperlimit=18+mcm*18;
448 Int_t shiftposition = 1+3*mcm;
449 for(Int_t index=lowerlimit;index<upperlimit;index++)
451 fgLutPadNumbering[index]=index+shiftposition;