Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorVolumeSvgConverter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorVolumeSvgConverter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 #include "Acts/Detector/Portal.hpp"
17 
18 #include <utility>
19 
20 std::tuple<Acts::Svg::ProtoVolume, Acts::Svg::ProtoIndexedSurfaceGrid>
22  const GeometryContext& gctx, const Experimental::DetectorVolume& dVolume,
23  const DetectorVolumeConverter::Options& volumeOptions) {
24  ProtoVolume pVolume;
25  pVolume._name = dVolume.name();
26 
27  auto volumeTransform = dVolume.transform(gctx);
28 
29  // The detector volume is of cylindrical shape
30  const auto& boundValues = dVolume.volumeBounds().values();
31  if (dVolume.volumeBounds().type() == Acts::VolumeBounds::eCylinder) {
32  // we keep 6 for the moment
33  for (unsigned int ib = 0; ib < 2u; ++ib) {
34  pVolume._bound_values.push_back(
35  static_cast<actsvg::scalar>(boundValues[ib]));
36  }
37  pVolume._bound_values.push_back(
38  static_cast<actsvg::scalar>(volumeTransform.translation().z()));
39  for (unsigned int ib = 2u; ib < 5u; ++ib) {
40  pVolume._bound_values.push_back(
41  static_cast<actsvg::scalar>(boundValues[ib]));
42  }
43  }
44 
45  // Adding the portals to the lot
46  for (auto [ip, p] : enumerate(dVolume.portals())) {
47  auto pPortal =
48  PortalConverter::convert(gctx, *p, volumeOptions.portalOptions);
49  auto pPortalCandidate = volumeOptions.portalIndices.find(p);
50  if (pPortalCandidate != volumeOptions.portalIndices.end()) {
51  pPortal._name = "portal_" + std::to_string(pPortalCandidate->second);
52  } else {
53  pPortal._name = dVolume.name() + "_portal_" + std::to_string(ip);
54  }
55  pVolume._portals.push_back(pPortal);
56  }
57 
58  // Adding the surfaces to the volume
59  std::vector<ProtoSurface> pSurfaces;
60  for (auto [is, s] : enumerate(dVolume.surfaces())) {
61  auto pSurface =
62  SurfaceConverter::convert(gctx, *s, volumeOptions.surfaceOptions);
63  pSurface._name = dVolume.name() + "_surface_" + std::to_string(is);
64  pSurfaces.push_back(pSurface);
65  }
66  pVolume._v_surfaces = pSurfaces;
67 
68  // Make dedicated surface grid sheets
69  const auto& internalNavigationDelegate = dVolume.surfaceCandidatesUpdator();
70 
72  // Use or transfer the surface style
73  if (isOptions.surfaceStyles.empty()) {
74  std::pair<Acts::GeometryIdentifier, Acts::Svg::Style> style{
75  dVolume.geometryId(), volumeOptions.surfaceOptions.style};
76  isOptions.surfaceStyles =
78  }
79 
80  auto pSurfacesGrid = IndexedSurfacesConverter::convert(
81  gctx, dVolume.surfaces(), internalNavigationDelegate, isOptions);
82 
83  return {pVolume, pSurfacesGrid};
84 }