File indexing completed on 2024-04-06 12:04:16
0001 #ifndef GeometryVector_PhiInterval_H
0002 #define GeometryVector_PhiInterval_H
0003 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
0004 #include "DataFormats/Math/interface/normalizedPhi.h"
0005
0006 class PhiInterval {
0007 public:
0008 PhiInterval(float phi1, float phi2) {
0009 phi2 = proxim(phi2, phi1);
0010 constexpr float c1 = 2. * M_PI;
0011 if (phi2 < phi1)
0012 phi2 += c1;
0013 auto dphi = 0.5f * (phi2 - phi1);
0014 auto phi = phi1 + dphi;
0015 x = std::cos(phi);
0016 y = std::sin(phi);
0017 dcos = std::cos(dphi);
0018 }
0019
0020 PhiInterval(float ix, float iy, float dphi) {
0021 auto norm = 1.f / std::sqrt(ix * ix + iy * iy);
0022 x = ix * norm;
0023 y = iy * norm;
0024 dcos = std::cos(dphi);
0025 }
0026
0027 template <typename T>
0028 bool inside(Basic3DVector<T> const& v) const {
0029 return inside(v.x(), v.y());
0030 }
0031
0032 bool inside(float ix, float iy) const { return ix * x + iy * y > dcos * std::sqrt(ix * ix + iy * iy); }
0033
0034 private:
0035 float x, y;
0036 float dcos;
0037 };
0038
0039 #endif