Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:24

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/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   // loop over the builders and wrap one around the other
0047   for (auto& volumeBuilder : m_cfg.trackingVolumeBuilders) {
0048     // assign a new highest volume (and potentially wrap around the given
0049     // highest volume so far)
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   // create the TrackingGeometry & decorate it with the material
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 }