Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CutoutCylinderVolumeBounds.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CutoutCylinderVolumeBounds.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 
15 #include "Acts/Geometry/Volume.hpp"
23 
24 #include <memory>
25 #include <ostream>
26 #include <type_traits>
27 #include <utility>
28 
30  double tol) const {
31  // first check whether we are in the outer envelope at all (ignore r_med)
32  using VectorHelpers::perp;
33  using VectorHelpers::phi;
34  double ros = perp(gpos);
35 
36  bool insideR = (ros >= get(eMinR) - tol) && (ros <= get(eMaxR) + tol);
37  bool insideZ = std::abs(gpos.z()) <= get(eHalfLengthZ) + tol;
38 
39  if (!insideR || !insideZ) {
40  return false;
41  }
42 
43  // we're inside the outer volume, but we might be in inside the
44  // cutout section in the middle
45  bool insideRInner = ros <= get(eMedR) - tol;
46  bool insideZInner = std::abs(gpos.z()) < get(eHalfLengthZcutout) - tol;
47 
48  return !insideRInner || !insideZInner; // we are not, inside bounds
49 }
50 
52  const Transform3& transform) const {
53  OrientedSurfaces oSurfaces;
54 
55  if (get(eMinR) == 0.) {
56  oSurfaces.resize(6); // exactly six surfaces (no choke inner cover)
57  } else {
58  oSurfaces.resize(8); // exactly eight surfaces
59  }
60 
61  // Outer cylinder envelope
62  auto outer =
63  Surface::makeShared<CylinderSurface>(transform, m_outerCylinderBounds);
64  oSurfaces.at(tubeOuterCover) =
66 
67  // Inner (cutout) cylinder envelope
68  auto cutoutInner =
69  Surface::makeShared<CylinderSurface>(transform, m_cutoutCylinderBounds);
70  oSurfaces.at(tubeInnerCover) =
72 
73  // z position of the pos and neg choke points
74  double hlChoke = (get(eHalfLengthZ) - get(eHalfLengthZcutout)) * 0.5;
75  double zChoke = get(eHalfLengthZcutout) + hlChoke;
76 
77  if (m_innerCylinderBounds != nullptr) {
78  auto posChokeTrf = transform * Translation3(Vector3(0, 0, zChoke));
79  auto posInner = Surface::makeShared<CylinderSurface>(posChokeTrf,
80  m_innerCylinderBounds);
81  oSurfaces.at(index7) =
83 
84  auto negChokeTrf = transform * Translation3(Vector3(0, 0, -zChoke));
85  auto negInner = Surface::makeShared<CylinderSurface>(negChokeTrf,
86  m_innerCylinderBounds);
87  oSurfaces.at(index6) =
89  }
90 
91  // Two Outer disks
92  auto posOutDiscTrf =
93  transform * Translation3(Vector3(0, 0, get(eHalfLengthZ)));
94  auto posOutDisc =
95  Surface::makeShared<DiscSurface>(posOutDiscTrf, m_outerDiscBounds);
96  oSurfaces.at(positiveFaceXY) =
98 
99  auto negOutDiscTrf =
100  transform * Translation3(Vector3(0, 0, -get(eHalfLengthZ)));
101  auto negOutDisc =
102  Surface::makeShared<DiscSurface>(negOutDiscTrf, m_outerDiscBounds);
103  oSurfaces.at(negativeFaceXY) =
105 
106  // Two Inner disks
107  auto posInDiscTrf =
108  transform * Translation3(Vector3(0, 0, get(eHalfLengthZcutout)));
109  auto posInDisc =
110  Surface::makeShared<DiscSurface>(posInDiscTrf, m_innerDiscBounds);
111  oSurfaces.at(index5) =
113 
114  auto negInDiscTrf =
115  transform * Translation3(Vector3(0, 0, -get(eHalfLengthZcutout)));
116  auto negInDisc =
117  Surface::makeShared<DiscSurface>(negInDiscTrf, m_innerDiscBounds);
118  oSurfaces.at(index4) =
120 
121  return oSurfaces;
122 }
123 
125  const Acts::Transform3* trf, const Acts::Vector3& envelope,
126  const Acts::Volume* entity) const {
127  Vector3 vmin, vmax;
128 
129  // no phi sector is possible, so this is just the outer size of
130  // the cylinder
131 
132  vmax = {get(eMaxR), get(eMaxR), get(eHalfLengthZ)};
133  vmin = {-get(eMaxR), -get(eMaxR), -get(eHalfLengthZ)};
134 
135  Acts::Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope);
136  // transform at the very end, if required
137  return trf == nullptr ? box : box.transformed(*trf);
138 }
139 
141  std::ostream& sl) const {
142  sl << "Acts::CutoutCylinderVolumeBounds(\n";
143  sl << "rmin = " << get(eMinR) << " rmed = " << get(eMedR)
144  << " rmax = " << get(eMaxR) << "\n";
145  sl << "dz1 = " << get(eHalfLengthZ) << " dz2 = " << get(eHalfLengthZcutout);
146  return sl;
147 }
148 
150  if (get(eMinR) > s_epsilon) {
151  double hlChoke = (get(eHalfLengthZ) - get(eHalfLengthZcutout)) * 0.5;
152  m_innerCylinderBounds =
153  std::make_shared<CylinderBounds>(get(eMinR), hlChoke);
154  }
155 
156  m_cutoutCylinderBounds =
157  std::make_shared<CylinderBounds>(get(eMedR), get(eHalfLengthZcutout));
158 
159  m_outerCylinderBounds =
160  std::make_shared<CylinderBounds>(get(eMaxR), get(eHalfLengthZ));
161 
162  m_innerDiscBounds = std::make_shared<RadialBounds>(get(eMinR), get(eMedR));
163 
164  m_outerDiscBounds = std::make_shared<RadialBounds>(get(eMinR), get(eMaxR));
165 }