Analysis Software
Documentation for sPHENIX simulation 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
16 
17 #include <algorithm>
18 #include <array>
19 #include <cmath>
20 #include <iosfwd>
21 #include <stdexcept>
22 #include <vector>
23 
24 namespace Acts {
25 
31 
33  public:
34  enum BoundValues : int {
37  eMinR = 2,
38  eMaxR = 3,
40  eStereo = 5,
41  eSize = 6
42  };
43 
44  DiscTrapezoidBounds() = delete;
45 
54  DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR,
55  double maxR, double avgPhi = M_PI_2,
56  double stereo = 0.) noexcept(false);
57 
61  DiscTrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
62  : m_values(values) {
64  }
65 
66  ~DiscTrapezoidBounds() override = default;
67 
68  SurfaceBounds::BoundsType type() const final;
69 
73  std::vector<double> values() const final;
74 
81  bool inside(const Vector2& lposition,
82  const BoundaryCheck& bcheck = true) const final;
83 
85  std::ostream& toStream(std::ostream& sl) const final;
86 
89  double get(BoundValues bValue) const { return m_values[bValue]; }
90 
92  double rMin() const final;
93 
95  double rMax() const final;
96 
98  double rCenter() const;
99 
101  double stereo() const;
102 
104  double halfPhiSector() const;
105 
107  double halfLengthY() const;
108 
110  bool coversFullAzimuth() const final;
111 
114  bool insideRadialBounds(double R, double tolerance = 0.) const final;
115 
117  double binningValueR() const final;
118 
120  double binningValuePhi() const final;
121 
131  std::vector<Vector2> vertices(unsigned int lseg) const final;
132 
133  private:
134  std::array<double, eSize> m_values;
135 
137  double m_ymax = 0;
138 
141  void checkConsistency() noexcept(false);
142 
147  Vector2 toLocalCartesian(const Vector2& lposition) const;
148 
153  ActsMatrix<2, 2> jacobianToLocalCartesian(const Vector2& lposition) const;
154 };
155 
156 inline double DiscTrapezoidBounds::rMin() const {
157  return get(eMinR);
158 }
159 
160 inline double DiscTrapezoidBounds::rMax() const {
161  return get(eMaxR);
162 }
163 
164 inline double DiscTrapezoidBounds::stereo() const {
165  return get(eStereo);
166 }
167 
168 inline double DiscTrapezoidBounds::halfPhiSector() const {
169  auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
170  auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
171  return std::max(minHalfPhi, maxHalfPhi);
172 }
173 
174 inline double DiscTrapezoidBounds::rCenter() const {
175  double rmin = get(eMinR);
176  double rmax = get(eMaxR);
177  double hxmin = get(eHalfLengthXminR);
178  double hxmax = get(eHalfLengthXmaxR);
179  auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
180  auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
181  return 0.5 * (hmin + hmax);
182 }
183 
184 inline double DiscTrapezoidBounds::halfLengthY() const {
185  double rmin = get(eMinR);
186  double rmax = get(eMaxR);
187  double hxmin = get(eHalfLengthXminR);
188  double hxmax = get(eHalfLengthXmaxR);
189  auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
190  auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
191  return 0.5 * (hmax - hmin);
192 }
193 
195  return false;
196 }
197 
199  double tolerance) const {
200  return (R + tolerance > get(eMinR) and R - tolerance < get(eMaxR));
201 }
202 
203 inline double DiscTrapezoidBounds::binningValueR() const {
204  return 0.5 * (get(eMinR) + get(eMaxR));
205 }
206 
208  return get(eAveragePhi);
209 }
210 
211 inline std::vector<double> DiscTrapezoidBounds::values() const {
212  std::vector<double> valvector;
213  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
214  return valvector;
215 }
216 
218  if (get(eMinR) < 0. or get(eMaxR) <= 0. or get(eMinR) > get(eMaxR)) {
219  throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup.");
220  }
221  if (get(eHalfLengthXminR) < 0. or get(eHalfLengthXmaxR) <= 0.) {
222  throw std::invalid_argument("DiscTrapezoidBounds: negative length given.");
223  }
224  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
225  throw std::invalid_argument(
226  "DiscTrapezoidBounds: invalid phi positioning.");
227  }
228 }
229 
230 } // namespace Acts