]>
Commit | Line | Data |
---|---|---|
1 | #ifndef ALITRDTRAPALU_H\r | |
2 | #define ALITRDTRAPALU_H\r | |
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 | |
14 | #include <TObject.h>\r | |
15 | \r | |
16 | class AliTRDtrapAlu:public TObject {\r | |
17 | \r | |
18 | public:\r | |
19 | \r | |
20 | AliTRDtrapAlu();\r | |
21 | //AliTRDtrapAlu(AliTRDtrapAlu& bin); //copy constructor\r | |
22 | virtual ~AliTRDtrapAlu();\r | |
23 | \r | |
24 | \r | |
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 | |
27 | \r | |
28 | Int_t GetValue () const { \r | |
29 | // return the value \r | |
30 | return fValue;\r | |
31 | }\r | |
32 | \r | |
33 | Int_t GetSignedValue ()const{ \r | |
34 | // return the value with its sign\r | |
35 | if(fSigned == kFALSE) return fValue;\r | |
36 | else return fValue*(-1);\r | |
37 | }\r | |
38 | \r | |
39 | Int_t GetValuePre ()const{\r | |
40 | // return value of pre-comma part as integer\r | |
41 | Int_t valPre = fValue>>fPostCom;\r | |
42 | return valPre; \r | |
43 | }\r | |
44 | \r | |
45 | Double_t GetValueWhole() const; \r | |
46 | \r | |
47 | Int_t GetPre()const{\r | |
48 | // return nr of pre-comma bits\r | |
49 | return fPreCom;\r | |
50 | }\r | |
51 | \r | |
52 | Int_t GetPost()const{\r | |
53 | // return nr of past-comma bits\r | |
54 | return fPostCom;\r | |
55 | }\r | |
56 | \r | |
57 | Bool_t GetSign()const{\r | |
58 | // return true if signed\r | |
59 | if(fSigned == kTRUE) return kTRUE;\r | |
60 | return kFALSE;\r | |
61 | }\r | |
62 | \r | |
63 | Bool_t CheckUSize(const Int_t& val)const{\r | |
64 | // compare value to the upper restriction\r | |
65 | if(val>fuRestriction) return kFALSE;\r | |
66 | return kTRUE;\r | |
67 | }\r | |
68 | \r | |
69 | Bool_t CheckLSize(const Int_t& val)const{\r | |
70 | // compare value to the lower restriction\r | |
71 | if(val<flRestriction) return kFALSE;\r | |
72 | return kTRUE;\r | |
73 | }\r | |
74 | \r | |
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 | |
77 | fValue = formVal;\r | |
78 | //fValue = fValue & (LUT(fPreCom + fPostCom) - 1); // no cut-off wanted\r | |
79 | } \r | |
80 | \r | |
81 | void SetSign(const Int_t& s){\r | |
82 | // sets the sign\r | |
83 | if(s >= 0) fSigned = kFALSE;\r | |
84 | if(s < 0) fSigned = kTRUE;\r | |
85 | }\r | |
86 | \r | |
87 | void WriteWord(); \r | |
88 | \r | |
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 | |
92 | \r | |
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 | |
97 | \r | |
98 | protected:\r | |
99 | \r | |
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 | |
101 | \r | |
102 | //the following two functions encapsulate global static members; can only be changed by member functions (visibility only inside class)\r | |
103 | \r | |
104 | Int_t MakePower(const Int_t& base=1,const Int_t& exponent=1)const;\r | |
105 | \r | |
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 | |
111 | \r | |
112 | static Int_t LUT(const Int_t& index);\r | |
113 | \r | |
114 | const Int_t& Min(const Int_t& comp1, const Int_t& comp2)const{\r | |
115 | // return the minimum\r | |
116 | if (comp1 <= comp2) return comp1;\r | |
117 | return comp2;\r | |
118 | }\r | |
119 | \r | |
120 | const Int_t& Max(const Int_t& comp1, const Int_t& comp2)const{\r | |
121 | // return the maximum\r | |
122 | if (comp1 >= comp2) return comp1;\r | |
123 | return comp2;\r | |
124 | }\r | |
125 | \r | |
126 | //static AliTRDtrapAlu fAlu;\r | |
127 | \r | |
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 | |
134 | \r | |
135 | ClassDef(AliTRDtrapAlu,1) // TRAP-ALU\r | |
136 | \r | |
137 | };\r | |
138 | #endif\r | |
139 | \r | |
140 | \r |