#include "AliTRDarrayDictionary.h"
#include "AliTRDfeeParam.h"
+#include "AliLog.h"
ClassImp(AliTRDarrayDictionary)
,fNtime(0)
,fNDdim(0)
,fDictionary(0)
+ ,fFlag(kFALSE)
{
//
// AliTRDarrayDictionary default contructor
,fNtime(0)
,fNDdim(0)
,fDictionary(0)
-
+ ,fFlag(kFALSE)
{
//
// AliTRDarrayDictionary contructor
,fNtime(a.fNtime)
,fNDdim(a.fNDdim)
,fDictionary(0)
+ ,fFlag(a.fFlag)
{
//
// AliTRDarrayDictionary copy constructor
// AliTRDarrayDictionary destructor
//
- if(fDictionary)
- {
- delete [] fDictionary;
- fDictionary=0;
- }
+ delete [] fDictionary;
+ fDictionary=0;
}
{
fDictionary[i]=a.fDictionary[i];
}
+ fFlag=a.fFlag;
return *this;
}
fDictionary=0;
}
fDictionary = new Int_t[fNDdim];
- for(Int_t i=0; i<fNDdim; i++)
- {
- fDictionary[i] = -1;
- }
+ memset(fDictionary,-1,sizeof(Int_t)*fNDdim);
}
Int_t g=0;
if(buffer)
{
-
for(Int_t i=0; i<newDim; i++)
{
if(counterTwo<fNDdim)
delete [] fDictionary;
fDictionary=0;
}
- fDictionary = new Int_t[newDim];
+ fDictionary = buffer;
fNDdim = newDim;
- for(Int_t i=0; i<newDim; i++)
- {
- fDictionary[i] = buffer[i];
- }
-
- delete [] buffer;
- buffer=0;
-
}
delete [] longArr;
longArr=0;
-
}
-
+ fFlag=kFALSE; // This way it can be expanded afterwards
}
//________________________________________________________________________________
// Expand the array
//
- Int_t *longArr;
- longArr = new Int_t[fNDdim];
+ if(fNDdim==0)
+ {
+ AliError("Called expand with dimension zero");
+ return;
+ }
+
+
Int_t dimexp=0;
+
+// if(WasExpandCalled())
+// return;
- //Initialize the array
- memset(longArr,0,sizeof(Int_t)*fNDdim);
+ if(fNDdim==fNrow*fNumberOfChannels*fNtime)
+ return;
- Int_t r2=0;
- for(Int_t i=0; i<fNDdim;i++)
- {
- if((fDictionary[i]<0)&&(fDictionary[i]!=-1))
- {
- longArr[r2]=-fDictionary[i];
- r2++;
- }
+ if(fDictionary&&fNDdim==1)
+ {
+ dimexp = -fDictionary[0];
+ delete [] fDictionary;
+ fDictionary=0;
+ fDictionary = new Int_t[dimexp];
+ fNDdim = dimexp;
+ // Re-initialize the array
+ memset(fDictionary,-1,sizeof(Int_t)*dimexp);
+ fFlag=kTRUE; // Not expand again
+ return;
}
- //Calculate new dimensions
- for(Int_t i=0; i<fNDdim;i++)
- {
- if(longArr[i]!=0)
- {
- dimexp=dimexp+longArr[i]-1;
- }
- }
- dimexp=dimexp+fNDdim;
-
- //Write in the buffer the new array
- Int_t* bufferE;
- bufferE = new Int_t[dimexp];
- Int_t contaexp =0;
- Int_t h=0;
- for(Int_t i=0; i<dimexp; i++)
+ Int_t *longArr = new Int_t[fNDdim];
+ if(longArr && fDictionary)
{
- if(fDictionary[contaexp]>=-1)
- {
- bufferE[i]=fDictionary[contaexp];
- }
- if(fDictionary[contaexp]<-1)
- {
- for(Int_t j=0; j<longArr[h];j++)
+ //Initialize the array
+ memset(longArr,0,sizeof(Int_t)*fNDdim);
+
+ Int_t r2=0;
+ for(Int_t i=0; i<fNDdim;i++)
+ {
+ if((fDictionary[i]<0)&&(fDictionary[i]!=-1))
{
- bufferE[i+j]=-1;
+ longArr[r2]=-fDictionary[i];
+ r2++;
}
- i=i+longArr[h]-1;
- h++;
- }
- contaexp++;
- }
+ }
- //Copy the buffer
- if(fDictionary)
- {
- delete [] fDictionary;
- fDictionary=0;
- }
+ //Calculate new dimensions
+ for(Int_t i=0; i<fNDdim;i++)
+ {
+ if(longArr[i]!=0)
+ dimexp=dimexp+longArr[i]-1;
+ if(longArr[i]==0)
+ break;
+ }
+ dimexp=dimexp+fNDdim;
+
+ //Write in the buffer the new array
+ Int_t contaexp =0;
+ Int_t h=0;
+ Int_t* bufferE = new Int_t[dimexp];
- fDictionary = new Int_t[dimexp];
- fNDdim = dimexp;
- for(Int_t i=0; i<dimexp; i++)
+ if(bufferE)
+ {
+ memset(bufferE,-1,sizeof(Int_t)*dimexp);
+ for(Int_t i=0; i<dimexp; i++)
+ {
+ if(fDictionary[contaexp]>=-1)
+ {
+ bufferE[i]=fDictionary[contaexp];
+ }
+ if(fDictionary[contaexp]<-1)
+ {
+ i=i+longArr[h]-1;
+ h++;
+ }
+ contaexp++;
+ }
+
+ //Copy the buffer
+ delete [] fDictionary;
+ fDictionary=bufferE;
+ fNDdim = dimexp;
+ }
+ }
+ if (longArr)
{
- fDictionary[i] = bufferE[i];
+ delete [] longArr;
}
- if(bufferE) delete [] bufferE;
- if(longArr) delete [] longArr;
+ fFlag=kTRUE; // Not expand again
}
//________________________________________________________________________________
Int_t shiftposition = 1+3*mcm;
for(Int_t index=lowerlimit;index<upperlimit;index++)
{
- fgLutPadNumbering[index]=index+shiftposition;
+ fgLutPadNumbering[index]= index+shiftposition;
}
}
}