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
6 /* $Id: AliTRDtrapAlu.h 23387 2008-01-17 17:25:16Z cblume $ */
\r
8 ////////////////////////////////////////////////////////////////////////////
\r
10 // TRAP-ALU implementation //
\r
12 ////////////////////////////////////////////////////////////////////////////
\r
14 #include <TObject.h>
\r
16 class AliTRDtrapAlu:public TObject {
\r
21 //AliTRDtrapAlu(AliTRDtrapAlu& bin); //copy constructor
\r
22 virtual ~AliTRDtrapAlu();
\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
28 Int_t GetValue () const {
\r
29 // return the value
\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
39 Int_t GetValuePre ()const{
\r
40 // return value of pre-comma part as integer
\r
41 Int_t valPre = fValue>>fPostCom;
\r
45 Double_t GetValueWhole() const;
\r
47 Int_t GetPre()const{
\r
48 // return nr of pre-comma bits
\r
52 Int_t GetPost()const{
\r
53 // return nr of past-comma bits
\r
57 Bool_t GetSign()const{
\r
58 // return true if signed
\r
59 if(fSigned == kTRUE) return kTRUE;
\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
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
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
78 //fValue = fValue & (LUT(fPreCom + fPostCom) - 1); // no cut-off wanted
\r
81 void SetSign(const Int_t& s){
\r
83 if(s >= 0) fSigned = kFALSE;
\r
84 if(s < 0) fSigned = kTRUE;
\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
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
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
102 //the following two functions encapsulate global static members; can only be changed by member functions (visibility only inside class)
\r
104 Int_t MakePower(const Int_t& base=1,const Int_t& exponent=1)const;
\r
106 /*static AliTRDtrapAlu& Mem() {
\r
107 // a global instance of the class, which is only defined once
\r
108 static AliTRDtrapAlu fAuxiliary;
\r
112 static Int_t LUT(const Int_t& index);
\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
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
126 //static AliTRDtrapAlu fAlu;
\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
135 ClassDef(AliTRDtrapAlu,1) // TRAP-ALU
\r