ECCE @ EIC 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 
14 
15 #include <cmath>
16 #include <iostream>
17 
19  double halez)
20  : VolumeBounds(),
21  m_values({halex, haley, halez}),
22  m_xyBounds(std::make_shared<const RectangleBounds>(halex, haley)),
23  m_yzBounds(std::make_shared<const RectangleBounds>(haley, halez)),
24  m_zxBounds(std::make_shared<const RectangleBounds>(halez, halex)) {
25  checkConsistency();
26 }
27 
29  : VolumeBounds(),
30  m_values(bobo.m_values),
31  m_xyBounds(bobo.m_xyBounds),
32  m_yzBounds(bobo.m_yzBounds),
33  m_zxBounds(bobo.m_zxBounds) {}
34 
36  const CuboidVolumeBounds& bobo) {
37  if (this != &bobo) {
38  m_values = bobo.m_values;
39  m_xyBounds = bobo.m_xyBounds;
40  m_yzBounds = bobo.m_yzBounds;
41  m_zxBounds = bobo.m_zxBounds;
42  }
43  return *this;
44 }
45 
47  const Transform3D* transformPtr) const {
48  // the transform - apply when given
50  (transformPtr == nullptr) ? Transform3D::Identity() : (*transformPtr);
51  const Transform3D* tTransform = nullptr;
52 
53  SurfacePtrVector rSurfaces;
54  rSurfaces.reserve(6);
55  // face surfaces xy -------------------------------------
56  // (1) - at negative local z
57  tTransform =
58  new Transform3D(transform * AngleAxis3D(M_PI, Vector3D(0., 1., 0.)) *
59  Translation3D(Vector3D(0., 0., get(eHalfLengthZ))));
60  rSurfaces.push_back(Surface::makeShared<PlaneSurface>(
61  std::shared_ptr<const Transform3D>(tTransform), m_xyBounds));
62  // (2) - at positive local z
63  tTransform = new Transform3D(
64  transform * Translation3D(Vector3D(0., 0., get(eHalfLengthZ))));
65  rSurfaces.push_back(Surface::makeShared<PlaneSurface>(
66  std::shared_ptr<const Transform3D>(tTransform), m_xyBounds));
67  // face surfaces yz -------------------------------------
68  // transmute cyclical
69  // (3) - at negative local x
70  tTransform =
71  new Transform3D(transform * AngleAxis3D(M_PI, Vector3D(0., 0., 1.)) *
72  Translation3D(Vector3D(get(eHalfLengthX), 0., 0)) *
73  AngleAxis3D(0.5 * M_PI, Vector3D(0., 1., 0)) *
74  AngleAxis3D(0.5 * M_PI, Vector3D(0., 0., 1.)));
75  rSurfaces.push_back(Surface::makeShared<PlaneSurface>(
76  std::shared_ptr<const Transform3D>(tTransform), m_yzBounds));
77  // (4) - at positive local x
78  tTransform = new Transform3D(
79  transform * Translation3D(Vector3D(get(eHalfLengthX), 0., 0.)) *
80  AngleAxis3D(0.5 * M_PI, Vector3D(0., 1., 0.)) *
81  AngleAxis3D(0.5 * M_PI, Vector3D(0., 0., 1.)));
82  rSurfaces.push_back(Surface::makeShared<PlaneSurface>(
83  std::shared_ptr<const Transform3D>(tTransform), m_yzBounds));
84  // face surfaces zx -------------------------------------
85  // (5) - at negative local y
86  tTransform =
87  new Transform3D(transform * AngleAxis3D(M_PI, Vector3D(1., 0., 0.)) *
88  Translation3D(Vector3D(0., get(eHalfLengthY), 0.)) *
89  AngleAxis3D(-0.5 * M_PI, Vector3D(0., 1., 0.)) *
90  AngleAxis3D(-0.5 * M_PI, Vector3D(1., 0., 0.)));
91  rSurfaces.push_back(Surface::makeShared<PlaneSurface>(
92  std::shared_ptr<const Transform3D>(tTransform), m_zxBounds));
93  // (6) - at positive local y
94  tTransform = new Transform3D(
95  transform * Translation3D(Vector3D(0., get(eHalfLengthY), 0.)) *
96  AngleAxis3D(-0.5 * M_PI, Vector3D(0., 1., 0.)) *
97  AngleAxis3D(-0.5 * M_PI, Vector3D(1., 0., 0.)));
98  rSurfaces.push_back(Surface::makeShared<PlaneSurface>(
99  std::shared_ptr<const Transform3D>(tTransform), m_zxBounds));
100  // return the surfaces
101  return rSurfaces;
102 }
103 
104 std::ostream& Acts::CuboidVolumeBounds::toStream(std::ostream& sl) const {
105  return dumpT(sl);
106 }
107 
109  const Acts::Transform3D* trf, const Vector3D& envelope,
110  const Volume* entity) const {
111  Vector3D vmin(-get(eHalfLengthX), -get(eHalfLengthY), -get(eHalfLengthZ));
112  Vector3D vmax(get(eHalfLengthX), get(eHalfLengthY), get(eHalfLengthZ));
113 
114  Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope);
115  return trf == nullptr ? box : box.transformed(*trf);
116 }