Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingGeometrySvgConverter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackingGeometrySvgConverter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 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 
14 
15 std::vector<actsvg::svg::object> Acts::Svg::TrackingGeometryConverter::convert(
17  const TrackingGeometryConverter::Options& cOptions) {
18  // Get the world volume
19  const TrackingVolume* world = tGeometry.highestTrackingVolume();
20 
21  // Initiate the cache
23 
24  // Run the conversion recursively
25  convert(gctx, *world, cOptions, cState);
26 
27  // Digest the views and globals
28  std::vector<actsvg::svg::object> finalViews = cState.finalViews;
29  if (not cState.xyCrossSection.empty()) {
30  finalViews.push_back(
31  Acts::Svg::group(cState.xyCrossSection, cOptions.prefix + "layers_xy"));
32  }
33  if (not cState.zrCrossSection.empty()) {
34  finalViews.push_back(
35  Acts::Svg::group(cState.zrCrossSection, cOptions.prefix + "layers_zr"));
36  }
37  // return all final Views
38  return finalViews;
39 }
40 
42  const GeometryContext& gctx, const TrackingVolume& tVolume,
43  const TrackingGeometryConverter::Options& cOptions,
45  // Process confined layers first
46  if (tVolume.confinedLayers() != nullptr) {
47  for (const auto& layer : tVolume.confinedLayers()->arrayObjects()) {
48  if (layer->surfaceArray() != nullptr) {
49  GeometryIdentifier geoID = layer->geometryId();
50  std::string layerName = cOptions.prefix + "vol_" +
51  std::to_string(geoID.volume()) + "_layer_" +
52  std::to_string(geoID.layer());
53 
54  LayerConverter::Options lOptions;
55  // Search for predefined layer options
56  auto deflOptions = cOptions.layerOptions.find(geoID);
57  if (deflOptions != cOptions.layerOptions.end()) {
58  lOptions = (*deflOptions);
59  lOptions.name = layerName;
60  }
61  // Retrieve the layer sheets
62  auto layerSheets = LayerConverter::convert(gctx, *layer, lOptions);
63 
64  // Record the sheets
65  for (const auto& lSheet : layerSheets) {
66  if (lSheet.is_defined()) {
67  cState.finalViews.push_back(lSheet);
68  }
69  }
70  // Collect the xy views
71  if (layerSheets[LayerConverter::eCrossSectionXY].is_defined() and
72  layer->surfaceRepresentation().type() == Acts::Surface::Cylinder) {
73  cState.xyCrossSection.push_back(
74  layerSheets[LayerConverter::eCrossSectionXY]);
75  }
76  // Collect the zr views
77  if (layerSheets[LayerConverter::eCrossSectionZR].is_defined()) {
78  cState.zrCrossSection.push_back(
79  layerSheets[LayerConverter::eCrossSectionZR]);
80  }
81  }
82  }
83  }
84 
85  // Run recursively over confined volumes
86  if (tVolume.confinedVolumes() != nullptr) {
87  for (const auto& volume : tVolume.confinedVolumes()->arrayObjects()) {
88  convert(gctx, *volume, cOptions, cState);
89  }
90  }
91 }
92 
93 std::array<actsvg::svg::object, 2>
96  const TrackingGeometryProjections::Options& cOptions) {
97  // The projections
98  actsvg::svg::object xyView;
99  actsvg::svg::object zrView;
100 
101  // Get the world volume
102  const Acts::TrackingVolume* world = tGeometry.highestTrackingVolume();
103  if (world != nullptr) {
104  // Initiate the cache
106 
107  // Run the conversion recursively
109  gctx, *world, cOptions.trackingGeometryOptions, cState);
110 
111  xyView = Acts::Svg::group(cState.xyCrossSection,
112  cOptions.prefix + "projection_xy");
113  zrView = Acts::Svg::group(cState.zrCrossSection,
114  cOptions.prefix + "projection_zr");
115  }
116  return {xyView, zrView};
117 }