EIC 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 
11 #include "Acts/Geometry/Volume.hpp"
15 
16 #include <array>
17 #include <vector>
18 
19 namespace Acts {
20 
21 class Surface;
22 class RectangleBounds;
23 class TrapezoidBounds;
24 
48  public:
50  enum BoundValues : unsigned int {
55  eAlpha = 4,
56  eBeta = 5,
58  };
59 
60  TrapezoidVolumeBounds() = delete;
61 
68  TrapezoidVolumeBounds(double minhalex, double maxhalex, double haley,
69  double halez) noexcept(false);
70 
78  TrapezoidVolumeBounds(double minhalex, double haley, double halez,
79  double alpha, double beta) noexcept(false);
80 
84  TrapezoidVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
85  : m_values(values) {
88  }
89 
90  TrapezoidVolumeBounds(const TrapezoidVolumeBounds& trabo) = default;
91  ~TrapezoidVolumeBounds() override = default;
93  default;
94 
97  }
98 
102  std::vector<double> values() const final;
103 
111  bool inside(const Vector3D& pos, double tol = 0.) const override;
112 
124  const Transform3D& transform = Transform3D::Identity()) const override;
125 
131  Volume::BoundingBox boundingBox(const Transform3D* trf = nullptr,
132  const Vector3D& envelope = {0, 0, 0},
133  const Volume* entity = nullptr) const final;
134 
136  std::ostream& toStream(std::ostream& sl) const override;
137 
140  double get(BoundValues bValue) const { return m_values[bValue]; }
141 
142  private:
144  std::array<double, eSize> m_values;
146  std::shared_ptr<const TrapezoidBounds> m_faceXYTrapezoidBounds{nullptr};
148  std::shared_ptr<const RectangleBounds> m_faceAlphaRectangleBounds{nullptr};
150  std::shared_ptr<const RectangleBounds> m_faceBetaRectangleBounds{nullptr};
152  std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsBottom{nullptr};
154  std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsTop{nullptr};
155 
158  void checkConsistency() noexcept(false);
159 
161  void buildSurfaceBounds();
162 
166  template <class stream_t>
167  stream_t& dumpT(stream_t& dt) const;
168 };
169 
170 template <class stream_t>
171 stream_t& TrapezoidVolumeBounds::dumpT(stream_t& dt) const {
172  dt << std::setiosflags(std::ios::fixed);
173  dt << std::setprecision(5);
174  dt << "Acts::TrapezoidVolumeBounds: (minhalfX, halfY, halfZ, alpha, beta) "
175  "= ";
176  dt << "(" << get(eHalfLengthXnegY) << ", " << get(eHalfLengthXposY) << ", "
177  << get(eHalfLengthY) << ", " << get(eHalfLengthZ);
178  dt << ", " << get(eAlpha) << ", " << get(eBeta) << ")";
179  return dt;
180 }
181 
182 inline std::vector<double> TrapezoidVolumeBounds::values() const {
183  std::vector<double> valvector;
184  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
185  return valvector;
186 }
187 
189  if (get(eHalfLengthXnegY) < 0. or get(eHalfLengthXposY) < 0.) {
190  throw std::invalid_argument(
191  "TrapezoidVolumeBounds: invalid trapezoid parameters in x.");
192  }
193  if (get(eHalfLengthY) <= 0.) {
194  throw std::invalid_argument("TrapezoidVolumeBounds: invalid y extrusion.");
195  }
196  if (get(eHalfLengthZ) <= 0.) {
197  throw std::invalid_argument("TrapezoidVolumeBounds: invalid z extrusion.");
198  }
199 }
200 
201 } // namespace Acts