Analysis Software
Documentation for sPHENIX simulation 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 
17 
18 #include <array>
19 #include <cmath>
20 #include <cstdlib>
21 #include <exception>
22 #include <iosfwd>
23 #include <stdexcept>
24 #include <vector>
25 
26 namespace Acts {
27 
35 class EllipseBounds : public PlanarBounds {
36  public:
37  enum BoundValues {
38  eInnerRx = 0,
39  eInnerRy = 1,
40  eOuterRx = 2,
41  eOuterRy = 3,
44  eSize = 6
45  };
46 
47  EllipseBounds() = delete;
48 
57  EllipseBounds(double innerRx, double innerRy, double outerRx, double outerRy,
58  double halfPhi = M_PI, double averagePhi = 0.) noexcept(false)
59  : m_values({innerRx, innerRy, outerRx, outerRy, halfPhi, averagePhi}),
62  }
63 
67  EllipseBounds(const std::array<double, eSize>& values) noexcept(false)
68  : m_values(values), m_boundingBox(values[eInnerRy], values[eOuterRy]) {
70  }
71 
72  ~EllipseBounds() override = default;
73 
74  BoundsType type() const final;
75 
79  std::vector<double> values() const final;
80 
88  bool inside(const Vector2& lposition,
89  const BoundaryCheck& bcheck) const final;
90 
100  std::vector<Vector2> vertices(unsigned int lseg) const final;
101 
102  // Bounding box representation
103  const RectangleBounds& boundingBox() const final;
104 
106  std::ostream& toStream(std::ostream& sl) const final;
107 
110  double get(BoundValues bValue) const { return m_values[bValue]; }
111 
112  private:
113  std::array<double, eSize> m_values;
115 
118  void checkConsistency() noexcept(false);
119 };
120 
121 inline std::vector<double> EllipseBounds::values() const {
122  std::vector<double> valvector;
123  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
124  return valvector;
125 }
126 
127 inline void EllipseBounds::checkConsistency() noexcept(false) {
128  if (get(eInnerRx) >= get(eOuterRx) or get(eInnerRx) < 0. or
129  get(eOuterRx) <= 0.) {
130  throw std::invalid_argument("EllipseBounds: invalid along x axis");
131  }
132  if (get(eInnerRy) >= get(eOuterRy) or get(eInnerRy) < 0. or
133  get(eOuterRy) <= 0.) {
134  throw std::invalid_argument("EllipseBounds: invalid along y axis.");
135  }
136  if (get(eHalfPhiSector) < 0. or get(eHalfPhiSector) > M_PI) {
137  throw std::invalid_argument("EllipseBounds: invalid phi sector setup.");
138  }
139  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
140  throw std::invalid_argument("EllipseBounds: invalid phi positioning.");
141  }
142 }
143 
144 } // namespace Acts