ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CylinderVolumeBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CylinderVolumeBounds.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 
9 #pragma once
10 
12 #include "Acts/Geometry/Volume.hpp"
20 
21 #include <array>
22 #include <cmath>
23 #include <exception>
24 #include <vector>
25 
26 namespace Acts {
27 
28 class Surface;
29 class CylinderBounds;
30 class RadialBounds;
31 class PlanarBounds;
32 class IVisualization;
33 
71 // Rectangular Acts::PlaneSurface attached to
75 
77  public:
79  enum BoundValues {
80  eMinR = 0,
81  eMaxR = 1,
85  eSize = 5
86  };
87 
88  CylinderVolumeBounds() = delete;
89 
97  CylinderVolumeBounds(double rmin, double rmax, double halfz,
98  double halfphi = M_PI,
99  double avgphi = 0.) noexcept(false)
100  : m_values({rmin, rmax, halfz, halfphi, avgphi}) {
103  }
104 
108  CylinderVolumeBounds(const std::array<double, eSize>& values) noexcept(false)
109  : m_values(values) {
112  }
113 
118  CylinderVolumeBounds(const CylinderBounds& cBounds,
119  double thickness) noexcept(false);
120 
125  CylinderVolumeBounds(const RadialBounds& rBounds,
126  double thickness) noexcept(false);
127 
131  CylinderVolumeBounds(const CylinderVolumeBounds& cylbo) = default;
132 
133  ~CylinderVolumeBounds() override = default;
134 
135  CylinderVolumeBounds& operator=(const CylinderVolumeBounds& cylbo) = default;
136 
139  }
140 
144  std::vector<double> values() const final;
145 
151  bool inside(const Vector3D& pos, double tol = 0.) const override;
152 
156  std::vector<std::shared_ptr<const Surface>> decomposeToSurfaces(
157  const Transform3D* transformPtr = nullptr) const override;
158 
164  Volume::BoundingBox boundingBox(const Transform3D* trf = nullptr,
165  const Vector3D& envelope = {0, 0, 0},
166  const Volume* entity = nullptr) const final;
167 
171  Vector3D binningOffset(BinningValue bValue) const override;
172 
176  double binningBorder(BinningValue bValue) const override;
177 
179  std::ostream& toStream(std::ostream& sl) const override;
180 
183  double get(BoundValues bValue) const { return m_values[bValue]; }
184 
185  private:
187  std::array<double, eSize> m_values;
189  std::shared_ptr<const CylinderBounds> m_innerCylinderBounds{nullptr};
191  std::shared_ptr<const CylinderBounds> m_outerCylinderBounds{nullptr};
193  std::shared_ptr<const RadialBounds> m_discBounds{nullptr};
195  std::shared_ptr<const PlanarBounds> m_sectorPlaneBounds{nullptr};
196 
199  void checkConsistency() noexcept(false);
200 
202  void buildSurfaceBounds();
203 
205  template <class T>
206  T& dumpT(T& tstream) const;
207 };
208 
210  double tol) const {
211  using VectorHelpers::perp;
212  using VectorHelpers::phi;
213  double ros = perp(pos);
214  bool insidePhi = cos(phi(pos)) >= cos(get(eHalfPhiSector)) - tol;
215  bool insideR = insidePhi
216  ? ((ros >= get(eMinR) - tol) && (ros <= get(eMaxR) + tol))
217  : false;
218  bool insideZ =
219  insideR ? (std::abs(pos.z()) <= get(eHalfLengthZ) + tol) : false;
220  return (insideZ && insideR && insidePhi);
221 }
222 
224  const { // the medium radius is taken for r-type binning
225  if (bValue == Acts::binR || bValue == Acts::binRPhi) {
226  return Vector3D(0.5 * (get(eMinR) + get(eMaxR)), 0., 0.);
227  }
228  return VolumeBounds::binningOffset(bValue);
229 }
230 
232  if (bValue == Acts::binR) {
233  return 0.5 * (get(eMaxR) - get(eMinR));
234  }
235  if (bValue == Acts::binZ) {
236  return get(eHalfLengthZ);
237  }
238  return VolumeBounds::binningBorder(bValue);
239 }
240 
241 template <class T>
242 T& CylinderVolumeBounds::dumpT(T& tstream) const {
243  tstream << std::setiosflags(std::ios::fixed);
244  tstream << std::setprecision(5);
245  tstream << "Acts::CylinderVolumeBounds: (rMin, rMax, halfZ, halfPhi, "
246  "averagePhi) = ";
247  tstream << get(eMinR) << ", " << get(eMaxR) << ", " << get(eHalfLengthZ)
248  << ", " << get(eHalfPhiSector) << get(eAveragePhi);
249  return tstream;
250 }
251 
252 inline std::vector<double> CylinderVolumeBounds::values() const {
253  std::vector<double> valvector;
254  valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
255  return valvector;
256 }
257 
259  if (get(eMinR) < 0. or get(eMaxR) <= 0. or get(eMinR) >= get(eMaxR)) {
260  throw std::invalid_argument("CylinderVolumeBounds: invalid radial input.");
261  }
262  if (get(eHalfLengthZ) <= 0) {
263  throw std::invalid_argument(
264  "CylinderVolumeBounds: invalid longitudinal input.");
265  }
266  if (get(eHalfPhiSector) < 0. or get(eHalfPhiSector) > M_PI) {
267  throw std::invalid_argument(
268  "CylinderVolumeBounds: invalid phi sector setup.");
269  }
270  if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
271  throw std::invalid_argument(
272  "CylinderVolumeBounds: invalid phi positioning.");
273  }
274 }
275 
276 } // namespace Acts