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/detail/TrackingGeometryPrintVisitor.hpp"
0010 
0011 #include "Acts/Utilities/Helpers.hpp"
0012 #include "Acts/Utilities/StringHelpers.hpp"
0013 
0014 namespace {
0015 inline std::string whiteSpaces(const std::size_t n) {
0016   std::string str{};
0017   str.resize(n, ' ');
0018   return str;
0019 }
0020 }  // namespace
0021 
0022 namespace Acts::detail {
0023 TrackingGeometryPrintVisitor::TrackingGeometryPrintVisitor(
0024     const Acts::GeometryContext& gctx, std::size_t indentation)
0025     : m_gctx{gctx}, m_indentation{indentation} {}
0026 TrackingGeometryPrintVisitor::~TrackingGeometryPrintVisitor() = default;
0027 std::stringstream& TrackingGeometryPrintVisitor::stream() {
0028   return m_printStream;
0029 }
0030 const std::stringstream& TrackingGeometryPrintVisitor::stream() const {
0031   return m_printStream;
0032 }
0033 void TrackingGeometryPrintVisitor::visitVolume(
0034     const Acts::TrackingVolume& volume) {
0035   updateDepth(volume);
0036   m_printStream << whiteSpaces(m_currentDepth) << volNumber(volume) << ") "
0037                 << (volume.isAlignable() ? "Alignable volume " : "Volume ")
0038                 << volume.volumeName() << " @ "
0039                 << toString(volume.center(m_gctx))
0040                 << " --- id: " << volume.geometryId()
0041                 << " #surfaces: " << volume.surfaces().size()
0042                 << ", #portals: " << volume.portals().size()
0043                 << ", #sub-volumes: " << volume.volumes().size() << std::endl;
0044 }
0045 std::size_t TrackingGeometryPrintVisitor::volNumber(
0046     const TrackingVolume& trkVol) const {
0047   const TrackingVolume* parent = trkVol.motherVolume();
0048   if (parent == nullptr) {
0049     return 1;
0050   }
0051   return 1 + std::distance(
0052                  parent->volumes().begin(),
0053                  std::ranges::find_if(parent->volumes(),
0054                                       [&trkVol](const TrackingVolume& child) {
0055                                         return &child == &trkVol;
0056                                       }));
0057 }
0058 void TrackingGeometryPrintVisitor::visitPortal(const Portal& portal) {
0059   const auto& surf = portal.surface();
0060   m_printStream << whiteSpaces(m_currentDepth + m_indentation) << " ++++ "
0061                 << Surface::s_surfaceTypeNames[toUnderlying(surf.type())] <<
0062 
0063       " portal  --- id: " << surf.geometryId() << ", bounds: " << surf.bounds()
0064                 << ", alignable: " << (surf.isAlignable() ? "yay" : "nay")
0065                 << ", material: "
0066                 << (surf.surfaceMaterial() != nullptr ? "yay" : "nay")
0067                 << std::endl;
0068 }
0069 
0070 void TrackingGeometryPrintVisitor::visitSurface(const Surface& surface) {
0071   m_printStream << whiteSpaces(m_currentDepth + m_indentation) << " **** "
0072                 << Surface::s_surfaceTypeNames[toUnderlying(surface.type())]
0073                 << " surface "
0074                 << " @ " << toString(surface.center(m_gctx))
0075                 << " --- id: " << surface.geometryId()
0076                 << ", sensitive: " << (surface.isSensitive() ? "yay" : "nay")
0077                 << ", alignable: " << (surface.isAlignable() ? "yay" : "nay")
0078                 << ", material: "
0079                 << (surface.surfaceMaterial() != nullptr ? "yay" : "nay")
0080                 << std::endl;
0081 }
0082 
0083 void TrackingGeometryPrintVisitor::updateDepth(const TrackingVolume& trkVol) {
0084   m_currentDepth = 0;
0085   const TrackingVolume* parent = trkVol.motherVolume();
0086   while (parent != nullptr) {
0087     ++m_currentDepth;
0088     parent = parent->motherVolume();
0089   }
0090   m_currentDepth *= m_indentation;
0091 }
0092 
0093 }  // namespace Acts::detail