#include <TObjArray.h>
#include <Riostream.h>
#include <TMath.h>
+#include <TSystem.h>
#include "AliTPCBuffer160.h"
#include "AliTPCHuffman.h"
#include "AliTPCCompression.h"
//////////////////////////////////////////////////////////////////////////////////////////////////
AliTPCCompression::AliTPCCompression(){
//Defaul constructor
- fDimBuffer=sizeof(ULong_t)*8;
+ fDimBuffer=sizeof(UInt_t)*8;
fFreeBitsBuffer=fDimBuffer;
fReadBits=0;
fPos=0;
return;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-AliTPCCompression::AliTPCCompression(const AliTPCCompression &source){
+AliTPCCompression::AliTPCCompression(const AliTPCCompression &source)
+ :TObject(source){
//Constructor
this->fDimBuffer=source.fDimBuffer;
this->fFreeBitsBuffer=source.fFreeBitsBuffer;
/////////////////////////////////////////////////////////////////////////////////////////////////////
-Int_t AliTPCCompression::FillTables(const char* fSource,AliTPCHTable* table[],const Int_t NumTables){
+Int_t AliTPCCompression::FillTables(const char* fSource,AliTPCHTable* table[],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;
+ UInt_t countWords=0;
+ UInt_t countTrailer=0;
Int_t numWords,padNum,rowNum,secNum=0;
Int_t value=0;
- ULong_t stat[5]={0,0,0,0,0};
+ UInt_t stat[5]={0,0,0,0,0};
Int_t endFill=0;
Int_t end=1;
while(buff.ReadTrailerBackward(numWords,padNum,rowNum,secNum) !=-1 ){
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));
+ UInt_t fileDimension=(UInt_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;
+ fStat<<"Fill Words................"<<(UInt_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;
- fStat<<"Data......................"<<(ULong_t)TMath::Ceil((stat[0]+stat[1]+stat[2]+stat[3]+stat[4])*10/8)<<" bytes "<<percentage<<"%"<<endl;
+ fStat<<"Data......................"<<(UInt_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;
- fStat<<"Bunch....................."<<(ULong_t)TMath::Ceil(stat[0]*10/8)<<" bytes "<<percentage<<"%"<<endl; //
+ fStat<<"Bunch....................."<<(UInt_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; //
+ fStat<<"Time......................"<<(UInt_t)TMath::Ceil(stat[1]*10/8)<<" bytes "<<percentage<<"%"<<endl; //
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;
+ fStat<<"Amplitude values.........."<<(UInt_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; //
+ fStat<<" One Samples..............."<<(UInt_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; //
+ fStat<<" Central Samples..........."<<(UInt_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<<" Border Samples............"<<(UInt_t)TMath::Ceil(stat[4]*10/8)<<" bytes "<<percentage<<"%"<<endl; //
fStat.close();
return 0;
}
//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];
+ // UInt_t code=(UInt_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(UInt_t));
fTable.write((char*)(&code),sizeof(Double_t));
} //end for
fTable.close();
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
-Int_t AliTPCCompression::CreateTableFormula(Double_t beta,ULong_t M,Int_t dim,Int_t Type){
+Int_t AliTPCCompression::CreateTableFormula(Double_t beta,UInt_t M,Int_t dim,Int_t Type){
// Type = 0 for Bunch length
// Type = 1 for Time Gap
- ULong_t freq;
+ UInt_t freq;
Double_t sum=0;
Double_t min=10;
Double_t alpha=0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
-Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables){
+Int_t AliTPCCompression::CreateTables(const char* fSource,Int_t NumTables){
//Tables manager
/*
Table index:
//This method retrieve the Huffman tables from a sequence of binary files
if (fVerbose)
cout<<"Retrieving tables from files \n";
- // ULong_t code;
+ // UInt_t code;
Double_t code;
UChar_t codeLen;
ifstream fTable;
- char filename[15];
+ char filename[256];
//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
#else
fTable.open(filename);
#endif
- if(!fTable){cout<<"File doesn't exist:"<<filename<<endl; exit(1);}
+ if(!fTable && gSystem->Getenv("ALICE_ROOT")){
+ fTable.clear();
+ sprintf(filename,"%s/RAW/Table%d.dat",gSystem->Getenv("ALICE_ROOT"),k);
+#ifndef __DECCXX
+ fTable.open(filename,ios::binary);
+#else
+ fTable.open(filename);
+#endif
+ }
+ if(!fTable){
+ Error("RetrieveTables", "File doesn't exist: %s", filename);
+ return 1;
+ }
fTable.read((char*)(&dim),sizeof(Int_t));
if (fVerbose)
cout<<"Table dimension: "<<dim<<endl;
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(UInt_t));
fTable.read((char*)(&code),sizeof(Double_t));
- table[k]->SetCode(Mirror((ULong_t)code,codeLen),i);
+ table[k]->SetCode(Mirror((UInt_t)code,codeLen),i);
}//end for
fTable.close();
}//end for
sprintf(filename,"Table%d.txt",k);
cout<<filename<<endl;
fTable.open(filename);
- if(!fTable){cout<<"File doesn't exist: "<<filename<<endl; exit(1);}
+ if(!fTable){
+ Error("CreateTablesFromTxtFiles", "File doesn't exist: %s", filename);
+ return 1;
+ }
Int_t symbol=0;
Double_t freq=0;
table[k]=new AliTPCHTable(1024);
/* COMPRESSION */
////////////////////////////////////////////////////////////////////////////////////////
-void AliTPCCompression::StoreValue(ULong_t val,UChar_t len){
+void AliTPCCompression::StoreValue(UInt_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;
fBuffer=fBuffer|val;
if(!fFreeBitsBuffer){ // if the buffer is full it is written into a file
- f.write((char*)(&fBuffer),sizeof(ULong_t));
+ f.write((char*)(&fBuffer),sizeof(UInt_t));
fFreeBitsBuffer=fDimBuffer;
fBuffer=0;
}
}//end if
else{ //val has to be splitted in two buffers
fBuffer=fBuffer<<fFreeBitsBuffer;
- ULong_t temp;
+ UInt_t temp;
temp=val;
temp=temp>>(len-fFreeBitsBuffer);
fBuffer=fBuffer|temp;
- f.write((char*)(&fBuffer),sizeof(ULong_t));
+ f.write((char*)(&fBuffer),sizeof(UInt_t));
fFreeBitsBuffer=fDimBuffer-(len-fFreeBitsBuffer);
val=val<<fFreeBitsBuffer;
val=val>>fFreeBitsBuffer;
//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));
+ f.write((char*)(&fBuffer),sizeof(UInt_t));
}//end if
return;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-ULong_t AliTPCCompression::Mirror(ULong_t val,UChar_t len)const{
+UInt_t AliTPCCompression::Mirror(UInt_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 bit;
+ UInt_t specular=0;
+ UInt_t mask=0x1;
+ UInt_t bit;
for(Int_t i=0;i<len;i++){
bit=val&mask;
bit=bit>>i;
}
//Tables are read from the files (Each codeword has been "Mirrored")
AliTPCHTable **table = new AliTPCHTable*[NumTable];
- RetrieveTables(table,NumTable);
+ for(Int_t i=0;i<NumTable;i++) table[i] = NULL;
+ if (RetrieveTables(table,NumTable) != 0) {
+ for(Int_t i=0;i<NumTable;i++) delete table[i];
+ delete [] table;
+ return 1;
+ }
//the output file is open
+ f.clear();
#ifndef __DECCXX
f.open(fDest,ios::binary|ios::out);
#else
AliTPCBuffer160 buff(fSource,0);
//coded words are written into a file
Int_t numWords,padNum,rowNum,secNum=0;
- ULong_t storedWords=0;
+ UInt_t storedWords=0;
Int_t value=0;
- ULong_t numPackets=0;
+ UInt_t numPackets=0;
Double_t stat[5]={0.,0.,0.,0.,0.};
- ULong_t trailerNumbers=0;
+ UInt_t trailerNumbers=0;
Double_t numElem[5]={0,0,0,0,0};
Double_t fillWords=0.;
+ fStat.clear();
fStat.open("Statistics",ios::app);
fStat<<endl;
fStat<<"-------------------COMPRESSION STATISTICS----------"<<endl;
value=packet[i];
if(nextTableType==1)timeBin=value;
if(nextTableType>1){
- //ULong_t val=(ULong_t)table[nextTableType]->Code()[value]; // val is the code
+ //UInt_t val=(UInt_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);
+ StoreValue((UInt_t)val,len);
storedWords++;
}//end if
NextTable(value,nextTableType,bunchLen,count);
if(nextTableType==0){
- // ULong_t val=(ULong_t)table[1]->Code()[timeBin]; // val is the code
+ // UInt_t val=(UInt_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
+ StoreValue((UInt_t)val,len);
+ // val=(UInt_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);
+ StoreValue((UInt_t)val,len);
stat[nextTableType]+=len;
numElem[nextTableType]++;
storedWords+=2;
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)+trailerNumbers*5;
+ Double_t dimension=(UInt_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;
+ fStat<<"Data Dimension in bytes........."<<(UInt_t)TMath::Ceil((stat[0]+stat[1]+stat[2]+stat[3]+stat[4])/8)<<endl;
+ fStat<<"Compressed file dimension......."<<(UInt_t)dimension<<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;
+ fStat<<(UInt_t)trailerNumbers<<endl;
+ fStat<<(UInt_t)fillWords<<endl;
+ fStat<<(UInt_t)numElem[0]<<endl;
+ fStat<<(UInt_t)numElem[1]<<endl;
+ fStat<<(UInt_t)numElem[2]<<endl;
+ fStat<<(UInt_t)numElem[3]<<endl;
+ fStat<<(UInt_t)numElem[4]<<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;
+ fStat<<"Original file dimension........."<<(UInt_t)fillWords<<endl;
Double_t ratio=(dimension/fillWords)*100;
fStat<<"Compression ratio (Compressed/Uncompressed)..."<<ratio<<"%"<<endl;
fStat<<endl;
if (numElem[0])
- fStat<<"Bunch length size in bytes......"<<(ULong_t)TMath::Ceil(stat[0]/8)<<" Comppression.."<<(stat[0]/numElem[0])*10<<"%"<<endl;
+ fStat<<"Bunch length size in bytes......"<<(UInt_t)TMath::Ceil(stat[0]/8)<<" Comppression.."<<(stat[0]/numElem[0])*10<<"%"<<endl;
if (numElem[1])
- fStat<<"Time gap size in bytes.........."<<(ULong_t)TMath::Ceil(stat[1]/8)<<" Comppression.."<<(stat[1]/numElem[1])*10<<"%"<<endl;
+ fStat<<"Time gap size in bytes.........."<<(UInt_t)TMath::Ceil(stat[1]/8)<<" Comppression.."<<(stat[1]/numElem[1])*10<<"%"<<endl;
if (numElem[2]+numElem[3]+numElem[4])
- fStat<<"Amplitude values in bytes......."<<(ULong_t)TMath::Ceil((stat[2]+stat[3]+stat[4])/8)<<" Comppression.."<<
+ fStat<<"Amplitude values in bytes......."<<(UInt_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;
if (numElem[2])
- fStat<<" One Samples in bytes............"<<(ULong_t)TMath::Ceil(stat[2]/8)<<" Comppression.."<<(stat[2]/numElem[2])*10<<"%"<<endl;
+ fStat<<" One Samples in bytes............"<<(UInt_t)TMath::Ceil(stat[2]/8)<<" Comppression.."<<(stat[2]/numElem[2])*10<<"%"<<endl;
if (numElem[3])
- fStat<<" Central Samples size in bytes..."<<(ULong_t)TMath::Ceil(stat[3]/8)<<" Comppression.."<<(stat[3]/numElem[3])*10<<"%"<<endl;
+ fStat<<" Central Samples size in bytes..."<<(UInt_t)TMath::Ceil(stat[3]/8)<<" Comppression.."<<(stat[3]/numElem[3])*10<<"%"<<endl;
if (numElem[4])
- fStat<<" Border Samples size in bytes...."<<(ULong_t)TMath::Ceil(stat[4]/8)<<" Comppression.."<<(stat[4]/numElem[4])*10<<"%"<<endl;
+ fStat<<" Border Samples size in bytes...."<<(UInt_t)TMath::Ceil(stat[4]/8)<<" Comppression.."<<(stat[4]/numElem[4])*10<<"%"<<endl;
fStat<<endl;
fStat<<"Average number of bits per word"<<endl;
if (numElem[0])
/* DECOMPRESSION */
////////////////////////////////////////////////////////////////////////////////////////
-void AliTPCCompression::CreateTreesFromFile(AliTPCHNode *RootNode[],const Int_t NumTables){
+Int_t AliTPCCompression::CreateTreesFromFile(AliTPCHNode *RootNode[],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;
+ // UInt_t code;
Double_t code;
UChar_t codeLen;
ifstream fTable;
- char filename[15];
+ char filename[256];
//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++){
#else
fTable.open(filename);
#endif
- if(!fTable){cout<<"Tables don't exist !!!"<<endl;exit(1);}
+ if(!fTable && gSystem->Getenv("ALICE_ROOT")){
+ fTable.clear();
+ sprintf(filename,"%s/RAW/Table%d.dat",gSystem->Getenv("ALICE_ROOT"),k);
+#ifndef __DECCXX
+ fTable.open(filename,ios::binary);
+#else
+ fTable.open(filename);
+#endif
+ }
+ if(!fTable){
+ Error("CreateTreesFromFile", "File doesn't exist: %s", filename);
+ return 1;
+ }
fTable.read((char*)(&dim),sizeof(Int_t));
if (fVerbose)
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(UInt_t));
fTable.read((char*)(&code),sizeof(Double_t));
node=RootNode[k];
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;
+ UInt_t bit,val=0;
+ val=(UInt_t)TMath::Power(2,codeLen-j);
+ bit=(UInt_t)code&val;
AliTPCHNode *temp=node;
if(bit){
node=node->GetRight();
if (fVerbose)
cout<<"Trees generated \n";
//At this point the trees are been built
+ return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void AliTPCCompression::DeleteHuffmanTree(AliTPCHNode* node){
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-ULong_t AliTPCCompression::ReadWord(Int_t NumberOfBit){
+UInt_t AliTPCCompression::ReadWord(Int_t NumberOfBit){
//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;
+ UInt_t result=0;
+ UInt_t bit=0;
for (Int_t i=0;i<NumberOfBit;i++){
if (fReadBits==32){
- fPos-=sizeof(ULong_t);
+ fPos-=sizeof(UInt_t);
f.seekg(fPos);
- f.read((char*)(&fBuffer),sizeof(ULong_t));
+ f.read((char*)(&fBuffer),sizeof(UInt_t));
fReadBits=0;
}//end if
- ULong_t mask=0;
- mask=(ULong_t)TMath::Power(2,fReadBits);
+ UInt_t mask=0;
+ mask=(UInt_t)TMath::Power(2,fReadBits);
bit=fBuffer&mask;
bit=bit>>fReadBits;
fReadBits++;
return result;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-ULong_t AliTPCCompression::ReadWordBuffer(Int_t NumberOfBit){
+UInt_t AliTPCCompression::ReadWordBuffer(Int_t NumberOfBit){
//This method retrieves a word of a specific number of bits from the file through the buffer
- ULong_t result=0;
- ULong_t bit=0;
+ UInt_t result=0;
+ UInt_t bit=0;
for (Int_t i=0;i<NumberOfBit;i++){
if (fReadBits==32){
fPointBuffer-=8;
fBuffer=0;
for(Int_t i=0;i<4;i++){
- ULong_t val=0;
+ UInt_t val=0;
val=*fPointBuffer;
val&=0xFF;
fPointBuffer++;
}//end for
fReadBits=0;
}//end if
- ULong_t mask=0;
- mask=(ULong_t)TMath::Power(2,fReadBits);
+ UInt_t mask=0;
+ mask=(UInt_t)TMath::Power(2,fReadBits);
bit=fBuffer&mask;
bit=bit>>fReadBits;
fReadBits++;
return;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-ULong_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root,Bool_t Memory){
+UInt_t AliTPCCompression::GetDecodedWord(AliTPCHNode* root,Bool_t Memory){
//This method retrieves a decoded word.
AliTPCHNode *node=root;
- ULong_t symbol=0;
+ UInt_t symbol=0;
Bool_t decoded=0;
while(!decoded){
- ULong_t bit=0;
+ UInt_t bit=0;
if(Memory)
bit=ReadWordBuffer(1);
else
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-Int_t AliTPCCompression::DecompressDataOptTables(Int_t NumTables,const char* fname,char* fDest){
+Int_t AliTPCCompression::DecompressDataOptTables(Int_t NumTables,const char* fname, const 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];
+ for(Int_t i=0;i<NumTables;i++) rootNode[i] = NULL;
//Creation of the Huffman trees
- CreateTreesFromFile(rootNode,NumTables);
+ if (CreateTreesFromFile(rootNode,NumTables) != 0) {
+ for(Int_t i=0;i<NumTables;i++) {
+ if (rootNode[i]) DeleteHuffmanTree(rootNode[i]);
+ }
+ delete [] rootNode;
+ return 1;
+ }
+ f.clear();
#ifndef __DECCXX
f.open(fname,ios::binary|ios::in);
#else
f.open(fname,ios::in);
#endif
- if(!f){cout<<"File doesn't exist:"<<fname<<endl;;return -1;}
+ if(!f){
+ Error("DecompressDataOptTables", "File doesn't exist:",fname);
+ return -1;
+ }
//to go to the end of the file
f.seekg(0,ios::end);
//to get the file dimension in byte
fPos=f.tellg();
- fPos-=sizeof(ULong_t);
+ fPos-=sizeof(UInt_t);
f.seekg(fPos);
fReadBits=0;
fBuffer=0;
- f.read((char*)(&fBuffer),sizeof(ULong_t));
+ f.read((char*)(&fBuffer),sizeof(UInt_t));
Int_t bit=0;
- ULong_t mask=0x1;
+ UInt_t mask=0x1;
while(!bit){
bit=fBuffer&mask;
mask=mask<<1;
fReadBits++;
}
- ULong_t packetNumber=ReadWord(sizeof(ULong_t)*8);
+ UInt_t packetNumber=ReadWord(sizeof(UInt_t)*8);
if(fVerbose){
cout<<"Number of Packect: "<<packetNumber<<endl;
}
AliTPCBuffer160 bufferFile(fDest,1);
- ULong_t k=0;
- ULong_t wordsRead=0; //number of read coded words
+ UInt_t k=0;
+ UInt_t wordsRead=0; //number of read coded words
while(k<packetNumber){
Int_t numWords,padNumber,rowNumber,secNumber=0;
ReadTrailer(numWords,padNumber,rowNumber,secNumber,kFALSE);
Int_t bunchLen=0;
Int_t count=0;
for(Int_t i=0;i<numWords;i++){
- ULong_t symbol=GetDecodedWord(rootNode[nextTableType],kFALSE);
+ UInt_t symbol=GetDecodedWord(rootNode[nextTableType],kFALSE);
wordsRead++;
//Time reconstruction
if (nextTableType==1){
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-Int_t AliTPCCompression::Decompress(AliTPCHNode *RootNode[],const Int_t NumTables,char* PointBuffer,ULong_t BufferSize,UShort_t out[],ULong_t &dim){
+Int_t AliTPCCompression::Decompress(AliTPCHNode *RootNode[],Int_t /*NumTables*/,char* PointBuffer,UInt_t BufferSize,UShort_t out[],UInt_t &dim){
//This method decompress a file using separate Huffman tables
fPointBuffer=PointBuffer+BufferSize-4;
fBuffer=0;
for(Int_t i=0;i<4;i++){
- ULong_t val=0;
+ UInt_t val=0;
val=*fPointBuffer;
val&=0xFF;
fPointBuffer++;
fBuffer=fBuffer|val;
}//end for
Int_t bit=0;
- ULong_t mask=0x1;
+ UInt_t mask=0x1;
while(!bit){
bit=fBuffer&mask;
mask=mask<<1;
fReadBits++;
}//end while
- ULong_t packetNumber=ReadWordBuffer(sizeof(ULong_t)*8); //32 bits
+ UInt_t packetNumber=ReadWordBuffer(sizeof(UInt_t)*8); //32 bits
if (fVerbose){
cout<<"First one has been found "<<endl;
cout<<"Number of packets:"<<packetNumber<<endl;
}//end if
- ULong_t k=0;
- ULong_t wordsRead=0; //number of read coded words
+ UInt_t k=0;
+ UInt_t wordsRead=0; //number of read coded words
while(k<packetNumber){
Int_t numWords,padNumber,rowNumber,secNumber=0;
ReadTrailer(numWords,padNumber,rowNumber,secNumber,kTRUE);
Int_t count=0;
Int_t timeDigit=0;
for(Int_t i=0;i<numWords;i++){
- ULong_t symbol=GetDecodedWord(RootNode[nextTableType],kTRUE);
+ UInt_t symbol=GetDecodedWord(RootNode[nextTableType],kTRUE);
wordsRead++;
//Time reconstruction
if (nextTableType==1){
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-Int_t AliTPCCompression::DestroyTables(AliTPCHNode *RootNode[],const Int_t NumTables){
+Int_t AliTPCCompression::DestroyTables(AliTPCHNode *RootNode[],Int_t NumTables){
//The trees are deleted
for(Int_t j=0;j<NumTables;j++){
DeleteHuffmanTree(RootNode[j]);