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 /////////////////////////////////////////////////////////
29 #include "AliTRDarrayDictionary.h"
30 #include "AliTRDfeeParam.h"
32 ClassImp(AliTRDarrayDictionary)
34 Short_t *AliTRDarrayDictionary::fgLutPadNumbering = 0x0;
36 //________________________________________________________________________________
37 AliTRDarrayDictionary::AliTRDarrayDictionary()
48 // AliTRDarrayDictionary default contructor
55 //________________________________________________________________________________
56 AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime)
68 // AliTRDarrayDictionary contructor
72 Allocate(nrow,ncol,ntime);
76 //________________________________________________________________________________
77 AliTRDarrayDictionary::AliTRDarrayDictionary(const AliTRDarrayDictionary &a)
82 ,fNumberOfChannels(a.fNumberOfChannels)
88 // AliTRDarrayDictionary copy constructor
91 fDictionary = new Int_t[fNDdim];
92 for(Int_t i=0; i<fNDdim; i++)
94 fDictionary[i]=a.fDictionary[i];
99 //________________________________________________________________________________
100 AliTRDarrayDictionary::~AliTRDarrayDictionary()
103 // AliTRDarrayDictionary destructor
108 delete [] fDictionary;
114 //________________________________________________________________________________
115 AliTRDarrayDictionary &AliTRDarrayDictionary::operator=(const AliTRDarrayDictionary &a)
118 // Assignment operator
128 delete [] fDictionary;
134 fNumberOfChannels = a.fNumberOfChannels;
136 fDictionary = new Int_t[fNDdim];
137 for(Int_t i=0; i<fNDdim; i++)
139 fDictionary[i]=a.fDictionary[i];
145 //________________________________________________________________________________
146 void AliTRDarrayDictionary::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
149 // Allocates memory for the dictionary array with dimensions
150 // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time
151 // To be consistent with AliTRDarrayADC
152 // Object initialized to -1
158 Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm();
159 Int_t padspermcm = AliTRDfeeParam::GetNcolMcm();
160 Int_t numberofmcms = fNcol/padspermcm;
161 fNumberOfChannels = numberofmcms*adcchannelspermcm;
162 fNDdim=nrow*fNumberOfChannels*ntime;
165 delete [] fDictionary;
168 fDictionary = new Int_t[fNDdim];
169 for(Int_t i=0; i<fNDdim; i++)
176 //________________________________________________________________________________
177 void AliTRDarrayDictionary::Compress()
180 // Compress the array
184 // AliDebug(1,"Compressing");
190 longArr = new Int_t[fNDdim];
192 for(Int_t i=0; i<fNDdim;i++)
196 for(Int_t i=0;i<fNDdim; i++)
199 if(fDictionary[i]==-1)
201 for(k=i;k<fNDdim;k++)
203 if(fDictionary[k]==-1)
217 //Calculate the size of the compressed array
218 for(Int_t i=0; i<fNDdim;i++)
222 counter=counter+longArr[i]-1;
225 newDim=fNDdim-counter; //Size of the compressed array
226 //Fill the buffer of the compressed array
228 buffer = new Int_t[newDim];
231 for(Int_t i=0; i<newDim; i++)
233 if(counterTwo<fNDdim)
235 if(fDictionary[counterTwo]!=-1)
237 buffer[i]=fDictionary[counterTwo];
239 if(fDictionary[counterTwo]==-1)
241 buffer[i]=-(longArr[g]);
242 counterTwo=counterTwo+longArr[g]-1;
252 delete [] fDictionary;
255 fDictionary = new Int_t[newDim];
257 for(Int_t i=0; i<newDim; i++)
259 fDictionary[i] = buffer[i];
274 //________________________________________________________________________________
275 void AliTRDarrayDictionary::Expand()
282 longArr = new Int_t[fNDdim];
284 for(Int_t i=0; i<fNDdim;i++)
289 for(Int_t i=0; i<fNDdim;i++)
291 if((fDictionary[i]<0)&&(fDictionary[i]!=-1))
293 longArr[r2]=-fDictionary[i];
298 //Calculate new dimensions
299 for(Int_t i=0; i<fNDdim;i++)
303 dimexp=dimexp+longArr[i]-1;
306 dimexp=dimexp+fNDdim;
308 //Write in the buffer the new array
310 bufferE = new Int_t[dimexp];
313 for(Int_t i=0; i<dimexp; i++)
315 if(fDictionary[contaexp]>=-1)
317 bufferE[i]=fDictionary[contaexp];
319 if(fDictionary[contaexp]<-1)
321 for(Int_t j=0; j<longArr[h];j++)
334 delete [] fDictionary;
338 fDictionary = new Int_t[dimexp];
340 for(Int_t i=0; i<dimexp; i++)
342 fDictionary[i] = bufferE[i];
344 if(bufferE) delete [] bufferE;
345 if(longArr) delete [] longArr;
348 //________________________________________________________________________________
349 void AliTRDarrayDictionary::Reset()
352 // Reset the array, the old contents are deleted
353 // and the data array elements are set to zero.
356 memset(fDictionary,0,sizeof(Int_t)*fNDdim);
359 //________________________________________________________________________________
360 Int_t AliTRDarrayDictionary::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
363 // Get the data using the pad numbering.
364 // To access data using the mcm scheme use instead
365 // the method GetDataByAdcCol
368 Int_t corrcolumn = fgLutPadNumbering[ncol];
370 return fDictionary[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
373 //________________________________________________________________________________
374 void AliTRDarrayDictionary::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Int_t value)
377 // Set the data using the pad numbering.
378 // To write data using the mcm scheme use instead
379 // the method SetDataByAdcCol
382 Int_t colnumb = fgLutPadNumbering[ncol];
384 fDictionary[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;
388 //________________________________________________________________________________
389 void AliTRDarrayDictionary::CreateLut()
392 // Initializes the Look Up Table to relate
393 // pad numbering and mcm channel numbering
396 if(fgLutPadNumbering) return;
398 fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
399 memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());
401 for(Int_t mcm=0; mcm<8; mcm++)
403 Int_t lowerlimit=0+mcm*18;
404 Int_t upperlimit=18+mcm*18;
405 Int_t shiftposition = 1+3*mcm;
406 for(Int_t index=lowerlimit;index<upperlimit;index++)
408 fgLutPadNumbering[index]=index+shiftposition;