CMS 3D CMS Logo

PhiInterval.h
Go to the documentation of this file.
1 #ifndef GeometryVector_PhiInterval_H
2 #define GeometryVector_PhiInterval_H
5 
6 class PhiInterval {
7 public:
8  PhiInterval(float phi1, float phi2) {
9  phi2 = proxim(phi2,phi1);
10  constexpr float c1 = 2.*M_PI;
11  if (phi2<phi1) phi2+=c1;
12  auto dphi = 0.5f*(phi2-phi1);
13  auto phi = phi1+dphi;
14  x = std::cos(phi);
15  y = std::sin(phi);
16  dcos = std::cos(dphi);
17  }
18 
19  PhiInterval(float ix, float iy, float dphi) {
20  auto norm = 1.f/std::sqrt(ix*ix+iy*iy);
21  x = ix*norm;
22  y = iy*norm;
23  dcos = std::cos(dphi);
24  }
25 
26  template<typename T>
27  bool inside(Basic3DVector<T> const & v) const {
28  return inside(v.x(),v.y());
29  }
30 
31  bool inside(float ix, float iy) const {
32  return ix*x+iy*y > dcos*std::sqrt(ix*ix+iy*iy);
33  }
34 
35 private:
36  float x,y;
37  float dcos;
38 
39 };
40 
41 #endif
42 
float dcos
Definition: PhiInterval.h:37
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
PhiInterval(float ix, float iy, float dphi)
Definition: PhiInterval.h:19
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
constexpr T proxim(T b, T a)
Definition: normalizedPhi.h:14
bool inside(Basic3DVector< T > const &v) const
Definition: PhiInterval.h:27
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
PhiInterval(float phi1, float phi2)
Definition: PhiInterval.h:8
bool inside(float ix, float iy) const
Definition: PhiInterval.h:31
#define constexpr