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 
99  double get(BoundValues bValue) const { return m_values[bValue]; }
100 
102  bool coversFullAzimuth() const;
103 
105  std::ostream& toStream(std::ostream& sl) const final;
106 
107  private:
109  std::array<double, eSize> m_values;
111  bool m_closed{false};
112 
115  void checkConsistency() noexcept(false);
116 
119  Vector2D shifted(const Vector2D& lposition) const;
120 
122  ActsMatrixD<2, 2> jacobian() const;
123 };
124 
125 inline std::vector<double> CylinderBounds::values() const {
126  std::vector<double> valvector;
127  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
128  return valvector;
129 }
130 
132  return m_closed;
133 }
134 
135 inline void CylinderBounds::checkConsistency() noexcept(false) {
136  if (get(eR) <= 0.) {
137  throw std::invalid_argument("CylinderBounds: invalid radial setup.");
138  }
139  if (get(eHalfLengthZ) <= 0.) {
140  throw std::invalid_argument("CylinderBounds: invalid length setup.");
141  }
142  if (get(eHalfPhiSector) <= 0. or get(eHalfPhiSector) > M_PI) {
143  throw std::invalid_argument("CylinderBounds: invalid phi sector setup.");
144  }
145  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
146  throw std::invalid_argument("CylinderBounds: invalid phi positioning.");
147  }
148 }
149 
150 } // namespace Acts