CMS 3D CMS Logo

Functions
angle0to2pi Namespace Reference

Functions

template<class valType >
constexpr valType make0To2pi (valType angle)
 

Function Documentation

template<class valType >
constexpr valType angle0to2pi::make0To2pi ( valType  angle)
inline

Definition at line 67 of file deltaPhi.h.

References funct::abs(), constexpr, geometryDiff::epsilon, pileupReCalc_HLTpaths::trunc, and Geom::twoPi().

Referenced by magneticfield::bSector::bSector(), and Geom::NormalizeWrapper< T1, ZeroTo2pi >::normalize().

67  {
68  constexpr valType twoPi = 2._pi;
69  constexpr valType oneOverTwoPi = 1. / twoPi;
70  constexpr valType epsilon = 1.e-13;
71 
72  if ((std::abs(angle) <= epsilon) || (std::abs(twoPi - std::abs(angle)) <= epsilon))
73  return (0.);
74  if (std::abs(angle) > twoPi) {
75  valType nFac = trunc(angle * oneOverTwoPi);
76  angle -= (nFac * twoPi);
77  if (std::abs(angle) <= epsilon)
78  return (0.);
79  }
80  if (angle < 0.)
81  angle += twoPi;
82  return (angle);
83  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr double twoPi()
Definition: Pi.h:32
#define constexpr
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11