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: AliTRDarrayDictionary.cxx 25392 2008-04-23 19:40:29Z cblume $ */
18 /////////////////////////////////////////////////////////
20 // Container Class for Dictionary Info //
23 // Hermes Leon Vargas (hleon@ikf.uni-frankfurt.de) //
25 /////////////////////////////////////////////////////////
27 #include "AliTRDarrayDictionary.h"
28 #include "AliTRDfeeParam.h"
30 ClassImp(AliTRDarrayDictionary)
32 Short_t *AliTRDarrayDictionary::fgLutPadNumbering = 0x0;
34 //________________________________________________________________________________
35 AliTRDarrayDictionary::AliTRDarrayDictionary()
46 // AliTRDarrayDictionary default contructor
53 //________________________________________________________________________________
54 AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime)
66 // AliTRDarrayDictionary contructor
70 Allocate(nrow,ncol,ntime);
74 //________________________________________________________________________________
75 AliTRDarrayDictionary::AliTRDarrayDictionary(const AliTRDarrayDictionary &a)
80 ,fNumberOfChannels(a.fNumberOfChannels)
86 // AliTRDarrayDictionary copy constructor
89 fDictionary = new Int_t[fNDdim];
90 for(Int_t i=0; i<fNDdim; i++)
92 fDictionary[i]=a.fDictionary[i];
97 //________________________________________________________________________________
98 AliTRDarrayDictionary::~AliTRDarrayDictionary()
101 // AliTRDarrayDictionary destructor
106 delete [] fDictionary;
112 //________________________________________________________________________________
113 AliTRDarrayDictionary &AliTRDarrayDictionary::operator=(const AliTRDarrayDictionary &a)
116 // Assignment operator
126 delete [] fDictionary;
132 fNumberOfChannels = a.fNumberOfChannels;
134 fDictionary = new Int_t[fNDdim];
135 for(Int_t i=0; i<fNDdim; i++)
137 fDictionary[i]=a.fDictionary[i];
143 //________________________________________________________________________________
144 void AliTRDarrayDictionary::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
147 // Allocates memory for the dictionary array with dimensions
148 // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time
149 // To be consistent with AliTRDarrayADC
150 // Object initialized to -1
156 Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm();
157 Int_t padspermcm = AliTRDfeeParam::GetNcolMcm();
158 Int_t numberofmcms = fNcol/padspermcm;
159 fNumberOfChannels = numberofmcms*adcchannelspermcm;
160 fNDdim=nrow*fNumberOfChannels*ntime;
163 delete [] fDictionary;
166 fDictionary = new Int_t[fNDdim];
167 for(Int_t i=0; i<fNDdim; i++)
174 //________________________________________________________________________________
175 void AliTRDarrayDictionary::Compress()
178 // Compress the array
182 // AliDebug(1,"Compressing");
188 longArr = new Int_t[fNDdim];
190 for(Int_t i=0; i<fNDdim;i++)
194 for(Int_t i=0;i<fNDdim; i++)
197 if(fDictionary[i]==-1)
199 for(k=i;k<fNDdim;k++)
201 if(fDictionary[k]==-1)
215 //Calculate the size of the compressed array
216 for(Int_t i=0; i<fNDdim;i++)
220 counter=counter+longArr[i]-1;
223 newDim=fNDdim-counter; //Size of the compressed array
224 //Fill the buffer of the compressed array
226 buffer = new Int_t[newDim];
229 for(Int_t i=0; i<newDim; i++)
231 if(counterTwo<fNDdim)
233 if(fDictionary[counterTwo]!=-1)
235 buffer[i]=fDictionary[counterTwo];
237 if(fDictionary[counterTwo]==-1)
239 buffer[i]=-(longArr[g]);
240 counterTwo=counterTwo+longArr[g]-1;
250 delete [] fDictionary;
253 fDictionary = new Int_t[newDim];
255 for(Int_t i=0; i<newDim; i++)
257 fDictionary[i] = buffer[i];
272 //________________________________________________________________________________
273 void AliTRDarrayDictionary::Expand()
280 longArr = new Int_t[fNDdim];
282 for(Int_t i=0; i<fNDdim;i++)
287 for(Int_t i=0; i<fNDdim;i++)
289 if((fDictionary[i]<0)&&(fDictionary[i]!=-1))
291 longArr[r2]=-fDictionary[i];
296 //Calculate new dimensions
297 for(Int_t i=0; i<fNDdim;i++)
301 dimexp=dimexp+longArr[i]-1;
304 dimexp=dimexp+fNDdim;
306 //Write in the buffer the new array
308 bufferE = new Int_t[dimexp];
311 for(Int_t i=0; i<dimexp; i++)
313 if(fDictionary[contaexp]>=-1)
315 bufferE[i]=fDictionary[contaexp];
317 if(fDictionary[contaexp]<-1)
319 for(Int_t j=0; j<longArr[h];j++)
332 delete [] fDictionary;
336 fDictionary = new Int_t[dimexp];
338 for(Int_t i=0; i<dimexp; i++)
340 fDictionary[i] = bufferE[i];
342 if(bufferE) delete [] bufferE;
343 if(longArr) delete [] longArr;
346 //________________________________________________________________________________
347 void AliTRDarrayDictionary::Reset()
350 // Reset the array, the old contents are deleted
351 // and the data array elements are set to zero.
354 memset(fDictionary,0,sizeof(Int_t)*fNDdim);
357 //________________________________________________________________________________
358 Int_t AliTRDarrayDictionary::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
361 // Get the data using the pad numbering.
362 // To access data using the mcm scheme use instead
363 // the method GetDataByAdcCol
366 Int_t corrcolumn = fgLutPadNumbering[ncol];
368 return fDictionary[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
371 //________________________________________________________________________________
372 void AliTRDarrayDictionary::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Int_t value)
375 // Set the data using the pad numbering.
376 // To write data using the mcm scheme use instead
377 // the method SetDataByAdcCol
380 Int_t colnumb = fgLutPadNumbering[ncol];
382 fDictionary[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;
386 //________________________________________________________________________________
387 void AliTRDarrayDictionary::CreateLut()
390 // Initializes the Look Up Table to relate
391 // pad numbering and mcm channel numbering
394 if(fgLutPadNumbering) return;
396 fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
397 memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());
399 for(Int_t mcm=0; mcm<8; mcm++)
401 Int_t lowerlimit=0+mcm*18;
402 Int_t upperlimit=18+mcm*18;
403 Int_t shiftposition = 1+3*mcm;
404 for(Int_t index=lowerlimit;index<upperlimit;index++)
406 fgLutPadNumbering[index]=index+shiftposition;