ECCE @ 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 
11 #include "Acts/Geometry/Volume.hpp"
18 
19 #include <memory>
20 #include <vector>
21 
23  double tol) const {
24  // first check whether we are in the outer envelope at all (ignore r_med)
25  using VectorHelpers::perp;
26  using VectorHelpers::phi;
27  double ros = perp(gpos);
28 
29  bool insideR = (ros >= get(eMinR) - tol) && (ros <= get(eMaxR) + tol);
30  bool insideZ = std::abs(gpos.z()) <= get(eHalfLengthZ) + tol;
31 
32  if (!insideR || !insideZ) {
33  return false;
34  }
35 
36  // we're inside the outer volume, but we might be in inside the
37  // cutout section in the middle
38  bool insideRInner = ros <= get(eMedR) - tol;
39  bool insideZInner = std::abs(gpos.z()) < get(eHalfLengthZcutout) - tol;
40 
41  return !insideRInner || !insideZInner; // we are not, inside bounds
42 }
43 
44 std::vector<std::shared_ptr<const Acts::Surface>>
46  const Transform3D* transform) const {
47  std::vector<std::shared_ptr<const Acts::Surface>> surfaces;
48 
49  // transform copy
50  std::shared_ptr<const Transform3D> trf;
51  if (transform != nullptr) {
52  trf = std::make_shared<const Transform3D>(*transform);
53  } else {
54  trf = std::make_shared<const Transform3D>(Transform3D::Identity());
55  }
56 
57  if (get(eMinR) == 0.) {
58  surfaces.resize(6); // exactly six surfaces (no choke inner cover)
59  } else {
60  surfaces.resize(8); // exactly eight surfaces
61  }
62 
63  // outer cylinder envelope
64  auto outerBounds =
65  std::make_shared<CylinderBounds>(get(eMaxR), get(eHalfLengthZ));
66  auto outer = Surface::makeShared<CylinderSurface>(trf, outerBounds);
67  surfaces.at(tubeOuterCover) = outer;
68 
69  // inner (small) cylinder envelope
70  auto ctr_innerBounds =
71  std::make_shared<CylinderBounds>(get(eMedR), get(eHalfLengthZcutout));
72  auto ctr_inner = Surface::makeShared<CylinderSurface>(trf, ctr_innerBounds);
73  surfaces.at(tubeInnerCover) = ctr_inner;
74 
75  // z position of the pos and neg choke points
76  double hlChoke = (get(eHalfLengthZ) - get(eHalfLengthZcutout)) * 0.5;
77  double zChoke = get(eHalfLengthZcutout) + hlChoke;
78 
79  if (get(eMinR) > 0.) {
80  auto posChokeTrf = std::make_shared<const Transform3D>(
81  *trf * Translation3D(Vector3D(0, 0, zChoke)));
82  auto posInner =
83  Surface::makeShared<CylinderSurface>(posChokeTrf, get(eMinR), hlChoke);
84  surfaces.at(index7) = posInner;
85 
86  auto negChokeTrf = std::make_shared<const Transform3D>(
87  *trf * Translation3D(Vector3D(0, 0, -zChoke)));
88  auto negInner =
89  Surface::makeShared<CylinderSurface>(negChokeTrf, get(eMinR), hlChoke);
90  surfaces.at(index6) = negInner;
91  }
92 
93  // outer disks
94  auto posOutDiscTrf = std::make_shared<const Transform3D>(
95  *trf * Translation3D(Vector3D(0, 0, get(eHalfLengthZ))));
96  auto posOutDisc =
97  Surface::makeShared<DiscSurface>(posOutDiscTrf, get(eMinR), get(eMaxR));
98  surfaces.at(positiveFaceXY) = posOutDisc;
99 
100  auto negOutDiscTrf = std::make_shared<const Transform3D>(
101  *trf * Translation3D(Vector3D(0, 0, -get(eHalfLengthZ))) *
102  AngleAxis3D(M_PI, Vector3D::UnitX()));
103  auto negOutDisc =
104  Surface::makeShared<DiscSurface>(negOutDiscTrf, get(eMinR), get(eMaxR));
105  surfaces.at(negativeFaceXY) = negOutDisc;
106 
107  // inner disks
108  auto posInDiscTrf = std::make_shared<const Transform3D>(
109  *trf * Translation3D(Vector3D(0, 0, get(eHalfLengthZcutout))));
110  auto posInDisc =
111  Surface::makeShared<DiscSurface>(posInDiscTrf, get(eMinR), get(eMedR));
112  surfaces.at(index5) = posInDisc;
113 
114  auto negInDiscTrf = std::make_shared<const Transform3D>(
115  *trf * Translation3D(Vector3D(0, 0, -get(eHalfLengthZcutout))) *
116  AngleAxis3D(M_PI, Vector3D::UnitX()));
117  auto negInDisc =
118  Surface::makeShared<DiscSurface>(negInDiscTrf, get(eMinR), get(eMedR));
119  surfaces.at(index4) = negInDisc;
120 
121  return surfaces;
122 }
123 
125  const Acts::Transform3D* trf, const Acts::Vector3D& envelope,
126  const Acts::Volume* entity) const {
127  Vector3D 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 }