ECCE @ 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 
91  double distanceToBoundary(const Vector2D& lposition) const final;
92 
102  std::vector<Vector2D> vertices(unsigned int lseg) const final;
103 
104  // Bounding box representation
105  const RectangleBounds& boundingBox() const final;
106 
108  std::ostream& toStream(std::ostream& sl) const final;
109 
112  double get(BoundValues bValue) const { return m_values[bValue]; }
113 
114  private:
115  std::array<double, eSize> m_values;
117 
120  void checkConsistency() noexcept(false);
121 };
122 
123 inline std::vector<double> EllipseBounds::values() const {
124  std::vector<double> valvector;
125  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
126  return valvector;
127 }
128 
129 inline void EllipseBounds::checkConsistency() noexcept(false) {
130  if (get(eInnerRx) >= get(eOuterRx) or get(eInnerRx) < 0. or
131  get(eOuterRx) <= 0.) {
132  throw std::invalid_argument("EllipseBounds: invalid along x axis");
133  }
134  if (get(eInnerRy) >= get(eOuterRy) or get(eInnerRy) < 0. or
135  get(eOuterRy) <= 0.) {
136  throw std::invalid_argument("EllipseBounds: invalid along y axis.");
137  }
138  if (get(eHalfPhiSector) < 0. or get(eHalfPhiSector) > M_PI) {
139  throw std::invalid_argument("EllipseBounds: invalid phi sector setup.");
140  }
141  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
142  throw std::invalid_argument("EllipseBounds: invalid phi positioning.");
143  }
144 }
145 
146 } // namespace Acts