CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
Geom::Phi< T > Class Template Reference

#include <Phi.h>

Public Member Functions

T degrees () const
 
template<class T1 >
 operator Phi< T1 > ()
 Template argument conversion. More...
 
 operator T () const
 conversion operator makes transparent use possible. More...
 
Phioperator*= (const T &a)
 
Phioperator+= (const T &a)
 Standard arithmetics. More...
 
Phioperator+= (const Phi &a)
 
Phioperator-= (const T &a)
 
Phioperator-= (const Phi &a)
 
Phioperator/= (const T &a)
 
 Phi ()
 Default constructor does not initialise - just as double. More...
 
 Phi (const T &val)
 
T phi () const
 
T value () const
 Explicit access to value in case implicit conversion not OK. More...
 

Private Member Functions

void normalize ()
 

Private Attributes

T theValue
 

Detailed Description

template<class T>
class Geom::Phi< T >

A class for azimuthal angle represantation and algebra. The use of Phi<T> is tranparant due to the implicit conversion to T Constructs like cos(phi) work as with float or double. The difference with respect to built-in types is that Phi is kept in the range (-pi, pi], and this is consistently implemented in aritmetic operations. In other words, Phi implements "modulo(2 pi)" arithmetics.

Definition at line 20 of file Phi.h.

Constructor & Destructor Documentation

template<class T>
Geom::Phi< T >::Phi ( )
inline

Default constructor does not initialise - just as double.

Definition at line 24 of file Phi.h.

24 {}
template<class T>
Geom::Phi< T >::Phi ( const T val)
inlineexplicit

Constructor from T, does not provide automatic conversion. The constructor provides range checking and normalization, e.g. the value of Pi(2*pi()+1) is 1

Definition at line 29 of file Phi.h.

29 : theValue(val) { normalize();}
void normalize()
Definition: Phi.h:60
T theValue
Definition: Phi.h:58

Member Function Documentation

template<class T>
T Geom::Phi< T >::degrees ( ) const
inline

Definition at line 54 of file Phi.h.

Referenced by CSCRecHit2DValidation::analyze(), and TrackerHitAnalyzer::analyze().

54 { return theValue*180./pi();}
T theValue
Definition: Phi.h:58
double pi()
Definition: Pi.h:31
template<class T>
void Geom::Phi< T >::normalize ( )
inlineprivate

Definition at line 60 of file Phi.h.

Referenced by Geom::Phi< float >::operator*=(), Geom::Phi< float >::operator+=(), Geom::Phi< float >::operator-=(), Geom::Phi< float >::operator/=(), and Geom::Phi< float >::Phi().

60  {
61  if( theValue > twoPi() || theValue < -twoPi()) {
62  theValue = fmod( theValue, (T) twoPi());
63  }
64  if (theValue <= -pi()) theValue += twoPi();
65  if (theValue > pi()) theValue -= twoPi();
66  }
T theValue
Definition: Phi.h:58
double pi()
Definition: Pi.h:31
double twoPi()
Definition: Pi.h:32
long double T
template<class T>
template<class T1 >
Geom::Phi< T >::operator Phi< T1 > ( )
inline

Template argument conversion.

Definition at line 35 of file Phi.h.

35 { return Phi<T1>(theValue);}
T theValue
Definition: Phi.h:58
template<class T>
Geom::Phi< T >::operator T ( ) const
inline

conversion operator makes transparent use possible.

Definition at line 32 of file Phi.h.

References Geom::Phi< T >::theValue.

32 { return theValue;}
T theValue
Definition: Phi.h:58
template<class T>
Phi& Geom::Phi< T >::operator*= ( const T a)
inline

Definition at line 50 of file Phi.h.

50 {theValue*=a; normalize(); return *this;}
void normalize()
Definition: Phi.h:60
T theValue
Definition: Phi.h:58
double a
Definition: hdecay.h:121
template<class T>
Phi& Geom::Phi< T >::operator+= ( const T a)
inline

Standard arithmetics.

Definition at line 44 of file Phi.h.

44 {theValue+=a; normalize(); return *this;}
void normalize()
Definition: Phi.h:60
T theValue
Definition: Phi.h:58
double a
Definition: hdecay.h:121
template<class T>
Phi& Geom::Phi< T >::operator+= ( const Phi< T > &  a)
inline

Definition at line 45 of file Phi.h.

Referenced by Geom::Phi< float >::operator+=().

45 {return operator+=(a.value());}
Phi & operator+=(const T &a)
Standard arithmetics.
Definition: Phi.h:44
double a
Definition: hdecay.h:121
template<class T>
Phi& Geom::Phi< T >::operator-= ( const T a)
inline

Definition at line 47 of file Phi.h.

47 {theValue-=a; normalize(); return *this;}
void normalize()
Definition: Phi.h:60
T theValue
Definition: Phi.h:58
double a
Definition: hdecay.h:121
template<class T>
Phi& Geom::Phi< T >::operator-= ( const Phi< T > &  a)
inline

Definition at line 48 of file Phi.h.

Referenced by Geom::Phi< float >::operator-=().

48 {return operator-=(a.value());}
Phi & operator-=(const T &a)
Definition: Phi.h:47
double a
Definition: hdecay.h:121
template<class T>
Phi& Geom::Phi< T >::operator/= ( const T a)
inline

Definition at line 52 of file Phi.h.

52 {theValue/=a; normalize(); return *this;}
void normalize()
Definition: Phi.h:60
T theValue
Definition: Phi.h:58
double a
Definition: hdecay.h:121
template<class T>
T Geom::Phi< T >::phi ( ) const
inline
template<class T>
T Geom::Phi< T >::value ( ) const
inline

Member Data Documentation

template<class T>
T Geom::Phi< T >::theValue
private