Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LineBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LineBounds.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 
14 
15 #include <array>
16 #include <iosfwd>
17 #include <stdexcept>
18 #include <vector>
19 
20 namespace Acts {
21 
25 class LineBounds : public SurfaceBounds {
26  public:
27  enum BoundValues : int { eR = 0, eHalfLengthZ = 1, eSize = 2 };
28 
29  LineBounds() = delete;
30 
35  LineBounds(double r, double halfZ) noexcept(false) : m_values({r, halfZ}) {
37  }
38 
42  LineBounds(const std::array<double, eSize>& values) noexcept(false)
43  : m_values(values) {
45  }
46 
47  ~LineBounds() override = default;
48 
49  BoundsType type() const final;
50 
54  std::vector<double> values() const final;
55 
64  bool inside(const Vector2& lposition,
65  const BoundaryCheck& bcheck) const final;
66 
70  std::ostream& toStream(std::ostream& sl) const final;
71 
74  double get(BoundValues bValue) const { return m_values[bValue]; }
75 
76  private:
77  std::array<double, eSize> m_values;
78 
81  void checkConsistency() noexcept(false);
82 };
83 
84 inline std::vector<double> LineBounds::values() const {
85  std::vector<double> valvector;
86  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
87  return valvector;
88 }
89 
90 inline void LineBounds::checkConsistency() noexcept(false) {
91  if (get(eR) < 0.) {
92  throw std::invalid_argument("LineBounds: zero radius.");
93  }
94  if (get(eHalfLengthZ) <= 0.) {
95  throw std::invalid_argument("LineBounds: zero/negative length.");
96  }
97 }
98 
99 } // namespace Acts