Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IndexedSurfacesGenerator.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IndexedSurfacesGenerator.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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 
15 
16 #include <algorithm>
17 #include <array>
18 #include <memory>
19 
20 namespace Acts {
21 namespace Experimental {
22 namespace detail {
23 
35 template <typename surface_container, template <typename> class indexed_updator>
39  surface_container surfaces = {};
40  // Indices of surfaces that are to be assigned to all bins
41  std::vector<std::size_t> assignToAll = {};
43  std::vector<BinningValue> bValues = {};
44  // Bin expansion
45  std::vector<std::size_t> binExpansion = {};
47  Transform3 transform = Transform3::Identity();
49  std::unique_ptr<const Logger> oLogger =
50  getDefaultLogger("IndexedSurfacesGenerator", Logging::INFO);
51 
62  template <typename axis_generator, typename reference_generator>
64  const GeometryContext& gctx, const axis_generator& aGenerator,
65  const reference_generator& rGenerator) const {
66  ACTS_DEBUG("Indexing " << surfaces.size() << " surface, "
67  << assignToAll.size() << " of which into all bins.");
68  // Create the grid with the provided axis generator
69  using GridType =
70  typename axis_generator::template grid_type<std::vector<std::size_t>>;
71  GridType grid(std::move(aGenerator()));
72 
73  std::array<BinningValue, decltype(grid)::DIM> bvArray = {};
74  for (auto [ibv, bv] : enumerate(bValues)) {
75  bvArray[ibv] = bv;
76  }
77 
78  indexed_updator<GridType> indexedSurfaces(std::move(grid), bvArray,
79  transform);
80  // Fill the bin indices
82  filler.oLogger = oLogger->cloneWithSuffix("_filler");
83  filler.fill(gctx, indexedSurfaces, surfaces, rGenerator, assignToAll);
84 
85  // The portal delegate
86  AllPortalsImpl allPortals;
87 
88  // The chained delegate: indexed surfaces and all portals
89  using DelegateType =
91  auto indexedSurfacesAllPortals = std::make_unique<const DelegateType>(
92  std::tie(allPortals, indexedSurfaces));
93 
94  // Create the delegate and connect it
95  SurfaceCandidatesUpdator nStateUpdator;
96  nStateUpdator.connect<&DelegateType::update>(
97  std::move(indexedSurfacesAllPortals));
98  return nStateUpdator;
99  }
100 
104  const Logger& logger() const { return *oLogger; }
105 };
106 
107 } // namespace detail
108 } // namespace Experimental
109 } // namespace Acts