]>
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 | // Huffman Table associated classes for set:TPC // | |
6 | /////////////////////////////////////////////////// | |
7 | ||
8 | ||
9 | #ifndef AliTPCHUFFMAN_H | |
10 | #define AliTPCHUFFMAN_H | |
11 | class AliTPCBuffer160; | |
12 | ||
13 | class AliTPCHNode: public TObject { | |
14 | public: | |
15 | AliTPCHNode(); //default constructor | |
16 | AliTPCHNode(Int_t symbol, Double_t freq); | |
17 | virtual ~AliTPCHNode() {} | |
18 | AliTPCHNode(const AliTPCHNode &source); // copy constructor | |
19 | AliTPCHNode& operator=(const AliTPCHNode &source); // ass. op. | |
20 | ||
21 | Bool_t IsSortable() const{return kTRUE;} | |
22 | Int_t Compare(const TObject *obj) const; | |
23 | void SetLeft(AliTPCHNode* point){fLeft=point;} | |
24 | void SetRight(AliTPCHNode* point){fRight=point;} | |
25 | AliTPCHNode* GetRight()const{return fRight;} | |
26 | AliTPCHNode* GetLeft()const{return fLeft;} | |
27 | void SetSymbol(Int_t sym){fSymbol=sym;} | |
28 | void SetFrequency(Double_t freq){fFrequency=freq;} | |
29 | Double_t GetFrequency()const{return fFrequency;} | |
30 | Int_t GetSymbol()const{return fSymbol;} | |
31 | ||
32 | private: | |
33 | Int_t fSymbol; // Symbols | |
34 | Double_t fFrequency; // Frequency of the Symbol | |
35 | AliTPCHNode *fLeft; // Pointer to the left son | |
36 | AliTPCHNode *fRight; // pointer to the right son | |
37 | ClassDef(AliTPCHNode,1) | |
38 | }; | |
39 | ///////////////////////////////////////////////////////////////////////////////////////////////// | |
40 | class AliTPCHTable: public TObject{ | |
41 | public: | |
42 | AliTPCHTable(); | |
43 | AliTPCHTable(Int_t size); | |
44 | virtual ~AliTPCHTable(); | |
45 | AliTPCHTable(const AliTPCHTable &source); // copy constructor | |
46 | AliTPCHTable& operator=(const AliTPCHTable &source); // ass. op. | |
47 | ||
48 | Int_t Size()const {return fSize;} | |
49 | UChar_t* CodeLen()const {return fCodeLen;} | |
50 | Double_t* Code()const {return fCode;} | |
51 | Short_t* Sym()const {return fSym;} | |
52 | void SetCodeLen(UChar_t len,Int_t val); | |
53 | void SetCode(Double_t code,Int_t val); | |
54 | TObjArray* HNodes()const {return fHNodes;} | |
55 | void PrintTable()const; | |
56 | //This method builds the Huffman tree starting from the frequncies that are | |
57 | //strored temporary in fCode array | |
58 | Int_t BuildHTable(); | |
59 | //This method returns the number of words stored in the fSym array | |
60 | ULong_t GetWordsNumber()const{return fNum;} | |
61 | //This method increase by one the frequency of each value that is present | |
62 | //in the specified file | |
63 | Int_t GetFrequencies(const char* fname); | |
64 | //This method increase by one the frequency of a given value | |
65 | Int_t SetFrequency(const Int_t Val); | |
66 | //This method strores the frequency of the symbol in a text file | |
67 | Int_t StoreFrequencies(const char *fname); | |
68 | void CompleteTable(Int_t k); | |
69 | Double_t GetEntropy()const; | |
70 | void SetVerbose(Int_t val){fVerbose=val;} | |
71 | //Method to set directly a frequency | |
72 | Int_t SetValFrequency(const Int_t Val,Double_t Value); | |
73 | private: | |
74 | //This method executes the pre-order visit of an Huffman tree and calculates the | |
75 | //codeword for each leaf | |
76 | Bool_t SpanTree(AliTPCHNode*start, ULong_t code, UChar_t len); | |
77 | void ResetHNodes(); //Reset the array fHNodes but not delete the remuved objects | |
78 | void ClearTable(); //Reset the table | |
79 | Int_t fSize; // size of the arrays | |
80 | UChar_t *fCodeLen; //![fSize] number of bits array | |
81 | Double_t *fCode; //![fSize] coded symbols array | |
82 | ||
83 | Short_t *fSym; //![fSize] array of input symbols | |
84 | TObjArray *fHNodes; // array of nodes | |
85 | Int_t fNnodes; // number of nodes | |
86 | ULong_t fNum; // number of words | |
87 | Int_t fVerbose; | |
88 | ClassDef(AliTPCHTable,1) //Huffman Table object for set:TPC | |
89 | }; | |
90 | #endif |