Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Core/src/Navigation/TryAllNavigationPolicy.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 #include "Acts/Navigation/TryAllNavigationPolicy.hpp"
0010 
0011 #include "Acts/Geometry/TrackingVolume.hpp"
0012 #include "Acts/Navigation/NavigationStream.hpp"
0013 
0014 namespace Acts {
0015 
0016 TryAllNavigationPolicy::TryAllNavigationPolicy(const GeometryContext& /*gctx*/,
0017                                                const TrackingVolume& volume,
0018                                                const Logger& logger,
0019                                                const Config& config)
0020     : m_cfg{config}, m_volume(&volume) {
0021   assert(m_volume != nullptr);
0022   ACTS_VERBOSE("TryAllNavigationPolicy created for volume "
0023                << m_volume->volumeName() << " with config: "
0024                << " portals=" << m_cfg.portals << " sensitives="
0025                << m_cfg.sensitives << " passives=" << m_cfg.passives);
0026 }
0027 
0028 TryAllNavigationPolicy::TryAllNavigationPolicy(const GeometryContext& gctx,
0029                                                const TrackingVolume& volume,
0030                                                const Logger& logger)
0031     : TryAllNavigationPolicy(gctx, volume, logger, {}) {}
0032 
0033 void TryAllNavigationPolicy::initializeCandidates(
0034     [[maybe_unused]] const GeometryContext& gctx,
0035     const NavigationArguments& args, NavigationPolicyState& /*state*/,
0036     AppendOnlyNavigationStream& stream, const Logger& logger) const {
0037   ACTS_VERBOSE("TryAllNavigationPolicy initializing candidates for volume "
0038                << m_volume->volumeName());
0039   ACTS_VERBOSE("~> Config: portals=" << m_cfg.portals
0040                                      << " sensitives=" << m_cfg.sensitives
0041                                      << " passives=" << m_cfg.passives);
0042   assert(m_volume != nullptr);
0043 
0044   std::size_t numCandidates = 0;
0045 
0046   if (m_cfg.portals) {
0047     for (const auto& portal : m_volume->portals()) {
0048       stream.addPortalCandidate(portal);
0049       numCandidates++;
0050     }
0051   }
0052 
0053   if (!(m_cfg.sensitives || m_cfg.passives)) {
0054     return;
0055   }
0056 
0057   for (const auto& surface : m_volume->surfaces()) {
0058     bool isSensitive = surface.isSensitive();
0059     if ((m_cfg.passives && !isSensitive) || (m_cfg.sensitives && isSensitive)) {
0060       stream.addSurfaceCandidate(surface, args.tolerance);
0061       numCandidates++;
0062     }
0063   }
0064 
0065   ACTS_VERBOSE("TryAllNavigationPolicy added " << numCandidates
0066                                                << " candidates to the stream");
0067 }
0068 
0069 void TryAllNavigationPolicy::connect(NavigationDelegate& delegate) const {
0070   connectDefault<TryAllNavigationPolicy>(delegate);
0071 }
0072 
0073 const TryAllNavigationPolicy::Config& TryAllNavigationPolicy::config() const {
0074   return m_cfg;
0075 }
0076 
0077 }  // namespace Acts