ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BoundarySurfaceT.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BoundarySurfaceT.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 // BoundarySurfaceT.h, Acts project
12 
13 #pragma once
14 #include <memory>
17 #include "Acts/Geometry/Volume.hpp"
20 
21 namespace Acts {
22 
23 class Surface;
24 
38 
39 template <class T>
42  friend T;
43 
44  using VolumePtr = std::shared_ptr<const T>;
46 
47  public:
50  : m_surface(nullptr),
51  m_insideVolume(nullptr),
52  m_outsideVolume(nullptr),
53  m_insideVolumeArray(nullptr),
54  m_outsideVolumeArray(nullptr) {}
55 
62  BoundarySurfaceT(std::shared_ptr<const Surface> surface, const T* inside,
63  const T* outside)
64  : m_surface(std::move(surface)),
65  m_insideVolume(inside),
66  m_outsideVolume(outside),
67  m_insideVolumeArray(nullptr),
68  m_outsideVolumeArray(nullptr) {}
69 
76  BoundarySurfaceT(std::shared_ptr<const Surface> surface, VolumePtr inside,
77  VolumePtr outside)
78  : m_surface(std::move(surface)),
79  m_insideVolume(inside.get()),
80  m_outsideVolume(outside.get()),
81  m_insideVolumeArray(nullptr),
82  m_outsideVolumeArray(nullptr) {}
83 
91  BoundarySurfaceT(std::shared_ptr<const Surface> surface,
92  std::shared_ptr<const VolumeArray> insideArray,
93  std::shared_ptr<const VolumeArray> outsideArray)
94  : m_surface(std::move(surface)),
95  m_insideVolume(nullptr),
96  m_outsideVolume(nullptr),
97  m_insideVolumeArray(insideArray),
98  m_outsideVolumeArray(outsideArray) {}
99 
109  virtual const T* attachedVolume(const GeometryContext& gctx,
110  const Vector3D& pos, const Vector3D& mom,
111  NavigationDirection pdir) const;
112 
119  template <class P>
120  bool onBoundary(const GeometryContext& gctx, const P& pars) const {
121  return surfaceRepresentation().isOnSurface(gctx, pars);
122  }
123 
125  virtual const Surface& surfaceRepresentation() const;
126 
128  virtual ~BoundarySurfaceT() = default;
129 
136  void attachVolume(const T* volume, BoundaryOrientation inout);
137 
143  void attachVolumeArray(std::shared_ptr<const VolumeArray> volumes,
144  BoundaryOrientation inout);
145 
146  protected:
148  std::shared_ptr<const Surface> m_surface;
154  std::shared_ptr<const VolumeArray> m_insideVolumeArray;
156  std::shared_ptr<const VolumeArray> m_outsideVolumeArray;
157 };
158 
159 template <class T>
161  return (*(m_surface.get()));
162 }
163 
164 template <class T>
166  BoundaryOrientation inout) {
167  if (inout == insideVolume) {
168  m_insideVolume = volume;
169  } else {
170  m_outsideVolume = volume;
171  }
172 }
173 
174 template <class T>
176  const std::shared_ptr<const VolumeArray> volumes,
177  BoundaryOrientation inout) {
178  if (inout == insideVolume) {
179  m_insideVolumeArray = volumes;
180  } else {
181  m_outsideVolumeArray = volumes;
182  }
183 }
184 
185 template <class T>
187  const Vector3D& pos,
188  const Vector3D& mom,
189  NavigationDirection pdir) const {
190  const T* attVolume = nullptr;
191  // dot product with normal vector to distinguish inside/outside
192  if ((surfaceRepresentation().normal(gctx, pos)).dot(pdir * mom) > 0.) {
193  attVolume = m_outsideVolumeArray ? m_outsideVolumeArray->object(pos).get()
194  : m_outsideVolume;
195  } else {
196  attVolume = m_insideVolumeArray ? m_insideVolumeArray->object(pos).get()
197  : m_insideVolume;
198  }
199  return attVolume;
200 }
201 } // namespace Acts