Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:33

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Detector/detail/IndexedGridFiller.hpp"
0013 #include "Acts/Navigation/InternalNavigation.hpp"
0014 #include "Acts/Utilities/Enumerate.hpp"
0015 
0016 #include <algorithm>
0017 #include <array>
0018 #include <memory>
0019 
0020 namespace Acts::Experimental::detail {
0021 
0022 /// @brief  A templated indexed grid generator.
0023 ///
0024 /// This Generator creates a InternalNavigationDelegate delegate
0025 /// which can then be used in the DetectorVolume class for updating
0026 /// given surface candidates based on an index grid.
0027 ///
0028 /// It allows for:
0029 /// - certain indices being forcly assigned to all bins
0030 /// - a chosen expansion to fill indices in neighborhood bins
0031 ///
0032 /// @tparam objects_container the objects container
0033 template <typename surface_container, template <typename> class indexed_updator>
0034 struct IndexedSurfacesGenerator {
0035   /// The surfaces to be indexed
0036   /// (including surfaces that are assigned to all bins)
0037   surface_container surfaces = {};
0038   // Indices of surfaces that are to be assigned to all bins
0039   std::vector<std::size_t> assignToAll = {};
0040   /// The binning for the indexing
0041   std::vector<BinningValue> bValues = {};
0042   // Bin expansion
0043   std::vector<std::size_t> binExpansion = {};
0044   /// The transform into the local binning schema
0045   Transform3 transform = Transform3::Identity();
0046   /// Screen output logger
0047   std::unique_ptr<const Logger> oLogger =
0048       getDefaultLogger("IndexedSurfacesGenerator", Logging::INFO);
0049 
0050   /// Create the Surface candidate updator
0051   ///
0052   /// @tparam axis_generator does generate the axis of the grid
0053   /// @tparam reference_generator does generate the reference query points
0054   ///
0055   /// @param gctx the geometry context
0056   /// @param aGenerator the axis generator
0057   /// @param rGenerator the reference generataor
0058   ///
0059   /// @return an InternalNavigationDelegate
0060   template <typename axis_generator, typename reference_generator>
0061   InternalNavigationDelegate operator()(
0062       const GeometryContext& gctx, const axis_generator& aGenerator,
0063       const reference_generator& rGenerator) const {
0064     ACTS_DEBUG("Indexing " << surfaces.size() << " surface, "
0065                            << assignToAll.size() << " of which into all bins.");
0066     // Create the grid with the provided axis generator
0067     using GridType =
0068         typename axis_generator::template grid_type<std::vector<std::size_t>>;
0069     GridType grid(std::move(aGenerator()));
0070 
0071     std::array<BinningValue, decltype(grid)::DIM> bvArray = {};
0072     for (auto [ibv, bv] : enumerate(bValues)) {
0073       bvArray[ibv] = bv;
0074     }
0075 
0076     indexed_updator<GridType> indexedSurfaces(std::move(grid), bvArray,
0077                                               transform);
0078     // Fill the bin indices
0079     IndexedGridFiller filler{binExpansion};
0080     filler.oLogger = oLogger->cloneWithSuffix("_filler");
0081     filler.fill(gctx, indexedSurfaces, surfaces, rGenerator, assignToAll);
0082 
0083     // The portal delegate
0084     AllPortalsNavigation allPortals;
0085 
0086     // The chained delegate: indexed surfaces and all portals
0087     using DelegateType =
0088         IndexedSurfacesAllPortalsNavigation<decltype(grid), indexed_updator>;
0089     auto indexedSurfacesAllPortals = std::make_unique<const DelegateType>(
0090         std::tie(allPortals, indexedSurfaces));
0091 
0092     // Create the delegate and connect it
0093     InternalNavigationDelegate nStateUpdater;
0094     nStateUpdater.connect<&DelegateType::update>(
0095         std::move(indexedSurfacesAllPortals));
0096     return nStateUpdater;
0097   }
0098 
0099   /// Access to the logger
0100   ///
0101   /// @return a const reference to the logger
0102   const Logger& logger() const { return *oLogger; }
0103 };
0104 
0105 }  // namespace Acts::Experimental::detail