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"
29 ClassImp(AliTRDarrayDictionary)
31 //________________________________________________________________________________
32 AliTRDarrayDictionary::AliTRDarrayDictionary()
42 // AliTRDarrayDictionary default contructor
47 //________________________________________________________________________________
48 AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime)
59 // AliTRDarrayDictionary contructor
62 Allocate(nrow,ncol,ntime);
66 //________________________________________________________________________________
67 AliTRDarrayDictionary::AliTRDarrayDictionary(const AliTRDarrayDictionary &a)
77 // AliTRDarrayDictionary copy constructor
80 fDictionary = new Int_t[fNDdim];
81 for(Int_t i=0; i<fNDdim; i++)
83 fDictionary[i]=a.fDictionary[i];
88 //________________________________________________________________________________
89 AliTRDarrayDictionary::~AliTRDarrayDictionary()
92 // AliTRDarrayDictionary destructor
97 delete [] fDictionary;
103 //________________________________________________________________________________
104 AliTRDarrayDictionary &AliTRDarrayDictionary::operator=(const AliTRDarrayDictionary &a)
107 // Assignment operator
117 delete [] fDictionary;
124 fDictionary = new Int_t[fNDdim];
125 for(Int_t i=0; i<fNDdim; i++)
127 fDictionary[i]=a.fDictionary[i];
133 //________________________________________________________________________________
134 void AliTRDarrayDictionary::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
137 // Allocates memory for the dictionary array with dimensions
139 // Object initialized to -1
145 fNDdim=nrow*ncol*ntime;
148 delete [] fDictionary;
151 fDictionary = new Int_t[fNDdim];
152 for(Int_t i=0; i<fNDdim; i++)
159 //________________________________________________________________________________
160 void AliTRDarrayDictionary::Compress()
163 // Compress the array
167 // AliDebug(1,"Compressing");
173 longArr = new Int_t[fNDdim];
175 for(Int_t i=0; i<fNDdim;i++)
179 for(Int_t i=0;i<fNDdim; i++)
182 if(fDictionary[i]==-1)
184 for(k=i;k<fNDdim;k++)
186 if(fDictionary[k]==-1)
200 //Calculate the size of the compressed array
201 for(Int_t i=0; i<fNDdim;i++)
205 counter=counter+longArr[i]-1;
208 newDim=fNDdim-counter; //Size of the compressed array
209 //Fill the buffer of the compressed array
211 buffer = new Int_t[newDim];
214 for(Int_t i=0; i<newDim; i++)
216 if(counterTwo<fNDdim)
218 if(fDictionary[counterTwo]!=-1)
220 buffer[i]=fDictionary[counterTwo];
222 if(fDictionary[counterTwo]==-1)
224 buffer[i]=-(longArr[g]);
225 counterTwo=counterTwo+longArr[g]-1;
235 delete [] fDictionary;
238 fDictionary = new Int_t[newDim];
240 for(Int_t i=0; i<newDim; i++)
242 fDictionary[i] = buffer[i];
257 //________________________________________________________________________________
258 void AliTRDarrayDictionary::Expand()
265 longArr = new Int_t[fNDdim];
267 for(Int_t i=0; i<fNDdim;i++)
272 for(Int_t i=0; i<fNDdim;i++)
274 if((fDictionary[i]<0)&&(fDictionary[i]!=-1))
276 longArr[r2]=-fDictionary[i];
281 //Calculate new dimensions
282 for(Int_t i=0; i<fNDdim;i++)
286 dimexp=dimexp+longArr[i]-1;
289 dimexp=dimexp+fNDdim;
291 //Write in the buffer the new array
293 bufferE = new Int_t[dimexp];
296 for(Int_t i=0; i<dimexp; i++)
298 if(fDictionary[contaexp]>=-1)
300 bufferE[i]=fDictionary[contaexp];
302 if(fDictionary[contaexp]<-1)
304 for(Int_t j=0; j<longArr[h];j++)
317 delete [] fDictionary;
321 fDictionary = new Int_t[dimexp];
323 for(Int_t i=0; i<dimexp; i++)
325 fDictionary[i] = bufferE[i];
327 if(bufferE) delete [] bufferE;
328 if(longArr) delete [] longArr;