Analysis Software
Documentation for sPHENIX simulation 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 
16 
17 #include <array>
18 #include <cmath>
19 #include <cstdlib>
20 #include <iosfwd>
21 #include <stdexcept>
22 #include <vector>
23 
24 namespace Acts {
25 
36 
37 class ConeBounds : public SurfaceBounds {
38  public:
39  enum BoundValues : int {
40  eAlpha = 0,
41  eMinZ = 1,
42  eMaxZ = 2,
45  eSize = 5
46  };
47 
48  ConeBounds() = delete;
49 
58  ConeBounds(double alpha, bool symm, double halfphi = M_PI,
59  double avphi = 0.) noexcept(false);
60 
70  ConeBounds(double alpha, double minz, double maxz, double halfphi = M_PI,
71  double avphi = 0.) noexcept(false);
72 
76  ConeBounds(const std::array<double, eSize>& values) noexcept(false);
77 
78  ~ConeBounds() override = default;
79 
80  BoundsType type() const final;
81 
85  std::vector<double> values() const final;
86 
92  bool inside(const Vector2& lposition,
93  const BoundaryCheck& bcheck = true) 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  Vector2 shifted(const Vector2& 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