]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Corrections to obey the coding conventions (D.Favretto)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Mar 2003 17:21:10 +0000 (17:21 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Mar 2003 17:21:10 +0000 (17:21 +0000)
17 files changed:
ITS/AliITSDDLRawData.C
ITS/AliITSDDLRawData.cxx
ITS/AliITSDDLRawData.h
TPC/AliTPCAltro.C
TPC/AliTPCBuffer.cxx
TPC/AliTPCBuffer.h
TPC/AliTPCBuffer160.cxx
TPC/AliTPCBuffer160.h
TPC/AliTPCCompression.cxx
TPC/AliTPCCompression.h
TPC/AliTPCDDL.C
TPC/AliTPCDDLRawData.C
TPC/AliTPCDDLRawData.cxx
TPC/AliTPCDDLRawData.h
TPC/AliTPCH5OptimizedTables.C
TPC/AliTPCHuffman.cxx
TPC/AliTPCHuffman.h

index ede2ebb0398ff909349e05489e8e44fc67d757e1..de88a043743f179aee88e240a786b78da1e8888f 100644 (file)
@@ -5,7 +5,7 @@
 #endif
 
 /*
-Before running this macro it is necessary comment the following line of the method
+Before running this macro it is necessary to comment the following line of the method
 AddDigit in the class AliITSsimulationSDD
 //if( fResponse->Do10to8() ) signal = Convert8to10( signal ); 
 In this way the amplitude value for signal coming from SDD takes only 8 bits and not 10.
@@ -26,7 +26,7 @@ void AliITSDDLRawData(char* DigitsFile="galice.root"){
 #ifdef __NOCOMPILED__
   }
 #endif
-  // Connect the Root input  file containing Geometry, Kine and Hits
+  // Connect the Root input file containing Geometry, Kine and Hits
   // galice.root file by default
   char* filename="galice.root";
   // TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
@@ -71,6 +71,7 @@ void AliITSDDLRawData(char* DigitsFile="galice.root"){
   util->RawDataSPD(ITS,TD);
   timer.Stop();
   timer.Print();
+  //util->TestFormat();
     
   //SILICON DRIFT DETECTOR
   cout<<"Formatting data for SDD"<<endl;
index f0d35998fbd4538a37c9e4a8a53f28f8f9df684c..52de11212f8c39ac17e9c37b340600a65564b9f4 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 all the necessary methods to create the Raw Data
+//files (slides) for the ITS data challenges for:
+//SPD 
+//SDD
+//SSD
 
 #include <stdlib.h>
 #include "Riostream.h"
@@ -27,6 +34,7 @@ ClassImp(AliITSDDLRawData)
 
 ////////////////////////////////////////////////////////////////////////////////////////
 AliITSDDLRawData::AliITSDDLRawData(){
+  //Default constructor
   fIndex=-1;
   fHalfStaveModule=-1;
 }
@@ -34,7 +42,7 @@ AliITSDDLRawData::AliITSDDLRawData(){
 ////////////////////////////////////////////////////////////////////////////////////////
 
 AliITSDDLRawData::AliITSDDLRawData(const AliITSDDLRawData &source){
-  // Copy Constructor
+  //Copy Constructor
   this->fIndex=source.fIndex;
   this->fHalfStaveModule=source.fHalfStaveModule;
   return;
@@ -54,11 +62,12 @@ AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){
 //
 
 void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod, ULong_t *buf){
+  //This method packs the SSD digits in a proper 32 bits structure
   Int_t ix;
   Int_t iz;
   Int_t is;
-  ULong_t Word;
-  ULong_t BaseWord;
+  ULong_t word;
+  ULong_t baseWord;
   Int_t ndigits = ITSdigits->GetEntries();
   AliITSdigit *digs;
   if(ndigits){
@@ -68,17 +77,17 @@ void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod, ULong_t *
       ix=digs->fCoord2;  // Strip Numbar
       is=digs->fSignal;  // ADC Signal
       // cout<<" Module:"<<mod-500<<" N/P side:"<<iz<<" Strip Number:"<<ix<<" Amplidute:"<<is-1<<endl;
-      BaseWord=0;
-      Word=is-1;
-      PackWord(BaseWord,Word,0,9);//ADC data
-      Word=ix;
-      PackWord(BaseWord,Word,10,19);//Strip Number
-      Word=iz;      
-      PackWord(BaseWord,Word,20,20);//ADC Channel ID (N or P side)
-      Word=mod;
-      PackWord(BaseWord,Word,21,31);//ADC module ID
+      baseWord=0;
+      word=is-1;
+      PackWord(baseWord,word,0,9);//ADC data
+      word=ix;
+      PackWord(baseWord,word,10,19);//Strip Number
+      word=iz;      
+      PackWord(baseWord,word,20,20);//ADC Channel ID (N or P side)
+      word=mod;
+      PackWord(baseWord,word,21,31);//ADC module ID
       fIndex++;
-      buf[fIndex]=BaseWord;
+      buf[fIndex]=baseWord;
     }//end for
   }//end if
   return;
@@ -89,11 +98,12 @@ void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod, ULong_t *
 //
 
 void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod, ULong_t *buf){  
+  //This method packs the SSD digits in a proper 32 bits structure
   Int_t ix;
   Int_t iz;
   Int_t is;
-  ULong_t Word;
-  ULong_t BaseWord;
+  ULong_t word;
+  ULong_t baseWord;
   Int_t ndigits = ITSdigits->GetEntries();
   AliITSdigit *digs;
   if(ndigits){
@@ -105,31 +115,31 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod, ULong_t *
       is=digs->fSignal;  // ADC Signal
       //      cout<<"Amplitude value:"<<is<<" Time Bucket:"<<ix<<" Anode:"<<iz<<endl;
       if (is>255){cout<<"WARNING (!) bits words is needed)!!!\n";}
-      BaseWord=0;
+      baseWord=0;
       /*
       //10 bits words for amplitude value
-      Word=is;
-      PackWord(BaseWord,Word,0,9);//ADC data
-      Word=ix;
-      PackWord(BaseWord,Word,10,17);//Time bucket
-      Word=iz;
-      PackWord(BaseWord,Word,18,26);//Anode Number
-      Word=mod;
-      PackWord(BaseWord,Word,27,31);//Module number
+      word=is;
+      PackWord(baseWord,word,0,9);//ADC data
+      word=ix;
+      PackWord(baseWord,word,10,17);//Time bucket
+      word=iz;
+      PackWord(baseWord,word,18,26);//Anode Number
+      word=mod;
+      PackWord(baseWord,word,27,31);//Module number
       */
       
       //8bits words for amplitude value
-      Word=is;
-      PackWord(BaseWord,Word,0,7);//ADC data
-      Word=ix;
-      PackWord(BaseWord,Word,8,15);//Time bucket
-      Word=iz;
-      PackWord(BaseWord,Word,16,24);//Anode Number
-      Word=mod;
-      PackWord(BaseWord,Word,25,31);//Module number
+      word=is;
+      PackWord(baseWord,word,0,7);//ADC data
+      word=ix;
+      PackWord(baseWord,word,8,15);//Time bucket
+      word=iz;
+      PackWord(baseWord,word,16,24);//Anode Number
+      word=mod;
+      PackWord(baseWord,word,25,31);//Module number
      
       fIndex++;
-      buf[fIndex]=BaseWord;
+      buf[fIndex]=baseWord;
     }//end for
   }//end if
   return;
@@ -140,13 +150,14 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod, ULong_t *
 //
 
 void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod, ULong_t *buf){
+  //This method packs the SPD digits in a proper 32 strucure
   Int_t ix;
   Int_t iz;
-  Int_t ChipNo=0;
-  ULong_t BaseWord=0;
-  ULong_t HitRow=0;
-  Int_t ChipHitCount=0;  //Number of Hit in the current chip
-  Int_t PreviousChip=-1; //Previuos chip respect to the actual aone
+  Int_t chipNo=0;
+  ULong_t baseWord=0;
+  ULong_t hitRow=0;
+  Int_t chipHitCount=0;  //Number of Hit in the current chip
+  Int_t previousChip=-1; //Previuos chip respect to the actual aone
   Int_t ndigits = ITSdigits->GetEntries(); //number of digits in the current module
   //cout<<"      Number of digits in the current module:"<<ndigits<<" module:"<<mod<<endl;
   AliITSdigit *digs;
@@ -163,63 +174,63 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod, ULong_t *
        *     ---------------------------------------------------------------------*/
       iz=digs->fCoord1;  // Cell number in Z direction 
       ix=digs->fCoord2;  // Cell number in X direction
-      ChipNo=iz/32;
-      HitRow=iz-ChipNo*32;
+      chipNo=iz/32;
+      hitRow=iz-chipNo*32;
       if(fHalfStaveModule){
-       ChipNo+=5;
+       chipNo+=5;
        fHalfStaveModule=-1;
       }//end if
-      //cout<<"Chip number of the current digit:"<<ChipNo<<" Row:"<<HitRow<<" Column:"<<ix<<endl;
-      if(PreviousChip==-1){
+      //cout<<"Chip number of the current digit:"<<chipNo<<" Row:"<<hitRow<<" Column:"<<ix<<endl;
+      if(previousChip==-1){
        //loop over chip without digits 
        //Even if there aren't digits for a given chip 
        //the chip header and the chip trailer are stored
        for(Int_t i=0;i<(iz/32);i++){
-         if(ChipNo>4)
-           WriteChipHeader(i+5,(mod/2),BaseWord);
+         if(chipNo>4)
+           WriteChipHeader(i+5,(mod/2),baseWord);
          else
-           WriteChipHeader(i,(mod/2),BaseWord);
-         WriteChipTrailer(buf,ChipHitCount,BaseWord);
+           WriteChipHeader(i,(mod/2),baseWord);
+         WriteChipTrailer(buf,chipHitCount,baseWord);
        }//end for
-       PreviousChip=ChipNo;
-       WriteChipHeader(ChipNo,(mod/2),BaseWord);
-       ChipHitCount++;
-       WriteHit(buf,ix,HitRow,BaseWord);
+       previousChip=chipNo;
+       WriteChipHeader(chipNo,(mod/2),baseWord);
+       chipHitCount++;
+       WriteHit(buf,ix,hitRow,baseWord);
       }//end if
       else{
-       ChipHitCount++;
-       if(PreviousChip!=ChipNo){
-         WriteChipTrailer(buf,ChipHitCount-1,BaseWord);
-         for(Int_t i=PreviousChip+1;i<ChipNo;i++){
-           WriteChipHeader(i,(mod/2),BaseWord);
-           WriteChipTrailer(buf,0,BaseWord);
+       chipHitCount++;
+       if(previousChip!=chipNo){
+         WriteChipTrailer(buf,chipHitCount-1,baseWord);
+         for(Int_t i=previousChip+1;i<chipNo;i++){
+           WriteChipHeader(i,(mod/2),baseWord);
+           WriteChipTrailer(buf,0,baseWord);
          }//end for
-         WriteChipHeader(ChipNo,(mod/2),BaseWord);
-         PreviousChip=ChipNo;
+         WriteChipHeader(chipNo,(mod/2),baseWord);
+         previousChip=chipNo;
        }//end if
-       WriteHit(buf,ix,HitRow,BaseWord);
+       WriteHit(buf,ix,hitRow,baseWord);
       }//end else
     }//end for
     //Even if there aren't digits for a given chip 
     //the chip header and the chip trailer are stored
-    Int_t End=4;
-    if(ChipNo>4)End+=5;
-    WriteChipTrailer(buf,ChipHitCount,BaseWord);
-    for(Int_t i=ChipNo+1;i<=End;i++){
-      WriteChipHeader(i,(mod/2),BaseWord);
-      WriteChipTrailer(buf,0,BaseWord);
+    Int_t end=4;
+    if(chipNo>4)end+=5;
+    WriteChipTrailer(buf,chipHitCount,baseWord);
+    for(Int_t i=chipNo+1;i<=end;i++){
+      WriteChipHeader(i,(mod/2),baseWord);
+      WriteChipTrailer(buf,0,baseWord);
     }//end for
   }//end if
   else{
     //In this module there aren't digits but
     //the chip header and chip trailer are store anyway
     if(fHalfStaveModule){
-      ChipNo=5;
+      chipNo=5;
       fHalfStaveModule=-1;
     }//end if
     for(Int_t i=0;i<5;i++){
-      WriteChipHeader(ChipNo+i,(mod/2),BaseWord);
-      WriteChipTrailer(buf,ChipHitCount,BaseWord);
+      WriteChipHeader(chipNo+i,(mod/2),baseWord);
+      WriteChipTrailer(buf,chipHitCount,baseWord);
     }//end for
   }//end else 
   return;
@@ -228,40 +239,43 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod, ULong_t *
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void AliITSDDLRawData::PackWord(ULong_t &BaseWord, ULong_t Word, Int_t StartBit, Int_t StopBit){
-  ULong_t DummyWord,OffSet;
-  Int_t   Length;
-  ULong_t Sum;
+  //This method packs a word into the Baseword buffer starting form the "StartBit" 
+  //and tacking StopBit-StertBit+1 bits
+  ULong_t dummyWord,offSet;
+  Int_t   length;
+  ULong_t sum;
   //The BaseWord is being filled with 1 from StartBit to StopBit
-  Length=StopBit-StartBit+1;
-  Sum=(ULong_t)TMath::Power(2,Length)-1;
-  if(Word > Sum){
+  length=StopBit-StartBit+1;
+  sum=(ULong_t)TMath::Power(2,length)-1;
+  if(Word > sum){
     cout<<"WARNING::Word to be filled is not within desired length"<<endl;
     cout<<"Word:"<<Word<<" Start bit:"<<StartBit<<" Stop Bit:"<<StopBit<<endl;
     exit(-1);
   }
-  OffSet=Sum;
-  OffSet<<=StartBit;
-  BaseWord=BaseWord|OffSet;
+  offSet=sum;
+  offSet<<=StartBit;
+  BaseWord=BaseWord|offSet;
   //The Word to be filled is shifted to the position StartBit
   //and the remaining  Left and Right bits are filled with 1
-  Sum=(ULong_t)TMath::Power(2,StartBit)-1;
-  DummyWord=0xFFFFFFFF<<Length;
-  DummyWord +=Word;
-  DummyWord<<=StartBit;
-  DummyWord+=Sum;
-  BaseWord=BaseWord&DummyWord;
+  sum=(ULong_t)TMath::Power(2,StartBit)-1;
+  dummyWord=0xFFFFFFFF<<length;
+  dummyWord +=Word;
+  dummyWord<<=StartBit;
+  dummyWord+=sum;
+  BaseWord=BaseWord&dummyWord;
   return;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void AliITSDDLRawData::UnpackWord(ULong_t PackedWord, Int_t StartBit, Int_t StopBit, ULong_t &Word){   
-  ULong_t OffSet;
-  Int_t Length;
-  Length=StopBit-StartBit+1;
-  OffSet=(ULong_t)TMath::Power(2,Length)-1;
-  OffSet<<=StartBit;
-  Word=PackedWord&OffSet;
+  //This method unpacks a words of StopBit-StertBit+1 bits starting from "StopBits"  
+  ULong_t offSet;
+  Int_t length;
+  length=StopBit-StartBit+1;
+  offSet=(ULong_t)TMath::Power(2,length)-1;
+  offSet<<=StartBit;
+  Word=PackedWord&offSet;
   Word>>=StartBit;
   return;
 }
@@ -269,13 +283,13 @@ void AliITSDDLRawData::UnpackWord(ULong_t PackedWord, Int_t StartBit, Int_t Stop
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 Int_t AliITSDDLRawData::RawDataSPD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
-
+  //This method creates the Raw data files for SPD detectors
   //Silicon Pixel Detector
-  const Int_t DDLNumber=20;       // Number of DDL in SPD
-  const Int_t ModulePerDDL=12;    // Number of modules in each DDL 
+  const Int_t kDDLsNumber=20;       // Number of DDL in SPD
+  const Int_t kModulesPerDDL=12;    // Number of modules in each DDL 
   //Row    ==> DDLs
   //Column ==> Modules
-  Int_t SPDMap[DDLNumber][ModulePerDDL]={{ 0, 1, 4, 5, 80, 81, 84, 85, 88, 89, 92, 93},
+  Int_t mapSPD[kDDLsNumber][kModulesPerDDL]={{ 0, 1, 4, 5, 80, 81, 84, 85, 88, 89, 92, 93},
                                         { 2, 3, 6, 7, 82, 83, 86, 87, 90, 91, 94, 95},
                                         { 8, 9,12,13, 96, 97,100,101,104,105,108,109},
                                         {10,11,14,15, 98, 99,102,103,106,107,110,111},
@@ -295,50 +309,50 @@ Int_t AliITSDDLRawData::RawDataSPD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
                                         {66,67,70,71,210,211,214,215,218,219,222,223},
                                         {72,73,76,77,224,225,228,229,232,233,236,237},
                                         {74,75,78,79,226,227,230,231,234,235,238,239}};
-  Int_t DDLPerFile=DDLNumber/LDCsNumber;
-  if(DDLNumber%LDCsNumber)DDLPerFile++;
-  cout<<"Number of DDL per File: "<<DDLPerFile<<endl;
+  Int_t ddlsPerFile=kDDLsNumber/LDCsNumber;
+  if(kDDLsNumber%LDCsNumber)ddlsPerFile++;
+  cout<<"Number of DDL per File: "<<ddlsPerFile<<endl;
   Int_t subd=0;
-  Int_t CountDDL=0;
-  Int_t SliceNumber=1;
-  const Int_t size=21000; //256*32*5=40960 max number of digits per module
-  ULong_t buf[size];      //One buffer cell can contain 2 digits 
+  Int_t countDDL=0;
+  Int_t sliceNumber=1;
+  const Int_t kSize=21000; //256*32*5=40960 max number of digits per module
+  ULong_t buf[kSize];      //One buffer cell can contain 2 digits 
   fIndex=-1;
-  TClonesArray *ITSdigits  = ITS->DigitsAddress(subd);
+  TClonesArray *digitsInITS  = ITS->DigitsAddress(subd);
 
   Int_t nbytes = 0; 
   char fileName[15];
 
-  ULong_t MiniHeaderPosition=0; //variable used to store the position of the Mini Header inside a file
+  ULong_t miniHeaderPosition=0; //variable used to store the position of the Mini Header inside a file
   ofstream outfile;         // logical name of the output file 
-  Int_t Flag=0;             // 0==> Uncompressed data 1==>Compressed Data
-  Int_t Detector=1;         // 1==>ITS (Pixel) 2==>ITS (Drift) 3==>ITS (Strip) 0==>TPC ......
-  ULong_t Size=0;           // Size of the data block that follows the mini header
-  Int_t MagicWord=0x123456;  // Magic word used to distinguish between data and garbage
-  sprintf(fileName,"SPDslice%d",SliceNumber); //The name of  the output file. There are as many slides as the number of LDC
+  Int_t flag=0;             // 0==> Uncompressed data 1==>Compressed Data
+  Int_t detector=1;         // 1==>ITS (Pixel) 2==>ITS (Drift) 3==>ITS (Strip) 0==>TPC ......
+  ULong_t size=0;           // size of the data block that follows the mini header
+  Int_t magicWord=0x123456;  // Magic word used to distinguish between data and garbage
+  sprintf(fileName,"SPDslice%d",sliceNumber); //The name of  the output file. There are as many slides as the number of LDC
   outfile.open(fileName,ios::binary);
-  ULong_t MiniHeader[3];
-  Int_t MiniHeaderSize=sizeof(ULong_t)*3;
-  Int_t Version=1;          //Version of the mini header 
+  ULong_t miniHeader[3];
+  Int_t miniHeaderSize=sizeof(ULong_t)*3;
+  Int_t version=1;          //version of the mini header 
   //loop over DDLs
-  for(Int_t i=0;i<DDLNumber;i++){
-    CountDDL++;
+  for(Int_t i=0;i<kDDLsNumber;i++){
+    countDDL++;
     //write Dummy MINI HEADER
-    MiniHeader[0]=Size;
-    PackWord(MiniHeader[1],MagicWord,8,31);
-    PackWord(MiniHeader[1],Detector,0,7);
-    PackWord(MiniHeader[2],i,16,31);
-    PackWord(MiniHeader[2],Flag,8,15);
-    PackWord(MiniHeader[2],Version,0,7);
-    MiniHeaderPosition=outfile.tellp();
-    outfile.write((char*)(MiniHeader),MiniHeaderSize);
+    miniHeader[0]=size;
+    PackWord(miniHeader[1],magicWord,8,31);
+    PackWord(miniHeader[1],detector,0,7);
+    PackWord(miniHeader[2],i,16,31);
+    PackWord(miniHeader[2],flag,8,15);
+    PackWord(miniHeader[2],version,0,7);
+    miniHeaderPosition=outfile.tellp();
+    outfile.write((char*)(miniHeader),miniHeaderSize);
     //Loops over Modules of a particular DDL
-    for (Int_t mod=0; mod<ModulePerDDL; mod++){
+    for (Int_t mod=0; mod<kModulesPerDDL; mod++){
       ITS->ResetDigits();
-      nbytes += TD->GetEvent(SPDMap[i][mod]);
+      nbytes += TD->GetEvent(mapSPD[i][mod]);
       //For each Module, buf contains the array of data words in Binary format   
       //fIndex gives the number of 32 bits words in the buffer for each module
-      GetDigitsSPD(ITSdigits,SPDMap[i][mod],buf);
+      GetDigitsSPD(digitsInITS,mapSPD[i][mod],buf);
       outfile.write((char *)buf,((fIndex+1)*sizeof(ULong_t)));
       for(Int_t i=0;i<(fIndex+1);i++){
        buf[i]=0;
@@ -347,19 +361,19 @@ Int_t AliITSDDLRawData::RawDataSPD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
     }//end for
     
     //Write REAL MINI HEADER
-    ULong_t CurrentFilePosition=outfile.tellp();
-    outfile.seekp(MiniHeaderPosition);
-    Size=CurrentFilePosition-MiniHeaderPosition-MiniHeaderSize;
+    ULong_t currentFilePosition=outfile.tellp();
+    outfile.seekp(miniHeaderPosition);
+    size=currentFilePosition-miniHeaderPosition-miniHeaderSize;
     
-    outfile.write((char*)(&Size),sizeof(ULong_t));
-    outfile.seekp(CurrentFilePosition);
-    if(CountDDL==DDLPerFile){
+    outfile.write((char*)(&size),sizeof(ULong_t));
+    outfile.seekp(currentFilePosition);
+    if(countDDL==ddlsPerFile){
       outfile.close();
-      SliceNumber++;
-      sprintf(fileName,"SPDslice%d",SliceNumber); 
-      if(i!=(DDLNumber-1))
+      sliceNumber++;
+      sprintf(fileName,"SPDslice%d",sliceNumber); 
+      if(i!=(kDDLsNumber-1))
        outfile.open(fileName,ios::binary);
-      CountDDL=0;
+      countDDL=0;
     }//end if
   }//end for
   outfile.close();
@@ -369,13 +383,14 @@ Int_t AliITSDDLRawData::RawDataSPD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 Int_t AliITSDDLRawData::RawDataSSD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
+  //This method creates the Raw data files for SSD detectors
   //Strip detector
-  const Int_t DDLNumber=16;        // Number of DDL in SSD
-  const Int_t ModulePerDDL=109;    // Number of modules in each DDL 
+  const Int_t kDDLsNumber=16;        // Number of DDL in SSD
+  const Int_t kModulesPerDDL=109;    // Number of modules in each DDL 
   //DDL from 32 to 47 (16 DDL)
   //Row    ==> DDLs
   //Column ==> Modules
-  Int_t SSDMap[DDLNumber][ModulePerDDL]={
+  Int_t mapSSD[kDDLsNumber][kModulesPerDDL]={
     //104
     //DDL[32][]=
     { 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510,
@@ -554,52 +569,52 @@ Int_t AliITSDDLRawData::RawDataSSD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
      2085,2086,2087,2088,2089,2090,2091,2092,2093,2094,2095,2096,2097} };
 
 
-  Int_t DDLPerFile=DDLNumber/LDCsNumber;
-  if(20%LDCsNumber)DDLPerFile++;
-  cout<<"Number of DDL per File: "<<DDLPerFile<<endl;
+  Int_t ddlsPerFile=kDDLsNumber/LDCsNumber;
+  if(20%LDCsNumber)ddlsPerFile++;
+  cout<<"Number of DDL per File: "<<ddlsPerFile<<endl;
   Int_t subd=2;          //SSD
-  Int_t CountDDL=0;
-  Int_t SliceNumber=1;
-  const Int_t size=1536;//768*2 Number of stripe * number of sides(N and P)
-  ULong_t buf[size];      
+  Int_t countDDL=0;
+  Int_t sliceNumber=1;
+  const Int_t kSize=1536;//768*2 Number of stripe * number of sides(N and P)
+  ULong_t buf[kSize];      
   fIndex=-1;
   Int_t nbytes = 0; 
-  TClonesArray *ITSdigits  = ITS->DigitsAddress(subd);
+  TClonesArray *digitsInITS  = ITS->DigitsAddress(subd);
   char fileName[15];
 
-  ULong_t MiniHeaderPosition=0; //variable used to store the position of the Mini Header inside the file
+  ULong_t miniHeaderPosition=0; //variable used to store the position of the Mini Header inside the file
   ofstream outfile;             // logical name of the output file 
-  Int_t Flag=0;                 // 0==> Uncompressed data 1==>Compressed Data
-  Int_t Detector=3;             // 1==>ITS (Pixel) 2==>ITS (Drift) 3==>ITS (Strip) 0==>TPC ......
-  ULong_t Size=0;               // Size of the data block that follows the mini header
-  Int_t MagicWord=0x123456;     // Magic word used to distinguish between data and garbage
-  sprintf(fileName,"SSDslice%d",SliceNumber); //The name of  the output file. There are as many slides as the number of LDC
+  Int_t flag=0;                 // 0==> Uncompressed data 1==>Compressed Data
+  Int_t detector=3;             // 1==>ITS (Pixel) 2==>ITS (Drift) 3==>ITS (Strip) 0==>TPC ......
+  ULong_t size=0;               // size of the data block that follows the mini header
+  Int_t magicWord=0x123456;     // Magic word used to distinguish between data and garbage
+  sprintf(fileName,"SSDslice%d",sliceNumber); //The name of  the output file. There are as many slides as the number of LDC
   outfile.open(fileName,ios::binary);
-  ULong_t MiniHeader[3];
-  Int_t MiniHeaderSize=sizeof(ULong_t)*3;
-  Int_t Version=1;              //Version of the mini header 
+  ULong_t miniHeader[3];
+  Int_t miniHeaderSize=sizeof(ULong_t)*3;
+  Int_t version=1;              //version of the mini header 
   //loop over DDLs
   
-  for(Int_t i=0;i<DDLNumber;i++){
-    CountDDL++;
+  for(Int_t i=0;i<kDDLsNumber;i++){
+    countDDL++;
     //write Dummy MINI HEADER
-    MiniHeader[0]=Size;
-    PackWord(MiniHeader[1],MagicWord,8,31);
-    PackWord(MiniHeader[1],Detector,0,7);
-    PackWord(MiniHeader[2],i,16,31);
-    PackWord(MiniHeader[2],Flag,8,15);
-    PackWord(MiniHeader[2],Version,0,7);
-    MiniHeaderPosition=outfile.tellp();
-    outfile.write((char*)(MiniHeader),MiniHeaderSize);
+    miniHeader[0]=size;
+    PackWord(miniHeader[1],magicWord,8,31);
+    PackWord(miniHeader[1],detector,0,7);
+    PackWord(miniHeader[2],i,16,31);
+    PackWord(miniHeader[2],flag,8,15);
+    PackWord(miniHeader[2],version,0,7);
+    miniHeaderPosition=outfile.tellp();
+    outfile.write((char*)(miniHeader),miniHeaderSize);
     
     //Loops over Modules of a particular DDL
-    for (Int_t mod=0; mod<ModulePerDDL; mod++){
-      if(SSDMap[i][mod]!=-1){
+    for (Int_t mod=0; mod<kModulesPerDDL; mod++){
+      if(mapSSD[i][mod]!=-1){
        ITS->ResetDigits();
-       nbytes += TD->GetEvent(SSDMap[i][mod]);
+       nbytes += TD->GetEvent(mapSSD[i][mod]);
        //For each Module, buf contains the array of data words in Binary format          
        //fIndex gives the number of 32 bits words in the buffer for each module
-       GetDigitsSSD(ITSdigits,mod,buf);
+       GetDigitsSSD(digitsInITS,mod,buf);
        outfile.write((char *)buf,((fIndex+1)*sizeof(ULong_t)));
        for(Int_t i=0;i<(fIndex+1);i++){
          buf[i]=0;
@@ -608,19 +623,19 @@ Int_t AliITSDDLRawData::RawDataSSD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
       }//end if
     }//end for
     //Write REAL MINI HEADER
-    ULong_t CurrentFilePosition=outfile.tellp();
-    outfile.seekp(MiniHeaderPosition);
-    Size=CurrentFilePosition-MiniHeaderPosition-MiniHeaderSize;
+    ULong_t currentFilePosition=outfile.tellp();
+    outfile.seekp(miniHeaderPosition);
+    size=currentFilePosition-miniHeaderPosition-miniHeaderSize;
     
-    outfile.write((char*)(&Size),sizeof(ULong_t));
-    outfile.seekp(CurrentFilePosition);
-    if(CountDDL==DDLPerFile){
+    outfile.write((char*)(&size),sizeof(ULong_t));
+    outfile.seekp(currentFilePosition);
+    if(countDDL==ddlsPerFile){
       outfile.close();
-      SliceNumber++;
-      sprintf(fileName,"SSDslice%d",SliceNumber); 
-      if(i!=(DDLNumber-1))
+      sliceNumber++;
+      sprintf(fileName,"SSDslice%d",sliceNumber); 
+      if(i!=(kDDLsNumber-1))
        outfile.open(fileName,ios::binary);
-      CountDDL=0;
+      countDDL=0;
     }//end if
   }//end for
   outfile.close();
@@ -630,12 +645,13 @@ Int_t AliITSDDLRawData::RawDataSSD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 Int_t AliITSDDLRawData::RawDataSDD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
-  //Silicon Drift Detector
-  const Int_t DDLNumber=12;       // Number of DDL in SPD
-  const Int_t ModulePerDDL=22;    // Number of modules in each DDL 
+    //This method creates the Raw data files for SDD detectors
+  //Silicon Drift detector
+  const Int_t kDDLsNumber=12;       // Number of DDL in SPD
+  const Int_t kModulesPerDDL=22;    // Number of modules in each DDL 
   //Row    ==> DDLs
   //Column ==> Modules  
-  Int_t SDDMap[DDLNumber][ModulePerDDL]= {{240,241,242,246,247,248,252,253,254,258,259,260,264,265,266,270,271,272,276,277,278,-1},
+  Int_t mapSDD[kDDLsNumber][kModulesPerDDL]= {{240,241,242,246,247,248,252,253,254,258,259,260,264,265,266,270,271,272,276,277,278,-1},
                                          {243,244,245,249,250,251,255,256,257,261,262,263,267,268,269,273,274,275,279,280,281,-1},
                                          {282,283,284,288,289,290,294,295,296,300,301,302,306,307,308,312,313,314,318,319,320,-1},
                                          {285,286,287,291,292,293,297,298,299,303,304,305,309,310,311,315,316,317,321,322,323,-1},
@@ -648,51 +664,51 @@ Int_t AliITSDDLRawData::RawDataSDD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
                                          {454,455,460,461,462,463,468,469,470,471,476,477,478,479,484,485,486,487,492,493,494,495},
                                          {458,459,464,465,466,467,472,473,474,475,480,481,482,483,488,489,490,491,496,497,498,499}};
   
-  Int_t DDLPerFile=DDLNumber/LDCsNumber;
-  if(DDLNumber%LDCsNumber)DDLPerFile++;
-  cout<<"Number of DDL per File: "<<DDLPerFile<<endl;
+  Int_t ddlsPerFile=kDDLsNumber/LDCsNumber;
+  if(kDDLsNumber%LDCsNumber)ddlsPerFile++;
+  cout<<"Number of DDL per File: "<<ddlsPerFile<<endl;
   Int_t subd=1;
-  Int_t CountDDL=0;
-  Int_t SliceNumber=1;
-  const Int_t size=131072; //256*512
-  ULong_t buf[size];      
+  Int_t countDDL=0;
+  Int_t sliceNumber=1;
+  const Int_t kSize=131072; //256*512
+  ULong_t buf[kSize];      
   fIndex=-1;
   Int_t nbytes = 0; 
-  TClonesArray *ITSdigits  = ITS->DigitsAddress(subd);
+  TClonesArray *digitsInITS  = ITS->DigitsAddress(subd);
   char fileName[15];
 
-  ULong_t MiniHeaderPosition=0; // variable used to store the position of the Mini Header inside a file
+  ULong_t miniHeaderPosition=0; // variable used to store the position of the Mini Header inside a file
   ofstream outfile;             // logical name of the output file 
-  Int_t Flag=0;                 // 0==> Uncompressed data 1==>Compressed Data
-  Int_t Detector=2;             // 1==>ITS (Pixel) 2==>ITS (Drift) 3==>ITS (Strip) 0==>TPC ......
-  ULong_t Size=0;               // Size of the data block that follows the mini header
-  Int_t MagicWord=0x123456;     // Magic word used to distinguish between data and garbage
-  sprintf(fileName,"SDDslice%d",SliceNumber); //The name of  the output file. There are as many slides as the number of LDC
+  Int_t flag=0;                 // 0==> Uncompressed data 1==>Compressed Data
+  Int_t detector=2;             // 1==>ITS (Pixel) 2==>ITS (Drift) 3==>ITS (Strip) 0==>TPC ......
+  ULong_t size=0;               // size of the data block that follows the mini header
+  Int_t magicWord=0x123456;     // Magic word used to distinguish between data and garbage
+  sprintf(fileName,"SDDslice%d",sliceNumber); //The name of  the output file. There are as many slides as the number of LDC
   outfile.open(fileName,ios::binary);
-  ULong_t MiniHeader[3];
-  Int_t MiniHeaderSize=sizeof(ULong_t)*3;
-  Int_t Version=1;             //Version of the mini header 
+  ULong_t miniHeader[3];
+  Int_t miniHeaderSize=sizeof(ULong_t)*3;
+  Int_t version=1;             //version of the mini header 
   //loop over DDLs
-  for(Int_t i=0;i<DDLNumber;i++){
-    CountDDL++;
+  for(Int_t i=0;i<kDDLsNumber;i++){
+    countDDL++;
     //write Dummy MINI HEADER
-    MiniHeader[0]=Size;
-    PackWord(MiniHeader[1],MagicWord,8,31);
-    PackWord(MiniHeader[1],Detector,0,7);
-    PackWord(MiniHeader[2],i,16,31);
-    PackWord(MiniHeader[2],Flag,8,15);
-    PackWord(MiniHeader[2],Version,0,7);
-    MiniHeaderPosition=outfile.tellp();
-    outfile.write((char*)(MiniHeader),MiniHeaderSize);
+    miniHeader[0]=size;
+    PackWord(miniHeader[1],magicWord,8,31);
+    PackWord(miniHeader[1],detector,0,7);
+    PackWord(miniHeader[2],i,16,31);
+    PackWord(miniHeader[2],flag,8,15);
+    PackWord(miniHeader[2],version,0,7);
+    miniHeaderPosition=outfile.tellp();
+    outfile.write((char*)(miniHeader),miniHeaderSize);
     //Loops over Modules of a particular DDL
-    for (Int_t mod=0; mod<ModulePerDDL; mod++){
-      if(SDDMap[i][mod]!=-1){
+    for (Int_t mod=0; mod<kModulesPerDDL; mod++){
+      if(mapSDD[i][mod]!=-1){
        ITS->ResetDigits();
-       nbytes += TD->GetEvent(SDDMap[i][mod]);
+       nbytes += TD->GetEvent(mapSDD[i][mod]);
        //For each Module, buf contains the array of data words in Binary format          
        //fIndex gives the number of 32 bits words in the buffer for each module
-       //      cout<<"MODULE NUMBER:"<<SDDMap[i][mod]<<endl;
-       GetDigitsSDD(ITSdigits,mod,buf);
+       //      cout<<"MODULE NUMBER:"<<mapSDD[i][mod]<<endl;
+       GetDigitsSDD(digitsInITS,mod,buf);
        outfile.write((char *)buf,((fIndex+1)*sizeof(ULong_t)));
        for(Int_t i=0;i<(fIndex+1);i++){
          buf[i]=0;
@@ -702,19 +718,19 @@ Int_t AliITSDDLRawData::RawDataSDD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
     }//end for
     
     //Write REAL MINI HEADER
-    ULong_t CurrentFilePosition=outfile.tellp();
-    outfile.seekp(MiniHeaderPosition);
-    Size=CurrentFilePosition-MiniHeaderPosition-MiniHeaderSize;
+    ULong_t currentFilePosition=outfile.tellp();
+    outfile.seekp(miniHeaderPosition);
+    size=currentFilePosition-miniHeaderPosition-miniHeaderSize;
     
-    outfile.write((char*)(&Size),sizeof(ULong_t));
-    outfile.seekp(CurrentFilePosition);
-    if(CountDDL==DDLPerFile){
+    outfile.write((char*)(&size),sizeof(ULong_t));
+    outfile.seekp(currentFilePosition);
+    if(countDDL==ddlsPerFile){
       outfile.close();
-      SliceNumber++;
-      sprintf(fileName,"SDDslice%d",SliceNumber); 
-      if(i!=(DDLNumber-1))
+      sliceNumber++;
+      sprintf(fileName,"SDDslice%d",sliceNumber); 
+      if(i!=(kDDLsNumber-1))
        outfile.open(fileName,ios::binary);
-      CountDDL=0;
+      countDDL=0;
     }//end if
   }//end for
   outfile.close();
@@ -724,6 +740,7 @@ Int_t AliITSDDLRawData::RawDataSDD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void AliITSDDLRawData::WriteChipHeader(Int_t ChipAddr,Int_t EventCnt,ULong_t &BaseWord){
+  //This method writes a chip header 
   //cout<<"Chip: "<<ChipAddr<<" Half Stave module:"<<EventCnt<<endl;
   BaseWord=0;
   PackWord(BaseWord,ChipAddr,0,3);
@@ -736,6 +753,7 @@ void AliITSDDLRawData::WriteChipHeader(Int_t ChipAddr,Int_t EventCnt,ULong_t &Ba
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void AliITSDDLRawData::ReadChipHeader(Int_t &ChipAddr,Int_t &EventCnt,ULong_t BaseWord){
+  //This method reads a chip header
   ULong_t temp=0;
   UnpackWord(BaseWord,0,3,temp);
   ChipAddr=(Int_t)temp;
@@ -748,6 +766,7 @@ void AliITSDDLRawData::ReadChipHeader(Int_t &ChipAddr,Int_t &EventCnt,ULong_t Ba
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void  AliITSDDLRawData::WriteChipTrailer(ULong_t *buf,Int_t ChipHitCount,ULong_t &BaseWord){
+  //This method writes a chip trailer
   //pixel fill word
   if((ChipHitCount%2)!=0){
     PackWord(BaseWord,0xFECD,0,15);
@@ -763,6 +782,7 @@ void  AliITSDDLRawData::WriteChipTrailer(ULong_t *buf,Int_t ChipHitCount,ULong_t
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void  AliITSDDLRawData::ReadChipTrailer(Int_t &ChipHitCount,ULong_t BaseWord){
+  //This method reads a chip trailer
   ULong_t temp=0;
   UnpackWord(BaseWord,16,28,temp);
   ChipHitCount=(Int_t)temp;
@@ -772,6 +792,7 @@ void  AliITSDDLRawData::ReadChipTrailer(Int_t &ChipHitCount,ULong_t BaseWord){
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void  AliITSDDLRawData::WriteHit(ULong_t *buf,Int_t RowAddr,Int_t HitAddr,ULong_t &BaseWord){
+  //This method writs an hit
   if(!BaseWord){
     PackWord(BaseWord,HitAddr,0,4);
     PackWord(BaseWord,RowAddr,5,12);
@@ -791,58 +812,60 @@ void  AliITSDDLRawData::WriteHit(ULong_t *buf,Int_t RowAddr,Int_t HitAddr,ULong_
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void AliITSDDLRawData::TestFormat(){
+  //This method generates a text file containing SPD information
+  //Used for debugging
   ifstream f;
-  Int_t  LDCsNumber=2;
+  Int_t  ldcsNumber=2;
   ofstream ftxt("File2.txt");
-  ULong_t Size=0;
+  ULong_t size=0;
   char filename[15];
-  ULong_t DDLNumber=0;
-  ULong_t MiniHeader[3];
-  Int_t MiniHeaderSize=sizeof(ULong_t)*3;
-  for(Int_t i=1;i<=LDCsNumber;i++){
+  ULong_t ddlsNumber=0;
+  ULong_t miniHeader[3];
+  Int_t miniHeaderSize=sizeof(ULong_t)*3;
+  for(Int_t i=1;i<=ldcsNumber;i++){
     sprintf(filename,"SPDslice%d",i);  
     f.open(filename,ios::binary|ios::in);
     if(!f){exit(1);}
     //loop over the DDL block 
     //here the Mini Header is read
-    while( f.read((char*)(MiniHeader),MiniHeaderSize)){
-      //cout<<"Block Size: "<<Size<<endl;
-      Size=MiniHeader[0];
-      UnpackWord(MiniHeader[2],16,31,DDLNumber);
-      ftxt<<"DDL NUMBER:"<<DDLNumber<<endl;
-      ULong_t Word=0;
-      ULong_t Code=0;
-      ULong_t Decoded1,Decoded2=0;
-      for(ULong_t j=0;j<(Size/4);j++){
-       f.read((char*)(&Word),sizeof(Word)); //32 bits word
-       Code=0;
-       UnpackWord(Word,14,15,Code);
-       DecodeWord(Code,Word,0,Decoded1,Decoded2);
-       switch (Code){
+    while( f.read((char*)(miniHeader),miniHeaderSize)){
+      //cout<<"Block Size: "<<size<<endl;
+      size=miniHeader[0];
+      UnpackWord(miniHeader[2],16,31,ddlsNumber);
+      ftxt<<"DDL NUMBER:"<<ddlsNumber<<endl;
+      ULong_t word=0;
+      ULong_t code=0;
+      ULong_t decoded1,decoded2=0;
+      for(ULong_t j=0;j<(size/4);j++){
+       f.read((char*)(&word),sizeof(word)); //32 bits word
+       code=0;
+       UnpackWord(word,14,15,code);
+       DecodeWord(code,word,0,decoded1,decoded2);
+       switch (code){
        case 0://trailer
-         ftxt<<"Number of Hit:"<<Decoded1<<endl;
+         ftxt<<"Number of Hit:"<<decoded1<<endl;
          break;
        case 1://header
-         ftxt<<"Half Stave Number:"<<Decoded1<<" Chip Number:"<<Decoded2<<endl;
+         ftxt<<"Half Stave Number:"<<decoded1<<" Chip Number:"<<decoded2<<endl;
          break;
        case 2://hit
-         ftxt<<"Row:"<<Decoded1<<" Column:"<<Decoded2<<endl;
+         ftxt<<"Row:"<<decoded1<<" Column:"<<decoded2<<endl;
          break;
        case 3://fill word
          break;
        }//end switch
-       Code=0;
-       UnpackWord(Word,30,31,Code);
-       DecodeWord(Code,Word,1,Decoded1,Decoded2);
-       switch (Code){
+       code=0;
+       UnpackWord(word,30,31,code);
+       DecodeWord(code,word,1,decoded1,decoded2);
+       switch (code){
        case 0://trailer
-         ftxt<<"Number of Hit:"<<Decoded1<<endl;
+         ftxt<<"Number of Hit:"<<decoded1<<endl;
          break;
        case 1://header
-         ftxt<<"Half Stave Number:"<<Decoded1<<" Chip Number:"<<Decoded2<<endl;
+         ftxt<<"Half Stave Number:"<<decoded1<<" Chip Number:"<<decoded2<<endl;
          break;
        case 2://hit
-         ftxt<<"Row:"<<Decoded1<<" Column:"<<Decoded2<<endl;
+         ftxt<<"Row:"<<decoded1<<" Column:"<<decoded2<<endl;
          break;
        case 3://fill word
          break;
index baeabb65d80cdbaf4ef910191fe78a0f06c59143..b377c8d8ff14cba272972db8e2b0d044c57d6669 100644 (file)
@@ -1,9 +1,9 @@
 /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/////////////////////////////////////////////////////////////////////////////////////////
-// Class used for generating the files containung data, required by the Data Challenge //
-/////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////
+// Class used for generating the files containing raw data, required for  Data Challenge //
+///////////////////////////////////////////////////////////////////////////////////////////
 
 #ifndef AliITSDDLRAWDATA_H
 #define AliITSDDLRAWDATA_H
@@ -17,38 +17,39 @@ class AliITSDDLRawData:public TObject{
   virtual ~AliITSDDLRawData(){;}//destructor
   AliITSDDLRawData(const AliITSDDLRawData &source); // copy constructor
   AliITSDDLRawData& operator=(const AliITSDDLRawData &source); // ass. op.
+ Int_t RawDataSPD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber=2);
   // This method generates the files with the Silicon pixel detector data
-  Int_t RawDataSPD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber=2);
+  Int_t RawDataSDD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber=4); 
   // This method generates the files with the Silicon drift detector data
-  Int_t RawDataSDD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber=4);
-  // This method generates the files with the Silicon pixel detector data
   Int_t RawDataSSD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber=2);
-  //A debugging method used to test the files generated for the SPD.
+  // This method generates the files with the Silicon pixel detector data
   void  TestFormat();
+  //A debugging method used to test the files generated for the SPD.
  private: 
-  //This method formats and stores in buf all the digits of a SPD module
   void  GetDigitsSPD(TClonesArray *ITSdigits, Int_t mod, ULong_t *buf);
-  //This method formats and stores in buf all the digits of a SDD module
+  //This method formats and stores in buf all the digits of a SPD module
   void  GetDigitsSDD(TClonesArray *ITSdigits, Int_t mod, ULong_t *buf);
-  //This method formats and stores in buf all the digits of a SSD module
+  //This method formats and stores in buf all the digits of a SDD module
   void  GetDigitsSSD(TClonesArray *ITSdigits, Int_t mod, ULong_t *buf);
+  //This method formats and stores in buf all the digits of a SSD module
+  void  PackWord(ULong_t &BaseWord, ULong_t Word, Int_t StartBit, Int_t StopBit);
   //This method stores the value of the variable Word of StopBit-StartBit+1 bits 
   //in BaseWord, starting from the bit StartBit
-  void  PackWord(ULong_t &BaseWord, ULong_t Word, Int_t StartBit, Int_t StopBit);
-  //This method extracts a group of adiacents bits, specified by StartBit and StopBit, 
-  //from the word PackedWord. The resulting word is saved in the Word variable
   void  UnpackWord(ULong_t PackedWord, Int_t StartBit, Int_t StopBit, ULong_t &Word);
-  //The following three methods are used to store the data according to the 
-  //Silicon pixel detector data format
+  //This method extracts a group of adjacent bits, specified by StartBit and StopBit, 
+  //from the word PackedWord. The resulting word is saved in the Word variable
   void  WriteChipHeader(Int_t ChipAddr,Int_t EventCnt,ULong_t &BaseWord);
   void  WriteChipTrailer(ULong_t *buf,Int_t ChipHitCount,ULong_t &BaseWord);
   void  WriteHit(ULong_t *buf,Int_t RowAddr,Int_t HitAddr,ULong_t &BaseWord);
-  //Methods used for reading and dubugging SPD data files
+  //The three previous  methods are used to store the data according to the 
+  //Silicon pixel detector data format
   void  ReadChipHeader(Int_t &ChipAddr,Int_t &EventCnt,ULong_t BaseWord);
   void  ReadChipTrailer(Int_t &ChipHitCount,ULong_t BaseWord);
   void  DecodeWord(ULong_t Code,ULong_t BaseWord,Int_t FirstHalf,ULong_t &Decoded1,ULong_t &Decoded2);
-  Int_t fIndex;
-  Int_t fHalfStaveModule;
+  //Methods used for reading and dubugging SPD data files
+
+  Long_t fIndex;             //number of 32 words to be stored into the output file
+  Int_t fHalfStaveModule;     //first or second half of an Half Stave module
   ClassDef(AliITSDDLRawData,1)
 };
     
index 4f3c6bd4513efd03e458103a69e30846b97e3242..6ede116790afd3b60a9838ee9494730f6a99e04f 100644 (file)
@@ -6,10 +6,10 @@
 
 int AliTPCAltro(char* FileName,Int_t eth=0){
   //eth is a threshold.
-  //Digits stored into a file have an amplitude value greater than eth
+  //Digits stored into a file have an amplitude value greater than "eth"
   Int_t offset=1; //this should be equal to the threshold
   /*
-    NB the amplitude values strored in the ALTRO file are shifted  by offset 
+    NB the amplitude values stored in the ALTRO file are shifted  by offset 
     because the range for each word goes from 0 to 1023, now due to zero suppression 
     values lower that the threshold never appear.
    */
index 090ddbed36c5eb8dcab6e39bbc0bf1b186092bd4..117cb60362a53674eff025a6f8d2ddacecf70b51 100644 (file)
@@ -31,9 +31,7 @@
 ClassImp(AliTPCBuffer)
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCBuffer::AliTPCBuffer(const char* fileName){
-  //
   // Constructor
-  //
   f.open("AliTPCDDL.dat",ios::binary|ios::out);
   // fout=new TFile(fileName,"recreate");
   // tree=new TTree("tree","Values");
@@ -51,11 +49,13 @@ AliTPCBuffer::~AliTPCBuffer(){
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source){
   // Copy Constructor
+  this->fVerbose=source.fVerbose;
   return;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 AliTPCBuffer& AliTPCBuffer::operator=(const AliTPCBuffer &source){
   //Assigment operator
+  this->fVerbose=source.fVerbose;
   return *this;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -109,9 +109,11 @@ void AliTPCBuffer::WriteRow(Int_t eth,AliSimDigits *digrow,Int_t minPad,Int_t ma
 */
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void AliTPCBuffer::WriteRowBinary(Int_t eth,AliSimDigits *digrow,Int_t minPad,Int_t maxPad,Int_t flag,Int_t sec,Int_t SubSec,Int_t row){
-  //flag=0 the whole row is written intto the file
+  //It writes TPC digits as par the flag specifications. Being called by AliTPCDDL.C
+  //flag=0 the whole row is written into the file
   //flag=1 only value in the range [minPad,MaxPasd] are written into the file
   //flag=2 complementary case of 1
+
   struct DataPad{
     Int_t Sec;
     Int_t SubSec;
index eb7869534afadf67dcdf23936a91f3ddba2b58e2..28d242f90c56d5276053971b84c46d5dda9a3e6f 100644 (file)
@@ -3,9 +3,9 @@
 /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/////////////////////////////////////////////////////
-// Class used for                                  //
-/////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+// Class used for storing TPC digits according to the DDLs format//
+//////////////////////////////////////////////////////////////////
 
 #ifdef __CINT__
 class fstream;
index 6620e60ca08acd9039af0c497366127c9cbce209..5e2aa1fed76155c4befc6ec4083d68dd08a71c89 100644 (file)
@@ -17,7 +17,7 @@
 
 // Interface to the Altro format
 // to read and write digits
-// To be used in Alice Data Challenges
+// To be used in Alice Data Challenges 
 // and in the compression of the RAW data
 // Author: D.Favretto
 
@@ -61,7 +61,7 @@ AliTPCBuffer160::AliTPCBuffer160(const char* fileName,Int_t flag){
 AliTPCBuffer160::~AliTPCBuffer160(){
   // destructor
   if (fFlag){
-    //Last Buffer filled couldn't be full
+    //Flush out the Buffer content at the end only if Buffer wasn't completely filled
     Flush();
     if(fVerbose)
       cout<<"File Created\n";
@@ -101,6 +101,8 @@ AliTPCBuffer160& AliTPCBuffer160::operator=(const AliTPCBuffer160 &source){
 }
 
 Int_t AliTPCBuffer160::GetNext(){
+  //It reads a 10 bits word in forward dicection from the Buffer.
+  //A new Buffer is read from the file only when Buffer is empty.
   //If there aren't elements anymore -1 is returned otherwise 
   //the next element is returned
   ULong_t mask=0xFFC00000;
@@ -140,6 +142,8 @@ Int_t AliTPCBuffer160::GetNext(){
 }
 
 Int_t AliTPCBuffer160::GetNextBackWord(){
+  //It reads a 10 bits word in backward dicection from the Buffer.
+  //A new Buffer is read from the file only when Buffer is empty.
   //If there aren't elements anymore -1 is returned otherwise 
   //the next element is returned
   ULong_t mask=0x3FF;
@@ -181,7 +185,7 @@ Int_t AliTPCBuffer160::GetNextBackWord(){
 }
 
 void AliTPCBuffer160::Flush(){
-  // Flushes the internal buffer
+  // Flushes the Buffer content 
   if(fFreeCellBuffer!=16){
     Int_t temp=fFreeCellBuffer;
     for(Int_t i=0;i<temp;i++){
@@ -191,7 +195,7 @@ void AliTPCBuffer160::Flush(){
 }
 
 void AliTPCBuffer160::FillBuffer(Int_t Val){
-  //each value takes 10 bits
+  //Fills the Buffer with 16 ten bits words and write into a file 
   fFreeCellBuffer--;
   if (fShift<10){
     Int_t temp=Val;
@@ -225,6 +229,7 @@ void AliTPCBuffer160::FillBuffer(Int_t Val){
 }
 
 void   AliTPCBuffer160::WriteTrailer(Int_t WordsNumber,Int_t PadNumber,Int_t RowNumber,Int_t SecNumber){
+  //Writes a trailer of 40 bits
   Int_t num=fFreeCellBuffer%4;
   for(Int_t i=0;i<num;i++){
     FillBuffer(0x2AA);
@@ -236,6 +241,7 @@ void   AliTPCBuffer160::WriteTrailer(Int_t WordsNumber,Int_t PadNumber,Int_t Row
 }
 
 void AliTPCBuffer160::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber){
+  //Read a trailer of 40 bits in the forward reading mode
   WordsNumber=GetNext();
   PadNumber=GetNext();
   RowNumber=GetNext();
@@ -244,6 +250,7 @@ void AliTPCBuffer160::ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &Row
 
 
 Int_t AliTPCBuffer160::ReadTrailerBackward(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber){
+  //Read a trailer of 40 bits in the backward reading mode
   Int_t temp;
   fEndingFillWords=0;
   do{
@@ -260,7 +267,7 @@ Int_t AliTPCBuffer160::ReadTrailerBackward(Int_t &WordsNumber,Int_t &PadNumber,I
 } 
 
 void AliTPCBuffer160::WriteMiniHeader(ULong_t Size,Int_t SecNumber,Int_t SubSector,Int_t Detector,Int_t Flag ){
-  //size msg errore sector number sub-sector number 0 for TPC 0 for uncompressed
+  //Size msg errore sector number sub-sector number 0 for TPC 0 for uncompressed
   Int_t ddlNumber;
   ULong_t miniHeader[3];
   Int_t version=1;
@@ -300,6 +307,7 @@ void AliTPCBuffer160::WriteMiniHeader(ULong_t Size,Int_t SecNumber,Int_t SubSect
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void AliTPCBuffer160::PackWord(ULong_t &BaseWord, ULong_t Word, Int_t StartBit, Int_t StopBit){
+  //Packs a word into the BaseWord buffer from StartBit bit up to StopBit bit
   ULong_t dummyWord,offSet;
   Int_t   length;
   ULong_t sum;
@@ -327,6 +335,8 @@ void AliTPCBuffer160::PackWord(ULong_t &BaseWord, ULong_t Word, Int_t StartBit,
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void AliTPCBuffer160::UnpackWord(ULong_t PackedWord, Int_t StartBit, Int_t StopBit, ULong_t &Word){    
+  //Unpacks a word of StopBit-StartBit+1 bits from PackedWord buffer starting from the position 
+  //indicated by StartBit
   ULong_t offSet;
   Int_t length;
   length=StopBit-StartBit+1;
index a6457b3c5c724c7f172d287c3081422991c8f8f3..0768ecc7bc045c8515a2de72219610f660c6048b 100644 (file)
@@ -25,41 +25,41 @@ public:
   AliTPCBuffer160(const AliTPCBuffer160 &source); // copy constructor
   AliTPCBuffer160& operator=(const AliTPCBuffer160 &source); // ass. op.
   void  FillBuffer(Int_t Val);
-  //this method returmn the number of free cells of the internal buffer
+  //this method store a word into the buffer
   Int_t GetFreeCellNumber()const{return fFreeCellBuffer;}
-  //this method return the next word of 10 bit (reading the file backward) if it exists -1 otherwise
+  //this method return the number of free cells of the internal buffer
   Int_t GetNextBackWord();
-  //this method return the next word of 10 bit (reading the file forward) if it exists -1 otherwise
+  //this method return the next word of 10 bit (reading the file backward) if it exists -1 otherwise
   Int_t GetNext();
-  //this method is used to write tha trailer
+  //this method return the next word of 10 bit (reading the file forward) if it exists -1 otherwise
   void  WriteTrailer(Int_t WordsNumber,Int_t PadNumber,Int_t RowNumber,Int_t SecNumber);
-  //this method is used to read the trailer when the file is read forward
+  //this method is used to write the trailer
   void  ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber);
-  //this method is used to read the trailer when the file is read backward
+  //this method is used to read the trailer when the file is read forward
   Int_t ReadTrailerBackward(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber);
-  //this methos is used to write the Mini header
+  //this method is used to read the trailer when the file is read backward
   void  WriteMiniHeader(ULong_t Size,Int_t SecNumber,Int_t SubSector,Int_t Detector,Int_t Flag );
-  //this methos is used to set the verbose level 
+  //this method is used to write the Mini header
+  void  SetVerbose(Int_t val){fVerbose=val;}
+  //this method is used to set the verbose level 
   //level  0 no output messages
   //level !=0 some messages are displayed during the run
-  void  SetVerbose(Int_t val){fVerbose=val;}
-  //this method is used to fill the buffer with 2AA hexadecimal value and save it into the output file
   void  Flush();
-  Int_t GetFillWordsNum(){return fEndingFillWords;}
+  //this method is used to fill the buffer with 2AA hexadecimal value and save it into the output file
+  Int_t GetFillWordsNum()const{return fEndingFillWords;}
 private:
-  //this method is used to pack bits into a word of 32 bits
   void  PackWord(ULong_t &BaseWord, ULong_t Word, Int_t StartBit, Int_t StopBit);
-  //this method is used to read a precise number of bits from a word of 32 bits
+  //this method is used to pack bits into a word of 32 bits
   void  UnpackWord(ULong_t PackedWord, Int_t StartBit, Int_t StopBit, ULong_t &Word);
-
+  //this method is used to read a precise number of bits from a word of 32 bits
   ULong_t fBuffer[5];   //Buffer dimension is 32*5=160 bits and it contains 16 values
                         //A value is never splitted in two Buffer
 
 
-  Int_t fShift;         //This variable contains the number of free bits in the current cel of
+  Int_t fShift;         //This variable contains the number of free bits in the current cell of
                         //the Buffer after that the value Val is been inserted.
                         //size of Int_t is 32 bit that is the same size of a cell of Buffer so 
-                        //the shift operation are perfomend only on value Val.
+                        //the shift operation are performed only on value Val.
   Int_t fCurrentCell;   //This variable contains the cell number of the cell currently used 
   Int_t fFreeCellBuffer;//number of free cells of the buffer
   Int_t fFlag;          //0 read  1 write
index 422a6036ab23f8c6e7f01739cd61ba8a0ce2749f..0f265c85f98d8b04849e7eb9508a0e2002dfe17a 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,113 +122,114 @@ 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++){
@@ -227,12 +240,12 @@ Int_t AliTPCCompression::StoreTables(AliTPCHTable* table[],const Int_t NumTable)
     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 +253,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 +262,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 +285,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 +345,29 @@ 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); 
     fTable.open(filename,ios::binary);
-    fTable.read((char*)(&Dim),sizeof(Int_t));
+    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 +381,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 +408,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,21 +417,25 @@ 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
@@ -426,264 +447,265 @@ 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
   f.open(fDest,ios::binary|ios::out);
   // 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 +720,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 +756,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 +769,36 @@ 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); 
     fTable.open(filename,ios::binary);
-    fTable.read((char*)(&Dim),sizeof(Int_t));
+    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 +815,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 +829,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 +839,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 +848,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 +864,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 +880,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 +899,14 @@ 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; 
   f.open(fname,ios::binary|ios::in);
   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,69 +917,70 @@ 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);
   f.open(fname,ios::binary|ios::in);
   if(!f){cout<<"File doesn't exist\n";return -1;}
   //to go to the end of the file
@@ -964,80 +993,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();
index 9dd64fbcb7c4673acd935006dbced1e394a5cbb5..30697f9c2cf76fe9f112f05a432f9a52370fc6cb 100644 (file)
@@ -2,7 +2,7 @@
  * See cxx source for full Copyright notice                               */
 
 //////////////////////////////////////////////////////
-// Utility Class for Compression and Decompression  //
+// Class for Compression and Decompression          //
 //////////////////////////////////////////////////////
 
  
@@ -18,74 +18,76 @@ class AliTPCCompression:public TObject{
   virtual ~AliTPCCompression(){;}
   AliTPCCompression(const AliTPCCompression &source); // copy constructor
   AliTPCCompression& operator=(const AliTPCCompression &source); // ass. op.
-  //This method is used to compress the data store in the altro format file using specific tables
-  //calculate on a particular file that has to be compressed
-  //The tables are stored at the beginning of the compressed file
   Int_t  CompressData(AliTPCHTable* table[],Int_t NumTable,const char* fSource,const char* fDest);
-  //This methos is used to compress an Altro file using a set of general table previously calculated  and
-  //stored as a sequence of txt file. In this case the tables are not stored in the compressed file
+  //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
+  //The tables are stored at the beginning of the compressed file
   Int_t  CompressDataOptTables(Int_t NumTable,const char* fSource,const char* fDest);
-  //This method is used tho decompress a file compressed using the CompressData method
+  //This method is used to compress an Altro file using a set of general table previously calculated  and
+  //stored as a sequence of txt file. In this case the tables are not stored in the compressed file
   Int_t  DecompressData(Int_t NumTables,const char* fname,char* fDest="SourceDecompressed.dat");
-  //This methos is used yo decompress a file compressed using the CompressDataOptTable method
-  //It expects a set of table used for compressing the file in the same direcotory of the compressed file
+  //This method is used tho decompress a file compressed using the CompressData method
   Int_t  DecompressDataOptTables(Int_t NumTables,const char* fname,char* fDest="SourceDecompressed.dat");
-  //This method is used to compute the frequencies of the symbols in the source file
+  //This method is used to decompress a file compressed using the CompressDataOptTable method
+  //It expects a set of table used for compressing the file in the same directory of the compressed file
   Int_t  FillTables(const char* fSource,AliTPCHTable* table[],const Int_t NumTables);
-  //This method is used to create and store the tables 
+  //This method is used to compute the frequencies of the symbols in the source file
   Int_t  CreateTables(const char* fSource,const Int_t NumTables);
+  //This method is used to create and store the tables 
+  void   SetVerbose(Int_t val){fVerbose=val;}
   //This method is used to set up the verbose level
   //   0 ==> No output messages are displayed
   //   1 ==> Some output messages are displayed during the running
   //   2 ==> A complete output is displayed
-  void   SetVerbose(Int_t val){fVerbose=val;}
+  void   ReadAltroFormat(char* fileOut,char* fileIn)const;
   //This method is used to read an Altro file and generate a text file containing the same information
   //It's is useful for debugging
-  void   ReadAltroFormat(char* fileOut,char* fileIn);
+
  private:
+  Int_t   StoreTables(AliTPCHTable* table[],const Int_t NumTable);
   //This method is used to store an array of tables in a sequence of binary files
-  //Each file contains the Size of the table (number of words) and for each word contains the corrispondent 
+  //Each file contains the Size of the table (number of words) and for each word contains the correspondent 
   //codeword and codelength
-  Int_t   StoreTables(AliTPCHTable* table[],const Int_t NumTable);
-  //This method is used to retrieve an array of tables from a sequence of binaruy files created using 
-  //the previous method 
   Int_t   RetrieveTables(AliTPCHTable* table[],Int_t NumTable);
-  //This method is used to delete an Huffamn tree
+  //This method is used to retrieve an array of tables from a sequence of binary files created using 
+  //the previous method 
   void    DeleteHuffmanTree(AliTPCHNode* node);
-  //This method realizes an in order visit of a binary tree
+  //This method is used to delete an Huffman tree
   void    VisitHuffmanTree(AliTPCHNode* node);
-  //This methos is used to create one or more Huffman tree strarting from one or more tables 
-  //It is used in the decompression phase (DecompressData())
+  //This method realizes an in order visit of a binary tree
   void    CreateTrees(AliTPCHNode *RootNode[],const Int_t NumTables);
+  //This method is used to create one or more Huffman tree starting from one or more tables 
+  //It is used in the decompression phase (DecompressData())
+  void    CreateTreesFromFile(AliTPCHNode *RootNode[],const Int_t NumTables);
   //This method is like the previous one but the tables are stored in binary files
   //It is used in the decompression phase (DecompressDataOptTables())
-  void    CreateTreesFromFile(AliTPCHNode *RootNode[],const Int_t NumTables);
+  void    NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count)const;
   //This method is used to deduce which is the next table that as to be used to interpret the next value
   //reading the Altro format
-  void    NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count);
-  //This method is used to store a value in the compressed file 
   void    StoreValue(ULong_t val,UChar_t len);
-  //This methos is used to get the specular value of a given value
-  //for istance the specular value of 12345 is 54321
-  ULong_t Mirror(ULong_t val,UChar_t len);
-  //This method is used to complete and store the buffer in the output file when it isn't completely full 
+  //This method is used to store a value in the compressed file 
+  ULong_t Mirror(ULong_t val,UChar_t len)const;
+  //This method is used to get the specular value of a given value
+  //for instance the specular value of 12345 is 54321
   void    Flush();
-  //this method is used to read a specified number of bits from the compressed file
+  //This method is used to complete and store the buffer in the output file when it isn't completely full 
   ULong_t ReadWord(Int_t NumberOfBit);
-  //This method is used to read the trailer 
+  //this method is used to read a specified number of bits from the compressed file
   void    ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber);
-  //This method is used to get a decoded word from the compressed file
+  //This method is used to read the trailer 
   ULong_t GetDecodedWord(AliTPCHNode* root);
+  //This method is used to get a decoded word from the compressed file
+
 
   fstream f;                  // f is the logical name for the compressed and uncompressed file
-  ofstream stat;              // Statistics 
+  ofstream fStat;             // Logical name for the Statistics file
   ULong_t fBuffer;            // buffer 
   Int_t   fDimBuffer;         // buffer dimension (32 bit)
   Int_t   fFreeBitsBuffer;    // number of free bits inside the buffer
   Int_t   fReadBits;          // number of bit read
   ULong_t fPos;               // current file position
-  Int_t   fVerbose;           // verbose level
-  ULong_t fFillWords;
+  Int_t   fVerbose;           // verbose level (0 silent, !=0 output messages)
+  ULong_t fFillWords;         // Number of hexadecimally words (2AA pattern) inside a pad data block 
   ClassDef(AliTPCCompression,1)
 };
 #endif
index 3762b6bc018b831ed2393d2105d783ca8c629cf9..520f203ecdf4191b8a58e59fc262afdb5a8d2a81 100644 (file)
@@ -6,7 +6,7 @@
 
 void AliTPCDDL(char* FileName,Int_t eth=0){
   //eth is a threshold.
-  //Digits stored into a file have an amplitude value greater than eth
+  //Digits stored into a file have an amplitude value greater than "eth"
   TFile *cf=TFile::Open(FileName);
   // old geometry (3.07)
   //AliTPCParamSR *param =(AliTPCParamSR *)cf->Get("75x40_100x60");
index 666f1bda395c2defae6feb728d69d842fe9fb19f..0417afeb05ed0d62c46b43f201ede9813527f42b 100644 (file)
@@ -32,10 +32,10 @@ void AliTPCDDLRawData(Int_t LDCsNumber=12){
   timer.Stop();
   timer.Print();
   
-  
-  /* 
+  /*
   //SLICE CHECKING
   //An Altro File is created from the slides
+  cout<<"slice control"<<endl;
   util->RawDataAltroDecode(LDCsNumber,0);
   ///The Altro file AltroDDLRecomposed.dat is converted in a txt file AltroDDLRecomposed.txt
   //This file must be equal to the ones created above.
@@ -44,7 +44,9 @@ void AliTPCDDLRawData(Int_t LDCsNumber=12){
 
   
   //SLICE COMPRESSION
-  //Slices are compressed here using the tables created above or an optimized set of tables (Tables file for Huffman coding are required)
+  cout<<"Slice Compression"<<endl;
+  //Slices are compressed here using the tables created above or an optimized set of tables 
+  //(Tables file for Huffman coding are required)
   timer.Start();
   util->RawDataCompDecompress(LDCsNumber,0);
   timer.Stop();
@@ -59,14 +61,14 @@ void AliTPCDDLRawData(Int_t LDCsNumber=12){
   timer.Print();
   */
 
-  
+  /*
   //SLICE DECOMPRESSED CHECKING  
   //A new Altro file is created from the decompressed slides
   util->RawDataAltroDecode(LDCsNumber,1);
   //Convertion of the Altro file AltroDDLRecomposedDec.dat in a txt file AltroDDLRecomposedDec.txt
   //Useful for debugging
   u->ReadAltroFormat("AltroDDLRecomposedDec.txt","AltroDDLRecomposedDec.dat");
-  
+  */
   delete util;
   delete u;
   return;
index b4917aac7df6baa3caf849d05cc78f9fefd3ae55..714bb9e42aabb0ff7f3383cf717cd387e7d6d927 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+/* $Id:*/
+
+//This class conteins all the methods to create raw data 
+//as par a given DDL.
+//It produces DDL with both compressed and uncompressed format.
+//For compression we use the optimized table wich needs 
+//to be provided.
+
 
 #include "TObjArray.h"
 #include "Riostream.h"
@@ -37,13 +45,14 @@ AliTPCDDLRawData& AliTPCDDLRawData::operator=(const AliTPCDDLRawData &source){
 
 ////////////////////////////////////////////////////////////////////////////
 void AliTPCDDLRawData::RawData(Int_t LDCsNumber){
+  //Raw data slides generation
   //Number of DDL=2*36+4*36=216
   //2 DDL for each inner sector
   //4 DDL for each outer sector
-  Int_t DDLPerFile=216/LDCsNumber;
+  Int_t ddlPerFile=216/LDCsNumber;
   Int_t offset=1;
-  if (216%LDCsNumber) DDLPerFile++;
-  cout<<"Number of DDL per slide: "<<DDLPerFile<<endl;
+  if (216%LDCsNumber) ddlPerFile++;
+  cout<<"Number of DDL per slide: "<<ddlPerFile<<endl;
   ifstream f;
   f.open("AliTPCDDL.dat",ios::binary);
   if(!f){cout<<"File doesn't exist !!"<<endl;return;}
@@ -58,112 +67,113 @@ void AliTPCDDLRawData::RawData(Int_t LDCsNumber){
   DataPad data;
 
   //AliTPCBuffer160 is used in write mode to generate AltroFormat.dat file
-  Int_t SliceNumber=1;
+  Int_t sliceNumber=1;
   char  filename[15];
-  sprintf(filename,"TPCslice%d",SliceNumber); 
+  sprintf(filename,"TPCslice%d",sliceNumber); 
   cout<<"   Creating "<<filename<<endl;
-  AliTPCBuffer160 *Buffer=new AliTPCBuffer160(filename,1);
+  AliTPCBuffer160 *buffer=new AliTPCBuffer160(filename,1);
 
-  ULong_t Count=0;
-  Int_t PSecNumber=-1;  //Previous Sector number
-  Int_t PRowNumber=-1;  //Previous Row number  
-  Int_t PPadNumber=-1;  //Previous Pad number
-  Int_t PTimeBin=-1;    //Previous Time-Bin
-  Int_t PSubSector=-1;  //Previous Sub Sector
-  Int_t BunchLength=0;
-  Int_t CountDDL=0;
+  ULong_t count=0;
+  Int_t pSecNumber=-1;  //Previous Sector number
+  Int_t pRowNumber=-1;  //Previous Row number  
+  Int_t pPadNumber=-1;  //Previous Pad number
+  Int_t pTimeBin=-1;    //Previous Time-Bin
+  Int_t pSubSector=-1;  //Previous Sub Sector
+  Int_t bunchLength=0;
+  Int_t countDDL=0;
   Int_t nwords=0;
   ULong_t numPackets=0;
   while (f.read((char*)(&data),sizeof(data))){
-    Count++;
-    if (PPadNumber==-1){
-      PSecNumber=data.Sec;
-      PRowNumber=data.Row;
-      PPadNumber=data.Pad;
-      PTimeBin=data.Time;
-      PSubSector=data.SubSec;
+    count++;
+    if (pPadNumber==-1){
+      pSecNumber=data.Sec;
+      pRowNumber=data.Row;
+      pPadNumber=data.Pad;
+      pTimeBin=data.Time;
+      pSubSector=data.SubSec;
       //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed
-      Buffer->WriteMiniHeader(0,PSecNumber,PSubSector,0,0);//Dummy;
-      BunchLength=1;
-      Buffer->FillBuffer(data.Dig-offset);
+      buffer->WriteMiniHeader(0,pSecNumber,pSubSector,0,0);//Dummy;
+      bunchLength=1;
+      buffer->FillBuffer(data.Dig-offset);
       nwords++;
     }//end if
     else{
-      if ( (data.Time==(PTimeBin+1)) &&
-          (PPadNumber==data.Pad) &&
-          (PRowNumber==data.Row) &&
-          (PSecNumber==data.Sec)){
-       BunchLength++;
+      if ( (data.Time==(pTimeBin+1)) &&
+          (pPadNumber==data.Pad) &&
+          (pRowNumber==data.Row) &&
+          (pSecNumber==data.Sec)){
+       bunchLength++;
       }//end if
       else{
-       Buffer->FillBuffer(PTimeBin);
-       Buffer->FillBuffer(BunchLength+2);
+       buffer->FillBuffer(pTimeBin);
+       buffer->FillBuffer(bunchLength+2);
        nwords+=2;
-       if ((PPadNumber!=data.Pad)||(PRowNumber!=data.Row)||(PSecNumber!=data.Sec)){
+       if ((pPadNumber!=data.Pad)||(pRowNumber!=data.Row)||(pSecNumber!=data.Sec)){
          //Trailer is formatted and inserted!!
-         Buffer->WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
+         buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
          numPackets++;
          nwords=0;
 
-         if(PSubSector!=data.SubSec){
-           CountDDL++;
-           if(CountDDL==DDLPerFile){
+         if(pSubSector!=data.SubSec){
+           countDDL++;
+           if(countDDL==ddlPerFile){
              //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed
-             Buffer->Flush();
-             Buffer->WriteMiniHeader(1,PSecNumber,PSubSector,0,0);
+             buffer->Flush();
+             buffer->WriteMiniHeader(1,pSecNumber,pSubSector,0,0);
              //cout<<"Mini header for DDL:"<<PSecNumber<<" Sub-sec:"<<PSubSector<<endl;
-             delete Buffer;
-             SliceNumber++;
-             sprintf(filename,"TPCslice%d",SliceNumber);
+             delete buffer;
+             sliceNumber++;
+             sprintf(filename,"TPCslice%d",sliceNumber);
              cout<<"   Creating "<<filename<<endl;
-             Buffer=new AliTPCBuffer160(filename,1);
-             Buffer->WriteMiniHeader(0,data.Sec,data.SubSec,0,0);//Dummy;
-             CountDDL=0;
+             buffer=new AliTPCBuffer160(filename,1);
+             buffer->WriteMiniHeader(0,data.Sec,data.SubSec,0,0);//Dummy;
+             countDDL=0;
            }//end if
            else{
-             Buffer->Flush();
-             Buffer->WriteMiniHeader(1,PSecNumber,PSubSector,0,0);
-             Buffer->WriteMiniHeader(0,data.Sec,data.SubSec,0,0);//Dummy;
+             buffer->Flush();
+             buffer->WriteMiniHeader(1,pSecNumber,pSubSector,0,0);
+             buffer->WriteMiniHeader(0,data.Sec,data.SubSec,0,0);//Dummy;
            }
-           PSubSector=data.SubSec;
+           pSubSector=data.SubSec;
          }//end if
        }//end if
        
-       BunchLength=1;
-       PPadNumber=data.Pad;
-       PRowNumber=data.Row;
-       PSecNumber=data.Sec;
+       bunchLength=1;
+       pPadNumber=data.Pad;
+       pRowNumber=data.Row;
+       pSecNumber=data.Sec;
       }//end else
-      PTimeBin=data.Time;
-      Buffer->FillBuffer(data.Dig-offset);
+      pTimeBin=data.Time;
+      buffer->FillBuffer(data.Dig-offset);
       nwords++;
     }//end else
   }//end while
-  Buffer->FillBuffer(PTimeBin);
-  Buffer->FillBuffer(BunchLength+2);
+  buffer->FillBuffer(pTimeBin);
+  buffer->FillBuffer(bunchLength+2);
   nwords+=2;
-  Buffer->WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
+  buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
   //write the  M.H.
-  Buffer->Flush();
-  Buffer->WriteMiniHeader(1,PSecNumber,PSubSector,0,0);
-  //cout<<"Mini header for D D L:"<<PSecNumber<<" Sub-sec:"<<PSubSector<<endl;
-  delete Buffer;
-  cout<<"Number of digits: "<<Count<<endl;
+  buffer->Flush();
+  buffer->WriteMiniHeader(1,pSecNumber,pSubSector,0,0);
+  //cout<<"Mini header for D D L:"<<pSecNumber<<" Sub-sec:"<<pSubSector<<endl;
+  delete buffer;
+  cout<<"Number of digits: "<<count<<endl;
   f.close();
   return;
 }
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
-//This method is used to Compress and decompress the slides
+
 
 Int_t AliTPCDDLRawData::RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp){
-  static const Int_t NumTable=5;
+  //This method is used to compress and decompress the slides
+  static const Int_t kNumTables=5;
   char filename[20];
   char dest[20];
   fstream f;
-  ULong_t Size=0;
+  ULong_t size=0;
   //Int_t MagicWord,DDLNumber,SecNumber,SubSector,Detector;
-  Int_t Flag=0;
+  Int_t flag=0;
   for(Int_t i=1;i<=LDCsNumber;i++){
     if(!Comp){
       sprintf(filename,"TPCslice%d",i);
@@ -181,18 +191,18 @@ Int_t AliTPCDDLRawData::RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp){
     //loop over the DDL block 
     //Each block contains a Mini Header followed by raw data (ALTRO FORMAT)
     //The number of block is ceil(216/LDCsNumber)
-    ULong_t MiniHeader[3];
+    ULong_t miniHeader[3];
     //here the Mini Header is read
-    while( (f.read((char*)(MiniHeader),sizeof(ULong_t)*3)) ){
-      Size=MiniHeader[0];
+    while( (f.read((char*)(miniHeader),sizeof(ULong_t)*3)) ){
+      size=miniHeader[0];
       //Int_t dim=sizeof(ULong_t)+sizeof(Int_t)*5;
-      //cout<<" Sec "<<SecNumber<<" SubSector "<<SubSector<<" Size "<<Size<<endl;
+      //cout<<" Sec "<<SecNumber<<" SubSector "<<SubSector<<" size "<<size<<endl;
       //open the temporay File
       ofstream fo;
       char temp[15]="TempFile";
       fo.open(temp,ios::binary);
       Int_t car=0;
-      for(ULong_t j=0;j<Size;j++){
+      for(ULong_t j=0;j<size;j++){
        f.read((char*)(&car),1);
        fo.write((char*)(&car),1);
       }//end for
@@ -200,31 +210,31 @@ Int_t AliTPCDDLRawData::RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp){
       //The temp file is compressed or decompressed
       AliTPCCompression *util = new AliTPCCompression();
       if(!Comp)
-       util->CompressDataOptTables(NumTable,temp,"TempCompDecomp");
+       util->CompressDataOptTables(kNumTables,temp,"TempCompDecomp");
       else
-       util->DecompressDataOptTables(NumTable,temp,"TempCompDecomp");
+       util->DecompressDataOptTables(kNumTables,temp,"TempCompDecomp");
       delete util;
       //the temp compressed file is open and copied to the final file fdest
       ifstream fi;
       fi.open("TempCompDecomp",ios::binary);
       fi.seekg(0,ios::end);
-      Size=fi.tellg();
+      size=fi.tellg();
       fi.seekg(0);
-      //The Mini Header is updated (Size and Compressed flag) 
+      //The Mini Header is updated (size and Compressed flag) 
       //and written into the output file
-      MiniHeader[0]=Size;
+      miniHeader[0]=size;
       if(!Comp)
-       Flag=1;
+       flag=1;
       else
-       Flag=0;
+       flag=0;
       ULong_t aux=0xFFFF;
       aux<<=16;
-      aux|=Flag;
+      aux|=flag;
       aux|=0xFF;
-      MiniHeader[2]=MiniHeader[2]&aux;
-      fdest.write((char*)(MiniHeader),sizeof(ULong_t)*3);
+      miniHeader[2]=miniHeader[2]&aux;
+      fdest.write((char*)(miniHeader),sizeof(ULong_t)*3);
       //The compressem temp file is copied into the output file fdest
-      for(ULong_t j=0;j<Size;j++){
+      for(ULong_t j=0;j<size;j++){
        fi.read((char*)(&car),1);
        fdest.write((char*)(&car),1);
       }//end for
@@ -240,9 +250,9 @@ Int_t AliTPCDDLRawData::RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp){
 }
 
 /////////////////////////////////////////////////////////////////////////////////
-//This method is used to build the Altro format from AliTPCDDL.dat
-//It is used to debug the code and create the tables used in the compresseion phase
-void AliTPCDDLRawData::RawDataAltro(){
+void AliTPCDDLRawData::RawDataAltro()const{
+  //This method is used to build the Altro format from AliTPCDDL.dat
+  //It is used to debug the code and create the tables used in the compresseion phase
   Int_t offset=1;
   ifstream f;
   f.open("AliTPCDDL.dat",ios::binary);
@@ -260,67 +270,71 @@ void AliTPCDDLRawData::RawDataAltro(){
   //AliTPCBuffer160 is used in write mode to generate AltroFormat.dat file
   char  filename[30]="AltroFormatDDL.dat";
   cout<<"   Creating "<<filename<<endl;
-  AliTPCBuffer160 *Buffer=new AliTPCBuffer160(filename,1);
+  AliTPCBuffer160 *buffer=new AliTPCBuffer160(filename,1);
 
-  ULong_t Count=0;
-  Int_t PSecNumber=-1;  //Previous Sector number
-  Int_t PRowNumber=-1;  //Previous Row number  
-  Int_t PPadNumber=-1;  //Previous Pad number
-  Int_t PTimeBin=-1;    //Previous Time-Bin
-  Int_t BunchLength=0;
+  ULong_t count=0;
+  Int_t pSecNumber=-1;  //Previous Sector number
+  Int_t pRowNumber=-1;  //Previous Row number  
+  Int_t pPadNumber=-1;  //Previous Pad number
+  Int_t pTimeBin=-1;    //Previous Time-Bin
+  Int_t bunchLength=0;
   Int_t nwords=0;
   ULong_t numPackets=0;
   while (f.read((char*)(&data),sizeof(data))){
-    Count++;
-    if (PPadNumber==-1){
-      PSecNumber=data.Sec;
-      PRowNumber=data.Row;
-      PPadNumber=data.Pad;
-      PTimeBin=data.Time;
-      BunchLength=1;
-      Buffer->FillBuffer(data.Dig-offset);
+    count++;
+    if (pPadNumber==-1){
+      pSecNumber=data.Sec;
+      pRowNumber=data.Row;
+      pPadNumber=data.Pad;
+      pTimeBin=data.Time;
+      bunchLength=1;
+      buffer->FillBuffer(data.Dig-offset);
       nwords++;
     }//end if
     else{
-      if ( (data.Time==(PTimeBin+1)) &&
-          (PPadNumber==data.Pad) &&
-          (PRowNumber==data.Row) &&
-          (PSecNumber==data.Sec)){
-       BunchLength++;
+      if ( (data.Time==(pTimeBin+1)) &&
+          (pPadNumber==data.Pad) &&
+          (pRowNumber==data.Row) &&
+          (pSecNumber==data.Sec)){
+       bunchLength++;
       }//end if
       else{
-       Buffer->FillBuffer(PTimeBin);
-       Buffer->FillBuffer(BunchLength+2);
+       buffer->FillBuffer(pTimeBin);
+       buffer->FillBuffer(bunchLength+2);
        nwords+=2;
-       if ((PPadNumber!=data.Pad)||(PRowNumber!=data.Row)||(PSecNumber!=data.Sec)){
+       if ((pPadNumber!=data.Pad)||(pRowNumber!=data.Row)||(pSecNumber!=data.Sec)){
          //Trailer is formatted and inserted!!
-         Buffer->WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
+         buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
          numPackets++;
          nwords=0;
        }//end if
        
-       BunchLength=1;
-       PPadNumber=data.Pad;
-       PRowNumber=data.Row;
-       PSecNumber=data.Sec;
+       bunchLength=1;
+       pPadNumber=data.Pad;
+       pRowNumber=data.Row;
+       pSecNumber=data.Sec;
       }//end else
-      PTimeBin=data.Time;
-      Buffer->FillBuffer(data.Dig-offset);
+      pTimeBin=data.Time;
+      buffer->FillBuffer(data.Dig-offset);
       nwords++;
     }//end else
   }//end while
-  Buffer->FillBuffer(PTimeBin);
-  Buffer->FillBuffer(BunchLength+2);
+  buffer->FillBuffer(pTimeBin);
+  buffer->FillBuffer(bunchLength+2);
   nwords+=2;
-  Buffer->WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
-  delete Buffer;
-  cout<<"Number of digits: "<<Count<<endl;
+  buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
+  delete buffer;
+  cout<<"Number of digits: "<<count<<endl;
   f.close(); 
   return;
 }
 
-
+/////////////////////////////////////////////////////////////////////////
 void AliTPCDDLRawData::RawDataAltroDecode(Int_t LDCsNumber,Int_t Comp){
+  //This method merges the slides in only one file removing at the same 
+  //time all the mini headers. The file so obtained must be Altro format
+  //complaiant.
+  //It is used mainly in the debugging phase 
   char filename[15];
   char dest[30];
   fstream f;
@@ -331,8 +345,8 @@ void AliTPCDDLRawData::RawDataAltroDecode(Int_t LDCsNumber,Int_t Comp){
   ofstream fdest;
 
   fdest.open(dest,ios::binary);
-  ULong_t Size=0;
-  //Int_t MagicWord,DDLNumber,SecNumber,SubSector,Detector,Flag=0;
+  ULong_t size=0;
+  //Int_t MagicWord,DDLNumber,SecNumber,SubSector,Detector,flag=0;
   for(Int_t i=1;i<=LDCsNumber;i++){
     if(!Comp)
       sprintf(filename,"TPCslice%d",i);  
@@ -343,13 +357,13 @@ void AliTPCDDLRawData::RawDataAltroDecode(Int_t LDCsNumber,Int_t Comp){
     //loop over the DDL block 
     //Each block contains a Mini Header followed by raw data (ALTRO FORMAT)
     //The number of block is ceil(216/LDCsNumber)
-    ULong_t MiniHeader[3];
+    ULong_t miniHeader[3];
     //here the Mini Header is read
-    while( (f.read((char*)(MiniHeader),sizeof(ULong_t)*3)) ){
-      //cout<<"Mini header dimension "<<MiniHeader[0]<<endl;
+    while( (f.read((char*)(miniHeader),sizeof(ULong_t)*3)) ){
+      //cout<<"Mini header dimension "<<miniHeader[0]<<endl;
       Int_t car=0;
-      Size=MiniHeader[0];
-      for(ULong_t j=0;j<Size;j++){
+      size=miniHeader[0];
+      for(ULong_t j=0;j<size;j++){
        f.read((char*)(&car),1);
        fdest.write((char*)(&car),1);
       }//end for
index 164747ff6ebadc07fc84284f0cd81854dd98f1e7..be115ad3e367c3a3b7e924be59ef4d8c5e555a31 100644 (file)
@@ -2,7 +2,7 @@
  * See cxx source for full Copyright notice                               */
 
 /////////////////////////////////////////////////////
-// Class used for the fifth ALICE data challenge  //
+// Class used for the ALICE data challenges        //
 /////////////////////////////////////////////////////
 
 #ifndef AliTPCDDLRAWDATA_H
@@ -15,16 +15,16 @@ class AliTPCDDLRawData:public TObject{
   virtual ~AliTPCDDLRawData(){;}//destructor
   AliTPCDDLRawData(const AliTPCDDLRawData &source); // copy constructor
   AliTPCDDLRawData& operator=(const AliTPCDDLRawData &source); // ass. op.
-  //This method is used to create the slides (sequence of files)
   void  RawData(Int_t LDCsNumber);
+  //This method is used to create the slides (sequence of files)
+  Int_t RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp=0);
   //This method is used to create the compressed slides starting from the uncompressed ones 
   //or it can be used to decompress a sequence of compressed slices
-  Int_t RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp=0);
+  void  RawDataAltro()const;
   //This method is used to create the Altro format file from "AliTPCDDL.dat"
-  void  RawDataAltro();
-  //This method is used to Construct an Altro format file starting from
-  //the slices compressed or uncompressed
   void RawDataAltroDecode(Int_t LDCsNumber,Int_t Comp=0);
+  //This method is used to construct an Altro format file starting from
+  //the slices compressed or uncompressed
  private:
   ClassDef(AliTPCDDLRawData,1)
 };
index e465b7149470ea0424621b00a2654d397a2d53c5..d53420caabf0c8b9011daaa381d8be976addde48 100644 (file)
@@ -13,6 +13,7 @@ void AliTPCH5OptimizedTables(const char* fSource="AltroFormat.dat",const char* f
   static const Int_t NumTable=5;
   AliTPCCompression *util = new AliTPCCompression();
   TStopwatch timer;
+  //verbose level can be: 0=silent 1=few messages 2=pedantic output
   util->SetVerbose(2);
   //Tables are created
   util->CreateTables(fSource,NumTable);
@@ -24,7 +25,7 @@ void AliTPCH5OptimizedTables(const char* fSource="AltroFormat.dat",const char* f
   timer.Stop();
   timer.Print();
   
-  /*
+  /*  
   //The Compressed file is decompressed  
   timer.Start();
   util->DecompressDataOptTables(NumTable,fDest);
index 73405673ca496f6ee329dd89629d8e623461d64e..11670b399c9980444bf4b8828c3a1ddee09371bf 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
+/* $Id:*/
 ////////////////////////////////////////////////
 //  Huffman classes for set:TPC               //
 ////////////////////////////////////////////////
+//This file contains two classes and it implements 
+//the Huffman algorithm for creating tables
+//used in the compression phase.
+//The class AliTPCHNode represents a node of the Huffman tree, while
+//the class AliTPCHTable represents a compression table
+
 
 #include <TObjArray.h>
 #include "Riostream.h"
@@ -26,7 +32,7 @@
 ClassImp(AliTPCHNode)
 
 AliTPCHNode::AliTPCHNode(){
-  // constructor
+  //Constructor
   fLeft=0;
   fRight=0;
 }
@@ -34,7 +40,7 @@ AliTPCHNode::AliTPCHNode(){
 //////////////////////////////////////////////////////////////////////////////
 
 AliTPCHNode::AliTPCHNode(Int_t sym, Double_t freq){
-  // standard constructor
+  //Standard constructor
   fSymbol=sym;
   fFrequency=freq;
   fLeft=0;
@@ -44,7 +50,7 @@ AliTPCHNode::AliTPCHNode(Int_t sym, Double_t freq){
 //////////////////////////////////////////////////////////////////////////////
 
 AliTPCHNode::AliTPCHNode(const AliTPCHNode &source){
-  //     Copy Constructor 
+  //Copy Constructor 
   if(&source == this) return;
   this->fSymbol = source.fSymbol;
   this->fFrequency = source.fFrequency;
@@ -56,7 +62,7 @@ AliTPCHNode::AliTPCHNode(const AliTPCHNode &source){
 //////////////////////////////////////////////////////////////////////////////
 
 AliTPCHNode& AliTPCHNode::operator=(const AliTPCHNode &source){
-  //    Assignment operator
+  //Assignment operator
   if(&source == this) return *this;
   this->fSymbol = source.fSymbol;
   this->fFrequency = source.fFrequency;
@@ -68,7 +74,7 @@ AliTPCHNode& AliTPCHNode::operator=(const AliTPCHNode &source){
 //////////////////////////////////////////////////////////////////////////////
 
 Int_t AliTPCHNode::Compare(const TObject *obj)const{
-  // function called by Sort method of TObjArray
+  //Function called by Sort method of TObjArray
   AliTPCHNode *node=(AliTPCHNode *)obj;
   Double_t f=fFrequency;
   Double_t fo=node->fFrequency;
@@ -84,7 +90,7 @@ Int_t AliTPCHNode::Compare(const TObject *obj)const{
 ClassImp(AliTPCHTable)
   
 AliTPCHTable::AliTPCHTable(){
-  // constructor
+  //Constructor
   fCodeLen=0;
   fCode=0;
   fHNodes=0;
@@ -96,7 +102,7 @@ AliTPCHTable::AliTPCHTable(){
 //////////////////////////////////////////////////////////////////////////////
 
 AliTPCHTable::AliTPCHTable(Int_t size){
-  //initialise
+  //Initialization
   fSize=size;
   fCodeLen = new UChar_t[fSize]; 
   fCode = new Double_t[fSize]; 
@@ -114,7 +120,7 @@ AliTPCHTable::AliTPCHTable(Int_t size){
 //////////////////////////////////////////////////////////////////////////////
 
 AliTPCHTable::AliTPCHTable(const AliTPCHTable &source){
-  //     Copy Constructor 
+  //Copy Constructor 
   if(&source == this) return;
   this->fSize = source.fSize;
   this->fCodeLen = source.fCodeLen;
@@ -130,7 +136,7 @@ AliTPCHTable::AliTPCHTable(const AliTPCHTable &source){
 //////////////////////////////////////////////////////////////////////////////
 
 AliTPCHTable& AliTPCHTable::operator=(const AliTPCHTable &source) {
-  //    Assignment operator
+  //Assignment operator
   if(&source == this) return *this;
   this->fSize = source.fSize;
   this->fCodeLen = source.fCodeLen;
@@ -146,7 +152,7 @@ AliTPCHTable& AliTPCHTable::operator=(const AliTPCHTable &source) {
 //////////////////////////////////////////////////////////////////////////////
 
 AliTPCHTable::~AliTPCHTable(){
-  // HTable
+  //HTable destructor
   if(fVerbose)
     cout<<"HTable destructor !\n";
   if (fCodeLen) delete[] fCodeLen;
@@ -160,6 +166,7 @@ AliTPCHTable::~AliTPCHTable(){
 //////////////////////////////////////////////////////////////////////////////
 
 void AliTPCHTable::SetCodeLen(UChar_t len,Int_t val){
+  //Sets codelength of "val" to the variable "len"
   fCodeLen[val]=len;
   return;
 }
@@ -167,6 +174,7 @@ void AliTPCHTable::SetCodeLen(UChar_t len,Int_t val){
 //////////////////////////////////////////////////////////////////////////////
 
 void AliTPCHTable::SetCode(Double_t code,Int_t val){
+  //Sets the binary code of the variable "val"
   fCode[val]=code;
   return;
 }
@@ -174,6 +182,7 @@ void AliTPCHTable::SetCode(Double_t code,Int_t val){
 //////////////////////////////////////////////////////////////////////////////
 
 void AliTPCHTable::PrintTable()const{
+  //This method prints a table
   cout<<"Table for Huffman coding\n";
   cout<<"  Symbol|   Code   |   Length \n";
   for (Int_t i=0;i<fSize;i++){
@@ -190,7 +199,7 @@ void AliTPCHTable::PrintTable()const{
 //////////////////////////////////////////////////////////////////////////////
 
 Bool_t AliTPCHTable::SpanTree(AliTPCHNode *start, ULong_t code, UChar_t len){
-  // span tree
+  //Hoffman codes are generated spanning the Huffman tree
   //In an Huffman tree any internal node has always two children
   AliTPCHNode * visited;
   visited = start;
@@ -208,7 +217,7 @@ Bool_t AliTPCHTable::SpanTree(AliTPCHNode *start, ULong_t code, UChar_t len){
 //////////////////////////////////////////////////////////////////////////////
 
 void AliTPCHTable::ResetHNodes(){
-  // Reset number of HNodes and the HNodes array 
+  //Reset number of HNodes and the HNodes array 
   if (fHNodes)  fHNodes->Clear();
   if (fNnodes)  fNnodes=0;
 }
@@ -216,7 +225,7 @@ void AliTPCHTable::ResetHNodes(){
 //////////////////////////////////////////////////////////////////////////////
 
 void AliTPCHTable::ClearTable(){
-  // Clear the table
+  //Clear the table
   memset(fCodeLen,0,sizeof(UChar_t)*fSize);
   memset(fCode,0,sizeof(Double_t)*fSize);
 }
@@ -224,15 +233,16 @@ void AliTPCHTable::ClearTable(){
 //////////////////////////////////////////////////////////////////////////////
 
 Int_t  AliTPCHTable::GetFrequencies(const char *fname){
+  //It fills the "fCode" array with the frequencies of the symbols read from the file
   AliTPCBuffer160 buff(fname,0);
-  ULong_t NumberOfWords=0;
-  Int_t Val;
-  while((Val=buff.GetNext())!=-1){
-    fCode[Val]++;
+  ULong_t numberOfWords=0;
+  Int_t val;
+  while((val=buff.GetNext())!=-1){
+    fCode[val]++;
     fNum++;
-    NumberOfWords++;
+    numberOfWords++;
   }
-  cout<<"Total number of words: "<<NumberOfWords<<endl;
+  cout<<"Total number of words: "<<numberOfWords<<endl;
   //Print out the frequencies 
   /*
     for (Int_t i=0;i<fSize;i++){
@@ -244,6 +254,7 @@ Int_t  AliTPCHTable::GetFrequencies(const char *fname){
 }
 
 Int_t AliTPCHTable::SetValFrequency(const Int_t Val,Double_t Value){
+  //This method sets to "Value" the frequency of the symbol "Val"
   fCode[Val]=Value;
   fNum=1;
   return 0;
@@ -252,6 +263,8 @@ Int_t AliTPCHTable::SetValFrequency(const Int_t Val,Double_t Value){
 //////////////////////////////////////////////////////////////////////////////
 
 Int_t AliTPCHTable::SetFrequency(const Int_t Val){
+  //It increments by one the frequency of the symbol "Val" whose frequency is 
+  //stored in the fCode array
   fCode[Val]++;
   fNum++;
   return 0;
@@ -259,7 +272,8 @@ Int_t AliTPCHTable::SetFrequency(const Int_t Val){
 
 //////////////////////////////////////////////////////////////////////////////
 
-Int_t AliTPCHTable::StoreFrequencies(const char *fname){
+Int_t AliTPCHTable::StoreFrequencies(const char *fname)const{
+  //It stores the frequencies in a text file
   ofstream ftxt(fname);  
   for (Int_t i=0;i<fSize;i++){
     ftxt<<(ULong_t)fCode[i]<<endl;
@@ -271,6 +285,8 @@ Int_t AliTPCHTable::StoreFrequencies(const char *fname){
 //////////////////////////////////////////////////////////////////////////////
 
 void AliTPCHTable::CompleteTable(Int_t k){
+  //According to the kind of table (0..4) it associates a dummy frequency (1) to 
+  //every symbols whose real frequency is zero, in a given range 0..max
   Int_t max;
   ULong_t val;
   switch(k){
@@ -297,6 +313,7 @@ void AliTPCHTable::CompleteTable(Int_t k){
 //////////////////////////////////////////////////////////////////////////////
 
 Double_t  AliTPCHTable::GetEntropy()const{
+  //This method calculates the value of the entropy 
   Double_t entropy=0;
   Double_t prob=0;
   for (Int_t i=0;i<fSize;i++){
@@ -311,7 +328,7 @@ Double_t  AliTPCHTable::GetEntropy()const{
 //////////////////////////////////////////////////////////////////////////////
 
 Int_t AliTPCHTable::BuildHTable(){
-  // build Htable
+  //It builds a Huffman tree 
   if(GetWordsNumber()){
     for (Int_t i=0; i< fSize; i++) {
       if (fCode[i] > 0.){
@@ -345,5 +362,4 @@ Int_t AliTPCHTable::BuildHTable(){
   }//end else
   return 0;
 }
-
 //////////////////////////////////////////////////////////////////////////////
index c6c64393c3dce6cc36505c8a2ba611a73c97e8e3..7be26c567e899c8b7a7b63e3f655bccad521d769 100644 (file)
@@ -8,6 +8,7 @@
  
 #ifndef AliTPCHUFFMAN_H
 #define AliTPCHUFFMAN_H
+
 class AliTPCBuffer160;
 
 class AliTPCHNode: public TObject  {
@@ -24,16 +25,16 @@ class AliTPCHNode: public TObject  {
   void    SetRight(AliTPCHNode* point){fRight=point;}
   AliTPCHNode* GetRight()const{return fRight;}
   AliTPCHNode* GetLeft()const{return fLeft;}
-  void    SetSymbol(Int_t sym){fSymbol=sym;}
-  void    SetFrequency(Double_t freq){fFrequency=freq;}
+  void     SetSymbol(Int_t sym){fSymbol=sym;}
+  void     SetFrequency(Double_t freq){fFrequency=freq;}
   Double_t GetFrequency()const{return fFrequency;}
-  Int_t   GetSymbol()const{return fSymbol;}
+  Int_t    GetSymbol()const{return fSymbol;}
 
  private:
   Int_t         fSymbol;       // Symbols
-  Double_t       fFrequency;    // Frequency of the Symbol
+  Double_t      fFrequency;    // Frequency of the Symbol
   AliTPCHNode   *fLeft;        // Pointer to the left son
-  AliTPCHNode   *fRight;       // pointer to the right son
+  AliTPCHNode   *fRight;       // Pointer to the right son
   ClassDef(AliTPCHNode,1)     
 };
 /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -53,7 +54,7 @@ class AliTPCHTable: public TObject{
   void       SetCode(Double_t code,Int_t val);
   TObjArray* HNodes()const {return fHNodes;}
   void       PrintTable()const;
-  //This method builds the Huffman tree starting from the frequncies that are 
+  //This method builds the Huffman tree starting from the frequencies that are 
   //strored temporary in fCode array
   Int_t      BuildHTable();
   //This method returns the number of words stored in the fSym array
@@ -63,28 +64,28 @@ class AliTPCHTable: public TObject{
   Int_t      GetFrequencies(const char* fname);
   //This method increase by one the frequency of a given value
   Int_t      SetFrequency(const Int_t Val);
-  //This method strores the frequency of the symbol in a text file
-  Int_t      StoreFrequencies(const char *fname);
+  //This method stores the frequency of the symbol in a text file
+  Int_t      StoreFrequencies(const char *fname)const;
   void       CompleteTable(Int_t k);
   Double_t   GetEntropy()const;
   void       SetVerbose(Int_t val){fVerbose=val;}
-  //Method to set directly a frequency
+  //Method to set directly a frequency 
   Int_t      SetValFrequency(const Int_t Val,Double_t Value);
  private:
   //This method executes the pre-order visit of an Huffman tree and calculates the 
   //codeword for each leaf
   Bool_t     SpanTree(AliTPCHNode*start, ULong_t code, UChar_t len);
-  void       ResetHNodes();  //Reset the array fHNodes but not delete the remuved objects
+  void       ResetHNodes();  //Reset the array fHNodes but not delete the removed objects
   void       ClearTable();   //Reset the table
-  Int_t       fSize;       // size of the arrays
-  UChar_t     *fCodeLen;   //![fSize] number of bits array
-  Double_t    *fCode;     //![fSize] coded symbols array
+  Int_t       fSize;         //size of the arrays fCodelen and fCode
+  UChar_t     *fCodeLen;     //![fSize] number of bits array
+  Double_t    *fCode;        //![fSize] coded symbols array
   
-  Short_t    *fSym;      //![fSize] array of input symbols
-  TObjArray  *fHNodes;   // array of nodes
-  Int_t       fNnodes;   // number of nodes
-  ULong_t     fNum;      // number of words
-  Int_t       fVerbose;
-  ClassDef(AliTPCHTable,1)  //Huffman Table  object for set:TPC
+  Short_t    *fSym;          //![fSize] array of input symbols
+  TObjArray  *fHNodes;       // array of nodes
+  Int_t       fNnodes;       // number of nodes
+  ULong_t     fNum;          // number of words
+  Int_t       fVerbose;      // if fVerbose== 0 no output messages; fVerbose!=0 output messages are printed out 
+  ClassDef(AliTPCHTable,1)   //Huffman Table object for set:TPC
 };
 #endif