]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliTPCCompression.h
fix some coding violations.
[u/mrichter/AliRoot.git] / RAW / 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 #ifdef __CINT__
13 class fstream;
14 #else
15 #include "Riostream.h"
16 #endif
17
18 class AliTPCHNode;
19 class AliTPCHTable;
20
21 class 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.
27   Int_t  CompressDataOptTables(Int_t NumTable,const char* fSource,const char* fDest);
28   //This method is used to compress an Altro file using a set of general table previously calculated  and
29   //stored as a sequence of txt file. 
30   Int_t  DecompressDataOptTables(Int_t NumTables,const char* fname,const 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  Decompress(AliTPCHNode *RootNode[],Int_t NumTables,char* PointBuffer,UInt_t BufferSize,UShort_t out[],UInt_t &dim);
34   //This method is used to decompress data stored in a char* buffer
35   Int_t  FillTables(const char* fSource,AliTPCHTable* table[],Int_t NumTables);
36   //This method is used to compute the frequencies of the symbols in the source file
37   Int_t  CreateTables(const char* fSource,Int_t NumTables);
38   //This method is used to create and store the tables 
39   Int_t  CreateTableFormula(Double_t beta,UInt_t  M,Int_t dim,Int_t Type);
40   //This method is used to create and store the Bunch length or Time Gap Table using a formula
41   void   SetVerbose(Int_t val){fVerbose=val;}
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
46   void   ReadAltroFormat(char* fileOut,char* fileIn)const;
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
49   Int_t  CreateTablesFromTxtFiles(Int_t NumTable);
50   //This method creates a set of binary tables starting from a set of txt tables
51   Int_t  DestroyTables(AliTPCHNode *RootNode[],Int_t NumTables);
52   //This methods is use to deallocate the memory used by Huffman trees
53   Int_t  CreateTreesFromFile(AliTPCHNode *RootNode[],Int_t NumTables);
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())
56  private:
57   Int_t   StoreTables(AliTPCHTable* table[],const Int_t NumTable);
58   //This method is used to store an array of tables in a sequence of binary files
59   //Each file contains the Size of the table (number of words) and for each word contains the correspondent 
60   //codeword and codelength
61   Int_t   RetrieveTables(AliTPCHTable* table[],Int_t NumTable);
62   //This method is used to retrieve an array of tables from a sequence of binary files created using 
63   //the previous method 
64   void    DeleteHuffmanTree(AliTPCHNode* node);
65   //This method is used to delete an Huffman tree
66   void    VisitHuffmanTree(AliTPCHNode* node);
67   //This method realizes an in order visit of a binary tree
68   void    NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count)const;
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
71   void    StoreValue(UInt_t val,UChar_t len);
72   //This method is used to store a value in the compressed file 
73   UInt_t  Mirror(UInt_t val,UChar_t len)const;
74   //This method is used to get the specular value of a given value
75   //for instance the specular value of 12345 is 54321
76   void    Flush();
77   //This method is used to complete and store the buffer in the output file when it isn't completely full 
78   UInt_t  ReadWord(Int_t NumberOfBit);
79   //this method is used to read a specified number of bits from the compressed file
80   UInt_t  ReadWordBuffer(Int_t NumberOfBit);
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);
83   //This method is used to read the trailer 
84   UInt_t GetDecodedWord(AliTPCHNode* root,Bool_t Memory);
85   //This method is used to get a decoded word from the compressed file
86
87   fstream f;                  // f is the logical name for the compressed and uncompressed file
88   ofstream fStat;             // Logical name for the Statistics file
89   UInt_t  fBuffer;            // buffer 
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
93   UInt_t  fPos;               // current file position
94   Int_t   fVerbose;           // verbose level (0 silent, !=0 output messages)
95   UInt_t  fFillWords;         // Number of hexadecimally words (2AA pattern) inside a pad data block 
96   char*   fPointBuffer;       //pointer to the compressed raw data
97   ClassDef(AliTPCCompression,1)
98 };
99 #endif