Move back to Int_t and include a protection if arrays are already uncompressed (Hermes)
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 1 Apr 2011 08:58:14 +0000 (08:58 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 1 Apr 2011 08:58:14 +0000 (08:58 +0000)
TRD/AliTRDarrayDictionary.cxx
TRD/AliTRDarrayDictionary.h

index 09c1514..c8e83f8 100644 (file)
@@ -43,7 +43,7 @@ AliTRDarrayDictionary::AliTRDarrayDictionary()
                       ,fNtime(0)
                       ,fNDdim(0)
                       ,fDictionary(0)
-                      ,fFlag(kTRUE)
+                      ,fFlag(kFALSE)
 {
   //
   // AliTRDarrayDictionary default contructor
@@ -63,7 +63,7 @@ AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime
                       ,fNtime(0)
                      ,fNDdim(0)
                      ,fDictionary(0)
-                      ,fFlag(kTRUE)
+                      ,fFlag(kFALSE)
 
 {
   //
@@ -228,10 +228,6 @@ void AliTRDarrayDictionary::Compress()
         }
       newDim=fNDdim-counter;   //Size of the compressed array
 
-      //Set the flag if the array has no data
-      if(newDim==1)
-       fFlag=kFALSE;
-
       //Fill the buffer of the compressed array
       Int_t* buffer = new Int_t[newDim];
       Int_t counterTwo=0;
@@ -268,8 +264,8 @@ void AliTRDarrayDictionary::Compress()
     
       delete [] longArr;
       longArr=0;
-
     }
+  fFlag=kTRUE; // flag to signal compression
 
 }
 
@@ -281,29 +277,28 @@ void AliTRDarrayDictionary::Expand()
   //  
 
   Int_t dimexp=0;
+  if(!IsCompressed())
+    return;
 
-  if(!HasData()) //if the array has no data (only -1's)
-    {
-      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);
-       }
+  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);
       return;
     }
 
-  UShort_t *longArr = new UShort_t[fNDdim];
+  Int_t *longArr = new Int_t[fNDdim];
   if(longArr && fDictionary)
     {
       //Initialize the array
-      memset(longArr,0,sizeof(UShort_t)*fNDdim);
+      memset(longArr,0,sizeof(Int_t)*fNDdim);
 
-      UShort_t r2=0;
+      Int_t r2=0;
       for(Int_t i=0; i<fNDdim;i++)
         {
           if((fDictionary[i]<0)&&(fDictionary[i]!=-1))  
@@ -357,6 +352,8 @@ void AliTRDarrayDictionary::Expand()
       delete [] longArr; 
     }
 
+  fFlag=kFALSE; // flag to signal that is not compressed anymore
+
 }
 //________________________________________________________________________________
 void AliTRDarrayDictionary::Reset()
index 9d5f9c2..53ad86b 100644 (file)
@@ -38,7 +38,7 @@ class AliTRDarrayDictionary: public TObject
   Int_t GetData(Int_t nrow, Int_t ncol, Int_t ntime) const;\r
   void  SetData(Int_t nrow, Int_t ncol, Int_t ntime, Int_t value);\r
   static  void    CreateLut();\r
-  Bool_t HasData() const {return fFlag;}; \r
+  Bool_t IsCompressed() const {return fFlag;}; \r
 \r
  protected:\r
 \r
@@ -49,10 +49,10 @@ class AliTRDarrayDictionary: public TObject
   Int_t   fNtime;       //Number of time bins\r
   Int_t   fNDdim;       //Dimension of the Dictionary array\r
   Int_t*  fDictionary;  //[fNDdim]  //Pointer to integers array\r
-  Bool_t  fFlag;        //Flag for data contents in the array\r
+  Bool_t  fFlag;        //Flag in case of compressed array\r
   static Short_t *fgLutPadNumbering;   //  [fNcol] Look Up Table\r
 \r
-  ClassDef(AliTRDarrayDictionary,4) //Dictionary container class\r
+  ClassDef(AliTRDarrayDictionary,5) //Dictionary container class\r
     \r
 };\r
 #endif\r