EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EllipseBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EllipseBounds.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
15 
16 #include <array>
17 #include <cmath>
18 #include <cstdlib>
19 #include <exception>
20 #include <vector>
21 
22 namespace Acts {
23 
31 class EllipseBounds : public PlanarBounds {
32  public:
33  enum BoundValues {
34  eInnerRx = 0,
35  eInnerRy = 1,
36  eOuterRx = 2,
37  eOuterRy = 3,
40  eSize = 6
41  };
42 
43  EllipseBounds() = delete;
44 
53  EllipseBounds(double innerRx, double innerRy, double outerRx, double outerRy,
54  double halfPhi = M_PI, double averagePhi = 0.) noexcept(false)
55  : m_values({innerRx, innerRy, outerRx, outerRy, halfPhi, averagePhi}),
58  }
59 
63  EllipseBounds(const std::array<double, eSize>& values) noexcept(false)
64  : m_values(values), m_boundingBox(values[eInnerRy], values[eOuterRy]) {
66  }
67 
68  ~EllipseBounds() override = default;
69 
70  BoundsType type() const final;
71 
75  std::vector<double> values() const final;
76 
84  bool inside(const Vector2D& lposition,
85  const BoundaryCheck& bcheck) const final;
86 
96  std::vector<Vector2D> vertices(unsigned int lseg) const final;
97 
98  // Bounding box representation
99  const RectangleBounds& boundingBox() const final;
100 
102  std::ostream& toStream(std::ostream& sl) const final;
103 
106  double get(BoundValues bValue) const { return m_values[bValue]; }
107 
108  private:
109  std::array<double, eSize> m_values;
111 
114  void checkConsistency() noexcept(false);
115 };
116 
117 inline std::vector<double> EllipseBounds::values() const {
118  std::vector<double> valvector;
119  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
120  return valvector;
121 }
122 
123 inline void EllipseBounds::checkConsistency() noexcept(false) {
124  if (get(eInnerRx) >= get(eOuterRx) or get(eInnerRx) < 0. or
125  get(eOuterRx) <= 0.) {
126  throw std::invalid_argument("EllipseBounds: invalid along x axis");
127  }
128  if (get(eInnerRy) >= get(eOuterRy) or get(eInnerRy) < 0. or
129  get(eOuterRy) <= 0.) {
130  throw std::invalid_argument("EllipseBounds: invalid along y axis.");
131  }
132  if (get(eHalfPhiSector) < 0. or get(eHalfPhiSector) > M_PI) {
133  throw std::invalid_argument("EllipseBounds: invalid phi sector setup.");
134  }
135  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
136  throw std::invalid_argument("EllipseBounds: invalid phi positioning.");
137  }
138 }
139 
140 } // namespace Acts