EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RadialBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RadialBounds.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 <vector>
18 
19 namespace Acts {
20 
27 class RadialBounds : public DiscBounds {
28  public:
29  enum BoundValues {
30  eMinR = 0,
31  eMaxR = 1,
34  eSize = 4
35  };
36 
37  RadialBounds() = delete;
38 
45  RadialBounds(double minR, double maxR, double halfPhi = M_PI,
46  double avgPhi = 0.) noexcept(false)
47  : m_values({minR, maxR, halfPhi, avgPhi}) {
49  }
50 
54  RadialBounds(const std::array<double, eSize>& values) noexcept(false)
55  : m_values(values) {
57  }
58 
59  ~RadialBounds() override = default;
60 
61  SurfaceBounds::BoundsType type() const final;
62 
66  std::vector<double> values() const final;
67 
74  bool inside(const Vector2D& lposition,
75  const BoundaryCheck& bcheck) const final;
76 
80  std::ostream& toStream(std::ostream& sl) const final;
81 
83  double rMin() const final;
84 
86  double rMax() const final;
87 
90  double get(BoundValues bValue) const { return m_values[bValue]; }
91 
93  bool coversFullAzimuth() const final;
94 
97  bool insideRadialBounds(double R, double tolerance = 0.) const final;
98 
100  double binningValueR() const final;
101 
103  double binningValuePhi() const final;
104 
105  private:
106  std::array<double, eSize> m_values;
107 
110  void checkConsistency() noexcept(false);
111 
116  Vector2D shifted(const Vector2D& lposition) const;
117 
128  std::vector<Vector2D> vertices(unsigned int lseg) const final;
129 };
130 
131 inline double RadialBounds::rMin() const {
132  return get(eMinR);
133 }
134 
135 inline double RadialBounds::rMax() const {
136  return get(eMaxR);
137 }
138 
139 inline bool RadialBounds::coversFullAzimuth() const {
140  return (get(eHalfPhiSector) == M_PI);
141 }
142 
143 inline bool RadialBounds::insideRadialBounds(double R, double tolerance) const {
144  return (R + tolerance > get(eMinR) and R - tolerance < get(eMaxR));
145 }
146 
147 inline double RadialBounds::binningValueR() const {
148  return 0.5 * (get(eMinR) + get(eMaxR));
149 }
150 
151 inline double RadialBounds::binningValuePhi() const {
152  return get(eAveragePhi);
153 }
154 
155 inline std::vector<double> RadialBounds::values() const {
156  std::vector<double> valvector;
157  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
158  return valvector;
159 }
160 
161 inline void RadialBounds::checkConsistency() noexcept(false) {
162  if (get(eMinR) < 0. or get(eMaxR) <= 0. or get(eMinR) > get(eMaxR)) {
163  throw std::invalid_argument("RadialBounds: invalid radial setup");
164  }
165  if (get(eHalfPhiSector) < 0. or get(eHalfPhiSector) > M_PI) {
166  throw std::invalid_argument("CylinderBounds: invalid phi sector setup.");
167  }
168  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
169  throw std::invalid_argument("CylinderBounds: invalid phi positioning.");
170  }
171 }
172 
173 } // namespace Acts