re-activate contrib code
[u/mrichter/AliRoot.git] / TRD / AliTRDarrayDictionary.cxx
index c8e83f8..3d5dfee 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "AliTRDarrayDictionary.h"
 #include "AliTRDfeeParam.h"
+#include "AliLog.h"
 
 ClassImp(AliTRDarrayDictionary)
 
@@ -64,7 +65,6 @@ AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime
                      ,fNDdim(0)
                      ,fDictionary(0)
                       ,fFlag(kFALSE)
-
 {
   //
   // AliTRDarrayDictionary contructor
@@ -106,11 +106,8 @@ AliTRDarrayDictionary::~AliTRDarrayDictionary()
   //   AliTRDarrayDictionary destructor
   //
 
-  if(fDictionary)
-    {
-      delete [] fDictionary;
-      fDictionary=0;
-    }
+  delete [] fDictionary;
+  fDictionary=0;
 
 }
 
@@ -265,8 +262,7 @@ void AliTRDarrayDictionary::Compress()
       delete [] longArr;
       longArr=0;
     }
-  fFlag=kTRUE; // flag to signal compression
-
+  fFlag=kFALSE; // This way it can be expanded afterwards
 }
 
 //________________________________________________________________________________
@@ -276,8 +272,19 @@ void AliTRDarrayDictionary::Expand()
   //  Expand the array
   //  
 
+  if(fNDdim==0)
+    {
+      AliError("Called expand with dimension zero");
+      return;    
+    }
+
+
   Int_t dimexp=0;
-  if(!IsCompressed())
+  
+//   if(WasExpandCalled()) 
+//     return;
+
+  if(fNDdim==fNrow*fNumberOfChannels*fNtime)
     return;
 
   if(fDictionary&&fNDdim==1)
@@ -289,6 +296,7 @@ void AliTRDarrayDictionary::Expand()
       fNDdim = dimexp;
       // Re-initialize the array
       memset(fDictionary,-1,sizeof(Int_t)*dimexp);
+      fFlag=kTRUE; // Not expand again
       return;
     }
 
@@ -322,11 +330,10 @@ void AliTRDarrayDictionary::Expand()
       Int_t contaexp =0;    
       Int_t h=0;
       Int_t* bufferE = new Int_t[dimexp];
-      memset(bufferE,-1,sizeof(Int_t)*dimexp);
 
       if(bufferE)
        {
-
+         memset(bufferE,-1,sizeof(Int_t)*dimexp);
           for(Int_t i=0; i<dimexp; i++)
             {
               if(fDictionary[contaexp]>=-1)  
@@ -351,8 +358,7 @@ void AliTRDarrayDictionary::Expand()
     {
       delete [] longArr; 
     }
-
-  fFlag=kFALSE; // flag to signal that is not compressed anymore
+  fFlag=kTRUE; // Not expand again
 
 }
 //________________________________________________________________________________