CMS 3D CMS Logo

Functions
normalizedPhi.h File Reference
#include "DataFormats/Math/interface/deltaPhi.h"
#include <algorithm>
#include <iostream>

Go to the source code of this file.

Functions

template<typename T >
constexpr bool checkPhiInRange (T phi, T phi1, T phi2, float maxDphi=float(M_PI))
 
template<typename T >
constexpr bool checkPhiInSymRange (T phi, T phi1, T phi2, float maxDphi=float(M_PI))
 
template<typename T >
constexpr T normalizedPhi (T phi)
 
template<typename T >
constexpr T proxim (T b, T a)
 

Function Documentation

template<typename T >
constexpr bool checkPhiInRange ( T  phi,
T  phi1,
T  phi2,
float  maxDphi = float(M_PI) 
)

Definition at line 33 of file normalizedPhi.h.

References funct::abs(), alignmentValidation::c1, constexpr, f, M_PI, min(), and proxim().

Referenced by checkPhiInSymRange(), PixelTripletLargeTipGenerator::hitTriplets(), and PixelTripletHLTGenerator::hitTriplets().

33  {
34  phi2 = proxim(phi2, phi1);
35  constexpr float c1 = 2. * M_PI;
36  if (phi2 < phi1)
37  phi2 += c1;
38  auto dphi = std::min(maxDphi, 0.5f * (phi2 - phi1));
39  auto phiA = phi1 + dphi;
40  phi = proxim(phi, phiA);
41  return std::abs(phiA - phi) < dphi;
42 
43  /* old "alternative algo"
44  constexpr T c1 = 2.*M_PI;
45  phi1 = normalizedPhi(phi1);
46  phi2 = proxim(phi2,phi1);
47  if (phi2<phi1) phi2+=c1;
48  // phi & phi1 are in [-pi,pi] range...
49  return ( (phi1 <= phi) & (phi <= phi2) )
50 // || ( (phi1 <= phi-c1) & (phi-c1 <= phi2) )
51  || ( (phi1 <= phi+c1) & (phi+c1 <= phi2) );
52  */
53 }
constexpr T proxim(T b, T a)
Definition: normalizedPhi.h:14
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
#define M_PI
#define constexpr
template<typename T >
constexpr bool checkPhiInSymRange ( T  phi,
T  phi1,
T  phi2,
float  maxDphi = float(M_PI) 
)

Definition at line 24 of file normalizedPhi.h.

References checkPhiInRange(), and std::swap().

24  {
25  // symmetrize
26  if (phi2 < phi1)
27  std::swap(phi1, phi2);
28  return checkPhiInRange(phi, phi1, phi2, maxDphi);
29 }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
constexpr bool checkPhiInRange(T phi, T phi1, T phi2, float maxDphi=float(M_PI))
Definition: normalizedPhi.h:33
template<typename T >
constexpr T normalizedPhi ( T  phi)
template<typename T >
constexpr T proxim ( T  b,
T  a 
)