Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CylinderBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CylinderBounds.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 <cstddef>
20 #include <iostream>
21 #include <stdexcept>
22 #include <vector>
23 
24 namespace Acts {
25 
49 class CylinderBounds : public SurfaceBounds {
50  public:
51  enum BoundValues : int {
52  eR = 0,
58  eSize = 6
59  };
60 
61  CylinderBounds() = delete;
62 
71  CylinderBounds(double r, double halfZ, double halfPhi = M_PI,
72  double avgPhi = 0., double bevelMinZ = 0.,
73  double bevelMaxZ = 0.) noexcept(false)
74  : m_values({r, halfZ, halfPhi, avgPhi, bevelMinZ, bevelMaxZ}),
75  m_closed(std::abs(halfPhi - M_PI) < s_epsilon) {
77  }
78 
82  CylinderBounds(const std::array<double, eSize>& values) noexcept(false)
83  : m_values(values),
84  m_closed(std::abs(values[eHalfPhiSector] - M_PI) < s_epsilon) {
86  }
87 
88  ~CylinderBounds() override = default;
89 
90  BoundsType type() const final;
91 
95  std::vector<double> values() const final;
96 
104  bool inside(const Vector2& lposition,
105  const BoundaryCheck& bcheck) const final;
106 
113  bool inside3D(const Vector3& position,
114  const BoundaryCheck& bcheck = true) const;
115 
118  double get(BoundValues bValue) const { return m_values[bValue]; }
119 
121  bool coversFullAzimuth() const;
122 
127  std::vector<Vector3> createCircles(const Transform3 trans, size_t lseg) const;
128 
130  std::ostream& toStream(std::ostream& sl) const final;
131 
132  private:
134  std::array<double, eSize> m_values;
136  bool m_closed{false};
137 
140  void checkConsistency() noexcept(false);
141 
144  Vector2 shifted(const Vector2& lposition) const;
145 
147  ActsMatrix<2, 2> jacobian() const;
148 };
149 
150 inline std::vector<double> CylinderBounds::values() const {
151  std::vector<double> valvector;
152  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
153  return valvector;
154 }
155 
157  return m_closed;
158 }
159 
160 inline void CylinderBounds::checkConsistency() noexcept(false) {
161  if (get(eR) <= 0.) {
162  throw std::invalid_argument("CylinderBounds: invalid radial setup.");
163  }
164  if (get(eHalfLengthZ) <= 0.) {
165  throw std::invalid_argument("CylinderBounds: invalid length setup.");
166  }
167  if (get(eHalfPhiSector) <= 0. or get(eHalfPhiSector) > M_PI) {
168  throw std::invalid_argument("CylinderBounds: invalid phi sector setup.");
169  }
170  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
171  throw std::invalid_argument("CylinderBounds: invalid phi positioning.");
172  }
173  if (get(eBevelMinZ) != detail::radian_sym(get(eBevelMinZ))) {
174  throw std::invalid_argument("CylinderBounds: invalid bevel at min Z.");
175  }
176  if (get(eBevelMaxZ) != detail::radian_sym(get(eBevelMaxZ))) {
177  throw std::invalid_argument("CylinderBounds: invalid bevel at max Z.");
178  }
179 }
180 
181 } // namespace Acts