Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CuboidVolumeBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CuboidVolumeBounds.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"
15 
16 #include <array>
17 #include <cmath>
18 #include <iomanip>
19 #include <iosfwd>
20 #include <memory>
21 #include <ostream>
22 #include <stdexcept>
23 #include <vector>
24 
25 namespace Acts {
26 
27 class RectangleBounds;
28 
50  public:
52  enum BoundValues : unsigned int {
57  };
58 
59  CuboidVolumeBounds() = delete;
60 
66  CuboidVolumeBounds(double halex, double haley, double halez) noexcept(false);
67 
71  CuboidVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
72  : m_values(values) {
75  }
76 
81 
86 
87  ~CuboidVolumeBounds() override = default;
88 
90 
94  std::vector<double> values() const final;
95 
101  bool inside(const Vector3& pos, double tol = 0.) const override;
102 
114  const Transform3& transform = Transform3::Identity()) const override;
115 
121  Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
122  const Vector3& envelope = {0, 0, 0},
123  const Volume* entity = nullptr) const final;
124 
130  double binningBorder(BinningValue bValue) const final;
131 
134  double get(BoundValues bValue) const { return m_values[bValue]; }
135 
139  std::ostream& toStream(std::ostream& sl) const override;
140 
141  private:
145  template <class stream_t>
146  stream_t& dumpT(stream_t& dt) const;
147 
149  std::array<double, eSize> m_values;
150 
151  std::shared_ptr<const RectangleBounds> m_xyBounds{nullptr};
152  std::shared_ptr<const RectangleBounds> m_yzBounds{nullptr};
153  std::shared_ptr<const RectangleBounds> m_zxBounds{nullptr};
154 
156  void buildSurfaceBounds();
157 
160  void checkConsistency() noexcept(false);
161 };
162 
163 inline bool CuboidVolumeBounds::inside(const Vector3& pos, double tol) const {
164  return (std::abs(pos.x()) <= get(eHalfLengthX) + tol &&
165  std::abs(pos.y()) <= get(eHalfLengthY) + tol &&
166  std::abs(pos.z()) <= get(eHalfLengthZ) + tol);
167 }
168 
169 inline std::vector<double> CuboidVolumeBounds::values() const {
170  std::vector<double> valvector;
171  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
172  return valvector;
173 }
174 
176  if (get(eHalfLengthX) <= 0 or get(eHalfLengthY) <= 0 or
177  get(eHalfLengthZ) <= 0.) {
178  throw std::invalid_argument(
179  "CuboidVolumeBounds: invalid input, zero or negative.");
180  }
181 }
182 
183 template <class stream_t>
184 stream_t& CuboidVolumeBounds::dumpT(stream_t& dt) const {
185  dt << std::setiosflags(std::ios::fixed);
186  dt << std::setprecision(5);
187  dt << "Acts::CuboidVolumeBounds: (halfLengthX, halfLengthY, halfLengthZ) = ";
188  dt << "(" << get(eHalfLengthX) << ", " << get(eHalfLengthY) << ", "
189  << get(eHalfLengthZ) << ")";
190  return dt;
191 }
192 } // namespace Acts