Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CutoutCylinderVolumeBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CutoutCylinderVolumeBounds.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-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 
12 #include "Acts/Geometry/Volume.hpp"
14 
15 #include <array>
16 #include <iosfwd>
17 #include <memory>
18 #include <stdexcept>
19 #include <vector>
20 
21 namespace Acts {
22 
23 class CylinderBounds;
24 class DiscBounds;
25 
39  public:
41  enum BoundValues : int {
42  eMinR = 0,
43  eMedR = 1,
44  eMaxR = 2,
48  };
49 
50  CutoutCylinderVolumeBounds() = delete;
51 
59  CutoutCylinderVolumeBounds(double rmin, double rmed, double rmax, double hlZ,
60  double hlZc) noexcept(false)
61  : m_values({rmin, rmed, rmax, hlZ, hlZc}) {
64  }
65 
69  CutoutCylinderVolumeBounds(const std::array<double, eSize>& values) noexcept(
70  false)
71  : m_values(values) {
74  }
75 
76  ~CutoutCylinderVolumeBounds() override = default;
77 
80  }
81 
85  std::vector<double> values() const final;
86 
92  bool inside(const Vector3& gpos, double tol = 0) const override;
93 
105  const Transform3& transform = Transform3::Identity()) const override;
106 
113  Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
114  const Vector3& envelope = {0, 0, 0},
115  const Volume* entity = nullptr) const final;
116 
121  std::ostream& toStream(std::ostream& sl) const override;
122 
125  double get(BoundValues bValue) const { return m_values[bValue]; }
126 
127  private:
128  std::array<double, eSize> m_values;
129 
130  // The surface bound objects
131  std::shared_ptr<const CylinderBounds> m_innerCylinderBounds{nullptr};
132  std::shared_ptr<const CylinderBounds> m_cutoutCylinderBounds{nullptr};
133  std::shared_ptr<const CylinderBounds> m_outerCylinderBounds{nullptr};
134  std::shared_ptr<const DiscBounds> m_outerDiscBounds{nullptr};
135  std::shared_ptr<const DiscBounds> m_innerDiscBounds{nullptr};
136 
138  void buildSurfaceBounds();
139 
142  void checkConsistency() noexcept(false);
143 };
144 
145 inline std::vector<double> CutoutCylinderVolumeBounds::values() const {
146  std::vector<double> valvector;
147  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
148  return valvector;
149 }
150 
152  if (get(eMinR) < 0. or get(eMedR) <= 0. or get(eMaxR) <= 0. or
153  get(eMinR) >= get(eMedR) or get(eMinR) >= get(eMaxR) or
154  get(eMedR) >= get(eMaxR)) {
155  throw std::invalid_argument(
156  "CutoutCylinderVolumeBounds: invalid radial input.");
157  }
158  if (get(eHalfLengthZ) <= 0 or get(eHalfLengthZcutout) <= 0. or
159  get(eHalfLengthZcutout) > get(eHalfLengthZ)) {
160  throw std::invalid_argument(
161  "CutoutCylinderVolumeBounds: invalid longitudinal input.");
162  }
163 }
164 
165 } // namespace Acts