Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NavigationStateUpdators.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file NavigationStateUpdators.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 
13 #include "Acts/Detector/Portal.hpp"
18 #include "Acts/Utilities/IAxis.hpp"
20 
21 #include <array>
22 #include <memory>
23 
24 namespace Acts {
25 
26 namespace Experimental {
27 
39  const auto& position = nState.position;
40  const auto& direction = nState.direction;
41  auto& nCandidates = nState.surfaceCandidates;
42 
43  for (auto& c : nCandidates) {
44  // Get the surface representation: either native surfcae of portal
45  const Surface& sRep =
46  c.surface != nullptr ? *c.surface : c.portal->surface();
47 
48  // Get the intersection @todo make a templated intersector
49  // TODO surface tolerance
50  auto sIntersection = sRep.intersect(gctx, position, direction,
51  c.boundaryCheck, s_onSurfaceTolerance);
52  c.objectIntersection = sIntersection[c.objectIntersection.index()];
53  }
54 }
55 
59 template <typename object_type, typename filler_type>
61  public:
64  SingleObjectImpl(const object_type* so) : object(so) {}
65 
72  void update([[maybe_unused]] const GeometryContext& gctx,
73  NavigationState& nState) const {
74  filler_type::fill(nState, object);
75  }
76 
77  private:
78  // The object to be filled in
79  const object_type* object = nullptr;
80 };
81 
87 template <typename extractor_type, typename filler_type>
89  public:
96  void update([[maybe_unused]] const GeometryContext& gctx,
97  NavigationState& nState) const {
98  auto extracted = extractor_type::extract(gctx, nState);
99  filler_type::fill(nState, extracted);
100  }
101 };
102 
114 template <typename grid_t, typename extractor_type, typename filler_type>
116  public:
118  using grid_type = grid_t;
119 
121  extractor_type extractor;
122 
125 
127  std::array<BinningValue, grid_type::DIM> casts{};
128 
130  Transform3 transform = Transform3::Identity();
131 
137  const std::array<BinningValue, grid_type::DIM>& icasts,
138  const Transform3& itr = Transform3::Identity())
139  : grid(std::move(igrid)), casts(icasts), transform(itr) {}
140 
141  IndexedUpdatorImpl() = delete;
142 
151  // Extract the index grid entry
152  const auto& entry = grid.atPosition(castPosition(nState.position));
153  auto extracted = extractor.extract(gctx, nState, entry);
154  filler_type::fill(nState, extracted);
155 
156  updateCandidates(gctx, nState);
157  }
158 
162  std::array<ActsScalar, grid_type::DIM> castPosition(
163  const Vector3& position) const {
164  // Transform into local 3D frame
165  Vector3 tposition = transform * position;
166 
167  std::array<ActsScalar, grid_type::DIM> casted{};
168  fillCasts(tposition, casted,
169  std::make_integer_sequence<std::size_t, grid_type::DIM>{});
170  return casted;
171  }
172 
173  private:
177  template <typename Array, std::size_t... idx>
178  void fillCasts(const Vector3& position, Array& a,
179  std::index_sequence<idx...> /*indices*/) const {
180  ((a[idx] = VectorHelpers::cast(position, casts[idx])), ...);
181  }
182 };
183 
189 template <typename... updators_t>
191  public:
193  std::tuple<updators_t...> updators;
194 
199  ChainedUpdatorImpl(const std::tuple<updators_t...>&& upts)
200  : updators(std::move(upts)) {}
201 
208  // Unfold the tuple and add the attachers
209  std::apply(
210  [&](auto&&... updator) { ((updator.update(gctx, nState)), ...); },
211  updators);
212  }
213 };
214 
215 } // namespace Experimental
216 } // namespace Acts