Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:46:41

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/VolumePlacementBase.hpp"
0010 
0011 #include "Acts/Geometry/VolumeBounds.hpp"
0012 #include "Acts/Utilities/StringHelpers.hpp"
0013 
0014 #include <format>
0015 #include <sstream>
0016 namespace Acts {
0017 
0018 VolumePlacementBase::VolumePlacementBase() noexcept = default;
0019 
0020 VolumePlacementBase::~VolumePlacementBase() = default;
0021 
0022 void VolumePlacementBase::makePortalsAlignable(
0023     const GeometryContext& gctx,
0024     const std::vector<std::shared_ptr<RegularSurface>>& portalsToAlign) {
0025   if (portalsToAlign.empty()) {
0026     throw std::invalid_argument(
0027         "VolumePlacementBase::makePortalsAlignable() - The portals must not be "
0028         "empty");
0029   }
0030 
0031   if (!m_portalPlacements.empty()) {
0032     throw std::runtime_error(
0033         "VolumePlacementBase::makePortalsAlignable() - Portals were already "
0034         "registered before");
0035   }
0036 
0037   for (const auto& [portalIdx, portalSurface] : enumerate(portalsToAlign)) {
0038     if (portalSurface->surfacePlacement() != nullptr) {
0039       throw std::invalid_argument(std::format(
0040           "VolumePlacementBase::makePortalsAlignable() - The {:}-th surface is "
0041           "already connected to the alignment system",
0042           portalIdx));
0043     }
0044     // Calculate the portal transform w.r.t the current alignment
0045     const Transform3 portalToVolTrf =
0046         globalToLocalTransform(gctx) *
0047         portalSurface->localToGlobalTransform(gctx);
0048 
0049     m_portalPlacements.emplace_back(std::make_unique<detail::PortalPlacement>(
0050         portalIdx, portalToVolTrf, this, portalSurface));
0051   }
0052 }
0053 
0054 const detail::PortalPlacement* VolumePlacementBase::portalPlacement(
0055     const std::size_t portalIdx) const {
0056   return m_portalPlacements.at(portalIdx).get();
0057 }
0058 
0059 detail::PortalPlacement* VolumePlacementBase::portalPlacement(
0060     const std::size_t portalIdx) {
0061   return m_portalPlacements.at(portalIdx).get();
0062 }
0063 
0064 std::size_t VolumePlacementBase::nPortalPlacements() const {
0065   return m_portalPlacements.size();
0066 }
0067 
0068 Transform3 VolumePlacementBase::alignPortal(const GeometryContext& gctx,
0069                                             const std::size_t portalIdx) const {
0070   return m_portalPlacements.at(portalIdx)->assembleFullTransform(gctx);
0071 }
0072 
0073 }  // namespace Acts