get tables from the aliroot directory if they are not in the current one
[u/mrichter/AliRoot.git] / RAW / AliTPCCompression.h
2e9f335b 1/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
a79660fb 5// Class for Compression and Decompression //
2e9f335b 6//////////////////////////////////////////////////////
f8aae377 12#ifdef __CINT__
13class fstream;
15#include "Riostream.h"
2e9f335b 18class AliTPCHNode;
19class AliTPCHTable;
21class AliTPCCompression:public TObject{
22 public:
23 AliTPCCompression();
24 virtual ~AliTPCCompression(){;}
25 AliTPCCompression(const AliTPCCompression &source); // copy constructor
26 AliTPCCompression& operator=(const AliTPCCompression &source); // ass. op.
2e9f335b 27 Int_t CompressDataOptTables(Int_t NumTable,const char* fSource,const char* fDest);
a79660fb 28 //This method is used to compress an Altro file using a set of general table previously calculated and
c9bd9d3d 29 //stored as a sequence of txt file.
5fe3851e 30 Int_t DecompressDataOptTables(Int_t NumTables,const char* fname,const char* fDest="SourceDecompressed.dat");
a79660fb 31 //This method is used to decompress a file compressed using the CompressDataOptTable method
32 //It expects a set of table used for compressing the file in the same directory of the compressed file
09f6432c 33 Int_t Decompress(AliTPCHNode *RootNode[],Int_t NumTables,char* PointBuffer,UInt_t BufferSize,UShort_t out[],UInt_t &dim);
c9bd9d3d 34 //This method is used to decompress data stored in a char* buffer
09f6432c 35 Int_t FillTables(const char* fSource,AliTPCHTable* table[],Int_t NumTables);
a79660fb 36 //This method is used to compute the frequencies of the symbols in the source file
09f6432c 37 Int_t CreateTables(const char* fSource,Int_t NumTables);
a79660fb 38 //This method is used to create and store the tables
0b3c7dfc 39 Int_t CreateTableFormula(Double_t beta,UInt_t M,Int_t dim,Int_t Type);
9f992f70 40 //This method is used to create and store the Bunch length or Time Gap Table using a formula
a79660fb 41 void SetVerbose(Int_t val){fVerbose=val;}
2e9f335b 42 //This method is used to set up the verbose level
43 // 0 ==> No output messages are displayed
44 // 1 ==> Some output messages are displayed during the running
45 // 2 ==> A complete output is displayed
a79660fb 46 void ReadAltroFormat(char* fileOut,char* fileIn)const;
2e9f335b 47 //This method is used to read an Altro file and generate a text file containing the same information
48 //It's is useful for debugging
9f992f70 49 Int_t CreateTablesFromTxtFiles(Int_t NumTable);
50 //This method creates a set of binary tables starting from a set of txt tables
09f6432c 51 Int_t DestroyTables(AliTPCHNode *RootNode[],Int_t NumTables);
c9bd9d3d 52 //This methods is use to deallocate the memory used by Huffman trees
1d98347a 53 Int_t CreateTreesFromFile(AliTPCHNode *RootNode[],Int_t NumTables);
c9bd9d3d 54 //This method is like the previous one but the tables are stored in binary files
55 //It is used in the decompression phase (DecompressDataOptTables())
2e9f335b 56 private:
a79660fb 57 Int_t StoreTables(AliTPCHTable* table[],const Int_t NumTable);
2e9f335b 58 //This method is used to store an array of tables in a sequence of binary files
a79660fb 59 //Each file contains the Size of the table (number of words) and for each word contains the correspondent
2e9f335b 60 //codeword and codelength
2e9f335b 61 Int_t RetrieveTables(AliTPCHTable* table[],Int_t NumTable);
a79660fb 62 //This method is used to retrieve an array of tables from a sequence of binary files created using
63 //the previous method
2e9f335b 64 void DeleteHuffmanTree(AliTPCHNode* node);
a79660fb 65 //This method is used to delete an Huffman tree
2e9f335b 66 void VisitHuffmanTree(AliTPCHNode* node);
a79660fb 67 //This method realizes an in order visit of a binary tree
a79660fb 68 void NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count)const;
2e9f335b 69 //This method is used to deduce which is the next table that as to be used to interpret the next value
70 //reading the Altro format
0b3c7dfc 71 void StoreValue(UInt_t val,UChar_t len);
a79660fb 72 //This method is used to store a value in the compressed file
0b3c7dfc 73 UInt_t Mirror(UInt_t val,UChar_t len)const;
a79660fb 74 //This method is used to get the specular value of a given value
75 //for instance the specular value of 12345 is 54321
2e9f335b 76 void Flush();
a79660fb 77 //This method is used to complete and store the buffer in the output file when it isn't completely full
0b3c7dfc 78 UInt_t ReadWord(Int_t NumberOfBit);
a79660fb 79 //this method is used to read a specified number of bits from the compressed file
0b3c7dfc 80 UInt_t ReadWordBuffer(Int_t NumberOfBit);
c9bd9d3d 81 //this method is used to read a specified number of bits from the compressed memory buffer
82 void ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumberr,Bool_t Memory);
a79660fb 83 //This method is used to read the trailer
0b3c7dfc 84 UInt_t GetDecodedWord(AliTPCHNode* root,Bool_t Memory);
a79660fb 85 //This method is used to get a decoded word from the compressed file
2e9f335b 87 fstream f; // f is the logical name for the compressed and uncompressed file
a79660fb 88 ofstream fStat; // Logical name for the Statistics file
0b3c7dfc 89 UInt_t fBuffer; // buffer
2e9f335b 90 Int_t fDimBuffer; // buffer dimension (32 bit)
91 Int_t fFreeBitsBuffer; // number of free bits inside the buffer
92 Int_t fReadBits; // number of bit read
0b3c7dfc 93 UInt_t fPos; // current file position
a79660fb 94 Int_t fVerbose; // verbose level (0 silent, !=0 output messages)
0b3c7dfc 95 UInt_t fFillWords; // Number of hexadecimally words (2AA pattern) inside a pad data block
c9bd9d3d 96 char* fPointBuffer; //pointer to the compressed raw data
2e9f335b 97 ClassDef(AliTPCCompression,1)