CMS 3D CMS Logo

Functions
angle0to2pi Namespace Reference

Functions

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

Function Documentation

◆ make0To2pi()

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

Definition at line 67 of file deltaPhi.h.

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

Referenced by trklet::TrackletCalculatorDisplaced::approxproj(), trklet::TrackletCalculatorDisplaced::approxprojdisk(), trklet::TrackletCalculatorDisplaced::approxtracklet(), trklet::TrackletCalculatorBase::barrelSeeding(), magneticfield::bSector::bSector(), CmsMTDConstruction< FilteredView >::btlOrderPhi(), CmsMTDConstruction< FilteredView >::btlOrderZ(), GeometricDet::computeLegacyShapeParameters(), DDCmsMTDConstruction::construct(), trklet::TrackletCalculatorBase::diskSeeding(), trklet::TrackletCalculatorDisplaced::exacttracklet(), CmsMTDConstruction< FilteredView >::mtdOrderPhi(), Geom::NormalizeWrapper< T1, ZeroTo2pi >::normalize(), trklet::TrackletCalculatorBase::overlapSeeding(), and ParticleTowerProducer< T >::phi2iphi().

67  {
68  constexpr valType twoPi = 2. * M_PI;
69  constexpr valType oneOverTwoPi = 1. / (2. * M_PI);
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
#define M_PI
constexpr double twoPi()
Definition: Pi.h:32
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11