]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCompression.h
Included primary vertex rec. with pixels or tracks in pp (A.Dainese)
[u/mrichter/AliRoot.git] / TPC / AliTPCCompression.h
1 /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
2  * See cxx source for full Copyright notice                               */
3
4 //////////////////////////////////////////////////////
5 // 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   Int_t  CompressData(AliTPCHTable* table[],Int_t NumTable,const char* fSource,const char* fDest);
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
25   Int_t  CompressDataOptTables(Int_t NumTable,const char* fSource,const char* fDest);
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
28   Int_t  DecompressData(Int_t NumTables,const char* fname,char* fDest="SourceDecompressed.dat");
29   //This method is used tho decompress a file compressed using the CompressData method
30   Int_t  DecompressDataOptTables(Int_t NumTables,const char* fname,char* fDest="SourceDecompressed.dat");
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
33   Int_t  FillTables(const char* fSource,AliTPCHTable* table[],const Int_t NumTables);
34   //This method is used to compute the frequencies of the symbols in the source file
35   Int_t  CreateTables(const char* fSource,const Int_t NumTables);
36   //This method is used to create and store the tables 
37   void   SetVerbose(Int_t val){fVerbose=val;}
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
42   void   ReadAltroFormat(char* fileOut,char* fileIn)const;
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
45
46  private:
47   Int_t   StoreTables(AliTPCHTable* table[],const Int_t NumTable);
48   //This method is used to store an array of tables in a sequence of binary files
49   //Each file contains the Size of the table (number of words) and for each word contains the correspondent 
50   //codeword and codelength
51   Int_t   RetrieveTables(AliTPCHTable* table[],Int_t NumTable);
52   //This method is used to retrieve an array of tables from a sequence of binary files created using 
53   //the previous method 
54   void    DeleteHuffmanTree(AliTPCHNode* node);
55   //This method is used to delete an Huffman tree
56   void    VisitHuffmanTree(AliTPCHNode* node);
57   //This method realizes an in order visit of a binary tree
58   void    CreateTrees(AliTPCHNode *RootNode[],const Int_t NumTables);
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);
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())
64   void    NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count)const;
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
67   void    StoreValue(ULong_t val,UChar_t len);
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
72   void    Flush();
73   //This method is used to complete and store the buffer in the output file when it isn't completely full 
74   ULong_t ReadWord(Int_t NumberOfBit);
75   //this method is used to read a specified number of bits from the compressed file
76   void    ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumber);
77   //This method is used to read the trailer 
78   ULong_t GetDecodedWord(AliTPCHNode* root);
79   //This method is used to get a decoded word from the compressed file
80
81
82   fstream f;                  // f is the logical name for the compressed and uncompressed file
83   ofstream fStat;             // Logical name for the Statistics file
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
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 
91   ClassDef(AliTPCCompression,1)
92 };
93 #endif