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"
30 ClassImp(AliTRDarraySignal)
32 //_______________________________________________________________________
33 AliTRDarraySignal::AliTRDarraySignal()
44 // AliTRDarraySignal default constructor
49 //_______________________________________________________________________
50 AliTRDarraySignal::AliTRDarraySignal(Int_t nrow, Int_t ncol,Int_t ntime)
60 // AliTRDarraySignal constructor
63 Allocate(nrow,ncol,ntime);
67 //_______________________________________________________________________
68 AliTRDarraySignal::AliTRDarraySignal(const AliTRDarraySignal &d)
78 // AliTRDarraySignal copy constructor
81 fSignal = new Float_t[fNdim];
82 for(Int_t i=0; i<fNdim; i++)
84 fSignal[i]=d.fSignal[i];
89 //_______________________________________________________________________
90 AliTRDarraySignal::~AliTRDarraySignal()
93 // AliTRDarraySignal destructor
104 //_______________________________________________________________________
105 AliTRDarraySignal &AliTRDarraySignal::operator=(const AliTRDarraySignal &d)
108 // Assignment operator
125 fSignal = new Float_t[fNdim];
127 for(Int_t i=0; i<fNdim; i++)
129 fSignal[i]=d.fSignal[i];
136 //_______________________________________________________________________
137 void AliTRDarraySignal::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
140 // Allocates memory for an AliTRDarraySignal object with dimensions
147 fNdim = nrow*ncol*ntime;
152 fSignal = new Float_t[fNdim];
153 for(Int_t i=0; i<fNdim; i++)
160 //_______________________________________________________________________
161 Int_t AliTRDarraySignal::GetOverThreshold(Float_t threshold)
164 // Get the number of entries over the threshold
168 for(Int_t i=0; i<fNdim; i++)
170 if(fSignal[i]>threshold)
179 //_______________________________________________________________________
180 void AliTRDarraySignal::Compress(Float_t minval)
183 // Compress the array, setting values equal or
184 // below minval to zero (minval>=0)
192 longArr = new Int_t[fNdim];
195 //Initialize the array
196 for(Int_t i=0; i<fNdim;i++)
201 for(Int_t i=0;i<fNdim; i++)
204 if(fSignal[i]<=minval)
208 if(fSignal[k]<=minval)
223 //Calculate the size of the compressed array
224 for(Int_t i=0; i<fNdim;i++)
228 counter=counter+longArr[i]-1;
231 newDim=fNdim-counter; //New dimension
233 //Fill the buffer of the compressed array
235 buffer = new Float_t[newDim];
238 //Write the new array
240 for(Int_t i=0; i<newDim; i++)
244 if(fSignal[counterTwo]>minval)
246 buffer[i]=fSignal[counterTwo];
248 if(fSignal[counterTwo]<=minval)
250 buffer[i]=-(longArr[g]);
251 counterTwo=counterTwo+longArr[g]-1;
264 fSignal = new Float_t[newDim];
266 for(Int_t i=0; i<newDim; i++)
268 fSignal[i] = buffer[i];
283 //_______________________________________________________________________
284 void AliTRDarraySignal::Expand()
290 //Check if the array has not been already expanded
292 for(Int_t i=0; i<fNdim; i++)
306 longArr = new Int_t[fNdim];
308 for(Int_t i=0; i<fNdim;i++)
314 for(Int_t i=0; i<fNdim;i++)
318 longArr[r2]=(Int_t)(-fSignal[i]);
323 //Calculate new dimensions
324 for(Int_t i=0; i<fNdim;i++)
328 dimexp=dimexp+longArr[i]-1;
331 dimexp=dimexp+fNdim; //Dimension of the expanded array
333 //Write in the buffer the new array
335 bufferE = new Float_t[dimexp];
338 for(Int_t i=0; i<dimexp; i++)
340 if(fSignal[contaexp]>0)
342 bufferE[i]=fSignal[contaexp];
344 if(fSignal[contaexp]<0)
346 for(Int_t j=0; j<longArr[h];j++)
363 fSignal = new Float_t[dimexp];
365 for(Int_t i=0; i<dimexp; i++)
367 fSignal[i] = bufferE[i];
370 if(bufferE) delete [] bufferE;
371 if(longArr) delete [] longArr;