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
14 
15 #include <cmath>
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 
122  std::vector<Vector2D> vertices(unsigned int lseg = 1) const final;
123 
124  // Bounding box representation
125  const RectangleBounds& boundingBox() const final;
126 
130  std::ostream& toStream(std::ostream& sl) const final;
131 
134  double get(BoundValues bValue) const { return m_values[bValue]; }
135 
136  private:
137  std::array<double, eSize> m_values;
139 
142  void checkConsistency() noexcept(false);
143 };
144 
145 inline std::vector<double> TrapezoidBounds::values() const {
146  std::vector<double> valvector;
147  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
148  return valvector;
149 }
150 
151 inline void TrapezoidBounds::checkConsistency() noexcept(false) {
152  if (get(eHalfLengthXnegY) <= 0. or get(eHalfLengthXposY) <= 0.) {
153  throw std::invalid_argument("TrapezoidBounds: invalid local x setup");
154  }
155  if (get(eHalfLengthY) <= 0.) {
156  throw std::invalid_argument("TrapezoidBounds: invalid local y setup");
157  }
158 }
159 
160 } // namespace Acts