Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorVolumeUpdators.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorVolumeUpdators.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022-2023 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 
18 
19 #include <stdexcept>
20 
21 namespace Acts {
22 namespace Experimental {
23 
24 class DetectorVolume;
25 
33  inline void update(const GeometryContext& /*ignored*/,
34  NavigationState& nState) const {
35  nState.currentVolume = nullptr;
36  }
37 };
38 
43  const DetectorVolume* dVolume = nullptr;
44 
47  SingleDetectorVolumeImpl(const DetectorVolume* sVolume) noexcept(false)
48  : dVolume(sVolume) {
49  if (sVolume == nullptr) {
50  throw std::invalid_argument(
51  "DetectorVolumeUpdators: nullptr provided, use EndOfWorld instead.");
52  }
53  }
54 
55  SingleDetectorVolumeImpl() = delete;
56 
61  inline void update(const GeometryContext& /*ignored*/,
62  NavigationState& nState) const {
63  nState.currentVolume = dVolume;
64  }
65 };
66 
67 using SingleIndex = std::size_t;
68 
69 using VariableBoundAxis =
70  Acts::detail::Axis<Acts::detail::AxisType::Variable,
71  Acts::detail::AxisBoundaryType::Bound>;
74 
82  std::vector<const DetectorVolume*> dVolumes = {};
83 
90  inline const DetectorVolume* extract(const GeometryContext& /*gctx*/,
91  const NavigationState& /*nState*/,
92  const SingleIndex& index) const {
93  return dVolumes[index];
94  }
95 };
96 
102  using IndexedUpdator =
105  // The indexed updator
107 
115  const std::vector<ActsScalar>& gBoundaries, BinningValue bValue,
116  const std::vector<const DetectorVolume*>& cVolumes,
117  const Transform3& bTransform = Transform3::Identity()) noexcept(false)
119  VariableBoundAxis(gBoundaries))),
120  {bValue}, bTransform)) {
121  indexedUpdator.extractor.dVolumes = cVolumes;
122 
123  if (gBoundaries.size() != cVolumes.size() + 1u) {
124  throw std::invalid_argument(
125  "DetectorVolumeUpdators: mismatching boundaries and volume numbers");
126  }
127  // Initialize the grid entries
128  for (std::size_t ib = 1u; ib < gBoundaries.size(); ++ib) {
129  indexedUpdator.grid.at(ib) = ib - 1;
130  }
131  }
132  // Deleted default constructor
133  BoundVolumesGrid1Impl() = delete;
134 
139  inline void update(const GeometryContext& gctx,
140  NavigationState& nState) const {
141  indexedUpdator.update(gctx, nState);
142  }
143 };
144 
145 } // namespace Experimental
146 } // namespace Acts