New methods to read and write trailers. New method to read whole altro channel
[u/mrichter/AliRoot.git] / RAW / AliTPCHTable.h
2e9f335b 1/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
5// Huffman Table associated classes for set:TPC //
bea6b2a4 9#ifndef AliTPCHTABLE_H
10#define AliTPCHTABLE_H
a79660fb 11
bea6b2a4 12#include <TObject.h>
2e9f335b 13
bea6b2a4 14class TObjArray;
15class AliTPCHNode;
2e9f335b 16
2e9f335b 17class AliTPCHTable: public TObject{
18 public:
19 AliTPCHTable();
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;
a79660fb 33 //This method builds the Huffman tree starting from the frequencies that are
2e9f335b 34 //strored temporary in fCode array
35 Int_t BuildHTable();
36 //This method returns the number of words stored in the fSym array
0b3c7dfc 37 UInt_t GetWordsNumber()const{return fNum;}
2e9f335b 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
09f6432c 42 Int_t SetFrequency(Int_t Val);
a79660fb 43 //This method stores the frequency of the symbol in a text file
44 Int_t StoreFrequencies(const char *fname)const;
2e9f335b 45 void CompleteTable(Int_t k);
46 Double_t GetEntropy()const;
47 void SetVerbose(Int_t val){fVerbose=val;}
a79660fb 48 //Method to set directly a frequency
09f6432c 49 Int_t SetValFrequency(Int_t Val,Double_t Value);
9f992f70 50 Int_t NormalizeFrequencies();
2e9f335b 51 private:
52 //This method executes the pre-order visit of an Huffman tree and calculates the
53 //codeword for each leaf
0b3c7dfc 54 Bool_t SpanTree(AliTPCHNode*start, UInt_t code, UChar_t len);
a79660fb 55 void ResetHNodes(); //Reset the array fHNodes but not delete the removed objects
2e9f335b 56 void ClearTable(); //Reset the table
a79660fb 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
2e9f335b 60
a79660fb 61 Short_t *fSym; //![fSize] array of input symbols
62 TObjArray *fHNodes; // array of nodes
63 Int_t fNnodes; // number of nodes
0b3c7dfc 64 UInt_t fNum; // number of words
a79660fb 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
2e9f335b 67};
bea6b2a4 68
2e9f335b 69#endif