Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrapezoidVolumeBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrapezoidVolumeBounds.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 
12 #include "Acts/Geometry/Volume.hpp"
14 
15 #include <array>
16 #include <iomanip>
17 #include <iosfwd>
18 #include <memory>
19 #include <ostream>
20 #include <stdexcept>
21 #include <vector>
22 
23 namespace Acts {
24 
25 class RectangleBounds;
26 class TrapezoidBounds;
27 
51  public:
53  enum BoundValues : unsigned int {
58  eAlpha = 4,
59  eBeta = 5,
61  };
62 
63  TrapezoidVolumeBounds() = delete;
64 
71  TrapezoidVolumeBounds(double minhalex, double maxhalex, double haley,
72  double halez) noexcept(false);
73 
81  TrapezoidVolumeBounds(double minhalex, double haley, double halez,
82  double alpha, double beta) noexcept(false);
83 
87  TrapezoidVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
88  : m_values(values) {
91  }
92 
93  TrapezoidVolumeBounds(const TrapezoidVolumeBounds& trabo) = default;
94  ~TrapezoidVolumeBounds() override = default;
96  default;
97 
100  }
101 
105  std::vector<double> values() const final;
106 
114  bool inside(const Vector3& pos, double tol = 0.) const override;
115 
127  const Transform3& transform = Transform3::Identity()) const override;
128 
134  Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
135  const Vector3& envelope = {0, 0, 0},
136  const Volume* entity = nullptr) const final;
137 
139  std::ostream& toStream(std::ostream& sl) const override;
140 
143  double get(BoundValues bValue) const { return m_values[bValue]; }
144 
145  private:
147  std::array<double, eSize> m_values{};
149  std::shared_ptr<const TrapezoidBounds> m_faceXYTrapezoidBounds{nullptr};
151  std::shared_ptr<const RectangleBounds> m_faceAlphaRectangleBounds{nullptr};
153  std::shared_ptr<const RectangleBounds> m_faceBetaRectangleBounds{nullptr};
155  std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsBottom{nullptr};
157  std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsTop{nullptr};
158 
161  void checkConsistency() noexcept(false);
162 
164  void buildSurfaceBounds();
165 
169  template <class stream_t>
170  stream_t& dumpT(stream_t& dt) const;
171 };
172 
173 template <class stream_t>
174 stream_t& TrapezoidVolumeBounds::dumpT(stream_t& dt) const {
175  dt << std::setiosflags(std::ios::fixed);
176  dt << std::setprecision(5);
177  dt << "Acts::TrapezoidVolumeBounds: (minhalfX, halfY, halfZ, alpha, beta) "
178  "= ";
179  dt << "(" << get(eHalfLengthXnegY) << ", " << get(eHalfLengthXposY) << ", "
180  << get(eHalfLengthY) << ", " << get(eHalfLengthZ);
181  dt << ", " << get(eAlpha) << ", " << get(eBeta) << ")";
182  return dt;
183 }
184 
185 inline std::vector<double> TrapezoidVolumeBounds::values() const {
186  std::vector<double> valvector;
187  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
188  return valvector;
189 }
190 
192  if (get(eHalfLengthXnegY) < 0. or get(eHalfLengthXposY) < 0.) {
193  throw std::invalid_argument(
194  "TrapezoidVolumeBounds: invalid trapezoid parameters in x.");
195  }
196  if (get(eHalfLengthY) <= 0.) {
197  throw std::invalid_argument("TrapezoidVolumeBounds: invalid y extrusion.");
198  }
199  if (get(eHalfLengthZ) <= 0.) {
200  throw std::invalid_argument("TrapezoidVolumeBounds: invalid z extrusion.");
201  }
202 }
203 
204 } // namespace Acts