]>
Commit | Line | Data |
---|---|---|
1d93b218 | 1 | #ifndef ALITRDTRAPALU_H\r |
2 | #define ALITRDTRAPALU_H\r | |
23200400 | 3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r |
4 | * See cxx source for full Copyright notice */\r | |
5 | \r | |
6 | /* $Id: AliTRDtrapAlu.h 23387 2008-01-17 17:25:16Z cblume $ */\r | |
7 | \r | |
8 | ////////////////////////////////////////////////////////////////////////////\r | |
9 | // //\r | |
10 | // TRAP-ALU implementation //\r | |
11 | // //\r | |
12 | ////////////////////////////////////////////////////////////////////////////\r | |
13 | \r | |
1d93b218 | 14 | #include <TObject.h>\r |
15 | \r | |
16 | class AliTRDtrapAlu:public TObject {\r | |
1d93b218 | 17 | \r |
18 | public:\r | |
19 | \r | |
20 | AliTRDtrapAlu();\r | |
21 | //AliTRDtrapAlu(AliTRDtrapAlu& bin); //copy constructor\r | |
23200400 | 22 | virtual ~AliTRDtrapAlu();\r |
1d93b218 | 23 | \r |
24 | \r | |
23200400 | 25 | void Init(const Int_t& precom=10, const Int_t& postcom=2\r |
26 | , const Int_t& lRestriction = -1, const Int_t& uRestriction = -1);\r | |
1d93b218 | 27 | \r |
23200400 | 28 | Int_t GetValue () const { \r |
1d93b218 | 29 | // return the value \r |
30 | return fValue;\r | |
23200400 | 31 | }\r |
1d93b218 | 32 | \r |
23200400 | 33 | Int_t GetSignedValue ()const{ \r |
1d93b218 | 34 | // return the value with its sign\r |
35 | if(fSigned == kFALSE) return fValue;\r | |
36 | else return fValue*(-1);\r | |
23200400 | 37 | }\r |
1d93b218 | 38 | \r |
23200400 | 39 | Int_t GetValuePre ()const{\r |
1d93b218 | 40 | // return value of pre-comma part as integer\r |
41 | Int_t valPre = fValue>>fPostCom;\r | |
42 | return valPre; \r | |
23200400 | 43 | }\r |
1d93b218 | 44 | \r |
23200400 | 45 | Double_t GetValueWhole() const; \r |
1d93b218 | 46 | \r |
23200400 | 47 | Int_t GetPre()const{\r |
1d93b218 | 48 | // return nr of pre-comma bits\r |
49 | return fPreCom;\r | |
23200400 | 50 | }\r |
1d93b218 | 51 | \r |
23200400 | 52 | Int_t GetPost()const{\r |
1d93b218 | 53 | // return nr of past-comma bits\r |
54 | return fPostCom;\r | |
23200400 | 55 | }\r |
1d93b218 | 56 | \r |
23200400 | 57 | Bool_t GetSign()const{\r |
1d93b218 | 58 | // return true if signed\r |
59 | if(fSigned == kTRUE) return kTRUE;\r | |
60 | return kFALSE;\r | |
23200400 | 61 | }\r |
62 | \r | |
63 | Bool_t CheckUSize(const Int_t& val)const{\r | |
1d93b218 | 64 | // compare value to the upper restriction\r |
65 | if(val>fuRestriction) return kFALSE;\r | |
66 | return kTRUE;\r | |
23200400 | 67 | }\r |
1d93b218 | 68 | \r |
23200400 | 69 | Bool_t CheckLSize(const Int_t& val)const{\r |
1d93b218 | 70 | // compare value to the lower restriction\r |
71 | if(val<flRestriction) return kFALSE;\r | |
72 | return kTRUE;\r | |
23200400 | 73 | }\r |
1d93b218 | 74 | \r |
23200400 | 75 | void AssignFormatted(const Int_t& formVal){ \r |
76 | // assign a value with proper format; assigns formVal directly to fValue; better not use explicitely\r | |
1d93b218 | 77 | fValue = formVal;\r |
78 | //fValue = fValue & (LUT(fPreCom + fPostCom) - 1); // no cut-off wanted\r | |
23200400 | 79 | } \r |
1d93b218 | 80 | \r |
23200400 | 81 | void SetSign(const Int_t& s){\r |
1d93b218 | 82 | // sets the sign\r |
83 | if(s >= 0) fSigned = kFALSE;\r | |
84 | if(s < 0) fSigned = kTRUE;\r | |
23200400 | 85 | }\r |
1d93b218 | 86 | \r |
23200400 | 87 | void WriteWord(); \r |
1d93b218 | 88 | \r |
23200400 | 89 | AliTRDtrapAlu& AssignInt(const Int_t& first); // in case a decimal integer is assigned to a binary; \r |
90 | AliTRDtrapAlu& AssignDouble(const Double_t& first); // change "Double_t" into "Float_t"\r | |
91 | AliTRDtrapAlu& operator=(const AliTRDtrapAlu& binary);\r | |
1d93b218 | 92 | \r |
23200400 | 93 | AliTRDtrapAlu operator+(const AliTRDtrapAlu& binary); //binary is not const, because in a+(b*c) binary is reference to the object, to which Mem() is also a reference and this object is changed\r |
94 | AliTRDtrapAlu operator-(const AliTRDtrapAlu& binary);\r | |
95 | AliTRDtrapAlu operator*(const AliTRDtrapAlu& binary);\r | |
96 | AliTRDtrapAlu operator/(const AliTRDtrapAlu& binary);\r | |
1d93b218 | 97 | \r |
23200400 | 98 | protected:\r |
1d93b218 | 99 | \r |
23200400 | 100 | // void FastInit(const Int_t& precom = 10, const Int_t& postcom = 2, const Int_t& formVal = 0); //meant to combine definition of format with integer-value assignment; not to apply by user \r |
1d93b218 | 101 | \r |
23200400 | 102 | //the following two functions encapsulate global static members; can only be changed by member functions (visibility only inside class)\r |
1d93b218 | 103 | \r |
23200400 | 104 | Int_t MakePower(const Int_t& base=1,const Int_t& exponent=1)const;\r |
1d93b218 | 105 | \r |
23200400 | 106 | /*static AliTRDtrapAlu& Mem() { \r |
107 | // a global instance of the class, which is only defined once\r | |
108 | static AliTRDtrapAlu fAuxiliary;\r | |
109 | return fAuxiliary;\r | |
110 | }*/\r | |
1d93b218 | 111 | \r |
23200400 | 112 | static Int_t LUT(const Int_t& index);\r |
1d93b218 | 113 | \r |
23200400 | 114 | const Int_t& Min(const Int_t& comp1, const Int_t& comp2)const{\r |
1d93b218 | 115 | // return the minimum\r |
116 | if (comp1 <= comp2) return comp1;\r | |
117 | return comp2;\r | |
23200400 | 118 | }\r |
1d93b218 | 119 | \r |
23200400 | 120 | const Int_t& Max(const Int_t& comp1, const Int_t& comp2)const{\r |
1d93b218 | 121 | // return the maximum\r |
122 | if (comp1 >= comp2) return comp1;\r | |
123 | return comp2;\r | |
23200400 | 124 | }\r |
1d93b218 | 125 | \r |
23200400 | 126 | //static AliTRDtrapAlu fAlu;\r |
1d93b218 | 127 | \r |
23200400 | 128 | Int_t fValue; // the value in integers\r |
129 | Int_t fPreCom; // number of pre-comma bits\r | |
130 | Int_t fPostCom; // number of past-comma bits\r | |
131 | Int_t fuRestriction; // the upper restriction for the value\r | |
132 | Int_t flRestriction; // the lower restriction for the value\r | |
133 | Bool_t fSigned; // signed value? \r | |
1d93b218 | 134 | \r |
23200400 | 135 | ClassDef(AliTRDtrapAlu,1) // TRAP-ALU\r |
1d93b218 | 136 | \r |
1d93b218 | 137 | };\r |
1d93b218 | 138 | #endif\r |
139 | \r | |
140 | \r |