1 #ifndef ALITRDTRAPALU_H
\r
2 #define ALITRDTRAPALU_H
\r
5 class AliTRDtrapAlu:public TObject {
\r
7 //class AliTRDtrapAlu {
\r
12 //AliTRDtrapAlu(AliTRDtrapAlu& bin); //copy constructor
\r
13 virtual ~AliTRDtrapAlu();
\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
20 Int_t GetValue ()const{
\r
21 // return the value
\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
31 Int_t GetValuePre ()const{
\r
32 // return value of pre-comma part as integer
\r
33 Int_t valPre = fValue>>fPostCom;
\r
37 Double_t GetValueWhole() const;
\r
40 Int_t GetPre()const{
\r
41 // return nr of pre-comma bits
\r
45 Int_t GetPost()const{
\r
46 // return nr of past-comma bits
\r
50 Bool_t GetSign()const{
\r
51 // return true if signed
\r
52 if(fSigned == kTRUE) return kTRUE;
\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
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
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
73 //fValue = fValue & (LUT(fPreCom + fPostCom) - 1); // no cut-off wanted
\r
76 void SetSign(const Int_t& s){
\r
78 if(s >= 0) fSigned = kFALSE;
\r
79 if(s < 0) fSigned = kTRUE;
\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
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
92 AliTRDtrapAlu& operator-(AliTRDtrapAlu& binary);
\r
94 AliTRDtrapAlu& operator*(AliTRDtrapAlu& binary);
\r
96 AliTRDtrapAlu& operator/(AliTRDtrapAlu& binary);
\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
107 //the following two functions encapsulate global static members; can only be changed by member functions (visibility only inside class)
\r
112 Int_t MakePower(const Int_t& base=1,const Int_t& exponent=1)const;
\r
115 static AliTRDtrapAlu& Mem() {
\r
116 // a global instance of the class, which is only defined once
\r
117 static AliTRDtrapAlu fAuxiliary;
\r
122 static Int_t LUT(const Int_t& index);
\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
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
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
153 ClassDef(AliTRDtrapAlu,1)
\r