ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrapezoidBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrapezoidBounds.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 namespace Acts {
18 
26 
27 class TrapezoidBounds : public PlanarBounds {
28  public:
29  enum BoundValues {
33  eSize = 3
34  };
35 
36  TrapezoidBounds() = delete;
37 
43  TrapezoidBounds(double halfXnegY, double halfXposY,
44  double halfY) noexcept(false)
45  : m_values({halfXnegY, halfXposY, halfY}),
46  m_boundingBox(std::max(halfXnegY, halfXposY), halfY) {
48  }
49 
53  TrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
54  : m_values(values),
59  }
60 
61  ~TrapezoidBounds() override;
62 
63  BoundsType type() const final;
64 
65  std::vector<double> values() const final;
66 
111  bool inside(const Vector2D& lposition,
112  const BoundaryCheck& bcheck) const final;
113 
118  double distanceToBoundary(const Vector2D& lposition) const final;
119 
128  std::vector<Vector2D> vertices(unsigned int lseg = 1) const final;
129 
130  // Bounding box representation
131  const RectangleBounds& boundingBox() const final;
132 
136  std::ostream& toStream(std::ostream& sl) const final;
137 
140  double get(BoundValues bValue) const { return m_values[bValue]; }
141 
142  private:
143  std::array<double, eSize> m_values;
145 
148  void checkConsistency() noexcept(false);
149 };
150 
151 inline std::vector<double> TrapezoidBounds::values() const {
152  std::vector<double> valvector;
153  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
154  return valvector;
155 }
156 
157 inline void TrapezoidBounds::checkConsistency() noexcept(false) {
158  if (get(eHalfLengthXnegY) <= 0. or get(eHalfLengthXposY) <= 0.) {
159  throw std::invalid_argument("TrapezoidBounds: invalid local x setup");
160  }
161  if (get(eHalfLengthY) <= 0.) {
162  throw std::invalid_argument("TrapezoidBounds: invalid local y setup");
163  }
164 }
165 
166 } // namespace Acts