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