File indexing completed on 2025-01-18 09:11:24
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Geometry/TrackingGeometryBuilder.hpp"
0010
0011 #include "Acts/Geometry/TrackingGeometry.hpp"
0012
0013 #include <functional>
0014 #include <stdexcept>
0015 #include <utility>
0016
0017 Acts::TrackingGeometryBuilder::TrackingGeometryBuilder(
0018 const Acts::TrackingGeometryBuilder::Config& cgbConfig,
0019 std::unique_ptr<const Logger> logger)
0020 : m_cfg(), m_logger(std::move(logger)) {
0021 setConfiguration(cgbConfig);
0022 }
0023
0024 const Acts::TrackingGeometryBuilder::Config&
0025 Acts::TrackingGeometryBuilder::getConfiguration() const {
0026 return m_cfg;
0027 }
0028
0029 void Acts::TrackingGeometryBuilder::setConfiguration(
0030 const Acts::TrackingGeometryBuilder::Config& cgbConfig) {
0031 if (cgbConfig.trackingVolumeBuilders.empty()) {
0032 throw std::invalid_argument("Invalid configuration: no volume builders");
0033 }
0034 m_cfg = cgbConfig;
0035 }
0036
0037 void Acts::TrackingGeometryBuilder::setLogger(
0038 std::unique_ptr<const Logger> newLogger) {
0039 m_logger = std::move(newLogger);
0040 }
0041
0042 std::unique_ptr<const Acts::TrackingGeometry>
0043 Acts::TrackingGeometryBuilder::trackingGeometry(
0044 const GeometryContext& gctx) const {
0045 MutableTrackingVolumePtr highestVolume = nullptr;
0046
0047 for (auto& volumeBuilder : m_cfg.trackingVolumeBuilders) {
0048
0049
0050 auto volume = volumeBuilder(gctx, highestVolume, nullptr);
0051 if (!volume) {
0052 ACTS_INFO(
0053 "Received nullptr volume from builder, keeping previous highest "
0054 "volume");
0055 } else {
0056 highestVolume = std::move(volume);
0057 }
0058 }
0059
0060
0061 if (highestVolume) {
0062 return std::make_unique<TrackingGeometry>(
0063 highestVolume,
0064 m_cfg.materialDecorator ? m_cfg.materialDecorator.get() : nullptr,
0065 *m_cfg.geometryIdentifierHook, logger());
0066 } else {
0067 throw std::runtime_error(
0068 "Unable to construct tracking geometry: no tracking volume");
0069 }
0070 }