File indexing completed on 2025-01-18 09:11:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Navigation/SurfaceArrayNavigationPolicy.hpp"
0010
0011 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0012 #include "Acts/Geometry/TrackingVolume.hpp"
0013 #include "Acts/Navigation/NavigationStream.hpp"
0014
0015 #include <algorithm>
0016
0017 namespace Acts {
0018
0019 SurfaceArrayNavigationPolicy::SurfaceArrayNavigationPolicy(
0020 const GeometryContext& gctx, const TrackingVolume& volume,
0021 const Logger& logger, Config config)
0022 : m_volume(volume) {
0023 ACTS_VERBOSE("Constructing SurfaceArrayNavigationPolicy for volume "
0024 << volume.volumeName());
0025 ACTS_VERBOSE("~> Layer type is " << config.layerType);
0026 ACTS_VERBOSE("~> bins: " << config.bins.first << " x " << config.bins.second);
0027
0028 SurfaceArrayCreator::Config sacConfig;
0029 SurfaceArrayCreator sac{sacConfig, logger.clone("SrfArrCrtr")};
0030
0031 std::vector<std::shared_ptr<const Surface>> surfaces;
0032 surfaces.reserve(volume.surfaces().size());
0033 for (const auto& surface : volume.surfaces()) {
0034 if (surface.associatedDetectorElement() == nullptr) {
0035 continue;
0036 }
0037 surfaces.push_back(surface.getSharedPtr());
0038 }
0039
0040 if (config.layerType == LayerType::Disc) {
0041 auto [binsR, binsPhi] = config.bins;
0042 m_surfaceArray =
0043 sac.surfaceArrayOnDisc(gctx, std::move(surfaces), binsPhi, binsR);
0044 } else if (config.layerType == LayerType::Cylinder) {
0045 auto [binsPhi, binsZ] = config.bins;
0046 m_surfaceArray =
0047 sac.surfaceArrayOnCylinder(gctx, std::move(surfaces), binsPhi, binsZ);
0048 } else if (config.layerType == LayerType::Plane) {
0049 ACTS_ERROR("Plane layers are not yet supported");
0050 throw std::invalid_argument("Plane layers are not yet supported");
0051 } else {
0052 throw std::invalid_argument("Unknown layer type");
0053 }
0054
0055 if (!m_surfaceArray) {
0056 ACTS_ERROR("Failed to create surface array");
0057 throw std::runtime_error("Failed to create surface array");
0058 }
0059 }
0060
0061 void SurfaceArrayNavigationPolicy::initializeCandidates(
0062 const NavigationArguments& args, AppendOnlyNavigationStream& stream,
0063 const Logger& logger) const {
0064 ACTS_VERBOSE("SrfArrNavPol (volume=" << m_volume.volumeName() << ")");
0065
0066 ACTS_VERBOSE("Querying sensitive surfaces at " << args.position.transpose());
0067 const std::vector<const Surface*>& sensitiveSurfaces =
0068 m_surfaceArray->neighbors(args.position);
0069 ACTS_VERBOSE("~> Surface array reports " << sensitiveSurfaces.size()
0070 << " sensitive surfaces");
0071
0072 for (const auto* surface : sensitiveSurfaces) {
0073 stream.addSurfaceCandidate(*surface, args.tolerance);
0074 };
0075 }
0076
0077 void SurfaceArrayNavigationPolicy::connect(NavigationDelegate& delegate) const {
0078 connectDefault<SurfaceArrayNavigationPolicy>(delegate);
0079 }
0080
0081 }