Analysis Software
Documentation for sPHENIX simulation 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
16 
17 #include <algorithm>
18 #include <array>
19 #include <cmath>
20 #include <iosfwd>
21 #include <stdexcept>
22 #include <vector>
23 
24 namespace Acts {
25 
33 
34 class TrapezoidBounds : public PlanarBounds {
35  public:
36  enum BoundValues {
40  eSize = 3
41  };
42 
43  TrapezoidBounds() = delete;
44 
50  TrapezoidBounds(double halfXnegY, double halfXposY,
51  double halfY) noexcept(false)
52  : m_values({halfXnegY, halfXposY, halfY}),
53  m_boundingBox(std::max(halfXnegY, halfXposY), halfY) {
55  }
56 
60  TrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
61  : m_values(values),
66  }
67 
68  ~TrapezoidBounds() override;
69 
70  BoundsType type() const final;
71 
72  std::vector<double> values() const final;
73 
115  bool inside(const Vector2& lposition,
116  const BoundaryCheck& bcheck) const final;
117 
126  std::vector<Vector2> vertices(unsigned int lseg = 1) const final;
127 
128  // Bounding box representation
129  const RectangleBounds& boundingBox() const final;
130 
134  std::ostream& toStream(std::ostream& sl) const final;
135 
138  double get(BoundValues bValue) const { return m_values[bValue]; }
139 
140  private:
141  std::array<double, eSize> m_values;
143 
146  void checkConsistency() noexcept(false);
147 };
148 
149 inline std::vector<double> TrapezoidBounds::values() const {
150  std::vector<double> valvector;
151  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
152  return valvector;
153 }
154 
155 inline void TrapezoidBounds::checkConsistency() noexcept(false) {
156  if (get(eHalfLengthXnegY) <= 0. or get(eHalfLengthXposY) <= 0.) {
157  throw std::invalid_argument("TrapezoidBounds: invalid local x setup");
158  }
159  if (get(eHalfLengthY) <= 0.) {
160  throw std::invalid_argument("TrapezoidBounds: invalid local y setup");
161  }
162 }
163 
164 } // namespace Acts