test
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(), TrackerHitAnalyzer::analyze(), Geant4ePropagator::debugReportPlaneSetup(), and Geant4ePropagator::debugReportTrackState().

54 { return theValue*T(180.)/pi();}
T theValue
Definition: Phi.h:58
double pi()
Definition: Pi.h:31
long double T
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 = std::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

Explicit access to value in case implicit conversion not OK.

Definition at line 38 of file Phi.h.

Referenced by Types.int32::__nonzero__(), Types.uint32::__nonzero__(), Types.int64::__nonzero__(), Types.uint64::__nonzero__(), Types.double::__nonzero__(), Types.bool::__nonzero__(), Types.string::__nonzero__(), reco::WMuNuCandidate::acop(), EwkMuDQM::analyze(), average.Average::average(), Basic3DVector< long double >::Basic3DVector(), Basic3DVector< align::Scalar >::Basic3DVector(), Vispa.Views.PropertyView.FileProperty::buttonClicked(), Types.string::configValue(), Types.FileInPath::configValue(), Mixins.UsingBlock::dumpPython(), RPCSeedPattern::extropolateStep(), WMuNuValidator::filter(), L1TMuon::GeometryTranslator::getCSCSpecificPoint(), AngleConverter::getGlobalEta(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Mixins.UsingBlock::insertInto(), Types.double::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.FileInPath::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), Types.vstring::insertInto(), Vispa.Views.PropertyView.FileProperty::labelDoubleClicked(), Geom::Phi< float >::operator+=(), Geom::operator-(), Geom::Phi< float >::operator-=(), Geom::operator/(), PhiBorderFinder::PhiBorderFinder(), and RPCSeedPattern::SegmentAlgorithmSpecial().

38 { return theValue;}
T theValue
Definition: Phi.h:58

Member Data Documentation

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