EIC 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 
16 
17 #include <array>
18 #include <exception>
19 #include <vector>
20 
21 namespace Acts {
22 
23 class IVisualization3D;
24 
25 class CylinderBounds;
26 class DiscBounds;
27 
41  public:
43  enum BoundValues : int {
44  eMinR = 0,
45  eMedR = 1,
46  eMaxR = 2,
50  };
51 
52  CutoutCylinderVolumeBounds() = delete;
53 
61  CutoutCylinderVolumeBounds(double rmin, double rmed, double rmax, double hlZ,
62  double hlZc) noexcept(false)
63  : m_values({rmin, rmed, rmax, hlZ, hlZc}) {
66  }
67 
71  CutoutCylinderVolumeBounds(const std::array<double, eSize>& values) noexcept(
72  false)
73  : m_values(values) {
76  }
77 
78  ~CutoutCylinderVolumeBounds() override = default;
79 
82  }
83 
87  std::vector<double> values() const final;
88 
94  bool inside(const Vector3D& gpos, double tol = 0) const override;
95 
107  const Transform3D& transform = Transform3D::Identity()) const override;
108 
115  Volume::BoundingBox boundingBox(const Transform3D* trf = nullptr,
116  const Vector3D& envelope = {0, 0, 0},
117  const Volume* entity = nullptr) const final;
118 
123  std::ostream& toStream(std::ostream& sl) const override;
124 
127  double get(BoundValues bValue) const { return m_values[bValue]; }
128 
129  private:
130  std::array<double, eSize> m_values;
131 
132  // The surface bound objects
133  std::shared_ptr<const CylinderBounds> m_innerCylinderBounds{nullptr};
134  std::shared_ptr<const CylinderBounds> m_cutoutCylinderBounds{nullptr};
135  std::shared_ptr<const CylinderBounds> m_outerCylinderBounds{nullptr};
136  std::shared_ptr<const DiscBounds> m_outerDiscBounds{nullptr};
137  std::shared_ptr<const DiscBounds> m_innerDiscBounds{nullptr};
138 
140  void buildSurfaceBounds();
141 
144  void checkConsistency() noexcept(false);
145 };
146 
147 inline std::vector<double> CutoutCylinderVolumeBounds::values() const {
148  std::vector<double> valvector;
149  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
150  return valvector;
151 }
152 
154  if (get(eMinR) < 0. or get(eMedR) <= 0. or get(eMaxR) <= 0. or
155  get(eMinR) >= get(eMedR) or get(eMinR) >= get(eMaxR) or
156  get(eMedR) >= get(eMaxR)) {
157  throw std::invalid_argument(
158  "CutoutCylinderVolumeBounds: invalid radial input.");
159  }
160  if (get(eHalfLengthZ) <= 0 or get(eHalfLengthZcutout) <= 0. or
161  get(eHalfLengthZcutout) > get(eHalfLengthZ)) {
162  throw std::invalid_argument(
163  "CutoutCylinderVolumeBounds: invalid longitudinal input.");
164  }
165 }
166 
167 } // namespace Acts