Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:22:28

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Geometry/IndexGrid.hpp"
0012 #include "Acts/Geometry/TrackingVolume.hpp"
0013 #include "Acts/Navigation/INavigationPolicy.hpp"
0014 #include "Acts/Navigation/NavigationStream.hpp"
0015 #include "Acts/Surfaces/detail/IntersectionHelper2D.hpp"
0016 #include "Acts/Utilities/Grid.hpp"
0017 
0018 namespace Acts::Experimental {
0019 
0020 /// A navigation policy that uses grid based navigation for indexed surfaces
0021 /// Navigate through a multilayer structure by creating an artificial path on
0022 /// the grid.
0023 class MultiLayerNavigationPolicy : public INavigationPolicy {
0024  public:
0025   /// Type alias for 2D equidistant grid holding surface indices
0026   using GridType = Grid<std::vector<std::size_t>,
0027                         Axis<AxisType::Equidistant, AxisBoundaryType::Bound>,
0028                         Axis<AxisType::Equidistant, AxisBoundaryType::Bound>>;
0029 
0030   /// Type alias for indexed surfaces navigation updater
0031   using IndexedUpdatorType = IndexGrid<GridType>;
0032 
0033   struct Config {
0034     // The binning expansion for grid neighbor lookups
0035     std::vector<std::size_t> binExpansion = {0u, 0u};
0036   };
0037 
0038   /// Main constructor, which expects the grid and will fill it with the
0039   /// surfaces from the volume passed
0040   /// @note Expects that the grid is defined but not filled - it will be filled here with the surfaces assigned to the @p volume
0041   /// @param gctx The geometrycontext object
0042   /// @param volume The tracking volume holding the surfaces that will be the indexed objects
0043   /// @param config The configuration of the Navigation Policy
0044   /// @param logger A logging instance
0045   /// @param grid The grid that will be filled with the surfaces
0046   explicit MultiLayerNavigationPolicy(const GeometryContext& gctx,
0047                                       const TrackingVolume& volume,
0048                                       const Logger& logger,
0049                                       const Config& config,
0050                                       IndexedUpdatorType grid);
0051 
0052   /// Update the navigation state from the surface array
0053   /// @param gctx The geometry context
0054   /// @param args The navigation arguments
0055   /// @param stream The navigation stream to update
0056   /// @param logger The logger
0057   void initializeCandidates(const GeometryContext& gctx,
0058                             const NavigationArguments& args,
0059                             AppendOnlyNavigationStream& stream,
0060                             const Logger& logger) const;
0061 
0062   /// Connect this policy with a navigation delegate
0063   /// @param delegate The navigation delegate to connect to
0064   void connect(NavigationDelegate& delegate) const override {
0065     connectDefault<MultiLayerNavigationPolicy>(delegate);
0066   }
0067 
0068   /// Generate a path in the multilayer
0069   /// @param startPosition The starting position of the path (in local frame)
0070   /// @param direction The direction of the path (in local frame)
0071   /// @return A vector of positions along the path
0072   std::vector<Vector2> generatePath(const Vector3& startPosition,
0073                                     const Vector3& direction) const;
0074 
0075  private:
0076   // The tracking volume
0077   const TrackingVolume& m_volume;
0078 
0079   // The grid that holds the indexed surfaces
0080   IndexedUpdatorType m_indexedGrid;
0081 };
0082 
0083 static_assert(NavigationPolicyConcept<MultiLayerNavigationPolicy>);
0084 
0085 }  // namespace Acts::Experimental