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
14 
15 #include <array>
16 #include <cmath>
17 #include <vector>
18 
19 namespace Acts {
20 
26 
28  public:
29  enum BoundValues : int {
32  eMinR = 2,
33  eMaxR = 3,
35  eStereo = 5,
36  eSize = 6
37  };
38 
39  DiscTrapezoidBounds() = delete;
40 
49  DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR,
50  double maxR, double avgPhi = M_PI_2,
51  double stereo = 0.) noexcept(false);
52 
56  DiscTrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
57  : m_values(values) {
59  }
60 
61  ~DiscTrapezoidBounds() override = default;
62 
63  SurfaceBounds::BoundsType type() const final;
64 
68  std::vector<double> values() const final;
69 
76  bool inside(const Vector2D& lposition,
77  const BoundaryCheck& bcheck = true) const final;
78 
80  std::ostream& toStream(std::ostream& sl) const final;
81 
84  double get(BoundValues bValue) const { return m_values[bValue]; }
85 
87  double rMin() const final;
88 
90  double rMax() const final;
91 
93  double rCenter() const;
94 
96  double stereo() const;
97 
99  double halfPhiSector() const;
100 
102  double halfLengthY() const;
103 
105  bool coversFullAzimuth() const final;
106 
109  bool insideRadialBounds(double R, double tolerance = 0.) const final;
110 
112  double binningValueR() const final;
113 
115  double binningValuePhi() const final;
116 
126  std::vector<Vector2D> vertices(unsigned int lseg) const final;
127 
128  private:
129  std::array<double, eSize> m_values;
130 
133  void checkConsistency() noexcept(false);
134 
139  Vector2D toLocalCartesian(const Vector2D& lposition) const;
140 
145  ActsMatrixD<2, 2> jacobianToLocalCartesian(const Vector2D& lposition) const;
146 };
147 
148 inline double DiscTrapezoidBounds::rMin() const {
149  return get(eMinR);
150 }
151 
152 inline double DiscTrapezoidBounds::rMax() const {
153  return get(eMaxR);
154 }
155 
156 inline double DiscTrapezoidBounds::stereo() const {
157  return get(eStereo);
158 }
159 
160 inline double DiscTrapezoidBounds::halfPhiSector() const {
161  auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
162  auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
163  return std::max(minHalfPhi, maxHalfPhi);
164 }
165 
166 inline double DiscTrapezoidBounds::rCenter() const {
167  double rmin = get(eMinR);
168  double rmax = get(eMaxR);
169  double hxmin = get(eHalfLengthXminR);
170  double hxmax = get(eHalfLengthXmaxR);
171  auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
172  auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
173  return 0.5 * (hmin + hmax);
174 }
175 
176 inline double DiscTrapezoidBounds::halfLengthY() const {
177  double rmin = get(eMinR);
178  double rmax = get(eMaxR);
179  double hxmin = get(eHalfLengthXminR);
180  double hxmax = get(eHalfLengthXmaxR);
181  auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
182  auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
183  return 0.5 * (hmax - hmin);
184 }
185 
187  return false;
188 }
189 
191  double tolerance) const {
192  return (R + tolerance > get(eMinR) and R - tolerance < get(eMaxR));
193 }
194 
195 inline double DiscTrapezoidBounds::binningValueR() const {
196  return 0.5 * (get(eMinR) + get(eMaxR));
197 }
198 
200  return get(eAveragePhi);
201 }
202 
203 inline std::vector<double> DiscTrapezoidBounds::values() const {
204  std::vector<double> valvector;
205  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
206  return valvector;
207 }
208 
210  if (get(eMinR) < 0. or get(eMaxR) <= 0. or get(eMinR) > get(eMaxR)) {
211  throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup.");
212  }
213  if (get(eHalfLengthXminR) < 0. or get(eHalfLengthXmaxR) <= 0.) {
214  throw std::invalid_argument("DiscTrapezoidBounds: negative length given.");
215  }
216  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
217  throw std::invalid_argument(
218  "DiscTrapezoidBounds: invalid phi positioning.");
219  }
220 }
221 
222 } // namespace Acts