No ios::binary on Alpha with cxx
[u/mrichter/AliRoot.git] / TPC / AliTPCCompression.cxx
index 422a6036ab23f8c6e7f01739cd61ba8a0ce2749f..dc031e3d13a72ec8fc67e0948cc4e403d4d5f215 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+/* $Id$ */
+
+// This class contains the implementation of the 
+// compression and decompression algorithms 
+// Compression is performed reading the Altro data block (called packet) backward.
+// Similarly decompression is also done backward so that the final file is restored
+// after the compression and decompression phase.
+
 
 #include <TObjArray.h>
 #include "Riostream.h"
@@ -23,6 +31,7 @@
 ClassImp(AliTPCCompression)
 //////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCCompression::AliTPCCompression(){
+  //Defaul constructor
   fDimBuffer=sizeof(ULong_t)*8;
   fFreeBitsBuffer=fDimBuffer;
   fReadBits=0;
@@ -34,6 +43,7 @@ AliTPCCompression::AliTPCCompression(){
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCCompression::AliTPCCompression(const AliTPCCompression &source){
+  //Constructor
   this->fDimBuffer=source.fDimBuffer;
   this->fFreeBitsBuffer=source.fFreeBitsBuffer;
   this->fReadBits=source.fReadBits;
@@ -45,6 +55,7 @@ AliTPCCompression::AliTPCCompression(const AliTPCCompression &source){
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCCompression&  AliTPCCompression::operator=(const AliTPCCompression &source){
+  //Redefinition of the assignment operator
   this->fDimBuffer=source.fDimBuffer;
   this->fFreeBitsBuffer=source.fFreeBitsBuffer;
   this->fReadBits=source.fReadBits;
@@ -55,7 +66,8 @@ AliTPCCompression&  AliTPCCompression::operator=(const AliTPCCompression &source
   return *this;
 } 
 //////////////////////////////////////////////////////////////////////////////////////////////////
-void AliTPCCompression::NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count){
+void AliTPCCompression::NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count)const{
+  //Depending on the data type (5 types of data) a specific table is called
   /*
     Table index:
     0==> Bunch length value     
@@ -110,129 +122,134 @@ void AliTPCCompression::NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen
 
 Int_t AliTPCCompression::FillTables(const char* fSource,AliTPCHTable* table[],const Int_t NumTables){
   //This method is used to compute the frequencies of the symbols in the source file
-  AliTPCBuffer160 Buff(fSource,0);
-  ULong_t CountWords=0;
-  ULong_t CountTrailer=0;
-  Int_t NumWords,PadNum,RowNum,SecNum=0;
-  Int_t Value=0;
-  ULong_t Stat[5]={0,0,0,0,0};
-  Int_t EndFill=0;
-  Int_t End=1;
-  while(Buff.ReadTrailerBackward(NumWords,PadNum,RowNum,SecNum) !=-1 ){
-    if(End){
-      EndFill=Buff.GetFillWordsNum();
-      End=0;
+  AliTPCBuffer160 buff(fSource,0);
+  ULong_t countWords=0;
+  ULong_t countTrailer=0;
+  Int_t numWords,padNum,rowNum,secNum=0;
+  Int_t value=0;
+  ULong_t stat[5]={0,0,0,0,0};
+  Int_t endFill=0;
+  Int_t end=1;
+  while(buff.ReadTrailerBackward(numWords,padNum,rowNum,secNum) !=-1 ){
+    if(end){
+      endFill=buff.GetFillWordsNum();
+      end=0;
     }//endif
-    CountTrailer++;
-    if (NumWords%4){
-      fFillWords+=4-NumWords%4;
-      for(Int_t j=0;j<(4-NumWords%4);j++){
-       Value=Buff.GetNextBackWord();
+    countTrailer++;
+    if (numWords%4){
+      fFillWords+=4-numWords%4;
+      for(Int_t j=0;j<(4-numWords%4);j++){
+       value=buff.GetNextBackWord();
       }//end for
     }//end if
     
-    Int_t Packet[1024];
-    Int_t TimePos[345];
-    Int_t Tp=0;
-    for(Int_t i=0;i<345;i++)TimePos[i]=0;
-    for(Int_t i=0;i<1024;i++)Packet[i]=0;
+    Int_t packet[1024];
+    Int_t timePos[345];
+    Int_t tp=0;
+    for(Int_t i=0;i<345;i++)timePos[i]=0;
+    for(Int_t i=0;i<1024;i++)packet[i]=0;
     
-    Int_t NextTableType=0;
-    Int_t BunchLen=0;
-    Int_t Count=0;
-    for(Int_t i=0;i<NumWords;i++){
-      Value=Buff.GetNextBackWord();
-      Packet[i]=Value;
-      if(NextTableType==1){
-       TimePos[Tp]=i;
-       Tp++;
+    Int_t nextTableType=0;
+    Int_t bunchLen=0;
+    Int_t count=0;
+    for(Int_t i=0;i<numWords;i++){
+      value=buff.GetNextBackWord();
+      packet[i]=value;
+      if(nextTableType==1){
+       timePos[tp]=i;
+       tp++;
       }
-      NextTable(Value,NextTableType,BunchLen,Count);
+      NextTable(value,nextTableType,bunchLen,count);
     }//end for
     //computing the Time gap between two bunches
     Int_t temp=0;
-    Tp--;
-    Int_t PreviousTime=Packet[TimePos[Tp]];
-    for(Int_t i=Tp-1;i>=0;i--){
-      Int_t TimPos=TimePos[i];
-      Int_t BunchLen=Packet[TimPos-1]-2;
-      temp=Packet[TimPos];
-      Packet[TimPos]=Packet[TimPos]-PreviousTime-BunchLen;
-      PreviousTime=temp;
+    tp--;
+    Int_t previousTime=packet[timePos[tp]];
+    for(Int_t i=tp-1;i>=0;i--){
+      Int_t timPos=timePos[i];
+      Int_t bunchLen=packet[timPos-1]-2;
+      temp=packet[timPos];
+      packet[timPos]=packet[timPos]-previousTime-bunchLen;
+      previousTime=temp;
     }
-    NextTableType=0;
-    Count=0;
-    BunchLen=0;
-    for(Int_t i=0;i<NumWords;i++){
-      Value=Packet[i];
-      table[NextTableType]->SetFrequency(Value);
-      Stat[NextTableType]++;
-      NextTable(Value,NextTableType,BunchLen,Count);
-      CountWords++;
+    nextTableType=0;
+    count=0;
+    bunchLen=0;
+    for(Int_t i=0;i<numWords;i++){
+      value=packet[i];
+      table[nextTableType]->SetFrequency(value);
+      stat[nextTableType]++;
+      NextTable(value,nextTableType,bunchLen,count);
+      countWords++;
     }//end for
   }//end while
-  cout<<"Number of words:       "<<CountWords<<endl;
-  cout<<"Number of trailers:    "<<CountTrailer<<endl;
-  cout<<"Number of fill words   "<<fFillWords+EndFill<<endl;
-  cout<<"Total number of words: "<<CountWords+CountTrailer*4+fFillWords<<endl;
+  cout<<"Number of words:       "<<countWords<<endl;
+  cout<<"Number of trailers:    "<<countTrailer<<endl;
+  cout<<"Number of fill words   "<<fFillWords+endFill<<endl;
+  cout<<"Total number of words: "<<countWords+countTrailer*4+fFillWords<<endl;
   //STATISTICS  
-  stat.open("Statistics");
-  stat<<"Number of words:..........................................."<<CountWords<<endl;
-  stat<<"Number of trailers (4 10 bits words in each one)..........."<<CountTrailer<<endl;
-  stat<<"Number of fill words:......................................"<<fFillWords+EndFill<<endl;
-  stat<<"Total number of words:....................................."<<CountWords+CountTrailer*4+fFillWords+EndFill<<endl;
-  stat<<"-----------------------------------------"<<endl;
-  stat<<"Number of Bunches............."<<Stat[0]<<endl;
-  stat<<"Number of Time bin............"<<Stat[1]<<endl;
-  stat<<"Number of One Samples Bunch..."<<Stat[2]<<endl;
-  stat<<"Number of Central Samples....."<<Stat[3]<<endl;
-  stat<<"Number of Border Samples......"<<Stat[4]<<endl;
-  stat<<"-----------------------------------------"<<endl;
-  ULong_t FileDimension=(ULong_t)TMath::Ceil(double((CountTrailer*4+CountWords+fFillWords+EndFill)*10/8));
-  stat<<"Total file Size in bytes.."<<FileDimension<<endl;
-  Double_t Percentage=TMath::Ceil((fFillWords+EndFill)*125)/FileDimension;
-  stat<<"Fill Words................"<<(ULong_t)TMath::Ceil((fFillWords+EndFill)*10/8)<<" bytes   "<<Percentage<<"%"<<endl;  
-  Percentage=(Double_t)CountTrailer*500/FileDimension;
-  stat<<"Trailer..................."<<CountTrailer*5<<" bytes   "<<Percentage<<"%"<<endl;
+  fStat.open("Statistics");
+  fStat<<"Number of words:..........................................."<<countWords<<endl;
+  fStat<<"Number of trailers (4 10 bits words in each one)..........."<<countTrailer<<endl;
+  fStat<<"Number of fill words:......................................"<<fFillWords+endFill<<endl;
+  fStat<<"Total number of words:....................................."<<countWords+countTrailer*4+fFillWords+endFill<<endl;
+  fStat<<"-----------------------------------------"<<endl;
+  fStat<<"Number of Bunches............."<<stat[0]<<endl;
+  fStat<<"Number of Time bin............"<<stat[1]<<endl;
+  fStat<<"Number of One Samples Bunch..."<<stat[2]<<endl;
+  fStat<<"Number of Central Samples....."<<stat[3]<<endl;
+  fStat<<"Number of Border Samples......"<<stat[4]<<endl;
+  fStat<<"-----------------------------------------"<<endl;
+  ULong_t fileDimension=(ULong_t)TMath::Ceil(double((countTrailer*4+countWords+fFillWords+endFill)*10/8));
+  fStat<<"Total file Size in bytes.."<<fileDimension<<endl;
+  Double_t percentage=TMath::Ceil((fFillWords+endFill)*125)/fileDimension;
+  fStat<<"Fill Words................"<<(ULong_t)TMath::Ceil((fFillWords+endFill)*10/8)<<" bytes   "<<percentage<<"%"<<endl;  
+  percentage=(Double_t)countTrailer*500/fileDimension;
+  fStat<<"Trailer..................."<<countTrailer*5<<" bytes   "<<percentage<<"%"<<endl;
 
-  Percentage=(Double_t)((Stat[0]+Stat[1]+Stat[2]+Stat[3]+Stat[4])) *125/FileDimension;
-  stat<<"Data......................"<<(ULong_t)TMath::Ceil((Stat[0]+Stat[1]+Stat[2]+Stat[3]+Stat[4])*10/8)<<" bytes   "<<Percentage<<"%"<<endl;
+  percentage=(Double_t)((stat[0]+stat[1]+stat[2]+stat[3]+stat[4])) *125/fileDimension;
+  fStat<<"Data......................"<<(ULong_t)TMath::Ceil((stat[0]+stat[1]+stat[2]+stat[3]+stat[4])*10/8)<<" bytes   "<<percentage<<"%"<<endl;
 
-  Percentage=(Double_t)(Stat[0]*125)/FileDimension;
-  stat<<"Bunch....................."<<(ULong_t)TMath::Ceil(Stat[0]*10/8)<<" bytes  "<<Percentage<<"%"<<endl;  //  
-  Percentage=(Double_t)(Stat[1]*125)/FileDimension;
-  stat<<"Time......................"<<(ULong_t)TMath::Ceil(Stat[1]*10/8)<<" bytes  "<<Percentage<<"%"<<endl;  //  
+  percentage=(Double_t)(stat[0]*125)/fileDimension;
+  fStat<<"Bunch....................."<<(ULong_t)TMath::Ceil(stat[0]*10/8)<<" bytes  "<<percentage<<"%"<<endl;  //  
+  percentage=(Double_t)(stat[1]*125)/fileDimension;
+  fStat<<"Time......................"<<(ULong_t)TMath::Ceil(stat[1]*10/8)<<" bytes  "<<percentage<<"%"<<endl;  //  
 
 
-  Percentage=(Double_t)((Stat[2]+Stat[3]+Stat[4])) *125/FileDimension;
-  stat<<"Amplitude values.........."<<(ULong_t)TMath::Ceil((Stat[2]+Stat[3]+Stat[4])*10/8)<<" bytes  "<<Percentage<<"%"<<endl;
-  Percentage=(Double_t)(Stat[2]*125)/FileDimension;
-  stat<<"     One Samples..............."<<(ULong_t)TMath::Ceil(Stat[2]*10/8)<<" bytes  "<<Percentage<<"%"<<endl;  //  
-  Percentage=(Double_t)(Stat[3]*125)/FileDimension;
-  stat<<"     Central Samples..........."<<(ULong_t)TMath::Ceil(Stat[3]*10/8)<<" bytes  "<<Percentage<<"%"<<endl;  //  
-  Percentage=(Double_t)(Stat[4]*125)/FileDimension;
-  stat<<"     Border Samples............"<<(ULong_t)TMath::Ceil(Stat[4]*10/8)<<" bytes  "<<Percentage<<"%"<<endl;  //  
-  stat.close();
+  percentage=(Double_t)((stat[2]+stat[3]+stat[4])) *125/fileDimension;
+  fStat<<"Amplitude values.........."<<(ULong_t)TMath::Ceil((stat[2]+stat[3]+stat[4])*10/8)<<" bytes  "<<percentage<<"%"<<endl;
+  percentage=(Double_t)(stat[2]*125)/fileDimension;
+  fStat<<"     One Samples..............."<<(ULong_t)TMath::Ceil(stat[2]*10/8)<<" bytes  "<<percentage<<"%"<<endl;  //  
+  percentage=(Double_t)(stat[3]*125)/fileDimension;
+  fStat<<"     Central Samples..........."<<(ULong_t)TMath::Ceil(stat[3]*10/8)<<" bytes  "<<percentage<<"%"<<endl;  //  
+  percentage=(Double_t)(stat[4]*125)/fileDimension;
+  fStat<<"     Border Samples............"<<(ULong_t)TMath::Ceil(stat[4]*10/8)<<" bytes  "<<percentage<<"%"<<endl;  //  
+  fStat.close();
   return 0;
 }
 ////////////////////////////////////////////////////////////////////////////////////////
 Int_t AliTPCCompression::StoreTables(AliTPCHTable* table[],const Int_t NumTable){
+  //This method stores the tables in a sequence of binary file
   char filename[15];
   ofstream fTable;
   for(Int_t k=0;k<NumTable;k++){
-    sprintf(filename,"Table%d.dat",k); 
+    sprintf(filename,"Table%d.dat",k);
+#ifndef __DECCXX 
     fTable.open(filename,ios::binary);
+#else
+    fTable.open(filename);
+#endif
     Int_t dim=table[k]->Size();
     //Table dimension is written into a file
     fTable.write((char*)(&dim),sizeof(Int_t));
     //One table is written into a file
     for(Int_t i=0;i<dim;i++){
-      UChar_t CodeLen=table[k]->CodeLen()[i];
-      //      ULong_t Code=(ULong_t)table[k]->Code()[i];
-      Double_t Code=table[k]->Code()[i];
-      fTable.write((char*)(&CodeLen),sizeof(UChar_t));
-      //fTable.write((char*)(&Code),sizeof(ULong_t));
-      fTable.write((char*)(&Code),sizeof(Double_t));
+      UChar_t codeLen=table[k]->CodeLen()[i];
+      //      ULong_t code=(ULong_t)table[k]->Code()[i];
+      Double_t code=table[k]->Code()[i];
+      fTable.write((char*)(&codeLen),sizeof(UChar_t));
+      //fTable.write((char*)(&code),sizeof(ULong_t));
+      fTable.write((char*)(&code),sizeof(Double_t));
     } //end for
     fTable.close();
   }//end for
@@ -240,7 +257,7 @@ Int_t AliTPCCompression::StoreTables(AliTPCHTable* table[],const Int_t NumTable)
 }
 ////////////////////////////////////////////////////////////////////////////////////////
 Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables){
-    Int_t n=10;// 10 bits per symbol 
+  //Tables manager
   /*
     Table index:
     0==> Bunch length values     
@@ -249,6 +266,7 @@ Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables)
     3==> Central samples
     4==> Border samples
   */
+  Int_t n=10;// 10 bits per symbol 
   AliTPCHTable ** table = new AliTPCHTable*[NumTables];
   //The table is inizialized with the rigth number of rows 
   for(Int_t i=0;i<NumTables;i++){table[i]=new  AliTPCHTable((Int_t)(TMath::Power(2,n)));}
@@ -271,15 +289,15 @@ Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables)
     cout<<"Entropy of Central Sample table......."<<table[3]->GetEntropy()<<endl;
     cout<<"Entropy Border Samples table.........."<<table[4]->GetEntropy()<<endl;
   }
-  stat.open("Statistics",ios::app);
-  stat<<endl;
-  stat<<"----------------- ENTROPY for castomized tables --------------------------"<<endl;
-  stat<<"Entropy of Bunch length table......."<<table[0]->GetEntropy()<<endl;
-  stat<<"Entropy of Time bin table..........."<<table[1]->GetEntropy()<<endl;
-  stat<<"Entropy of one Sample bunch table..."<<table[2]->GetEntropy()<<endl;
-  stat<<"Entropy of Central Sample table....."<<table[3]->GetEntropy()<<endl;
-  stat<<"Entropy Border Samples table........"<<table[4]->GetEntropy()<<endl;
-  stat.close();
+  fStat.open("Statistics",ios::app);
+  fStat<<endl;
+  fStat<<"----------------- ENTROPY for castomized tables --------------------------"<<endl;
+  fStat<<"Entropy of Bunch length table......."<<table[0]->GetEntropy()<<endl;
+  fStat<<"Entropy of Time bin table..........."<<table[1]->GetEntropy()<<endl;
+  fStat<<"Entropy of one Sample bunch table..."<<table[2]->GetEntropy()<<endl;
+  fStat<<"Entropy of Central Sample table....."<<table[3]->GetEntropy()<<endl;
+  fStat<<"Entropy Border Samples table........"<<table[4]->GetEntropy()<<endl;
+  fStat.close();
  
   if (fVerbose)
     cout<<"Tables filled \n";
@@ -331,28 +349,33 @@ Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables)
 }
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 Int_t AliTPCCompression::RetrieveTables(AliTPCHTable* table[],Int_t NumTable){
+  //This method retrieve the Huffman tables from a sequence of binary files
   if (fVerbose)
     cout<<"Retrieving tables from files \n";
-  //  ULong_t Code;
-  Double_t Code;
-  UChar_t CodeLen;
+  //  ULong_t code;
+  Double_t code;
+  UChar_t codeLen;
   ifstream fTable;  
   char filename[15];
   //The following for loop is used to generate the Huffman trees acording to the tables
   for(Int_t k=0;k<NumTable;k++){
-    Int_t Dim;//this variable contains the table dimension
+    Int_t dim;//this variable contains the table dimension
     sprintf(filename,"Table%d.dat",k); 
+#ifndef __DECCXX 
     fTable.open(filename,ios::binary);
-    fTable.read((char*)(&Dim),sizeof(Int_t));
+#else
+    fTable.open(filename);
+#endif
+    fTable.read((char*)(&dim),sizeof(Int_t));
     if (fVerbose)
-      cout<<"Table dimension: "<<Dim<<endl;
-    table[k]=new AliTPCHTable(Dim);
-    for(Int_t i=0;i<Dim;i++){
-      fTable.read((char*)(&CodeLen),sizeof(UChar_t));
-      table[k]->SetCodeLen(CodeLen,i);
-      //      fTable.read((char*)(&Code),sizeof(ULong_t));
-      fTable.read((char*)(&Code),sizeof(Double_t));
-      table[k]->SetCode(Mirror((ULong_t)Code,CodeLen),i);
+      cout<<"Table dimension: "<<dim<<endl;
+    table[k]=new AliTPCHTable(dim);
+    for(Int_t i=0;i<dim;i++){
+      fTable.read((char*)(&codeLen),sizeof(UChar_t));
+      table[k]->SetCodeLen(codeLen,i);
+      //      fTable.read((char*)(&code),sizeof(ULong_t));
+      fTable.read((char*)(&code),sizeof(Double_t));
+      table[k]->SetCode(Mirror((ULong_t)code,codeLen),i);
     }//end for 
     fTable.close();
   }//end for 
@@ -366,6 +389,7 @@ Int_t AliTPCCompression::RetrieveTables(AliTPCHTable* table[],Int_t NumTable){
 ////////////////////////////////////////////////////////////////////////////////////////
 
 void AliTPCCompression::StoreValue(ULong_t val,UChar_t len){
+  //This method stores the value "val" of "len" bits into the internal buffer "fBuffer"
   if (len<=fFreeBitsBuffer){           // val is not splitted in two buffer
     fFreeBitsBuffer-=len;
     fBuffer=fBuffer<<len;
@@ -392,7 +416,8 @@ void AliTPCCompression::StoreValue(ULong_t val,UChar_t len){
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCCompression::Flush(){
-  //The last buffen cannot be completely full
+  //The last buffer cannot be completely full so to save it 
+  //into the output file it is first necessary to fill it with an hexadecimal pattern
   if(fFreeBitsBuffer<fDimBuffer){
     fBuffer=fBuffer<<fFreeBitsBuffer;
     f.write((char*)(&fBuffer),sizeof(ULong_t));         
@@ -400,25 +425,33 @@ void AliTPCCompression::Flush(){
   return;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
-ULong_t AliTPCCompression::Mirror(ULong_t val,UChar_t len){
+ULong_t AliTPCCompression::Mirror(ULong_t val,UChar_t len)const{
+  //This method inverts the digits of the number "val" and length "len"
+  //indicates the number of digits of the number considered in binary notation
   ULong_t specular=0;
-  ULong_t Mask=0x1;
+  ULong_t mask=0x1;
   ULong_t bit;
   for(Int_t i=0;i<len;i++){
-    bit=val&Mask;
+    bit=val&mask;
     bit=bit>>i;
     specular=specular<<1;
     specular=specular|bit;
-    Mask=Mask<<1;
+    mask=mask<<1;
   }
   return specular;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 Int_t AliTPCCompression::CompressData(AliTPCHTable* table[],Int_t NumTable,const char* fSource,const char* fDest){
+  //This method is used to compress the data stored in the Altro format file using specific tables
+  //calculated considering the frequencies of the symbol of the file that has to be compressed
   cout<<" COMPRESSION "<<endl;
   cout<<"compression of the file "<<fSource<<" Output File: "<<fDest<<endl;
   //the output file is open
+#ifndef __DECCXX 
   f.open(fDest,ios::binary|ios::out);
+#else
+  f.open(fDest,ios::out);
+#endif
   //Tables are written into the output file
   for(Int_t k=0;k<NumTable;k++){
     Int_t dim=table[k]->Size();
@@ -426,264 +459,269 @@ Int_t AliTPCCompression::CompressData(AliTPCHTable* table[],Int_t NumTable,const
     f.write((char*)(&dim),sizeof(Int_t));
     //One table is written into a file
     for(Int_t i=0;i<dim;i++){
-      UChar_t CodeLen=table[k]->CodeLen()[i];
-      ULong_t Code=(ULong_t)table[k]->Code()[i];
-      f.write((char*)(&CodeLen),sizeof(UChar_t));
-      f.write((char*)(&Code),sizeof(ULong_t));
+      UChar_t codeLen=table[k]->CodeLen()[i];
+      ULong_t code=(ULong_t)table[k]->Code()[i];
+      f.write((char*)(&codeLen),sizeof(UChar_t));
+      f.write((char*)(&code),sizeof(ULong_t));
     } //end for
   }//end for
 
   // Source file is open
-  AliTPCBuffer160 Buff(fSource,0);
+  AliTPCBuffer160 buff(fSource,0);
   //coded words are written into the output file
-  Int_t NumWords,PadNum,RowNum,SecNum=0;
-  ULong_t StoredWords=0;
-  Int_t Value=0;
-  ULong_t NumPacket=0;
-  while(Buff.ReadTrailerBackward(NumWords,PadNum,RowNum,SecNum) !=-1 ){
-    NumPacket++;
-    if (NumWords%4){
-      for(Int_t j=0;j<(4-NumWords%4);j++){
-       Value=Buff.GetNextBackWord();
+  Int_t numWords,padNum,rowNum,secNum=0;
+  ULong_t storedWords=0;
+  Int_t value=0;
+  ULong_t numPackets=0;
+  while(buff.ReadTrailerBackward(numWords,padNum,rowNum,secNum) !=-1 ){
+    numPackets++;
+    if (numWords%4){
+      for(Int_t j=0;j<(4-numWords%4);j++){
+       value=buff.GetNextBackWord();
       }//end for
     }//end if
 
-    Int_t Packet[1024];
-    Int_t TimePos[345];
-    Int_t Tp=0;
-    for(Int_t i=0;i<345;i++)TimePos[i]=0;
-    for(Int_t i=0;i<1024;i++)Packet[i]=0;
+    Int_t packet[1024];
+    Int_t timePos[345];
+    Int_t tp=0;
+    for(Int_t i=0;i<345;i++)timePos[i]=0;
+    for(Int_t i=0;i<1024;i++)packet[i]=0;
 
-    Int_t NextTableType=0;
-    Int_t BunchLen=0;
-    Int_t Count=0;
-    for(Int_t i=0;i<NumWords;i++){
-      Value=Buff.GetNextBackWord();
-      Packet[i]=Value;
-      if(NextTableType==1){
-       TimePos[Tp]=i;
-       Tp++;
+    Int_t nextTableType=0;
+    Int_t bunchLen=0;
+    Int_t count=0;
+    for(Int_t i=0;i<numWords;i++){
+      value=buff.GetNextBackWord();
+      packet[i]=value;
+      if(nextTableType==1){
+       timePos[tp]=i;
+       tp++;
       }
-      NextTable(Value,NextTableType,BunchLen,Count);
+      NextTable(value,nextTableType,bunchLen,count);
     }//end for
     //computing the Time gap between two bunches
     Int_t temp=0;
-    Tp--;
-    Int_t PreviousTime=Packet[TimePos[Tp]];
-    for(Int_t i=Tp-1;i>=0;i--){
-      Int_t TimPos=TimePos[i];
-      Int_t BunchLen=Packet[TimPos-1]-2;
-      temp=Packet[TimPos];
-      Packet[TimPos]=Packet[TimPos]-PreviousTime-BunchLen;
-      PreviousTime=temp;
+    tp--;
+    Int_t previousTime=packet[timePos[tp]];
+    for(Int_t i=tp-1;i>=0;i--){
+      Int_t timPos=timePos[i];
+      Int_t bunchLen=packet[timPos-1]-2;
+      temp=packet[timPos];
+      packet[timPos]=packet[timPos]-previousTime-bunchLen;
+      previousTime=temp;
     }//end for
-    NextTableType=0;
-    Count=0;
-    BunchLen=0;
-    Int_t TimeBin=0;
+    nextTableType=0;
+    count=0;
+    bunchLen=0;
+    Int_t timeBin=0;
     //All the words for one pad are compressed and stored in the compress file
-    for(Int_t i=0;i<NumWords;i++){
-      Value=Packet[i];
-      if(NextTableType==1)TimeBin=Value;
-      if(NextTableType>1){
-       //      ULong_t val=(ULong_t)table[NextTableType]->Code()[Value];     // val is the code
-       Double_t val=table[NextTableType]->Code()[Value];     // val is the code
-       UChar_t len=table[NextTableType]->CodeLen()[Value];  // len is the length (number of bits)of val
+    for(Int_t i=0;i<numWords;i++){
+      value=packet[i];
+      if(nextTableType==1)timeBin=value;
+      if(nextTableType>1){
+       //      ULong_t val=(ULong_t)table[nextTableType]->Code()[value];     // val is the code
+       Double_t val=table[nextTableType]->Code()[value];     // val is the code
+       UChar_t len=table[nextTableType]->CodeLen()[value];  // len is the length (number of bits)of val
        StoreValue(Mirror((ULong_t)val,len),len);
-       StoredWords++;
+       storedWords++;
       }//end if
-      NextTable(Value,NextTableType,BunchLen,Count);
-      if(NextTableType==0){
-       //      ULong_t val=(ULong_t)table[1]->Code()[TimeBin];     // val is the code
-       Double_t val=table[1]->Code()[TimeBin];     // val is the code
-       UChar_t len=table[1]->CodeLen()[TimeBin];  // len is the length (number of bits)of val
+      NextTable(value,nextTableType,bunchLen,count);
+      if(nextTableType==0){
+       //      ULong_t val=(ULong_t)table[1]->Code()[timeBin];     // val is the code
+       Double_t val=table[1]->Code()[timeBin];     // val is the code
+       UChar_t len=table[1]->CodeLen()[timeBin];  // len is the length (number of bits)of val
        StoreValue(Mirror((ULong_t)val,len),len);
-       //val=(ULong_t)table[NextTableType]->Code()[(BunchLen+2)];     // val is the code
-       val=table[NextTableType]->Code()[(BunchLen+2)];     // val is the code
-       len=table[NextTableType]->CodeLen()[(BunchLen+2)];  // len is the length (number of bits)of val
+       //val=(ULong_t)table[nextTableType]->Code()[(bunchLen+2)];     // val is the code
+       val=table[nextTableType]->Code()[(bunchLen+2)];     // val is the code
+       len=table[nextTableType]->CodeLen()[(bunchLen+2)];  // len is the length (number of bits)of val
        StoreValue(Mirror((ULong_t)val,len),len);
-       StoredWords+=2;
+       storedWords+=2;
       }
     }//end for
     //Trailer
-    StoreValue(NumWords,10);
-    StoreValue(PadNum,10);
-    StoreValue(RowNum,10);
-    StoreValue(SecNum,9);
+    StoreValue(numWords,10);
+    StoreValue(padNum,10);
+    StoreValue(rowNum,10);
+    StoreValue(secNum,9);
     StoreValue(1,1);
-    StoredWords+=4;
+    storedWords+=4;
   }//end  while
-  StoreValue(NumPacket,32);
-  cout<<"Number of strored packet: "<<NumPacket<<endl;
+  StoreValue(numPackets,32);
+  cout<<"Number of strored packet: "<<numPackets<<endl;
   StoreValue(1,1);
   //The last buffen cannot be completely full
   Flush();
-  cout<<"Number of stored words: "<<StoredWords<<endl;
+  cout<<"Number of stored words: "<<storedWords<<endl;
   f.close();
   return 0;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 Int_t AliTPCCompression::CompressDataOptTables(Int_t NumTable,const char* fSource,const char* fDest){
+  //This method compress an Altro format file using a general set of tables stored as binary files to be provided
   if (fVerbose){
     cout<<" BackWord COMPRESSION "<<endl;
     cout<<"compression of the file "<<fSource<<" Output File: "<<fDest<<endl;
   }
   //Tables are read from the files (Each codeword has been "Mirrored")
-  AliTPCHTable ** table = new AliTPCHTable*[NumTable];
+  AliTPCHTable **table = new AliTPCHTable*[NumTable];
   RetrieveTables(table,NumTable);
   //the output file is open
+#ifndef __DECCXX 
   f.open(fDest,ios::binary|ios::out);
+#else
+  f.open(fDest,ios::out);
+#endif
   // Source file is open
-  AliTPCBuffer160 Buff(fSource,0);
+  AliTPCBuffer160 buff(fSource,0);
   //coded words are written into a file
-  Int_t NumWords,PadNum,RowNum,SecNum=0;
-  ULong_t  StoredWords=0;
-  Int_t    Value=0;
-  ULong_t  NumPacket=0;
-  Double_t Stat[5]={0.,0.,0.,0.,0.};
-  ULong_t  TrailerNumber=0;
-  Double_t  NumElem[5]={0,0,0,0,0};
-  Double_t FillWords=0.;
-  stat.open("Statistics",ios::app);
-  stat<<endl;
-  stat<<"-------------------COMPRESSION STATISTICS----------"<<endl;
-  Int_t End=1;
-  while(Buff.ReadTrailerBackward(NumWords,PadNum,RowNum,SecNum) !=-1 ){
-    if(End){
-      FillWords=Buff.GetFillWordsNum();
-      End=0;
+  Int_t numWords,padNum,rowNum,secNum=0;
+  ULong_t  storedWords=0;
+  Int_t    value=0;
+  ULong_t  numPackets=0;
+  Double_t stat[5]={0.,0.,0.,0.,0.};
+  ULong_t  trailerNumbers=0;
+  Double_t numElem[5]={0,0,0,0,0};
+  Double_t fillWords=0.;
+  fStat.open("Statistics",ios::app);
+  fStat<<endl;
+  fStat<<"-------------------COMPRESSION STATISTICS----------"<<endl;
+  Int_t end=1;
+  while(buff.ReadTrailerBackward(numWords,padNum,rowNum,secNum) !=-1 ){
+    if(end){
+      fillWords=buff.GetFillWordsNum();
+      end=0;
     }//endif
 
-    NumPacket++;
-    if (NumWords%4){
-      FillWords+=4-NumWords%4;
-      for(Int_t j=0;j<(4-NumWords%4);j++){
-       Value=Buff.GetNextBackWord();
+    numPackets++;
+    if (numWords%4){
+      fillWords+=4-numWords%4;
+      for(Int_t j=0;j<(4-numWords%4);j++){
+       value=buff.GetNextBackWord();
       }//end for
     }//end if
 
-    Int_t Packet[1024];
-    Int_t TimePos[345];
-    Int_t Tp=0;
-    for(Int_t i=0;i<345;i++)TimePos[i]=0;
-    for(Int_t i=0;i<1024;i++)Packet[i]=0;
+    Int_t packet[1024];
+    Int_t timePos[345];
+    Int_t tp=0;
+    for(Int_t i=0;i<345;i++)timePos[i]=0;
+    for(Int_t i=0;i<1024;i++)packet[i]=0;
 
-    Int_t NextTableType=0;
-    Int_t BunchLen=0;
-    Int_t Count=0;
-    for(Int_t i=0;i<NumWords;i++){
-      Value=Buff.GetNextBackWord();
-      Packet[i]=Value;
-      if(NextTableType==1){
-       TimePos[Tp]=i;
-       Tp++;
+    Int_t nextTableType=0;
+    Int_t bunchLen=0;
+    Int_t count=0;
+    for(Int_t i=0;i<numWords;i++){
+      value=buff.GetNextBackWord();
+      packet[i]=value;
+      if(nextTableType==1){
+       timePos[tp]=i;
+       tp++;
       }
-      NextTable(Value,NextTableType,BunchLen,Count);
+      NextTable(value,nextTableType,bunchLen,count);
     }//end for
     //computing the Time gap between two bunches
     Int_t temp=0;
-    Tp--;
-    Int_t PreviousTime=Packet[TimePos[Tp]];
-    for(Int_t i=Tp-1;i>=0;i--){
-      Int_t TimPos=TimePos[i];
-      Int_t BunchLen=Packet[TimPos-1]-2;
-      temp=Packet[TimPos];
-      Packet[TimPos]=Packet[TimPos]-PreviousTime-BunchLen;
-      PreviousTime=temp;
+    tp--;
+    Int_t previousTime=packet[timePos[tp]];
+    for(Int_t i=tp-1;i>=0;i--){
+      Int_t timPos=timePos[i];
+      Int_t bunchLen=packet[timPos-1]-2;
+      temp=packet[timPos];
+      packet[timPos]=packet[timPos]-previousTime-bunchLen;
+      previousTime=temp;
     }//end for
 
-    NextTableType=0;
-    Count=0;
-    BunchLen=0;
-    Int_t TimeBin=0;
-    for(Int_t i=0;i<NumWords;i++){
-      Value=Packet[i];
-      if(NextTableType==1)TimeBin=Value;
-      if(NextTableType>1){
-       //ULong_t val=(ULong_t)table[NextTableType]->Code()[Value];     // val is the code
-       Double_t val=table[NextTableType]->Code()[Value];     // val is the code
-       UChar_t len=table[NextTableType]->CodeLen()[Value];  // len is the length (number of bits)of val
-       Stat[NextTableType]+=len;
-       NumElem[NextTableType]++;
+    nextTableType=0;
+    count=0;
+    bunchLen=0;
+    Int_t timeBin=0;
+    for(Int_t i=0;i<numWords;i++){
+      value=packet[i];
+      if(nextTableType==1)timeBin=value;
+      if(nextTableType>1){
+       //ULong_t val=(ULong_t)table[nextTableType]->Code()[value];     // val is the code
+       Double_t val=table[nextTableType]->Code()[value];     // val is the code
+       UChar_t len=table[nextTableType]->CodeLen()[value];  // len is the length (number of bits)of val
+       stat[nextTableType]+=len;
+       numElem[nextTableType]++;
        StoreValue((ULong_t)val,len);
-       StoredWords++;
+       storedWords++;
       }//end if
-      NextTable(Value,NextTableType,BunchLen,Count);
-      if(NextTableType==0){
-       //      ULong_t val=(ULong_t)table[1]->Code()[TimeBin];     // val is the code
-       Double_t val=table[1]->Code()[TimeBin];     // val is the code
-       UChar_t len=table[1]->CodeLen()[TimeBin];  // len is the length (number of bits)of val
-       Stat[1]+=len;
-       NumElem[1]++;
+      NextTable(value,nextTableType,bunchLen,count);
+      if(nextTableType==0){
+       //      ULong_t val=(ULong_t)table[1]->Code()[timeBin];     // val is the code
+       Double_t val=table[1]->Code()[timeBin];     // val is the code
+       UChar_t len=table[1]->CodeLen()[timeBin];  // len is the length (number of bits)of val
+       stat[1]+=len;
+       numElem[1]++;
        StoreValue((ULong_t)val,len);
-       //      val=(ULong_t)table[NextTableType]->Code()[(BunchLen+2)];     // val is the code
-       val=table[NextTableType]->Code()[(BunchLen+2)];     // val is the code
-       len=table[NextTableType]->CodeLen()[(BunchLen+2)];  // len is the length (number of bits)of val
+       //      val=(ULong_t)table[nextTableType]->Code()[(bunchLen+2)];     // val is the code
+       val=table[nextTableType]->Code()[(bunchLen+2)];     // val is the code
+       len=table[nextTableType]->CodeLen()[(bunchLen+2)];  // len is the length (number of bits)of val
        StoreValue((ULong_t)val,len);
-       Stat[NextTableType]+=len;
-       NumElem[NextTableType]++;
-       StoredWords+=2;
+       stat[nextTableType]+=len;
+       numElem[nextTableType]++;
+       storedWords+=2;
       }
     }//end for
     //Trailer
-    StoreValue(NumWords,10);
-    StoreValue(PadNum,10);
-    StoreValue(RowNum,10);
-    StoreValue(SecNum,9);
+    StoreValue(numWords,10);
+    StoreValue(padNum,10);
+    StoreValue(rowNum,10);
+    StoreValue(secNum,9);
     StoreValue(1,1);
-    StoredWords+=4;
-    TrailerNumber++;
+    storedWords+=4;
+    trailerNumbers++;
   }//end  while
-  StoreValue(NumPacket,32);
+  StoreValue(numPackets,32);
   if(fVerbose)
-    cout<<"Number of strored packet: "<<NumPacket<<endl;
+    cout<<"Number of strored packets: "<<numPackets<<endl;
   StoreValue(1,1);
   //The last buffen cannot be completely full
   Flush();
   if(fVerbose)
-    cout<<"Number of stored words: "<<StoredWords<<endl;
+    cout<<"Number of stored words: "<<storedWords<<endl;
   f.close();
   //Tables are deleted
   for(Int_t i=0;i<NumTable;i++){
     delete table[i];
   }//end for
   delete [] table;
-  Double_t dimension=(ULong_t)TMath::Ceil((Stat[0]+Stat[1]+Stat[2]+Stat[3]+Stat[4])/8)+TrailerNumber*5;
-  stat<<"Trailer Dimension in bytes......"<<TrailerNumber*5<<endl;
-  stat<<"Data Dimension in bytes........."<<(ULong_t)TMath::Ceil((Stat[0]+Stat[1]+Stat[2]+Stat[3]+Stat[4])/8)<<endl;
-  stat<<"Compressed file dimension......."<<(ULong_t)dimension<<endl;
+  Double_t dimension=(ULong_t)TMath::Ceil((stat[0]+stat[1]+stat[2]+stat[3]+stat[4])/8)+trailerNumbers*5;
+  fStat<<"Trailer Dimension in bytes......"<<trailerNumbers*5<<endl;
+  fStat<<"Data Dimension in bytes........."<<(ULong_t)TMath::Ceil((stat[0]+stat[1]+stat[2]+stat[3]+stat[4])/8)<<endl;
+  fStat<<"Compressed file dimension......."<<(ULong_t)dimension<<endl;
   /*
-  stat<<(ULong_t)TrailerNumber<<endl;
-  stat<<(ULong_t)FillWords<<endl;
-  stat<<(ULong_t)NumElem[0]<<endl;
-  stat<<(ULong_t)NumElem[1]<<endl;
-  stat<<(ULong_t)NumElem[2]<<endl;
-  stat<<(ULong_t)NumElem[3]<<endl;
-  stat<<(ULong_t)NumElem[4]<<endl;
+  fStat<<(ULong_t)trailerNumbers<<endl;
+  fStat<<(ULong_t)fillWords<<endl;
+  fStat<<(ULong_t)numElem[0]<<endl;
+  fStat<<(ULong_t)numElem[1]<<endl;
+  fStat<<(ULong_t)numElem[2]<<endl;
+  fStat<<(ULong_t)numElem[3]<<endl;
+  fStat<<(ULong_t)numElem[4]<<endl;
   */
-  FillWords=(FillWords+NumElem[0]+NumElem[1]+NumElem[2]+NumElem[3]+NumElem[4]+TrailerNumber*4)*10/8;
-  stat<<"Original file dimension........."<<(ULong_t)FillWords<<endl;
+  fillWords=(fillWords+numElem[0]+numElem[1]+numElem[2]+numElem[3]+numElem[4]+trailerNumbers*4)*10/8;
+  fStat<<"Original file dimension........."<<(ULong_t)fillWords<<endl;
 
-  Double_t ratio=(dimension/FillWords)*100;
-  stat<<"Compression ratio (Compressed/Uncompressed)..."<<ratio<<"%"<<endl;
-  stat<<endl;
-  stat<<"Bunch length size in bytes......"<<(ULong_t)TMath::Ceil(Stat[0]/8)<<" Comppression.."<<(Stat[0]/NumElem[0])*10<<"%"<<endl;
+  Double_t ratio=(dimension/fillWords)*100;
+  fStat<<"Compression ratio (Compressed/Uncompressed)..."<<ratio<<"%"<<endl;
+  fStat<<endl;
+  fStat<<"Bunch length size in bytes......"<<(ULong_t)TMath::Ceil(stat[0]/8)<<" Comppression.."<<(stat[0]/numElem[0])*10<<"%"<<endl;
   
-  stat<<"Time gap size in bytes.........."<<(ULong_t)TMath::Ceil(Stat[1]/8)<<" Comppression.."<<(Stat[1]/NumElem[1])*10<<"%"<<endl;
-  stat<<"Amplitude values in bytes......."<<(ULong_t)TMath::Ceil((Stat[2]+Stat[3]+Stat[4])/8)<<" Comppression.."<<
-    ((Stat[2]+Stat[3]+Stat[4])/(NumElem[2]+NumElem[3]+NumElem[4]))*10<<"%"<<endl;
-  stat<<"     One Samples in bytes............"<<(ULong_t)TMath::Ceil(Stat[2]/8)<<" Comppression.."<<(Stat[2]/NumElem[2])*10<<"%"<<endl;
-  stat<<"     Central Samples size in bytes..."<<(ULong_t)TMath::Ceil(Stat[3]/8)<<" Comppression.."<<(Stat[3]/NumElem[3])*10<<"%"<<endl;
-  stat<<"     Border Samples size in bytes...."<<(ULong_t)TMath::Ceil(Stat[4]/8)<<" Comppression.."<<(Stat[4]/NumElem[4])*10<<"%"<<endl;
-  stat<<endl;
-  stat<<"Average number of bits per word"<<endl;
-  stat<<"Bunch length ......"<<Stat[0]/NumElem[0]<<endl;
-  stat<<"Time gap .........."<<Stat[1]/NumElem[1]<<endl;
-  stat<<"One Samples........"<<Stat[2]/NumElem[2]<<endl;
-  stat<<"Central Samples ..."<<Stat[3]/NumElem[3]<<endl;
-  stat<<"Border Samples....."<<Stat[4]/NumElem[4]<<endl;
-  stat.close();
+  fStat<<"Time gap size in bytes.........."<<(ULong_t)TMath::Ceil(stat[1]/8)<<" Comppression.."<<(stat[1]/numElem[1])*10<<"%"<<endl;
+  fStat<<"Amplitude values in bytes......."<<(ULong_t)TMath::Ceil((stat[2]+stat[3]+stat[4])/8)<<" Comppression.."<<
+    ((stat[2]+stat[3]+stat[4])/(numElem[2]+numElem[3]+numElem[4]))*10<<"%"<<endl;
+  fStat<<"     One Samples in bytes............"<<(ULong_t)TMath::Ceil(stat[2]/8)<<" Comppression.."<<(stat[2]/numElem[2])*10<<"%"<<endl;
+  fStat<<"     Central Samples size in bytes..."<<(ULong_t)TMath::Ceil(stat[3]/8)<<" Comppression.."<<(stat[3]/numElem[3])*10<<"%"<<endl;
+  fStat<<"     Border Samples size in bytes...."<<(ULong_t)TMath::Ceil(stat[4]/8)<<" Comppression.."<<(stat[4]/numElem[4])*10<<"%"<<endl;
+  fStat<<endl;
+  fStat<<"Average number of bits per word"<<endl;
+  fStat<<"Bunch length ......"<<stat[0]/numElem[0]<<endl;
+  fStat<<"Time gap .........."<<stat[1]/numElem[1]<<endl;
+  fStat<<"One Samples........"<<stat[2]/numElem[2]<<endl;
+  fStat<<"Central Samples ..."<<stat[3]/numElem[3]<<endl;
+  fStat<<"Border Samples....."<<stat[4]/numElem[4]<<endl;
+  fStat.close();
   return 0;
 }
 
@@ -698,26 +736,26 @@ void AliTPCCompression::CreateTrees(AliTPCHNode *RootNode[],const Int_t NumTable
   if(fVerbose)
     cout<<"Creating the Huffman trees \n";
   AliTPCHNode *node=0;
-  //  ULong_t Code;
-  Double_t Code;
-  UChar_t CodeLen;
+  //  ULong_t code;
+  Double_t code;
+  UChar_t codeLen;
   //loop over the numbero of tables
   for(Int_t k=0;k<NumTables;k++){
     RootNode[k]=new AliTPCHNode(); //RootNode is the root of the tree
-    Int_t Dim;//this variable contains the table dimension
-    f.read((char*)(&Dim),sizeof(Int_t));
+    Int_t dim;//this variable contains the table dimension
+    f.read((char*)(&dim),sizeof(Int_t));
     if (fVerbose)
-      cout<<"Table dimension: "<<Dim<<endl;
+      cout<<"Table dimension: "<<dim<<endl;
     //loop over the words of a table
-    for(Int_t i=0;i<Dim;i++){
-      f.read((char*)(&CodeLen),sizeof(UChar_t));
-      //f.read((char*)(&Code),sizeof(ULong_t));
-      f.read((char*)(&Code),sizeof(Double_t));
+    for(Int_t i=0;i<dim;i++){
+      f.read((char*)(&codeLen),sizeof(UChar_t));
+      //f.read((char*)(&code),sizeof(ULong_t));
+      f.read((char*)(&code),sizeof(Double_t));
       node=RootNode[k];
-      for(Int_t j=1;j<=CodeLen;j++){
+      for(Int_t j=1;j<=codeLen;j++){
        ULong_t bit,val=0;
-       val=(ULong_t)TMath::Power(2,CodeLen-j);
-       bit=(ULong_t)Code&val; 
+       val=(ULong_t)TMath::Power(2,codeLen-j);
+       bit=(ULong_t)code&val; 
        AliTPCHNode *temp=node;
        if(bit){
          node=node->GetRight();
@@ -734,9 +772,9 @@ void AliTPCCompression::CreateTrees(AliTPCHNode *RootNode[],const Int_t NumTable
          }//end if
        }//end else
       }//end for
-      if(CodeLen){
+      if(codeLen){
        node->SetSymbol(i);
-       node->SetFrequency(CodeLen);
+       node->SetFrequency(codeLen);
       }//end if
       //cout<<node->GetSymbol()<<"  "<<(Int_t)node->GetFrequency()<<endl;
     }//end for 
@@ -747,34 +785,40 @@ void AliTPCCompression::CreateTrees(AliTPCHNode *RootNode[],const Int_t NumTable
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCCompression::CreateTreesFromFile(AliTPCHNode *RootNode[],const Int_t NumTables){
+  //For each table this method builds the associate Huffman tree starting from the codeword and 
+  //the codelength of each symbol 
   if(fVerbose)
     cout<<"Creating the Huffman trees \n";
   AliTPCHNode *node=0;
-  // ULong_t Code;
-  Double_t Code;
-  UChar_t CodeLen;
+  // ULong_t code;
+  Double_t code;
+  UChar_t codeLen;
   ifstream fTable;  
   char filename[15];
   //The following for loop is used to generate the Huffman trees acording to the tables
   //loop over the tables
   for(Int_t k=0;k<NumTables;k++){
     RootNode[k]=new AliTPCHNode(); //RootNode is the root of the tree
-    Int_t Dim=0;//this variable contains the table dimension
+    Int_t dim=0;//this variable contains the table dimension
     sprintf(filename,"Table%d.dat",k); 
+#ifndef __DECCXX 
     fTable.open(filename,ios::binary);
-    fTable.read((char*)(&Dim),sizeof(Int_t));
+#else
+    fTable.open(filename);
+#endif
+    fTable.read((char*)(&dim),sizeof(Int_t));
     if (fVerbose)
-      cout<<"Table dimension: "<<Dim<<endl;
+      cout<<"Table dimension: "<<dim<<endl;
     //loop over the words of one table
-    for(Int_t i=0;i<Dim;i++){
-      fTable.read((char*)(&CodeLen),sizeof(UChar_t));
-      //fTable.read((char*)(&Code),sizeof(ULong_t));
-      fTable.read((char*)(&Code),sizeof(Double_t));
+    for(Int_t i=0;i<dim;i++){
+      fTable.read((char*)(&codeLen),sizeof(UChar_t));
+      //fTable.read((char*)(&code),sizeof(ULong_t));
+      fTable.read((char*)(&code),sizeof(Double_t));
       node=RootNode[k];
-      for(Int_t j=1;j<=CodeLen;j++){
+      for(Int_t j=1;j<=codeLen;j++){
        ULong_t bit,val=0;
-       val=(ULong_t)TMath::Power(2,CodeLen-j);
-       bit=(ULong_t)Code&val; 
+       val=(ULong_t)TMath::Power(2,codeLen-j);
+       bit=(ULong_t)code&val; 
        AliTPCHNode *temp=node;
        if(bit){
          node=node->GetRight();
@@ -791,9 +835,9 @@ void AliTPCCompression::CreateTreesFromFile(AliTPCHNode *RootNode[],const Int_t
          }//end if
        }//end else
       }//end for
-      if(CodeLen){
+      if(codeLen){
        node->SetSymbol(i);
-       node->SetFrequency(CodeLen);
+       node->SetFrequency(codeLen);
       }//end if
     }//end for 
     fTable.close();
@@ -805,7 +849,7 @@ void AliTPCCompression::CreateTreesFromFile(AliTPCHNode *RootNode[],const Int_t
 //////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCCompression::DeleteHuffmanTree(AliTPCHNode* node){
   //This function deletes all the nodes of an Huffman tree
-  //In an Huffman tree any internal node has always two children
+  //In an Huffman tree any internal node has always two children 
   if (node){
     DeleteHuffmanTree(node->GetLeft());
     DeleteHuffmanTree(node->GetRight());
@@ -815,7 +859,7 @@ void AliTPCCompression::DeleteHuffmanTree(AliTPCHNode* node){
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCCompression::VisitHuffmanTree(AliTPCHNode* node){
-  //This function realizes an in order visit of a binary tree
+  //This function realizes an in order visit of a binary tree 
   if (node){
     cout<<node->GetSymbol()<<" "<<node->GetFrequency()<<endl;
     VisitHuffmanTree(node->GetLeft());
@@ -824,7 +868,8 @@ void AliTPCCompression::VisitHuffmanTree(AliTPCHNode* node){
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 ULong_t AliTPCCompression::ReadWord(Int_t NumberOfBit){
-  ULong_t Result=0;
+  //This method retrieves a word of a specific number of bits from the file through the internal buffer 
+  ULong_t result=0;
   ULong_t bit=0;
   for (Int_t i=0;i<NumberOfBit;i++){
     if (fReadBits==32){
@@ -839,12 +884,13 @@ ULong_t AliTPCCompression::ReadWord(Int_t NumberOfBit){
     bit=bit>>fReadBits;
     fReadBits++;
     bit=bit<<i;
-    Result=Result|bit;
+    result=result|bit;
   }//end for
-  return Result;
+  return result;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCCompression::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber){
+  //It retrieves a trailer 
   ReadWord(1);
   SecNumber=ReadWord(9);
   RowNumber=ReadWord(10);
@@ -854,6 +900,7 @@ void AliTPCCompression::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &R
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 ULong_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root){
+  //This method retrieves a decoded word.
   AliTPCHNode *node=root;
   ULong_t symbol=0;
   Bool_t decoded=0;
@@ -872,13 +919,18 @@ ULong_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root){
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////
 Int_t AliTPCCompression::DecompressData(Int_t NumTables,const char* fname,char* fDest){
+  //Decompression method 
   cout<<"   DECOMPRESSION:"<<endl;
-  cout<<"Source File "<<fname<<" Destination File "<<fDest<<endl; 
+  cout<<"Source File "<<fname<<" Destination File "<<fDest<<endl;
+#ifndef __DECCXX 
   f.open(fname,ios::binary|ios::in);
+#else
+  f.open(fname,ios::in);
+#endif
   if(!f){cout<<"File doesn't exist\n";return -1;}
-  AliTPCHNode ** RootNode = new AliTPCHNode*[NumTables];
+  AliTPCHNode ** rootNode = new AliTPCHNode*[NumTables];
   //Creation of the Huffman trees
-  CreateTrees(RootNode,NumTables);
+  CreateTrees(rootNode,NumTables);
   //to go to the end of the file
   f.seekg(0,ios::end);
   //to get the file dimension in byte
@@ -889,70 +941,75 @@ Int_t AliTPCCompression::DecompressData(Int_t NumTables,const char* fname,char*
   fBuffer=0;
   f.read((char*)(&fBuffer),sizeof(ULong_t));
   Int_t bit=0;
-  ULong_t Mask=0x1;
+  ULong_t mask=0x1;
   while(!bit){
-    bit=fBuffer&Mask;
-    Mask=Mask<<1;
+    bit=fBuffer&mask;
+    mask=mask<<1;
     fReadBits++;
   }
-  ULong_t PacketNumber=ReadWord(sizeof(ULong_t)*8);
-  cout<<"Number of Packect: "<<PacketNumber<<endl;
-  AliTPCBuffer160 BufferFile(fDest,1);
+  ULong_t packetNumber=ReadWord(sizeof(ULong_t)*8);
+  cout<<"Number of Packect: "<<packetNumber<<endl;
+  AliTPCBuffer160 bufferFile(fDest,1);
   ULong_t k=0;
-  ULong_t WordsRead=0; //number of read coded words 
-  while(k<PacketNumber){
-    Int_t NumWords,PadNumber,RowNumber,SecNumber=0;
-    ReadTrailer(NumWords,PadNumber,RowNumber,SecNumber);
+  ULong_t wordsRead=0; //number of read coded words 
+  while(k<packetNumber){
+    Int_t numWords,padNumber,rowNumber,secNumber=0;
+    ReadTrailer(numWords,padNumber,rowNumber,secNumber);
     k++;
-    WordsRead+=4;
-    Int_t PreviousTime=-1;
-    Int_t Time=0;
-    Int_t NextTableType=0;
-    Int_t BunchLen=0;
-    Int_t Count=0;
-    for(Int_t i=0;i<NumWords;i++){
-      ULong_t symbol=GetDecodedWord(RootNode[NextTableType]);
-      WordsRead++;
+    wordsRead+=4;
+    Int_t previousTime=-1;
+    Int_t time=0;
+    Int_t nextTableType=0;
+    Int_t bunchLen=0;
+    Int_t count=0;
+    for(Int_t i=0;i<numWords;i++){
+      ULong_t symbol=GetDecodedWord(rootNode[nextTableType]);
+      wordsRead++;
       //Time reconstruction
-      if (NextTableType==1){
-       if (PreviousTime!=-1){
-         PreviousTime=symbol+PreviousTime+BunchLen;
+      if (nextTableType==1){
+       if (previousTime!=-1){
+         previousTime=symbol+previousTime+bunchLen;
        }
-       else PreviousTime=symbol;
-       Time=PreviousTime;
+       else previousTime=symbol;
+       time=previousTime;
       }
-      if(NextTableType>1)
-       BufferFile.FillBuffer(symbol);
-      NextTable(symbol,NextTableType,BunchLen,Count); 
-      if(NextTableType==0){
-       BufferFile.FillBuffer(Time);
-       BufferFile.FillBuffer(BunchLen+2);
-       BunchLen=0;
+      if(nextTableType>1)
+       bufferFile.FillBuffer(symbol);
+      NextTable(symbol,nextTableType,bunchLen,count); 
+      if(nextTableType==0){
+       bufferFile.FillBuffer(time);
+       bufferFile.FillBuffer(bunchLen+2);
+       bunchLen=0;
       }
     }//end for
-    BufferFile.WriteTrailer(NumWords,PadNumber,RowNumber,SecNumber);
+    bufferFile.WriteTrailer(numWords,padNumber,rowNumber,secNumber);
   }//end while
-  cout<<"Number of decoded words:"<<WordsRead<<endl;
+  cout<<"Number of decoded words:"<<wordsRead<<endl;
   f.close();
   //The trees are deleted 
   for(Int_t j=0;j<NumTables;j++){
-      DeleteHuffmanTree(RootNode[j]);
+      DeleteHuffmanTree(rootNode[j]);
   }//end for
-  delete [] RootNode; 
+  delete [] rootNode; 
   return 0; 
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 Int_t AliTPCCompression::DecompressDataOptTables(Int_t NumTables,const char* fname,char* fDest){
+  //This method decompress a file using separate Huffman tables
   if(fVerbose){
     cout<<"   DECOMPRESSION:"<<endl;
     cout<<"Source File "<<fname<<" Destination File "<<fDest<<endl; 
   }
-  AliTPCHNode ** RootNode = new AliTPCHNode*[NumTables];
+  AliTPCHNode ** rootNode = new AliTPCHNode*[NumTables];
   //Creation of the Huffman trees
-  CreateTreesFromFile(RootNode,NumTables);
+  CreateTreesFromFile(rootNode,NumTables);
+#ifndef __DECCXX
   f.open(fname,ios::binary|ios::in);
+#else
+  f.open(fname,ios::in);
+#endif
   if(!f){cout<<"File doesn't exist\n";return -1;}
   //to go to the end of the file
   f.seekg(0,ios::end);
@@ -964,80 +1021,85 @@ Int_t AliTPCCompression::DecompressDataOptTables(Int_t NumTables,const char* fna
   fBuffer=0;
   f.read((char*)(&fBuffer),sizeof(ULong_t));
   Int_t bit=0;
-  ULong_t Mask=0x1;
+  ULong_t mask=0x1;
   while(!bit){
-    bit=fBuffer&Mask;
-    Mask=Mask<<1;
+    bit=fBuffer&mask;
+    mask=mask<<1;
     fReadBits++;
   }
-  ULong_t PacketNumber=ReadWord(sizeof(ULong_t)*8);
+  ULong_t packetNumber=ReadWord(sizeof(ULong_t)*8);
   if(fVerbose){
-    cout<<"Number of Packect: "<<PacketNumber<<endl;
+    cout<<"Number of Packect: "<<packetNumber<<endl;
   }
-  AliTPCBuffer160 BufferFile(fDest,1);
+  AliTPCBuffer160 bufferFile(fDest,1);
   ULong_t k=0;
-  ULong_t WordsRead=0; //number of read coded words 
-  while(k<PacketNumber){
-    Int_t NumWords,PadNumber,RowNumber,SecNumber=0;
-    ReadTrailer(NumWords,PadNumber,RowNumber,SecNumber);
+  ULong_t wordsRead=0; //number of read coded words 
+  while(k<packetNumber){
+    Int_t numWords,padNumber,rowNumber,secNumber=0;
+    ReadTrailer(numWords,padNumber,rowNumber,secNumber);
     k++;
-    WordsRead+=4;
-    Int_t PreviousTime=-1;
-    Int_t Time=0;
-    Int_t NextTableType=0;
-    Int_t BunchLen=0;
-    Int_t Count=0;
-    for(Int_t i=0;i<NumWords;i++){
-      ULong_t symbol=GetDecodedWord(RootNode[NextTableType]);
-      WordsRead++;
+    wordsRead+=4;
+    Int_t previousTime=-1;
+    Int_t time=0;
+    Int_t nextTableType=0;
+    Int_t bunchLen=0;
+    Int_t count=0;
+    for(Int_t i=0;i<numWords;i++){
+      ULong_t symbol=GetDecodedWord(rootNode[nextTableType]);
+      wordsRead++;
       //Time reconstruction
-      if (NextTableType==1){
-       if (PreviousTime!=-1){
-         PreviousTime=symbol+PreviousTime+BunchLen;
+      if (nextTableType==1){
+       if (previousTime!=-1){
+         previousTime=symbol+previousTime+bunchLen;
        }
-       else PreviousTime=symbol;
-       Time=PreviousTime;
+       else previousTime=symbol;
+       time=previousTime;
       }
-      if(NextTableType>1)
-       BufferFile.FillBuffer(symbol);
-      NextTable(symbol,NextTableType,BunchLen,Count); 
-      if(NextTableType==0){
-       BufferFile.FillBuffer(Time);
-       BufferFile.FillBuffer(BunchLen+2);
-       BunchLen=0;
+      if(nextTableType>1)
+       bufferFile.FillBuffer(symbol);
+      NextTable(symbol,nextTableType,bunchLen,count); 
+      if(nextTableType==0){
+       bufferFile.FillBuffer(time);
+       bufferFile.FillBuffer(bunchLen+2);
+       bunchLen=0;
       }
     }//end for
-    BufferFile.WriteTrailer(NumWords,PadNumber,RowNumber,SecNumber);
+    bufferFile.WriteTrailer(numWords,padNumber,rowNumber,secNumber);
   }//end while
   if(fVerbose){
-    cout<<"Number of decoded words:"<<WordsRead<<endl;
+    cout<<"Number of decoded words:"<<wordsRead<<endl;
   }
   f.close();
   //The trees are deleted 
   for(Int_t j=0;j<NumTables;j++){
-      DeleteHuffmanTree(RootNode[j]);
+      DeleteHuffmanTree(rootNode[j]);
   }//end for
-  delete [] RootNode;
+  delete [] rootNode;
   return 0; 
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
-void AliTPCCompression::ReadAltroFormat(char* fileOut,char* fileIn){
+void AliTPCCompression::ReadAltroFormat(char* fileOut,char* fileIn)const{
+  //This method creates a text file containing the same information stored in 
+  //an Altro file. The information in the text file is organized pad by pad and 
+  //and for each pad it consists in a sequence of bunches (Bunch length +2,
+  //Time bin of the last amplitude sample in the bunch, amplitude values)
+  //It is used mainly for debugging
   ofstream ftxt(fileOut);
-  AliTPCBuffer160 Buff(fileIn,0);
-  Int_t NumWords,PadNum,RowNum,SecNum=0;
-  Int_t Value=0;
-  while(Buff.ReadTrailerBackward(NumWords,PadNum,RowNum,SecNum) !=-1 ){
-    ftxt<<"W:"<<NumWords<<" P:"<<PadNum<<" R:"<<RowNum<<" S:"<<SecNum<<endl;
-    if (NumWords%4){
-      for(Int_t j=0;j<(4-NumWords%4);j++){
-       Value=Buff.GetNextBackWord();
+  AliTPCBuffer160 buff(fileIn,0);
+  Int_t numWords,padNum,rowNum,secNum=0;
+  Int_t value=0;
+  while(buff.ReadTrailerBackward(numWords,padNum,rowNum,secNum) !=-1 ){
+    ftxt<<"W:"<<numWords<<" P:"<<padNum<<" R:"<<rowNum<<" S:"<<secNum<<endl;
+    if (numWords%4){
+      for(Int_t j=0;j<(4-numWords%4);j++){
+       value=buff.GetNextBackWord();
       }//end for
     }//end if
-    for(Int_t i=0;i<NumWords;i++){
-      Value=Buff.GetNextBackWord();
-      ftxt<<Value<<endl;
+    for(Int_t i=0;i<numWords;i++){
+      value=buff.GetNextBackWord();
+      ftxt<<value<<endl;
     }//end for
   }//end while
   ftxt.close();