File indexing completed on 2025-01-18 09:13:13
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Plugins/TGeo/TGeoParser.hpp"
0013 #include "Acts/Plugins/TGeo/TGeoSurfaceConverter.hpp"
0014 #include "Acts/Tests/CommonHelpers/DataDirectory.hpp"
0015 #include "Acts/Utilities/BinningType.hpp"
0016 #include "Acts/Visualization/GeometryView3D.hpp"
0017 #include "Acts/Visualization/ObjVisualization3D.hpp"
0018
0019 #include <memory>
0020 #include <string>
0021 #include <utility>
0022 #include <vector>
0023
0024 #include "TGeoManager.h"
0025
0026 namespace Acts::Test {
0027
0028
0029 struct RootGeometry {
0030 RootGeometry() {
0031 auto path = Acts::Test::getDataPath("panda.root");
0032 TGeoManager::Import(path.c_str());
0033 }
0034 };
0035
0036 GeometryContext tgContext = GeometryContext();
0037
0038 RootGeometry rGeometry = RootGeometry();
0039
0040
0041 BOOST_AUTO_TEST_CASE(TGeoParser_Pixel) {
0042 if (gGeoManager != nullptr) {
0043 std::string volumeName = "*";
0044 TGeoParser::Options tgpOptions;
0045 tgpOptions.volumeNames = {volumeName};
0046 tgpOptions.targetNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
0047 "PixelActiveo6"};
0048 std::string axes = "XYZ";
0049 double scale = 10.;
0050
0051 TGeoParser::State tgpState;
0052 tgpState.volume = gGeoManager->GetTopVolume();
0053
0054
0055 TGeoParser::select(tgpState, tgpOptions);
0056
0057
0058 BOOST_CHECK_EQUAL(tgpState.selectedNodes.size(), 176u);
0059
0060
0061 ObjVisualization3D objVis;
0062 for (auto& snode : tgpState.selectedNodes) {
0063 const auto& shape = *(snode.node->GetVolume()->GetShape());
0064 const auto& transform = *(snode.transform.get());
0065 auto [surface, thickness] =
0066 TGeoSurfaceConverter::toSurface(shape, transform, axes, scale);
0067 GeometryView3D::drawSurface(objVis, *surface, tgContext);
0068 }
0069 objVis.write("PixelActive");
0070 }
0071 }
0072
0073
0074 BOOST_AUTO_TEST_CASE(TGeoParser_Pixel_SelectInnermost) {
0075 if (gGeoManager != nullptr) {
0076 std::string volumeName = "*";
0077 TGeoParser::Options tgpOptions;
0078 tgpOptions.volumeNames = {volumeName};
0079 tgpOptions.targetNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
0080 "PixelActiveo6"};
0081 tgpOptions.parseRanges.push_back({AxisDirection::AxisR, {0., 40.}});
0082 tgpOptions.parseRanges.push_back({AxisDirection::AxisZ, {-60., 15.}});
0083 tgpOptions.unit = 10.;
0084
0085 std::string axes = "XYZ";
0086
0087 TGeoParser::State tgpState;
0088 tgpState.volume = gGeoManager->GetTopVolume();
0089
0090
0091 TGeoParser::select(tgpState, tgpOptions);
0092
0093
0094 BOOST_CHECK_EQUAL(tgpState.selectedNodes.size(), 14u);
0095
0096
0097 ObjVisualization3D objVis;
0098 for (auto& snode : tgpState.selectedNodes) {
0099 const auto& shape = *(snode.node->GetVolume()->GetShape());
0100 const auto& transform = *(snode.transform.get());
0101 auto [surface, thickness] = TGeoSurfaceConverter::toSurface(
0102 shape, transform, axes, tgpOptions.unit);
0103 GeometryView3D::drawSurface(objVis, *surface, tgContext);
0104 }
0105 objVis.write("PixelActive_Innermost");
0106 }
0107 }
0108
0109 }