Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CuboidVolumeBounds.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CuboidVolumeBounds.cpp
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 
10 
16 
17 #include <type_traits>
18 #include <utility>
19 
21  double halez)
22  : VolumeBounds(), m_values({halex, haley, halez}) {
23  checkConsistency();
25 }
26 
28  : VolumeBounds(),
29  m_values(bobo.m_values),
30  m_xyBounds(bobo.m_xyBounds),
31  m_yzBounds(bobo.m_yzBounds),
32  m_zxBounds(bobo.m_zxBounds) {}
33 
35  const CuboidVolumeBounds& bobo) {
36  if (this != &bobo) {
37  m_values = bobo.m_values;
38  m_xyBounds = bobo.m_xyBounds;
39  m_yzBounds = bobo.m_yzBounds;
40  m_zxBounds = bobo.m_zxBounds;
41  }
42  return *this;
43 }
44 
46  const Transform3& transform) const {
47  OrientedSurfaces oSurfaces;
48  oSurfaces.reserve(6);
49  // Face surfaces xy -------------------------------------
50  // (1) - at negative local z
51  auto sf = Surface::makeShared<PlaneSurface>(
52  transform * Translation3(0., 0., -get(eHalfLengthZ)), m_xyBounds);
53  oSurfaces.push_back(OrientedSurface(std::move(sf), Direction::Positive));
54  // (2) - at positive local z
55  sf = Surface::makeShared<PlaneSurface>(
56  transform * Translation3(0., 0., get(eHalfLengthZ)), m_xyBounds);
57  oSurfaces.push_back(OrientedSurface(std::move(sf), Direction::Negative));
58  // Face surfaces yz -------------------------------------
59  // (3) - at negative local x
60  sf = Surface::makeShared<PlaneSurface>(
61  transform * Translation3(-get(eHalfLengthX), 0., 0.) * s_planeYZ,
62  m_yzBounds);
63  oSurfaces.push_back(OrientedSurface(std::move(sf), Direction::Positive));
64  // (4) - at positive local x
65  sf = Surface::makeShared<PlaneSurface>(
66  transform * Translation3(get(eHalfLengthX), 0., 0.) * s_planeYZ,
67  m_yzBounds);
68  oSurfaces.push_back(OrientedSurface(std::move(sf), Direction::Negative));
69  // Face surfaces zx -------------------------------------
70  // (5) - at negative local y
71  sf = Surface::makeShared<PlaneSurface>(
72  transform * Translation3(0., -get(eHalfLengthY), 0.) * s_planeZX,
73  m_zxBounds);
74  oSurfaces.push_back(OrientedSurface(std::move(sf), Direction::Positive));
75  // (6) - at positive local y
76  sf = Surface::makeShared<PlaneSurface>(
77  transform * Translation3(0., get(eHalfLengthY), 0.) * s_planeZX,
78  m_zxBounds);
79  oSurfaces.push_back(OrientedSurface(std::move(sf), Direction::Negative));
80 
81  return oSurfaces;
82 }
83 
84 std::ostream& Acts::CuboidVolumeBounds::toStream(std::ostream& sl) const {
85  return dumpT(sl);
86 }
87 
89  const Acts::Transform3* trf, const Vector3& envelope,
90  const Volume* entity) const {
91  Vector3 vmin(-get(eHalfLengthX), -get(eHalfLengthY), -get(eHalfLengthZ));
92  Vector3 vmax(get(eHalfLengthX), get(eHalfLengthY), get(eHalfLengthZ));
93 
94  Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope);
95  return trf == nullptr ? box : box.transformed(*trf);
96 }
97 
99  m_xyBounds = std::make_shared<const RectangleBounds>(get(eHalfLengthX),
100  get(eHalfLengthY));
101  m_yzBounds = std::make_shared<const RectangleBounds>(get(eHalfLengthY),
102  get(eHalfLengthZ));
103  m_zxBounds = std::make_shared<const RectangleBounds>(get(eHalfLengthZ),
104  get(eHalfLengthX));
105 }
106 
108  if (bValue <= binZ) {
109  return m_values[bValue];
110  }
111  if (bValue == binR) {
112  return std::sqrt(m_values[binX] * m_values[binX] +
113  m_values[binY] * m_values[binY]);
114  }
115  return 0.0;
116 }