1 /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
4 ///////////////////////////////////////////////////
5 // Huffman Table associated classes for set:TPC //
6 ///////////////////////////////////////////////////
10 #define AliTPCHTABLE_H
17 class AliTPCHTable: public TObject{
20 AliTPCHTable(Int_t size);
21 virtual ~AliTPCHTable();
22 AliTPCHTable(const AliTPCHTable &source); // copy constructor
23 AliTPCHTable& operator=(const AliTPCHTable &source); // ass. op.
25 Int_t Size()const {return fSize;}
26 UChar_t* CodeLen()const {return fCodeLen;}
27 Double_t* Code()const {return fCode;}
28 Short_t* Sym()const {return fSym;}
29 void SetCodeLen(UChar_t len,Int_t val);
30 void SetCode(Double_t code,Int_t val);
31 TObjArray* HNodes()const {return fHNodes;}
32 void PrintTable()const;
33 //This method builds the Huffman tree starting from the frequencies that are
34 //strored temporary in fCode array
36 //This method returns the number of words stored in the fSym array
37 UInt_t GetWordsNumber()const{return fNum;}
38 //This method increase by one the frequency of each value that is present
39 //in the specified file
40 Int_t GetFrequencies(const char* fname);
41 //This method increase by one the frequency of a given value
42 Int_t SetFrequency(Int_t Val);
43 //This method stores the frequency of the symbol in a text file
44 Int_t StoreFrequencies(const char *fname)const;
45 void CompleteTable(Int_t k);
46 Double_t GetEntropy()const;
47 void SetVerbose(Int_t val){fVerbose=val;}
48 //Method to set directly a frequency
49 Int_t SetValFrequency(Int_t Val,Double_t Value);
50 Int_t NormalizeFrequencies();
52 //This method executes the pre-order visit of an Huffman tree and calculates the
53 //codeword for each leaf
54 Bool_t SpanTree(AliTPCHNode*start, UInt_t code, UChar_t len);
55 void ResetHNodes(); //Reset the array fHNodes but not delete the removed objects
56 void ClearTable(); //Reset the table
57 Int_t fSize; //size of the arrays fCodelen and fCode
58 UChar_t *fCodeLen; //![fSize] number of bits array
59 Double_t *fCode; //![fSize] coded symbols array
61 Short_t *fSym; //![fSize] array of input symbols
62 TObjArray *fHNodes; // array of nodes
63 Int_t fNnodes; // number of nodes
64 UInt_t fNum; // number of words
65 Int_t fVerbose; // if fVerbose== 0 no output messages; fVerbose!=0 output messages are printed out
66 ClassDef(AliTPCHTable,1) //Huffman Table object for set:TPC