// //
/////////////////////////////////////////////////////////
+#include <TArray.h>
+
#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 newDim=0;
Int_t j;
Int_t r=0;
- Int_t *longArr;
- longArr = new Int_t[fNDdim];
Int_t k=0;
- for(Int_t i=0; i<fNDdim;i++)
- {
- longArr[i]=0;
- }
- for(Int_t i=0;i<fNDdim; i++)
- {
- j=0;
- if(fDictionary[i]==-1)
- {
- for(k=i;k<fNDdim;k++)
- {
- if(fDictionary[k]==-1)
- {
- j=j+1;
- longArr[r]=j;
- }
- else
- {
- break;
- }
- }
- r=r+1;
- }
- i=i+j;
- }
- //Calculate the size of the compressed array
- for(Int_t i=0; i<fNDdim;i++)
- {
- if(longArr[i]!=0)
- {
- counter=counter+longArr[i]-1;
- }
- }
- newDim=fNDdim-counter; //Size of the compressed array
- //Fill the buffer of the compressed array
- Int_t* buffer;
- buffer = new Int_t[newDim];
- Int_t counterTwo=0;
- Int_t g=0;
- for(Int_t i=0; i<newDim; i++)
- {
- if(counterTwo<fNDdim)
- {
- if(fDictionary[counterTwo]!=-1)
- {
- buffer[i]=fDictionary[counterTwo];
- }
- if(fDictionary[counterTwo]==-1)
- {
- buffer[i]=-(longArr[g]);
- counterTwo=counterTwo+longArr[g]-1;
- g++;
- }
- counterTwo++;
- }
- }
- //Copy the buffer
- if(fDictionary)
- {
- delete [] fDictionary;
- fDictionary=0;
- }
- fDictionary = new Int_t[newDim];
- fNDdim = newDim;
- for(Int_t i=0; i<newDim; i++)
- {
- fDictionary[i] = buffer[i];
- }
- if(buffer)
- {
- delete [] buffer;
- buffer=0;
- }
+ Int_t *longArr = new Int_t[fNDdim];
+
if(longArr)
{
+
+ memset(longArr,0,sizeof(Int_t)*fNDdim);
+
+ for(Int_t i=0;i<fNDdim; i++)
+ {
+ j=0;
+ if(fDictionary[i]==-1)
+ {
+ for(k=i;k<fNDdim;k++)
+ {
+ if(fDictionary[k]==-1)
+ {
+ j=j+1;
+ longArr[r]=j;
+ }
+ else
+ {
+ break;
+ }
+ }
+ r=r+1;
+ }
+ i=i+j;
+ }
+
+ //Calculate the size of the compressed array
+ for(Int_t i=0; i<fNDdim;i++)
+ {
+ if(longArr[i]!=0)
+ {
+ counter=counter+longArr[i]-1;
+ }
+ }
+ newDim=fNDdim-counter; //Size of the compressed array
+
+ //Fill the buffer of the compressed array
+ Int_t* buffer = new Int_t[newDim];
+ Int_t counterTwo=0;
+ Int_t g=0;
+ if(buffer)
+ {
+ for(Int_t i=0; i<newDim; i++)
+ {
+ if(counterTwo<fNDdim)
+ {
+ if(fDictionary[counterTwo]!=-1)
+ {
+ buffer[i]=fDictionary[counterTwo];
+ }
+ if(fDictionary[counterTwo]==-1)
+ {
+ buffer[i]=-(longArr[g]);
+ counterTwo=counterTwo+longArr[g]-1;
+ g++;
+ }
+ counterTwo++;
+ }
+ }
+
+ //Copy the buffer
+ if(fDictionary)
+ {
+ delete [] fDictionary;
+ fDictionary=0;
+ }
+ fDictionary = buffer;
+ fNDdim = newDim;
+ }
+
delete [] longArr;
longArr=0;
}
-
+ fFlag=kFALSE; // This way it can be expanded afterwards
}
//________________________________________________________________________________
// Expand the array
//
- Int_t *longArr;
- longArr = new Int_t[fNDdim];
- Int_t dimexp=0;
- for(Int_t i=0; i<fNDdim;i++)
+ if(fNDdim==0)
{
- longArr[i]=0;
- }
- Int_t r2=0;
- for(Int_t i=0; i<fNDdim;i++)
- {
- if((fDictionary[i]<0)&&(fDictionary[i]!=-1))
- {
- longArr[r2]=-fDictionary[i];
- r2++;
- }
+ AliError("Called expand with dimension zero");
+ return;
}
- //Calculate new dimensions
- for(Int_t i=0; i<fNDdim;i++)
- {
- if(longArr[i]!=0)
- {
- dimexp=dimexp+longArr[i]-1;
- }
+
+ Int_t dimexp=0;
+
+// if(WasExpandCalled())
+// return;
+
+ if(fNDdim==fNrow*fNumberOfChannels*fNtime)
+ return;
+
+ 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;
}
- 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++;
+ }
+
+ //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];
+
+ 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;
}
- contaexp++;
}
-
- //Copy the buffer
- if(fDictionary)
- {
- delete [] fDictionary;
- fDictionary=0;
- }
-
- fDictionary = new Int_t[dimexp];
- fNDdim = dimexp;
- for(Int_t i=0; i<dimexp; i++)
+ 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;
}
}
}