ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DiscTrapezoidBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DiscTrapezoidBounds.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 #include <cmath>
11 
16 
17 #include <array>
18 #include <vector>
19 
20 namespace Acts {
21 
27 
29  public:
30  enum BoundValues : int {
33  eMinR = 2,
34  eMaxR = 3,
36  eStereo = 5,
37  eSize = 6
38  };
39 
40  DiscTrapezoidBounds() = delete;
41 
50  DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR,
51  double maxR, double avgPhi = M_PI_2,
52  double stereo = 0.) noexcept(false);
53 
57  DiscTrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
58  : m_values(values) {
60  }
61 
62  ~DiscTrapezoidBounds() override = default;
63 
64  SurfaceBounds::BoundsType type() const final;
65 
69  std::vector<double> values() const final;
70 
77  bool inside(const Vector2D& lposition,
78  const BoundaryCheck& bcheck = true) const final;
79 
84  double distanceToBoundary(const Vector2D& lposition) const final;
85 
87  std::ostream& toStream(std::ostream& sl) const final;
88 
91  double get(BoundValues bValue) const { return m_values[bValue]; }
92 
94  double rMin() const final;
95 
97  double rMax() const final;
98 
100  double rCenter() const;
101 
103  double stereo() const;
104 
106  double halfPhiSector() const;
107 
109  double halfLengthY() const;
110 
112  bool coversFullAzimuth() const final;
113 
116  bool insideRadialBounds(double R, double tolerance = 0.) const final;
117 
119  double binningValueR() const final;
120 
122  double binningValuePhi() const final;
123 
133  std::vector<Vector2D> vertices(unsigned int lseg) const;
134 
135  private:
136  std::array<double, eSize> m_values;
137 
140  void checkConsistency() noexcept(false);
141 
146  Vector2D toLocalCartesian(const Vector2D& lposition) const;
147 
152  ActsMatrixD<2, 2> jacobianToLocalCartesian(const Vector2D& lposition) const;
153 };
154 
155 inline double DiscTrapezoidBounds::rMin() const {
156  return get(eMinR);
157 }
158 
159 inline double DiscTrapezoidBounds::rMax() const {
160  return get(eMaxR);
161 }
162 
163 inline double DiscTrapezoidBounds::stereo() const {
164  return get(eStereo);
165 }
166 
167 inline double DiscTrapezoidBounds::halfPhiSector() const {
168  auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
169  auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
170  return std::max(minHalfPhi, maxHalfPhi);
171 }
172 
173 inline double DiscTrapezoidBounds::rCenter() const {
174  double rmin = get(eMinR);
175  double rmax = get(eMaxR);
176  double hxmin = get(eHalfLengthXminR);
177  double hxmax = get(eHalfLengthXmaxR);
178  auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
179  auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
180  return 0.5 * (hmin + hmax);
181 }
182 
183 inline double DiscTrapezoidBounds::halfLengthY() const {
184  double rmin = get(eMinR);
185  double rmax = get(eMaxR);
186  double hxmin = get(eHalfLengthXminR);
187  double hxmax = get(eHalfLengthXmaxR);
188  auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
189  auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
190  return 0.5 * (hmax - hmin);
191 }
192 
194  return false;
195 }
196 
198  double tolerance) const {
199  return (R + tolerance > get(eMinR) and R - tolerance < get(eMaxR));
200 }
201 
202 inline double DiscTrapezoidBounds::binningValueR() const {
203  return 0.5 * (get(eMinR) + get(eMaxR));
204 }
205 
207  return get(eAveragePhi);
208 }
209 
210 inline std::vector<double> DiscTrapezoidBounds::values() const {
211  std::vector<double> valvector;
212  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
213  return valvector;
214 }
215 
217  if (get(eMinR) < 0. or get(eMaxR) <= 0. or get(eMinR) > get(eMaxR)) {
218  throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup.");
219  }
220  if (get(eHalfLengthXminR) < 0. or get(eHalfLengthXmaxR) <= 0.) {
221  throw std::invalid_argument("DiscTrapezoidBounds: negative length given.");
222  }
223  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
224  throw std::invalid_argument(
225  "DiscTrapezoidBounds: invalid phi positioning.");
226  }
227 }
228 
229 } // namespace Acts