File indexing completed on 2025-08-28 08:11:51
0001
0002
0003
0004
0005
0006
0007
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 }
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 " << volume.volumeName() << " @ "
0038 << toString(volume.center())
0039 << " --- id: " << volume.geometryId()
0040 << " #surfaces: " << volume.surfaces().size()
0041 << ", #portals: " << volume.portals().size()
0042 << ", #sub-volumes: " << volume.volumes().size() << std::endl;
0043 }
0044 std::size_t TrackingGeometryPrintVisitor::volNumber(
0045 const TrackingVolume& trkVol) const {
0046 const TrackingVolume* parent = trkVol.motherVolume();
0047 if (parent == nullptr) {
0048 return 1;
0049 }
0050 return 1 + std::distance(
0051 parent->volumes().begin(),
0052 std::ranges::find_if(parent->volumes(),
0053 [&trkVol](const TrackingVolume& child) {
0054 return &child == &trkVol;
0055 }));
0056 }
0057 void TrackingGeometryPrintVisitor::visitPortal(const Portal& ) {
0058
0059
0060
0061 }
0062
0063 void TrackingGeometryPrintVisitor::visitSurface(const Surface& surface) {
0064 m_printStream << whiteSpaces(m_currentDepth + m_indentation) << " **** "
0065 << Surface::s_surfaceTypeNames[toUnderlying(surface.type())]
0066 << " surface "
0067 << " @ " << toString(surface.center(m_gctx))
0068 << " --- id: " << surface.geometryId() << ", sensitive: "
0069 << (surface.associatedDetectorElement() != nullptr ? "yay"
0070 : "nay")
0071 << ", material: "
0072 << (surface.surfaceMaterial() != nullptr ? "yay" : "nay")
0073 << std::endl;
0074 }
0075
0076 void TrackingGeometryPrintVisitor::updateDepth(const TrackingVolume& trkVol) {
0077 m_currentDepth = 0;
0078 const TrackingVolume* parent = trkVol.motherVolume();
0079 while (parent != nullptr) {
0080 ++m_currentDepth;
0081 parent = parent->motherVolume();
0082 }
0083 m_currentDepth *= m_indentation;
0084 }
0085
0086 }