ECCE @ EIC 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 
14 
15 #include <array>
16 #include <cmath>
17 #include <iostream>
18 #include <vector>
19 
20 namespace Acts {
21 
35 class CylinderBounds : public SurfaceBounds {
36  public:
37  enum BoundValues : int {
38  eR = 0,
42  eSize = 4
43  };
44 
45  CylinderBounds() = delete;
46 
53  CylinderBounds(double r, double halfZ, double halfPhi = M_PI,
54  double avgPhi = 0.) noexcept(false)
55  : m_values({r, halfZ, halfPhi, avgPhi}),
56  m_closed(std::abs(halfPhi - M_PI) < s_epsilon) {
58  }
59 
63  CylinderBounds(const std::array<double, eSize>& values) noexcept(false)
64  : m_values(values),
67  }
68 
69  ~CylinderBounds() override = default;
70 
71  BoundsType type() const final;
72 
76  std::vector<double> values() const final;
77 
85  bool inside(const Vector2D& lposition,
86  const BoundaryCheck& bcheck) const final;
87 
94  bool inside3D(const Vector3D& position,
95  const BoundaryCheck& bcheck = true) const;
96 
101  double distanceToBoundary(const Vector2D& lposition) const final;
102 
105  double get(BoundValues bValue) const { return m_values[bValue]; }
106 
108  bool coversFullAzimuth() const;
109 
111  std::ostream& toStream(std::ostream& sl) const final;
112 
113  private:
115  std::array<double, eSize> m_values;
117  bool m_closed{false};
118 
121  void checkConsistency() noexcept(false);
122 
125  Vector2D shifted(const Vector2D& lposition) const;
126 
128  ActsSymMatrixD<2> jacobian() const;
129 };
130 
131 inline std::vector<double> CylinderBounds::values() const {
132  std::vector<double> valvector;
133  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
134  return valvector;
135 }
136 
138  return m_closed;
139 }
140 
141 inline void CylinderBounds::checkConsistency() noexcept(false) {
142  if (get(eR) <= 0.) {
143  throw std::invalid_argument("CylinderBounds: invalid radial setup.");
144  }
145  if (get(eHalfLengthZ) <= 0.) {
146  throw std::invalid_argument("CylinderBounds: invalid length setup.");
147  }
148  if (get(eHalfPhiSector) <= 0. or get(eHalfPhiSector) > M_PI) {
149  throw std::invalid_argument("CylinderBounds: invalid phi sector setup.");
150  }
151  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
152  throw std::invalid_argument("CylinderBounds: invalid phi positioning.");
153  }
154 }
155 
156 } // namespace Acts