EIC 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 
12 #include "Acts/Geometry/Volume.hpp"
21 
22 #include <memory>
23 #include <vector>
24 
26  double tol) const {
27  // first check whether we are in the outer envelope at all (ignore r_med)
28  using VectorHelpers::perp;
29  using VectorHelpers::phi;
30  double ros = perp(gpos);
31 
32  bool insideR = (ros >= get(eMinR) - tol) && (ros <= get(eMaxR) + tol);
33  bool insideZ = std::abs(gpos.z()) <= get(eHalfLengthZ) + tol;
34 
35  if (!insideR || !insideZ) {
36  return false;
37  }
38 
39  // we're inside the outer volume, but we might be in inside the
40  // cutout section in the middle
41  bool insideRInner = ros <= get(eMedR) - tol;
42  bool insideZInner = std::abs(gpos.z()) < get(eHalfLengthZcutout) - tol;
43 
44  return !insideRInner || !insideZInner; // we are not, inside bounds
45 }
46 
48  const Transform3D& transform) const {
49  OrientedSurfaces oSurfaces;
50 
51  if (get(eMinR) == 0.) {
52  oSurfaces.resize(6); // exactly six surfaces (no choke inner cover)
53  } else {
54  oSurfaces.resize(8); // exactly eight surfaces
55  }
56 
57  // Outer cylinder envelope
58  auto outer =
59  Surface::makeShared<CylinderSurface>(transform, m_outerCylinderBounds);
60  oSurfaces.at(tubeOuterCover) = OrientedSurface(std::move(outer), backward);
61 
62  // Inner (cutout) cylinder envelope
63  auto cutoutInner =
64  Surface::makeShared<CylinderSurface>(transform, m_cutoutCylinderBounds);
65  oSurfaces.at(tubeInnerCover) =
66  OrientedSurface(std::move(cutoutInner), forward);
67 
68  // z position of the pos and neg choke points
69  double hlChoke = (get(eHalfLengthZ) - get(eHalfLengthZcutout)) * 0.5;
70  double zChoke = get(eHalfLengthZcutout) + hlChoke;
71 
72  if (m_innerCylinderBounds != nullptr) {
73  auto posChokeTrf = transform * Translation3D(Vector3D(0, 0, zChoke));
74  auto posInner = Surface::makeShared<CylinderSurface>(posChokeTrf,
75  m_innerCylinderBounds);
76  oSurfaces.at(index7) = OrientedSurface(std::move(posInner), forward);
77 
78  auto negChokeTrf = transform * Translation3D(Vector3D(0, 0, -zChoke));
79  auto negInner = Surface::makeShared<CylinderSurface>(negChokeTrf,
80  m_innerCylinderBounds);
81  oSurfaces.at(index6) = OrientedSurface(std::move(negInner), forward);
82  }
83 
84  // Two Outer disks
85  auto posOutDiscTrf =
86  transform * Translation3D(Vector3D(0, 0, get(eHalfLengthZ)));
87  auto posOutDisc =
88  Surface::makeShared<DiscSurface>(posOutDiscTrf, m_outerDiscBounds);
89  oSurfaces.at(positiveFaceXY) =
90  OrientedSurface(std::move(posOutDisc), backward);
91 
92  auto negOutDiscTrf =
93  transform * Translation3D(Vector3D(0, 0, -get(eHalfLengthZ)));
94  auto negOutDisc =
95  Surface::makeShared<DiscSurface>(negOutDiscTrf, m_outerDiscBounds);
96  oSurfaces.at(negativeFaceXY) =
97  OrientedSurface(std::move(negOutDisc), forward);
98 
99  // Two Inner disks
100  auto posInDiscTrf =
101  transform * Translation3D(Vector3D(0, 0, get(eHalfLengthZcutout)));
102  auto posInDisc =
103  Surface::makeShared<DiscSurface>(posInDiscTrf, m_innerDiscBounds);
104  oSurfaces.at(index5) = OrientedSurface(std::move(posInDisc), forward);
105 
106  auto negInDiscTrf =
107  transform * Translation3D(Vector3D(0, 0, -get(eHalfLengthZcutout)));
108  auto negInDisc =
109  Surface::makeShared<DiscSurface>(negInDiscTrf, m_innerDiscBounds);
110  oSurfaces.at(index4) = OrientedSurface(std::move(negInDisc), backward);
111 
112  return oSurfaces;
113 }
114 
116  const Acts::Transform3D* trf, const Acts::Vector3D& envelope,
117  const Acts::Volume* entity) const {
118  Vector3D vmin, vmax;
119 
120  // no phi sector is possible, so this is just the outer size of
121  // the cylinder
122 
123  vmax = {get(eMaxR), get(eMaxR), get(eHalfLengthZ)};
124  vmin = {-get(eMaxR), -get(eMaxR), -get(eHalfLengthZ)};
125 
126  Acts::Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope);
127  // transform at the very end, if required
128  return trf == nullptr ? box : box.transformed(*trf);
129 }
130 
132  std::ostream& sl) const {
133  sl << "Acts::CutoutCylinderVolumeBounds(\n";
134  sl << "rmin = " << get(eMinR) << " rmed = " << get(eMedR)
135  << " rmax = " << get(eMaxR) << "\n";
136  sl << "dz1 = " << get(eHalfLengthZ) << " dz2 = " << get(eHalfLengthZcutout);
137  return sl;
138 }
139 
141  if (get(eMinR) > s_epsilon) {
142  double hlChoke = (get(eHalfLengthZ) - get(eHalfLengthZcutout)) * 0.5;
143  m_innerCylinderBounds =
144  std::make_shared<CylinderBounds>(get(eMinR), hlChoke);
145  }
146 
147  m_cutoutCylinderBounds =
148  std::make_shared<CylinderBounds>(get(eMedR), get(eHalfLengthZcutout));
149 
150  m_outerCylinderBounds =
151  std::make_shared<CylinderBounds>(get(eMaxR), get(eHalfLengthZ));
152 
153  m_innerDiscBounds = std::make_shared<RadialBounds>(get(eMinR), get(eMedR));
154 
155  m_outerDiscBounds = std::make_shared<RadialBounds>(get(eMinR), get(eMaxR));
156 }