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 "TArray.h" //for memset
31 ClassImp(AliTRDarraySignal)
33 //_______________________________________________________________________
34 AliTRDarraySignal::AliTRDarraySignal()
45 // AliTRDarraySignal default constructor
50 //_______________________________________________________________________
51 AliTRDarraySignal::AliTRDarraySignal(Int_t nrow, Int_t ncol,Int_t ntime)
61 // AliTRDarraySignal constructor
64 Allocate(nrow,ncol,ntime);
68 //_______________________________________________________________________
69 AliTRDarraySignal::AliTRDarraySignal(const AliTRDarraySignal &d)
79 // AliTRDarraySignal copy constructor
82 fSignal = new Float_t[fNdim];
83 memcpy(fSignal, d.fSignal, fNdim*sizeof(Float_t));
87 //_______________________________________________________________________
88 AliTRDarraySignal::~AliTRDarraySignal()
91 // AliTRDarraySignal destructor
102 //_______________________________________________________________________
103 AliTRDarraySignal &AliTRDarraySignal::operator=(const AliTRDarraySignal &d)
106 // Assignment operator
123 fSignal = new Float_t[fNdim];
124 memcpy(fSignal,d.fSignal, fNdim*sizeof(Float_t));
130 //_______________________________________________________________________
131 void AliTRDarraySignal::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
134 // Allocates memory for an AliTRDarraySignal object with dimensions
141 fNdim = nrow*ncol*ntime;
146 fSignal = new Float_t[fNdim];
147 memset(fSignal,0,sizeof(Float_t)*fNdim);
151 //_______________________________________________________________________
152 Int_t AliTRDarraySignal::GetOverThreshold(Float_t threshold)
155 // Get the number of entries over the threshold
159 for(Int_t i=0; i<fNdim; i++)
161 if(fSignal[i]>threshold)
170 //_______________________________________________________________________
171 void AliTRDarraySignal::Compress(Float_t minval)
174 // Compress the array, setting values equal or
175 // below minval to zero (minval>=0)
183 longArr = new Int_t[fNdim];
186 //Initialize the array
187 memset(longArr,0,sizeof(Int_t)*fNdim);
189 for(Int_t i=0;i<fNdim; i++)
192 if(fSignal[i]<=minval)
196 if(fSignal[k]<=minval)
211 //Calculate the size of the compressed array
212 for(Int_t i=0; i<fNdim;i++)
216 counter=counter+longArr[i]-1;
219 newDim=fNdim-counter; //New dimension
221 //Fill the buffer of the compressed array
223 buffer = new Float_t[newDim];
226 //Write the new array
228 for(Int_t i=0; i<newDim; i++)
232 if(fSignal[counterTwo]>minval)
234 buffer[i]=fSignal[counterTwo];
236 if(fSignal[counterTwo]<=minval)
238 buffer[i]=-(longArr[g]);
239 counterTwo=counterTwo+longArr[g]-1;
252 fSignal = new Float_t[newDim];
254 for(Int_t i=0; i<newDim; i++)
256 fSignal[i] = buffer[i];
271 //_______________________________________________________________________
272 void AliTRDarraySignal::Expand()
278 //Check if the array has not been already expanded
280 for(Int_t i=0; i<fNdim; i++)
294 longArr = new Int_t[fNdim];
296 memset(longArr,0,sizeof(Int_t)*fNdim);
299 for(Int_t i=0; i<fNdim;i++)
303 longArr[r2]=(Int_t)(-fSignal[i]);
308 //Calculate new dimensions
309 for(Int_t i=0; i<fNdim;i++)
313 dimexp=dimexp+longArr[i]-1;
316 dimexp=dimexp+fNdim; //Dimension of the expanded array
318 //Write in the buffer the new array
320 bufferE = new Float_t[dimexp];
323 for(Int_t i=0; i<dimexp; i++)
325 if(fSignal[contaexp]>0)
327 bufferE[i]=fSignal[contaexp];
329 if(fSignal[contaexp]<0)
331 for(Int_t j=0; j<longArr[h];j++)
348 fSignal = new Float_t[dimexp];
350 for(Int_t i=0; i<dimexp; i++)
352 fSignal[i] = bufferE[i];
355 if(bufferE) delete [] bufferE;
356 if(longArr) delete [] longArr;
359 //________________________________________________________________________________
360 void AliTRDarraySignal::Reset()
363 // Reset the array, the old contents are deleted
364 // The array keeps the same dimensions as before
367 memset(fSignal,0,sizeof(Float_t)*fNdim);