]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrapAlu.h
Changing fabs into TMath::Abs
[u/mrichter/AliRoot.git] / TRD / AliTRDtrapAlu.h
1 #ifndef ALITRDTRAPALU_H\r
2 #define ALITRDTRAPALU_H\r
3 #include <TObject.h>\r
4 \r
5 class AliTRDtrapAlu:public TObject {\r
6 \r
7 //class AliTRDtrapAlu {\r
8  \r
9  public:\r
10    \r
11                AliTRDtrapAlu();\r
12                //AliTRDtrapAlu(AliTRDtrapAlu& bin); //copy constructor\r
13  virtual      ~AliTRDtrapAlu();\r
14 \r
15 \r
16  void Init(const Int_t& precom=10, const Int_t& postcom=2, const Int_t& lRestriction = -1, const Int_t& uRestriction = -1);\r
17       \r
18 \r
19 \r
20 Int_t   GetValue ()const{ \r
21     // return the value \r
22     return fValue;\r
23  }\r
24 \r
25 Int_t   GetSignedValue ()const{  \r
26     // return the value with its sign\r
27     if(fSigned == kFALSE) return fValue;\r
28     else return fValue*(-1);\r
29  }\r
30 \r
31 Int_t   GetValuePre ()const{\r
32     // return value of pre-comma part as integer\r
33     Int_t valPre = fValue>>fPostCom;\r
34     return valPre;   \r
35 }\r
36 \r
37 Double_t GetValueWhole() const;  \r
38    \r
39 \r
40 Int_t   GetPre()const{\r
41     // return nr of pre-comma bits\r
42     return fPreCom;\r
43 }\r
44 \r
45 Int_t   GetPost()const{\r
46     // return nr of past-comma bits\r
47     return fPostCom;\r
48 }\r
49 \r
50 Bool_t  GetSign()const{\r
51     // return true if signed\r
52     if(fSigned == kTRUE) return kTRUE;\r
53     return kFALSE;\r
54 }\r
55 \r
56       \r
57 Bool_t  CheckUSize(const Int_t& val)const{\r
58     // compare value to the upper restriction\r
59     if(val>fuRestriction) return kFALSE;\r
60     return kTRUE;\r
61 }\r
62 \r
63 Bool_t  CheckLSize(const Int_t& val)const{\r
64     // compare value to the lower restriction\r
65     if(val<flRestriction) return kFALSE;\r
66     return kTRUE;\r
67 }\r
68 \r
69 \r
70 void AssignFormatted(const Int_t& formVal){ \r
71 // assign a value with proper format; assigns formVal directly to fValue; better not use explicitely\r
72     fValue  = formVal;\r
73     //fValue  = fValue & (LUT(fPreCom + fPostCom) - 1); // no cut-off wanted\r
74\r
75 \r
76 void SetSign(const Int_t& s){\r
77     // sets the sign\r
78     if(s >= 0) fSigned = kFALSE;\r
79     if(s <  0) fSigned = kTRUE;\r
80 }\r
81 \r
82 \r
83 void   WriteWord();  \r
84 \r
85 \r
86 AliTRDtrapAlu& AssignInt(const  Int_t& first);     // in case a decimal integer is assigned to a binary; \r
87 AliTRDtrapAlu& AssignDouble(const  Double_t& first);  // change "Double_t" into "Float_t"\r
88 AliTRDtrapAlu& operator=(const AliTRDtrapAlu& binary);\r
89        \r
90 AliTRDtrapAlu& operator+(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
91 \r
92 AliTRDtrapAlu& operator-(AliTRDtrapAlu& binary);\r
93 \r
94 AliTRDtrapAlu& operator*(AliTRDtrapAlu& binary);\r
95 \r
96 AliTRDtrapAlu& operator/(AliTRDtrapAlu& binary);\r
97       \r
98 \r
99 \r
100 \r
101 \r
102 protected:\r
103 \r
104 // 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
105 \r
106 \r
107 //the following two functions encapsulate global static members; can only be changed by member functions (visibility only inside class)\r
108 \r
109 \r
110  \r
111  \r
112  Int_t  MakePower(const Int_t& base=1,const  Int_t& exponent=1)const;\r
113 \r
114 \r
115  static AliTRDtrapAlu& Mem() { \r
116 // a global instance of the class, which is only defined once\r
117    static AliTRDtrapAlu fAuxiliary;\r
118    return fAuxiliary;\r
119  }\r
120 \r
121 \r
122  static Int_t LUT(const Int_t& index);\r
123        \r
124 \r
125 \r
126        \r
127 const Int_t&  Min(const Int_t& comp1, const Int_t& comp2)const{\r
128     // return the minimum\r
129     if (comp1 <= comp2) return comp1;\r
130     return comp2;\r
131 }\r
132 \r
133 const Int_t&  Max(const Int_t& comp1, const Int_t& comp2)const{\r
134     // return the maximum\r
135     if (comp1 >= comp2) return comp1;\r
136     return comp2;\r
137 }\r
138 \r
139 \r
140        Int_t    fValue;          // the value in integers\r
141        Int_t    fPreCom;         // number of pre-comma bits\r
142        Int_t    fPostCom;        // number of past-comma bits\r
143        Int_t    fuRestriction;   // the upper restriction for the value\r
144        Int_t    flRestriction;   // the lower restriction for the value\r
145        Bool_t   fSigned;         // signed value? \r
146       \r
147       \r
148        \r
149 \r
150 \r
151 \r
152 \r
153 ClassDef(AliTRDtrapAlu,1)\r
154 };\r
155 \r
156 \r
157 \r
158 #endif\r
159 \r
160 \r