ECCE @ 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 
82  double distanceToBoundary(const Vector2D& lposition) const final;
83 
87  std::ostream& toStream(std::ostream& sl) const final;
88 
90  double rMin() const;
91 
93  double rMax() const;
94 
97  double get(BoundValues bValue) const { return m_values[bValue]; }
98 
100  bool coversFullAzimuth() const final;
101 
104  bool insideRadialBounds(double R, double tolerance = 0.) const final;
105 
107  double binningValueR() const final;
108 
110  double binningValuePhi() const final;
111 
112  private:
113  std::array<double, eSize> m_values;
114 
117  void checkConsistency() noexcept(false);
118 
123  Vector2D shifted(const Vector2D& lposition) const;
124 
135  std::vector<Vector2D> vertices(unsigned int lseg) const;
136 };
137 
138 inline double RadialBounds::rMin() const {
139  return get(eMinR);
140 }
141 
142 inline double RadialBounds::rMax() const {
143  return get(eMaxR);
144 }
145 
146 inline bool RadialBounds::coversFullAzimuth() const {
147  return (get(eHalfPhiSector) == M_PI);
148 }
149 
150 inline bool RadialBounds::insideRadialBounds(double R, double tolerance) const {
151  return (R + tolerance > get(eMinR) and R - tolerance < get(eMaxR));
152 }
153 
154 inline double RadialBounds::binningValueR() const {
155  return 0.5 * (get(eMinR) + get(eMaxR));
156 }
157 
158 inline double RadialBounds::binningValuePhi() const {
159  return get(eAveragePhi);
160 }
161 
162 inline std::vector<double> RadialBounds::values() const {
163  std::vector<double> valvector;
164  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
165  return valvector;
166 }
167 
168 inline void RadialBounds::checkConsistency() noexcept(false) {
169  if (get(eMinR) < 0. or get(eMaxR) <= 0. or get(eMinR) > get(eMaxR)) {
170  throw std::invalid_argument("RadialBounds: invalid radial setup");
171  }
172  if (get(eHalfPhiSector) < 0. or get(eHalfPhiSector) > M_PI) {
173  throw std::invalid_argument("CylinderBounds: invalid phi sector setup.");
174  }
175  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
176  throw std::invalid_argument("CylinderBounds: invalid phi positioning.");
177  }
178 }
179 
180 } // namespace Acts