File indexing completed on 2025-08-05 08:09:37
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Geometry/TrackingGeometry.hpp"
0010
0011 #include "Acts/Geometry/GeometryIdentifier.hpp"
0012 #include "Acts/Geometry/TrackingVolume.hpp"
0013 #include "Acts/Surfaces/PerigeeSurface.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Surfaces/SurfaceArray.hpp"
0016
0017 #include <algorithm>
0018 #include <cstddef>
0019 #include <vector>
0020
0021 Acts::TrackingGeometry::TrackingGeometry(
0022 const MutableTrackingVolumePtr& highestVolume,
0023 const IMaterialDecorator* materialDecorator,
0024 const GeometryIdentifierHook& hook, const Logger& logger)
0025 : m_world(highestVolume),
0026 m_beam(Surface::makeShared<PerigeeSurface>(Vector3::Zero())) {
0027
0028 std::size_t volumeID = 0;
0029 highestVolume->closeGeometry(materialDecorator, m_volumesById, volumeID, hook,
0030 logger);
0031 m_volumesById.rehash(0);
0032
0033 m_world->visitSurfaces([this](const Acts::Surface* srf) {
0034 if (srf != nullptr) {
0035 m_surfacesById[srf->geometryId()] = srf;
0036 }
0037 });
0038 m_surfacesById.rehash(0);
0039 }
0040
0041 Acts::TrackingGeometry::~TrackingGeometry() = default;
0042
0043 const Acts::TrackingVolume* Acts::TrackingGeometry::lowestTrackingVolume(
0044 const GeometryContext& gctx, const Acts::Vector3& gp) const {
0045 const TrackingVolume* searchVolume = m_world.get();
0046 const TrackingVolume* currentVolume = nullptr;
0047 while (currentVolume != searchVolume && (searchVolume != nullptr)) {
0048 currentVolume = searchVolume;
0049 searchVolume = searchVolume->lowestTrackingVolume(gctx, gp);
0050 }
0051 return currentVolume;
0052 }
0053
0054 const Acts::TrackingVolume* Acts::TrackingGeometry::highestTrackingVolume()
0055 const {
0056 return m_world.get();
0057 }
0058
0059 const std::shared_ptr<const Acts::TrackingVolume>&
0060 Acts::TrackingGeometry::highestTrackingVolumeShared() const {
0061 return m_world;
0062 }
0063
0064 const Acts::Layer* Acts::TrackingGeometry::associatedLayer(
0065 const GeometryContext& gctx, const Acts::Vector3& gp) const {
0066 const TrackingVolume* lowestVol = (lowestTrackingVolume(gctx, gp));
0067 return lowestVol->associatedLayer(gctx, gp);
0068 }
0069
0070 void Acts::TrackingGeometry::registerBeamTube(
0071 std::shared_ptr<const PerigeeSurface> beam) {
0072 m_beam = std::move(beam);
0073 }
0074
0075 const Acts::Surface* Acts::TrackingGeometry::getBeamline() const {
0076 return m_beam.get();
0077 }
0078
0079 const Acts::TrackingVolume* Acts::TrackingGeometry::findVolume(
0080 GeometryIdentifier id) const {
0081 auto vol = m_volumesById.find(id);
0082 if (vol == m_volumesById.end()) {
0083 return nullptr;
0084 }
0085 return vol->second;
0086 }
0087
0088 const Acts::Surface* Acts::TrackingGeometry::findSurface(
0089 GeometryIdentifier id) const {
0090 auto srf = m_surfacesById.find(id);
0091 if (srf == m_surfacesById.end()) {
0092 return nullptr;
0093 }
0094 return srf->second;
0095 }