Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceCandidatesUpdators.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SurfaceCandidatesUpdators.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 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
10 
14 #include "Acts/Detector/Portal.hpp"
21 
22 #include <memory>
23 #include <tuple>
24 
25 namespace Acts {
26 namespace Experimental {
27 
38  inline void update(const GeometryContext& gctx,
39  NavigationState& nState) const {
40  if (nState.currentVolume == nullptr) {
41  throw std::runtime_error(
42  "AllPortalsImpl: no detector volume set to navigation state.");
43  }
44  // Retrieval necessary
45  if (nState.surfaceCandidates.empty()) {
46  // Fill internal portals if existing
47  for (const auto v : nState.currentVolume->volumes()) {
48  const auto& iPortals = v->portals();
49  PortalsFiller::fill(nState, iPortals);
50  }
51  // Filling the new portal candidates
52  const auto& portals = nState.currentVolume->portals();
53  PortalsFiller::fill(nState, portals);
54  }
55  // Sort and update
56  updateCandidates(gctx, nState);
57  }
58 };
59 
70  inline void update(const GeometryContext& gctx,
71  NavigationState& nState) const {
72  if (nState.currentDetector == nullptr) {
73  throw std::runtime_error(
74  "AllPortalsAndSurfacesImpl: no detector volume set to navigation "
75  "state.");
76  }
77  // A volume switch has happened, update list of portals & surfaces
78  if (nState.surfaceCandidates.empty()) {
79  // Fill internal portals if existing
80  for (const auto v : nState.currentVolume->volumes()) {
81  const auto& iPortals = v->portals();
82  PortalsFiller::fill(nState, iPortals);
83  }
84  // Assign the new volume
85  const auto& portals = nState.currentVolume->portals();
86  const auto& surfaces = nState.currentVolume->surfaces();
87  PortalsFiller::fill(nState, portals);
88  SurfacesFiller::fill(nState, surfaces);
89  }
90  // Update internal candidates
91  updateCandidates(gctx, nState);
92  }
93 };
94 
99  auto ap = std::make_unique<const AllPortalsImpl>();
100  SurfaceCandidatesUpdator nStateUpdator;
101  nStateUpdator.connect<&AllPortalsImpl::update>(std::move(ap));
102  return nStateUpdator;
103 }
104 
112  auto aps = std::make_unique<const AllPortalsAndSurfacesImpl>();
113  SurfaceCandidatesUpdator nStateUpdator;
114  nStateUpdator.connect<&AllPortalsAndSurfacesImpl::update>(std::move(aps));
115  return nStateUpdator;
116 }
117 
124  std::vector<const Surface*> surfaces = {};
125 
131  inline void update([[maybe_unused]] const GeometryContext& gctx,
132  NavigationState& nState) const {
134  }
135 };
136 
140 template <typename grid_type>
141 using IndexedSurfacesImpl =
143 
147 template <typename grid_type>
150 
154 template <typename grid_type, template <typename> class indexed_updator>
157 
158 } // namespace Experimental
159 } // namespace Acts