Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:55

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   ///
0100   /// @return an ordered list of portal and surface candidates
0101   inline void update(const GeometryContext& gctx,
0102                      NavigationState& nState) const {
0103     fill(gctx, nState);
0104     intitializeCandidates(gctx, nState);
0105   }
0106 };
0107 
0108 /// Generate a provider for all portals
0109 ///
0110 /// @return a connected navigationstate updator
0111 inline static InternalNavigationDelegate tryAllPortals() {
0112   auto ap = std::make_unique<const AllPortalsNavigation>();
0113   InternalNavigationDelegate nStateUpdater;
0114   nStateUpdater.connect<&AllPortalsNavigation::update>(std::move(ap));
0115   return nStateUpdater;
0116 }
0117 
0118 /// Generate a provider for all portals and Surfacess
0119 ///
0120 /// @note this is a try-and error navigation, not recommended for production
0121 /// setup with many surfaces
0122 ///
0123 /// @return a connected navigationstate updator
0124 inline static InternalNavigationDelegate tryAllPortalsAndSurfaces() {
0125   auto aps = std::make_unique<const AllPortalsAndSurfacesNavigation>();
0126   InternalNavigationDelegate nStateUpdater;
0127   nStateUpdater.connect<&AllPortalsAndSurfacesNavigation::update>(
0128       std::move(aps));
0129   return nStateUpdater;
0130 }
0131 
0132 /// @brief This holds and extracts a collection of surfaces without much
0133 /// checking, this could be e.g. support surfaces for layer structures,
0134 /// e.g.
0135 ///
0136 struct AdditionalSurfacesNavigation : public IInternalNavigation {
0137   /// The volumes held by this collection
0138   std::vector<const Surface*> surfaces = {};
0139 
0140   /// Extract the additional surfaces from the this volume
0141   ///
0142   /// @param gctx the geometry contextfor this extraction call (ignored)
0143   /// @param nState is the navigation state
0144   ///
0145   /// @note no intersection ordering is done at this stage
0146   inline void fill([[maybe_unused]] const GeometryContext& gctx,
0147                    NavigationState& nState) const {
0148     SurfacesFiller::fill(nState, surfaces);
0149   }
0150 
0151   /// Extract the additional surfaces from the this volume
0152   /// - update method that calls fill and initialize
0153   ///
0154   /// @param gctx is the Geometry context of this call
0155   /// @param nState is the navigation state to be updated
0156   ///
0157   /// @note that the intersections are ordered, such that the
0158   /// smallest intersection pathlength >= overstep tolerance is the lowest
0159   ///
0160   /// @return an ordered list of portal and surface candidates
0161   inline void update(const GeometryContext& gctx,
0162                      NavigationState& nState) const {
0163     fill(gctx, nState);
0164     intitializeCandidates(gctx, nState);
0165   }
0166 };
0167 
0168 /// @brief  An indexed surface implementation access
0169 ///
0170 /// @tparam grid_type is the grid type used for this indexed lookup
0171 template <typename grid_type>
0172 using IndexedSurfacesNavigation =
0173     IndexedGridNavigation<IInternalNavigation, grid_type,
0174                           IndexedSurfacesExtractor, SurfacesFiller>;
0175 
0176 /// @brief  An indexed multi layer surface implementation access
0177 ///
0178 /// @tparam grid_type is the grid type used for this indexed lookup
0179 template <typename grid_type>
0180 using MultiLayerSurfacesNavigation =
0181     MultiLayerNavigation<grid_type, PathGridSurfacesGenerator>;
0182 
0183 /// @brief An indexed surface implementation with portal access
0184 ///
0185 ///@tparam inexed_updator is the updator for the indexed surfaces
0186 template <typename grid_type, template <typename> class indexed_updator>
0187 using IndexedSurfacesAllPortalsNavigation =
0188     ChainedNavigation<IInternalNavigation, AllPortalsNavigation,
0189                       indexed_updator<grid_type>>;
0190 
0191 }  // namespace Acts::Experimental