Analysis Software
Documentation for sPHENIX simulation 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 
17 
18 #include <array>
19 #include <cmath>
20 #include <iosfwd>
21 #include <stdexcept>
22 #include <vector>
23 
24 namespace Acts {
25 
32 class RadialBounds : public DiscBounds {
33  public:
34  enum BoundValues {
35  eMinR = 0,
36  eMaxR = 1,
39  eSize = 4
40  };
41 
42  RadialBounds() = delete;
43 
50  RadialBounds(double minR, double maxR, double halfPhi = M_PI,
51  double avgPhi = 0.) noexcept(false)
52  : m_values({minR, maxR, halfPhi, avgPhi}) {
54  }
55 
59  RadialBounds(const std::array<double, eSize>& values) noexcept(false)
60  : m_values(values) {
62  }
63 
64  ~RadialBounds() override = default;
65 
66  SurfaceBounds::BoundsType type() const final;
67 
71  std::vector<double> values() const final;
72 
79  bool inside(const Vector2& lposition,
80  const BoundaryCheck& bcheck) const final;
81 
85  std::ostream& toStream(std::ostream& sl) const final;
86 
88  double rMin() const final;
89 
91  double rMax() const final;
92 
95  double get(BoundValues bValue) const { return m_values[bValue]; }
96 
98  bool coversFullAzimuth() const final;
99 
102  bool insideRadialBounds(double R, double tolerance = 0.) const final;
103 
105  double binningValueR() const final;
106 
108  double binningValuePhi() const final;
109 
110  private:
111  std::array<double, eSize> m_values;
112 
115  void checkConsistency() noexcept(false);
116 
121  Vector2 shifted(const Vector2& lposition) const;
122 
133  std::vector<Vector2> vertices(unsigned int lseg) const final;
134 };
135 
136 inline double RadialBounds::rMin() const {
137  return get(eMinR);
138 }
139 
140 inline double RadialBounds::rMax() const {
141  return get(eMaxR);
142 }
143 
144 inline bool RadialBounds::coversFullAzimuth() const {
145  return (get(eHalfPhiSector) == M_PI);
146 }
147 
148 inline bool RadialBounds::insideRadialBounds(double R, double tolerance) const {
149  return (R + tolerance > get(eMinR) and R - tolerance < get(eMaxR));
150 }
151 
152 inline double RadialBounds::binningValueR() const {
153  return 0.5 * (get(eMinR) + get(eMaxR));
154 }
155 
156 inline double RadialBounds::binningValuePhi() const {
157  return get(eAveragePhi);
158 }
159 
160 inline std::vector<double> RadialBounds::values() const {
161  std::vector<double> valvector;
162  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
163  return valvector;
164 }
165 
166 inline void RadialBounds::checkConsistency() noexcept(false) {
167  if (get(eMinR) < 0. or get(eMaxR) <= 0. or get(eMinR) > get(eMaxR)) {
168  throw std::invalid_argument("RadialBounds: invalid radial setup");
169  }
170  if (get(eHalfPhiSector) < 0. or get(eHalfPhiSector) > M_PI) {
171  throw std::invalid_argument("RadialBounds: invalid phi sector setup.");
172  }
173  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
174  throw std::invalid_argument("RadialBounds: invalid phi positioning.");
175  }
176 }
177 
178 } // namespace Acts