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