CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Geom::Phi< T1, Range > Class Template Reference

#include <Phi.h>

Public Member Functions

T1 degrees () const
 
bool nearEqual (const Phi< T1, Range > &angle, float tolerance=0.001) const
 
bool nearZero (float tolerance=1.0_deg) const
 
template<typename T2 , typename Range1 >
 operator Phi< T2, Range1 > ()
 Template argument conversion. More...
 
 operator T1 () const
 conversion operator makes transparent use possible. More...
 
Phioperator*= (const T1 &a)
 
Phioperator+= (const Phi &a)
 
Phioperator+= (const T1 &a)
 Standard arithmetics. More...
 
Phioperator-= (const Phi &a)
 
Phioperator-= (const T1 &a)
 
Phioperator/= (const T1 &a)
 
 Phi ()
 Default constructor does not initialise - just as double. More...
 
T1 phi () const
 
 Phi (const T1 &val)
 
T1 value () const
 Explicit access to value in case implicit conversion not OK. More...
 

Private Member Functions

void normalize (T1 &value)
 

Private Attributes

T1 theValue
 

Detailed Description

template<typename T1, typename Range = MinusPiToPi>
class Geom::Phi< T1, Range >

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] by default, and this is consistently implemented in aritmetic operations. In other words, Phi implements "modulo(2 pi)" arithmetics. Phi can be instantiated to implement the range 0 to 2pi.

Definition at line 52 of file Phi.h.

Constructor & Destructor Documentation

◆ Phi() [1/2]

template<typename T1, typename Range = MinusPiToPi>
Geom::Phi< T1, Range >::Phi ( )
inline

Default constructor does not initialise - just as double.

Definition at line 55 of file Phi.h.

55 {}

◆ Phi() [2/2]

template<typename T1, typename Range = MinusPiToPi>
Geom::Phi< T1, Range >::Phi ( const T1 &  val)
inline

Definition at line 63 of file Phi.h.

Member Function Documentation

◆ degrees()

template<typename T1, typename Range = MinusPiToPi>
T1 Geom::Phi< T1, Range >::degrees ( ) const
inline

◆ nearEqual()

template<typename T1, typename Range = MinusPiToPi>
bool Geom::Phi< T1, Range >::nearEqual ( const Phi< T1, Range > &  angle,
float  tolerance = 0.001 
) const
inline

Definition at line 115 of file Phi.h.

115  {
116  return (std::abs(theValue - angle) - tolerance <= 0.0);
117  }

◆ nearZero()

template<typename T1, typename Range = MinusPiToPi>
bool Geom::Phi< T1, Range >::nearZero ( float  tolerance = 1.0_deg) const
inline

Definition at line 111 of file Phi.h.

111 { return (std::abs(theValue) - tolerance <= 0.0); }

◆ normalize()

template<typename T1, typename Range = MinusPiToPi>
void Geom::Phi< T1, Range >::normalize ( T1 &  value)
inlineprivate

◆ operator Phi< T2, Range1 >()

template<typename T1, typename Range = MinusPiToPi>
template<typename T2 , typename Range1 >
Geom::Phi< T1, Range >::operator Phi< T2, Range1 > ( )
inline

Template argument conversion.

Definition at line 70 of file Phi.h.

70  {
71  return Phi<T2, Range1>(theValue);
72  }

◆ operator T1()

template<typename T1, typename Range = MinusPiToPi>
Geom::Phi< T1, Range >::operator T1 ( ) const
inline

conversion operator makes transparent use possible.

Definition at line 66 of file Phi.h.

66 { return theValue; }

References Geom::Phi< T1, Range >::theValue.

◆ operator*=()

template<typename T1, typename Range = MinusPiToPi>
Phi& Geom::Phi< T1, Range >::operator*= ( const T1 &  a)
inline

Definition at line 95 of file Phi.h.

95  {
96  theValue *= a;
98  return *this;
99  }

◆ operator+=() [1/2]

template<typename T1, typename Range = MinusPiToPi>
Phi& Geom::Phi< T1, Range >::operator+= ( const Phi< T1, Range > &  a)
inline

Definition at line 86 of file Phi.h.

86 { return operator+=(a.value()); }

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

◆ operator+=() [2/2]

template<typename T1, typename Range = MinusPiToPi>
Phi& Geom::Phi< T1, Range >::operator+= ( const T1 &  a)
inline

Standard arithmetics.

Definition at line 81 of file Phi.h.

81  {
82  theValue += a;
84  return *this;
85  }

◆ operator-=() [1/2]

template<typename T1, typename Range = MinusPiToPi>
Phi& Geom::Phi< T1, Range >::operator-= ( const Phi< T1, Range > &  a)
inline

Definition at line 93 of file Phi.h.

93 { return operator-=(a.value()); }

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

◆ operator-=() [2/2]

template<typename T1, typename Range = MinusPiToPi>
Phi& Geom::Phi< T1, Range >::operator-= ( const T1 &  a)
inline

Definition at line 88 of file Phi.h.

88  {
89  theValue -= a;
91  return *this;
92  }

◆ operator/=()

template<typename T1, typename Range = MinusPiToPi>
Phi& Geom::Phi< T1, Range >::operator/= ( const T1 &  a)
inline

Definition at line 101 of file Phi.h.

101  {
102  theValue /= a;
104  return *this;
105  }

◆ phi()

template<typename T1, typename Range = MinusPiToPi>
T1 Geom::Phi< T1, Range >::phi ( ) const
inline

◆ value()

template<typename T1, typename Range = MinusPiToPi>
T1 Geom::Phi< T1, Range >::value ( ) const
inline

Member Data Documentation

◆ theValue

template<typename T1, typename Range = MinusPiToPi>
T1 Geom::Phi< T1, Range >::theValue
private
reco::mlpf::normalize
float normalize(float in)
Definition: MLPFModel.cc:148
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Geom::Phi::operator+=
Phi & operator+=(const T1 &a)
Standard arithmetics.
Definition: Phi.h:81
Geom::Phi::operator-=
Phi & operator-=(const T1 &a)
Definition: Phi.h:88
a
double a
Definition: hdecay.h:119
value
Definition: value.py:1
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:29
heppy_batch.val
val
Definition: heppy_batch.py:351
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Geom::Phi::normalize
void normalize(T1 &value)
Definition: Phi.h:122
Geom::Phi::theValue
T1 theValue
Definition: Phi.h:120