ECCE @ 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-2018 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 
10 // TrapezoidVolumeBounds.h, Acts project
12 
13 #pragma once
14 
15 #include "Acts/Geometry/Volume.hpp"
19 
20 #include <array>
21 #include <vector>
22 
23 namespace Acts {
24 
25 class Surface;
26 class RectangleBounds;
27 class TrapezoidBounds;
28 
52 
54  public:
56  enum BoundValues {
61  eAlpha = 4,
62  eBeta = 5,
63  eSize = 6
64  };
65 
66  TrapezoidVolumeBounds() = delete;
67 
74  TrapezoidVolumeBounds(double minhalex, double maxhalex, double haley,
75  double halez) noexcept(false);
76 
84  TrapezoidVolumeBounds(double minhalex, double haley, double halez,
85  double alpha, double beta) noexcept(false);
86 
90  TrapezoidVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
91  : m_values(values) {
94  }
95 
96  TrapezoidVolumeBounds(const TrapezoidVolumeBounds& trabo) = default;
97 
99  default;
100 
101  ~TrapezoidVolumeBounds() override = default;
102 
105  }
106 
110  std::vector<double> values() const final;
111 
119  bool inside(const Vector3D& pos, double tol = 0.) const override;
120 
127  std::vector<std::shared_ptr<const Surface>> decomposeToSurfaces(
128  const Transform3D* transformPtr) const override;
129 
135  Volume::BoundingBox boundingBox(const Transform3D* trf = nullptr,
136  const Vector3D& envelope = {0, 0, 0},
137  const Volume* entity = nullptr) const final;
138 
140  std::ostream& toStream(std::ostream& sl) const override;
141 
144  double get(BoundValues bValue) const { return m_values[bValue]; }
145 
146  private:
148  std::array<double, eSize> m_values;
150  std::shared_ptr<const TrapezoidBounds> m_faceXYTrapezoidBounds = nullptr;
152  std::shared_ptr<const RectangleBounds> m_faceAlphaRectangleBounds = nullptr;
154  std::shared_ptr<const RectangleBounds> m_faceBetaRectangleBounds = nullptr;
156  std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsBottom =
157  nullptr;
159  std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsTop = nullptr;
160 
163  void checkConsistency() noexcept(false);
164 
166  void buildSurfaceBounds();
167 
169  template <class T>
170  T& dumpT(T& dt) const;
171 };
172 
173 template <class T>
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