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  std::ostream& toStream(std::ostream& sl) const final;
94 
99  double r(double z) const;
100 
102  double tanAlpha() const;
103 
106  double get(BoundValues bValue) const { return m_values[bValue]; }
107 
108  private:
109  std::array<double, eSize> m_values;
110  double m_tanAlpha;
111 
114  void checkConsistency() noexcept(false);
115 
119  Vector2D shifted(const Vector2D& lposition) const;
120 };
121 
122 inline double ConeBounds::r(double z) const {
123  return std::abs(z * m_tanAlpha);
124 }
125 
126 inline double ConeBounds::tanAlpha() const {
127  return m_tanAlpha;
128 }
129 
130 inline std::vector<double> ConeBounds::values() const {
131  std::vector<double> valvector;
132  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
133  return valvector;
134 }
135 
136 inline void ConeBounds::checkConsistency() noexcept(false) {
137  if (get(eAlpha) < 0. or get(eAlpha) >= M_PI) {
138  throw std::invalid_argument("ConeBounds: invalid open angle.");
139  }
140  if (get(eMinZ) > get(eMaxZ) or
141  std::abs(get(eMinZ) - get(eMaxZ)) < s_epsilon) {
142  throw std::invalid_argument("ConeBounds: invalid z range setup.");
143  }
144  if (get(eHalfPhiSector) < 0. or abs(eHalfPhiSector) > M_PI) {
145  throw std::invalid_argument("ConeBounds: invalid phi sector setup.");
146  }
147  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
148  throw std::invalid_argument("ConeBounds: invalid phi positioning.");
149  }
150 }
151 
152 } // namespace Acts