]>
Commit | Line | Data |
---|---|---|
2e9f335b | 1 | /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * |
2 | * See cxx source for full Copyright notice */ | |
3 | ||
4 | ////////////////////////////////////////////////////// | |
5 | // Utility Class for Compression and Decompression // | |
6 | ////////////////////////////////////////////////////// | |
7 | ||
8 | ||
9 | #ifndef AliTPCCOMPRESSION_H | |
10 | #define AliTPCCOMPRESSION_H | |
11 | ||
12 | class AliTPCHNode; | |
13 | class AliTPCHTable; | |
14 | ||
15 | class AliTPCCompression:public TObject{ | |
16 | public: | |
17 | AliTPCCompression(); | |
18 | virtual ~AliTPCCompression(){;} | |
19 | AliTPCCompression(const AliTPCCompression &source); // copy constructor | |
20 | AliTPCCompression& operator=(const AliTPCCompression &source); // ass. op. | |
21 | //This method is used to compress the data store in the altro format file using specific tables | |
22 | //calculate on a particular file that has to be compressed | |
23 | //The tables are stored at the beginning of the compressed file | |
24 | Int_t CompressData(AliTPCHTable* table[],Int_t NumTable,const char* fSource,const char* fDest); | |
25 | //This methos is used to compress an Altro file using a set of general table previously calculated and | |
26 | //stored as a sequence of txt file. In this case the tables are not stored in the compressed file | |
27 | Int_t CompressDataOptTables(Int_t NumTable,const char* fSource,const char* fDest); | |
28 | //This method is used tho decompress a file compressed using the CompressData method | |
29 | Int_t DecompressData(Int_t NumTables,const char* fname,char* fDest="SourceDecompressed.dat"); | |
30 | //This methos is used yo decompress a file compressed using the CompressDataOptTable method | |
31 | //It expects a set of table used for compressing the file in the same direcotory of the compressed file | |
32 | Int_t DecompressDataOptTables(Int_t NumTables,const char* fname,char* fDest="SourceDecompressed.dat"); | |
33 | //This method is used to compute the frequencies of the symbols in the source file | |
34 | Int_t FillTables(const char* fSource,AliTPCHTable* table[],const Int_t NumTables); | |
35 | //This method is used to create and store the tables | |
36 | Int_t CreateTables(const char* fSource,const Int_t NumTables); | |
37 | //This method is used to set up the verbose level | |
38 | // 0 ==> No output messages are displayed | |
39 | // 1 ==> Some output messages are displayed during the running | |
40 | // 2 ==> A complete output is displayed | |
41 | void SetVerbose(Int_t val){fVerbose=val;} | |
42 | //This method is used to read an Altro file and generate a text file containing the same information | |
43 | //It's is useful for debugging | |
44 | void ReadAltroFormat(char* fileOut,char* fileIn); | |
45 | private: | |
46 | //This method is used to store an array of tables in a sequence of binary files | |
47 | //Each file contains the Size of the table (number of words) and for each word contains the corrispondent | |
48 | //codeword and codelength | |
49 | Int_t StoreTables(AliTPCHTable* table[],const Int_t NumTable); | |
50 | //This method is used to retrieve an array of tables from a sequence of binaruy files created using | |
51 | //the previous method | |
52 | Int_t RetrieveTables(AliTPCHTable* table[],Int_t NumTable); | |
53 | //This method is used to delete an Huffamn tree | |
54 | void DeleteHuffmanTree(AliTPCHNode* node); | |
55 | //This method realizes an in order visit of a binary tree | |
56 | void VisitHuffmanTree(AliTPCHNode* node); | |
57 | //This methos is used to create one or more Huffman tree strarting from one or more tables | |
58 | //It is used in the decompression phase (DecompressData()) | |
59 | void CreateTrees(AliTPCHNode *RootNode[],const Int_t NumTables); | |
60 | //This method is like the previous one but the tables are stored in binary files | |
61 | //It is used in the decompression phase (DecompressDataOptTables()) | |
62 | void CreateTreesFromFile(AliTPCHNode *RootNode[],const Int_t NumTables); | |
63 | //This method is used to deduce which is the next table that as to be used to interpret the next value | |
64 | //reading the Altro format | |
65 | void NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count); | |
66 | //This method is used to store a value in the compressed file | |
67 | void StoreValue(ULong_t val,UChar_t len); | |
68 | //This methos is used to get the specular value of a given value | |
69 | //for istance the specular value of 12345 is 54321 | |
70 | ULong_t Mirror(ULong_t val,UChar_t len); | |
71 | //This method is used to complete and store the buffer in the output file when it isn't completely full | |
72 | void Flush(); | |
73 | //this method is used to read a specified number of bits from the compressed file | |
74 | ULong_t ReadWord(Int_t NumberOfBit); | |
75 | //This method is used to read the trailer | |
76 | void ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber); | |
77 | //This method is used to get a decoded word from the compressed file | |
78 | ULong_t GetDecodedWord(AliTPCHNode* root); | |
79 | ||
80 | fstream f; // f is the logical name for the compressed and uncompressed file | |
81 | ofstream stat; // Statistics | |
82 | ULong_t fBuffer; // buffer | |
83 | Int_t fDimBuffer; // buffer dimension (32 bit) | |
84 | Int_t fFreeBitsBuffer; // number of free bits inside the buffer | |
85 | Int_t fReadBits; // number of bit read | |
86 | ULong_t fPos; // current file position | |
87 | Int_t fVerbose; // verbose level | |
88 | ULong_t fFillWords; | |
89 | ClassDef(AliTPCCompression,1) | |
90 | }; | |
91 | #endif |