00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 #ifndef FASTSHOWER_PHI_H 00032 #define FASTSHOWER_PHI_H 00033 //#include "GaudiKernel/MsgStream.h" 00034 00035 class MsgStream; 00036 00037 namespace FastShower{ 00038 class Phi; 00040 MsgStream& operator << ( MsgStream&, const Phi& ) ; 00041 MsgStream& operator << ( MsgStream&, const Phi* const) ; 00042 00047 class Phi { 00048 00049 private: 00050 00051 double m_val ; 00052 00053 void reduce() { 00054 while( m_val > s_upperLimit ) { m_val -= s_range ; } 00055 while( m_val <= s_lowerLimit ) { m_val += s_range ; } 00056 } 00057 static const double s_upperLimit; 00058 static const double s_lowerLimit; 00059 static const double s_range; 00060 00061 00062 00063 public: 00064 00065 // Constructors: 00066 Phi() { this->m_val = 0. ; } 00067 Phi( double init ) { this->m_val = init ; this->reduce() ; } 00068 Phi( const Phi& src ) { this->m_val = src.m_val ; } 00069 00070 // Arithmetic: 00071 00072 Phi& operator= ( const Phi& rhs ) { 00073 this->m_val = rhs.m_val; 00074 return *this; 00075 } 00076 00077 Phi& operator+= ( Phi& rhs ) { 00078 this->m_val += rhs.m_val ; 00079 reduce() ; 00080 return *this; 00081 } 00082 00083 Phi& operator-= ( Phi& in ) { 00084 this->m_val -= in.m_val; 00085 reduce() ; 00086 return *this; 00087 } 00088 00089 Phi operator+ ( Phi& in ) const { 00090 Phi result( this->m_val + in.m_val ) ; 00091 return result ; 00092 } 00093 00094 Phi operator- ( Phi& in ) const { 00095 Phi result(this->m_val - in.m_val ) ; 00096 return result ; 00097 } 00098 00099 // boolean 00100 bool operator< ( Phi& in ) const { return this->m_val < in.m_val ; } 00101 bool operator> ( Phi& in ) const { return this->m_val > in.m_val ; } 00102 00103 // Conversions 00104 operator double() const { return this->m_val ; } 00105 // debug 00106 double lowerLimit() const {return s_lowerLimit;} 00107 double upperLimit() const {return s_upperLimit;} 00108 double range () const {return s_range;} 00109 double val() const {return m_val;} 00110 }; 00111 } 00112 #endif 00113