Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-01 07:53:20

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/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Detector/DetectorVolume.hpp"
0014 #include "Acts/Detector/Portal.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Navigation/MultiLayerNavigation.hpp"
0017 #include "Acts/Navigation/NavigationState.hpp"
0018 #include "Acts/Navigation/NavigationStateFillers.hpp"
0019 #include "Acts/Navigation/NavigationStateUpdaters.hpp"
0020 #include "Acts/Surfaces/Surface.hpp"
0021 
0022 #include <memory>
0023 #include <tuple>
0024 
0025 namespace Acts::Experimental {
0026 
0027 struct AllPortalsNavigation : public IInternalNavigation {
0028   /// Fills all portals into the navigation state
0029   ///
0030   /// @param gctx is the Geometry context of this call
0031   /// @param nState is the navigation state to be updated
0032   ///
0033   /// @note no intersection ordering is done at this stage
0034   inline void fill([[maybe_unused]] const GeometryContext& gctx,
0035                    NavigationState& nState) const {
0036     if (nState.currentVolume == nullptr) {
0037       throw std::runtime_error(
0038           "AllPortalsNavigation: no detector volume set to navigation state.");
0039     }
0040     // Fill internal portals if existing
0041     for (const auto v : nState.currentVolume->volumes()) {
0042       const auto& iPortals = v->portals();
0043       PortalsFiller::fill(nState, iPortals);
0044     }
0045     // Filling the new portal candidates
0046     const auto& portals = nState.currentVolume->portals();
0047     PortalsFiller::fill(nState, portals);
0048   }
0049 
0050   /// A ordered portal provider - update method that calls fill and initialize
0051   ///
0052   /// @param gctx is the Geometry context of this call
0053   /// @param nState is the navigation state to be updated
0054   ///
0055   /// @note that the intersections are ordered, such that the
0056   /// smallest intersection pathlength >= overstep tolerance is the lowest
0057   inline void update(const GeometryContext& gctx,
0058                      NavigationState& nState) const {
0059     fill(gctx, nState);
0060     intitializeCandidates(gctx, nState);
0061   }
0062 };
0063 
0064 struct AllPortalsAndSurfacesNavigation : public IInternalNavigation {
0065   /// Fills all portals and surfaces into the navigation state
0066   ///
0067   /// @param gctx is the Geometry context of this call
0068   /// @param nState is the navigation state to be updated
0069   ///
0070   /// @note no intersection ordering is done at this stage
0071   inline void fill([[maybe_unused]] const GeometryContext& gctx,
0072                    NavigationState& nState) const {
0073     if (nState.currentDetector == nullptr) {
0074       throw std::runtime_error(
0075           "AllPortalsAndSurfacesNavigation: no detector volume set to "
0076           "navigation "
0077           "state.");
0078     }
0079     // A volume switch has happened, update list of portals & surfaces
0080     for (const auto v : nState.currentVolume->volumes()) {
0081       const auto& iPortals = v->portals();
0082       PortalsFiller::fill(nState, iPortals);
0083     }
0084     // Assign the new volume
0085     const auto& portals = nState.currentVolume->portals();
0086     const auto& surfaces = nState.currentVolume->surfaces();
0087     PortalsFiller::fill(nState, portals);
0088     SurfacesFiller::fill(nState, surfaces);
0089   }
0090 
0091   /// A ordered list of portals and surfaces provider
0092   /// - update method that calls fill and initialize
0093   ///
0094   /// @param gctx is the Geometry context of this call
0095   /// @param nState is the navigation state to be updated
0096   ///
0097   /// @note that the intersections are ordered, such that the
0098   /// smallest intersection pathlength >= overstep tolerance is the lowest
0099   inline void update(const GeometryContext& gctx,
0100                      NavigationState& nState) const {
0101     fill(gctx, nState);
0102     intitializeCandidates(gctx, nState);
0103   }
0104 };
0105 
0106 /// Generate a provider for all portals
0107 ///
0108 /// @return a connected navigationstate updator
0109 inline static InternalNavigationDelegate tryAllPortals() {
0110   auto ap = std::make_unique<const AllPortalsNavigation>();
0111   InternalNavigationDelegate nStateUpdater;
0112   nStateUpdater.connect<&AllPortalsNavigation::update>(std::move(ap));
0113   return nStateUpdater;
0114 }
0115 
0116 /// Generate a provider for all portals and Surfacess
0117 ///
0118 /// @note this is a try-and error navigation, not recommended for production
0119 /// setup with many surfaces
0120 ///
0121 /// @return a connected navigationstate updator
0122 inline static InternalNavigationDelegate tryAllPortalsAndSurfaces() {
0123   auto aps = std::make_unique<const AllPortalsAndSurfacesNavigation>();
0124   InternalNavigationDelegate nStateUpdater;
0125   nStateUpdater.connect<&AllPortalsAndSurfacesNavigation::update>(
0126       std::move(aps));
0127   return nStateUpdater;
0128 }
0129 
0130 /// @brief This holds and extracts a collection of surfaces without much
0131 /// checking, this could be e.g. support surfaces for layer structures,
0132 /// e.g.
0133 ///
0134 struct AdditionalSurfacesNavigation : public IInternalNavigation {
0135   /// The volumes held by this collection
0136   std::vector<const Surface*> surfaces = {};
0137 
0138   /// Extract the additional surfaces from the this volume
0139   ///
0140   /// @param gctx the geometry contextfor this extraction call (ignored)
0141   /// @param nState is the navigation state
0142   ///
0143   /// @note no intersection ordering is done at this stage
0144   inline void fill([[maybe_unused]] const GeometryContext& gctx,
0145                    NavigationState& nState) const {
0146     SurfacesFiller::fill(nState, surfaces);
0147   }
0148 
0149   /// Extract the additional surfaces from the this volume
0150   /// - update method that calls fill and initialize
0151   ///
0152   /// @param gctx is the Geometry context of this call
0153   /// @param nState is the navigation state to be updated
0154   ///
0155   /// @note that the intersections are ordered, such that the
0156   /// smallest intersection pathlength >= overstep tolerance is the lowest
0157   inline void update(const GeometryContext& gctx,
0158                      NavigationState& nState) const {
0159     fill(gctx, nState);
0160     intitializeCandidates(gctx, nState);
0161   }
0162 };
0163 
0164 /// @brief  An indexed surface implementation access
0165 ///
0166 /// @tparam grid_type is the grid type used for this indexed lookup
0167 template <typename grid_type>
0168 using IndexedSurfacesNavigation =
0169     IndexedGridNavigation<IInternalNavigation, grid_type,
0170                           IndexedSurfacesExtractor, SurfacesFiller>;
0171 
0172 /// @brief  An indexed multi layer surface implementation access
0173 ///
0174 /// @tparam grid_type is the grid type used for this indexed lookup
0175 template <typename grid_type>
0176 using MultiLayerSurfacesNavigation =
0177     MultiLayerNavigation<grid_type, PathGridSurfacesGenerator>;
0178 
0179 /// @brief An indexed surface implementation with portal access
0180 ///
0181 ///@tparam inexed_updator is the updator for the indexed surfaces
0182 template <typename grid_type, template <typename> class indexed_updator>
0183 using IndexedSurfacesAllPortalsNavigation =
0184     ChainedNavigation<IInternalNavigation, AllPortalsNavigation,
0185                       indexed_updator<grid_type>>;
0186 
0187 }  // namespace Acts::Experimental