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 
9 #pragma once
12 #include "Acts/Geometry/Volume.hpp"
15 
16 #include <memory>
17 
18 namespace Acts {
19 
20 class Surface;
21 
35 
36 template <class volume_t>
39  friend volume_t;
40 
41  using VolumePtr = std::shared_ptr<const volume_t>;
43 
44  public:
46  : m_surface(nullptr),
47  m_oppositeVolume(nullptr),
48  m_alongVolume(nullptr),
49  m_oppositeVolumeArray(nullptr),
50  m_alongVolumeArray(nullptr) {}
51 
58  BoundarySurfaceT(std::shared_ptr<const Surface> surface,
59  const volume_t* inside, const volume_t* outside)
60  : m_surface(std::move(surface)),
61  m_oppositeVolume(inside),
62  m_alongVolume(outside),
63  m_oppositeVolumeArray(nullptr),
64  m_alongVolumeArray(nullptr) {}
65 
72  BoundarySurfaceT(std::shared_ptr<const Surface> surface, VolumePtr inside,
73  VolumePtr outside)
74  : m_surface(std::move(surface)),
75  m_oppositeVolume(inside.get()),
76  m_alongVolume(outside.get()),
77  m_oppositeVolumeArray(nullptr),
78  m_alongVolumeArray(nullptr) {}
79 
87  BoundarySurfaceT(std::shared_ptr<const Surface> surface,
88  std::shared_ptr<const VolumeArray> insideArray,
89  std::shared_ptr<const VolumeArray> outsideArray)
90  : m_surface(std::move(surface)),
91  m_oppositeVolume(nullptr),
92  m_alongVolume(nullptr),
93  m_oppositeVolumeArray(insideArray),
94  m_alongVolumeArray(outsideArray) {}
95 
96  virtual ~BoundarySurfaceT() = default;
97 
107  virtual const volume_t* attachedVolume(const GeometryContext& gctx,
108  const Vector3D& pos,
109  const Vector3D& mom,
110  NavigationDirection pdir) const;
111 
118  template <class parameters_t>
119  bool onBoundary(const GeometryContext& gctx, const parameters_t& pars) const {
120  return surfaceRepresentation().isOnSurface(gctx, pars);
121  }
122 
124  virtual const Surface& surfaceRepresentation() const;
125 
133 
139  void attachVolumeArray(std::shared_ptr<const VolumeArray> volumes,
141 
142  protected:
144  std::shared_ptr<const Surface> m_surface;
150  std::shared_ptr<const VolumeArray> m_oppositeVolumeArray;
152  std::shared_ptr<const VolumeArray> m_alongVolumeArray;
153 };
154 
155 template <class volume_t>
157  const {
158  return (*(m_surface.get()));
159 }
160 
161 template <class volume_t>
164  if (navDir == backward) {
165  m_oppositeVolume = volume;
166  } else {
167  m_alongVolume = volume;
168  }
169 }
170 
171 template <class volume_t>
173  const std::shared_ptr<const VolumeArray> volumes,
175  if (navDir == backward) {
176  m_oppositeVolumeArray = volumes;
177  } else {
178  m_alongVolumeArray = volumes;
179  }
180 }
181 
182 template <class volume_t>
184  const GeometryContext& gctx, const Vector3D& pos, const Vector3D& mom,
185  NavigationDirection navDir) const {
186  const volume_t* attVolume = nullptr;
187  // dot product with normal vector to distinguish inside/outside
188  if ((surfaceRepresentation().normal(gctx, pos)).dot(navDir * mom) > 0.) {
189  attVolume = m_alongVolumeArray ? m_alongVolumeArray->object(pos).get()
190  : m_alongVolume;
191  } else {
192  attVolume = m_oppositeVolumeArray ? m_oppositeVolumeArray->object(pos).get()
193  : m_oppositeVolume;
194  }
195  return attVolume;
196 }
197 } // namespace Acts