ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConeBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ConeBounds.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 
14 
15 #include <array>
16 #include <vector>
17 
18 namespace Acts {
19 
30 
31 class ConeBounds : public SurfaceBounds {
32  public:
33  enum BoundValues : int {
34  eAlpha = 0,
35  eMinZ = 1,
36  eMaxZ = 2,
39  eSize = 5
40  };
41 
42  ConeBounds() = delete;
43 
52  ConeBounds(double alpha, bool symm, double halfphi = M_PI,
53  double avphi = 0.) noexcept(false);
54 
64  ConeBounds(double alpha, double minz, double maxz, double halfphi = M_PI,
65  double avphi = 0.) noexcept(false);
66 
70  ConeBounds(const std::array<double, eSize>& values) noexcept(false);
71 
72  ~ConeBounds() override = default;
73 
74  BoundsType type() const final;
75 
79  std::vector<double> values() const final;
80 
86  bool inside(const Vector2D& lposition,
87  const BoundaryCheck& bcheck = true) const final;
88 
93  double distanceToBoundary(const Vector2D& lposition) const final;
94 
99  std::ostream& toStream(std::ostream& sl) const final;
100 
105  double r(double z) const;
106 
108  double tanAlpha() const;
109 
112  double get(BoundValues bValue) const { return m_values[bValue]; }
113 
114  private:
115  std::array<double, eSize> m_values;
116  double m_tanAlpha;
117 
120  void checkConsistency() noexcept(false);
121 
125  Vector2D shifted(const Vector2D& lposition) const;
126 };
127 
128 inline double ConeBounds::r(double z) const {
129  return std::abs(z * m_tanAlpha);
130 }
131 
132 inline double ConeBounds::tanAlpha() const {
133  return m_tanAlpha;
134 }
135 
136 inline std::vector<double> ConeBounds::values() const {
137  std::vector<double> valvector;
138  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
139  return valvector;
140 }
141 
142 inline void ConeBounds::checkConsistency() noexcept(false) {
143  if (get(eAlpha) < 0. or get(eAlpha) >= M_PI) {
144  throw std::invalid_argument("ConeBounds: invalid open angle.");
145  }
146  if (get(eMinZ) > get(eMaxZ) or
147  std::abs(get(eMinZ) - get(eMaxZ)) < s_epsilon) {
148  throw std::invalid_argument("ConeBounds: invalid z range setup.");
149  }
150  if (get(eHalfPhiSector) < 0. or abs(eHalfPhiSector) > M_PI) {
151  throw std::invalid_argument("ConeBounds: invalid phi sector setup.");
152  }
153  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
154  throw std::invalid_argument("ConeBounds: invalid phi positioning.");
155  }
156 }
157 
158 } // namespace Acts