From 0d3d440cb21b358c2cf1acad58d75fa5cd6dfe5f Mon Sep 17 00:00:00 2001 From: cms Date: Wed, 23 Oct 2024 13:31:41 +0200 Subject: [PATCH 1/7] Adding Trap converter in Geant4Converters --- .../Acts/Plugins/Geant4/Geant4Converters.hpp | 16 +++ Plugins/Geant4/src/Geant4Converters.cpp | 98 ++++++++++++++++++- 2 files changed, 112 insertions(+), 2 deletions(-) diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp index a65b9d5c711..f09829ab1bf 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp @@ -16,6 +16,7 @@ #include #include + namespace CLHEP { class Hep3Vector; class HepRotation; @@ -25,6 +26,11 @@ namespace HepGeom { class Transform3D; } +#include "/home/cms/software/geant4/install_dir/include/Geant4/G4RotationMatrix.hh" +#include "/home/cms/software/geant4/install_dir/include/Geant4/G4ThreeVector.hh" +#include "/home/cms/software/geant4/install_dir/include/Geant4/G4Transform3D.hh" + + class G4Box; class G4Material; class G4Trd; @@ -133,6 +139,16 @@ struct Geant4ShapeConverter { std::tuple, std::array, ActsScalar> trapezoidBounds(const G4Trd& g4Trd); + // ************************************************************************************* + /// @brief Convert to trapezoid bounds - from Trap + /// + /// @param g4Trd a Geant4 trapezoid shape + /// + /// @return an ACTS Trapezoid bounds object, axis orientation, and thickness + std::tuple, std::array, ActsScalar> + trapezoidBounds_g4Trap(const G4Trap& g4Trap); + // ************************************************************************************* + /// @brief Convert to general solid into a planar shape /// /// @param g4Solid a Geant4 solid shape diff --git a/Plugins/Geant4/src/Geant4Converters.cpp b/Plugins/Geant4/src/Geant4Converters.cpp index db7d9f93f1e..c1843f33926 100644 --- a/Plugins/Geant4/src/Geant4Converters.cpp +++ b/Plugins/Geant4/src/Geant4Converters.cpp @@ -6,7 +6,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -#include "Acts/Plugins/Geant4/Geant4Converters.hpp" +//#include "Acts/Plugins/Geant4/Geant4Converters.hpp" +#include "/home/cms/software/ACTS_ODD/ACTS_Source/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp" #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" @@ -18,7 +19,8 @@ #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/LineBounds.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" -#include "Acts/Surfaces/RadialBounds.hpp" +//#include "RadialBounds.hpp" +#include "/home/cms/software/ACTS_ODD/ACTS_Source/Core/include/Acts/Surfaces/RadialBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/StrawSurface.hpp" #include "Acts/Surfaces/TrapezoidBounds.hpp" @@ -30,6 +32,7 @@ #include #include #include +#include #include "G4Box.hh" #include "G4LogicalVolume.hh" @@ -38,6 +41,7 @@ #include "G4ThreeVector.hh" #include "G4Transform3D.hh" #include "G4Trd.hh" +#include "G4Trap.hh" #include "G4Tubs.hh" #include "G4VPhysicalVolume.hh" #include "G4VSolid.hh" @@ -234,6 +238,75 @@ Acts::Geant4ShapeConverter::trapezoidBounds(const G4Trd& g4Trd) { return std::make_tuple(std::move(tBounds), rAxes, thickness); } +// ********************************************************************************************************* + +std::tuple, std::array, + Acts::ActsScalar> +Acts::Geant4ShapeConverter::trapezoidBounds_g4Trap(const G4Trap& g4Trap) { + // primary parameters + ActsScalar y1 = static_cast(g4Trap.GetYHalfLength1()); + ActsScalar y2 = static_cast(g4Trap.GetYHalfLength2()); + ActsScalar x1 = static_cast(g4Trap.GetXHalfLength1()); + ActsScalar x2 = static_cast(g4Trap.GetXHalfLength2()); + ActsScalar x3 = static_cast(g4Trap.GetXHalfLength3()); + ActsScalar x4 = static_cast(g4Trap.GetXHalfLength4()); + ActsScalar phi = static_cast(g4Trap.GetPhi()); + ActsScalar theta = static_cast(g4Trap.GetTheta()); + ActsScalar z = static_cast(g4Trap.GetZHalfLength()); + + ActsScalar hlX0 = (x1 + x2)*0.5; + ActsScalar hlX1 = 2*z*std::tan(theta)*std::cos(phi) + (x3+x4)*0.5; + ActsScalar hlY0 = y1; + ActsScalar hlY1 = y2 + 2*z*std::tan(theta)*std::sin(phi); + ActsScalar hlZ = z; + + std::vector dXYZ = {(hlX0 + hlX1) * 0.5, (hlY0 + hlY1) * 0.5, + hlZ}; + + auto minAt = std::min_element(dXYZ.begin(), dXYZ.end()); + std::size_t minPos = std::distance(dXYZ.begin(), minAt); + ActsScalar thickness = 2. * dXYZ[minPos]; + + ActsScalar halfLengthXminY = 0.; + ActsScalar halfLengthXmaxY = 0.; + ActsScalar halfLengthY = 0.; + + std::array rAxes = {}; + switch (minPos) { + case 0: { + halfLengthXminY = std::min(hlY0,hlY1); + halfLengthXmaxY = std::max(hlY0,hlY1); + halfLengthY = hlZ; + rAxes = {1, 2}; + } break; + case 1: { + halfLengthXminY = std::min(hlX0,hlX1); + halfLengthXmaxY = std::max(hlX0,hlX1); + halfLengthY = hlZ; + rAxes = {0, -2}; + } break; + case 2: { + if (std::abs(hlY0 - hlY1) < std::abs(hlX0 - hlX1)) { + halfLengthXminY = std::min(hlX0,hlX1); + halfLengthXmaxY = std::max(hlX0,hlX1); + halfLengthY = (hlY0 + hlY1) * 0.5; + rAxes = {0, 1}; + } else { + halfLengthXminY = std::min(hlY0,hlY1); + halfLengthXmaxY = std::max(hlY0,hlY1); + halfLengthY = (hlX0 + hlX1) * 0.5; + rAxes = {-1, 0}; + } + } break; + } + + auto tBounds = std::make_shared( + halfLengthXminY, halfLengthXmaxY, halfLengthY); + return std::make_tuple(std::move(tBounds), rAxes, thickness); +} + +// ********************************************************************************************************* + std::tuple, std::array, Acts::ActsScalar> Acts::Geant4ShapeConverter::planarBounds(const G4VSolid& g4Solid) { @@ -332,6 +405,27 @@ std::shared_ptr Acts::Geant4PhysicalVolumeConverter::surface( } } + // *************************************************************************************** + + // Into a Trapezoid (G4Trap) + auto g4Trap = dynamic_cast(g4Solid); + if (g4Trap != nullptr) { + if (forcedType == Surface::SurfaceType::Other || + forcedType == Surface::SurfaceType::Plane) { + auto [bounds, axes, original] = + Geant4ShapeConverter{}.trapezoidBounds_g4Trap(*g4Trap); + auto orientedToGlobal = axesOriented(toGlobal, axes); + surface = Acts::Surface::makeShared(orientedToGlobal, + std::move(bounds)); + assignMaterial(*surface.get(), original, compressed); + return surface; + } else { + throw std::runtime_error("Can not convert 'G4Trap' into forced shape."); + } + } + + // *************************************************************************************** + // Into a Cylinder, disc or line auto g4Tubs = dynamic_cast(g4Solid); if (g4Tubs != nullptr) { From f04d7fa7722256cfe27e4c0363f0571d48ce688d Mon Sep 17 00:00:00 2001 From: cms Date: Wed, 23 Oct 2024 17:09:52 +0200 Subject: [PATCH 2/7] Adding Trap converter in Geant4Converters --- .../Acts/Plugins/Geant4/Geant4Converters.hpp | 8 +------- Plugins/Geant4/src/Geant4Converters.cpp | 13 +++---------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp index f09829ab1bf..03043427820 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp @@ -22,10 +22,6 @@ class Hep3Vector; class HepRotation; } // namespace CLHEP -namespace HepGeom { -class Transform3D; -} - #include "/home/cms/software/geant4/install_dir/include/Geant4/G4RotationMatrix.hh" #include "/home/cms/software/geant4/install_dir/include/Geant4/G4ThreeVector.hh" #include "/home/cms/software/geant4/install_dir/include/Geant4/G4Transform3D.hh" @@ -139,15 +135,13 @@ struct Geant4ShapeConverter { std::tuple, std::array, ActsScalar> trapezoidBounds(const G4Trd& g4Trd); - // ************************************************************************************* /// @brief Convert to trapezoid bounds - from Trap /// /// @param g4Trd a Geant4 trapezoid shape /// /// @return an ACTS Trapezoid bounds object, axis orientation, and thickness std::tuple, std::array, ActsScalar> - trapezoidBounds_g4Trap(const G4Trap& g4Trap); - // ************************************************************************************* + trapezoidBounds(const G4Trap& g4Trap); /// @brief Convert to general solid into a planar shape /// diff --git a/Plugins/Geant4/src/Geant4Converters.cpp b/Plugins/Geant4/src/Geant4Converters.cpp index c1843f33926..89e32e513d4 100644 --- a/Plugins/Geant4/src/Geant4Converters.cpp +++ b/Plugins/Geant4/src/Geant4Converters.cpp @@ -6,8 +6,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -//#include "Acts/Plugins/Geant4/Geant4Converters.hpp" -#include "/home/cms/software/ACTS_ODD/ACTS_Source/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp" +#include "Acts/Plugins/Geant4/Geant4Converters.hpp" #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" @@ -19,8 +18,7 @@ #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/LineBounds.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" -//#include "RadialBounds.hpp" -#include "/home/cms/software/ACTS_ODD/ACTS_Source/Core/include/Acts/Surfaces/RadialBounds.hpp" +#include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/StrawSurface.hpp" #include "Acts/Surfaces/TrapezoidBounds.hpp" @@ -32,7 +30,6 @@ #include #include #include -#include #include "G4Box.hh" #include "G4LogicalVolume.hh" @@ -238,11 +235,9 @@ Acts::Geant4ShapeConverter::trapezoidBounds(const G4Trd& g4Trd) { return std::make_tuple(std::move(tBounds), rAxes, thickness); } -// ********************************************************************************************************* - std::tuple, std::array, Acts::ActsScalar> -Acts::Geant4ShapeConverter::trapezoidBounds_g4Trap(const G4Trap& g4Trap) { +Acts::Geant4ShapeConverter::trapezoidBounds(const G4Trap& g4Trap) { // primary parameters ActsScalar y1 = static_cast(g4Trap.GetYHalfLength1()); ActsScalar y2 = static_cast(g4Trap.GetYHalfLength2()); @@ -305,8 +300,6 @@ Acts::Geant4ShapeConverter::trapezoidBounds_g4Trap(const G4Trap& g4Trap) { return std::make_tuple(std::move(tBounds), rAxes, thickness); } -// ********************************************************************************************************* - std::tuple, std::array, Acts::ActsScalar> Acts::Geant4ShapeConverter::planarBounds(const G4VSolid& g4Solid) { From 495dd67e5033e496ead9580560d9039a21520a8f Mon Sep 17 00:00:00 2001 From: cms Date: Wed, 23 Oct 2024 17:13:23 +0200 Subject: [PATCH 3/7] Adding Trap converter in Geant4Converters --- Plugins/Geant4/src/Geant4Converters.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Plugins/Geant4/src/Geant4Converters.cpp b/Plugins/Geant4/src/Geant4Converters.cpp index 89e32e513d4..9f97167b5a7 100644 --- a/Plugins/Geant4/src/Geant4Converters.cpp +++ b/Plugins/Geant4/src/Geant4Converters.cpp @@ -398,8 +398,6 @@ std::shared_ptr Acts::Geant4PhysicalVolumeConverter::surface( } } - // *************************************************************************************** - // Into a Trapezoid (G4Trap) auto g4Trap = dynamic_cast(g4Solid); if (g4Trap != nullptr) { @@ -417,8 +415,6 @@ std::shared_ptr Acts::Geant4PhysicalVolumeConverter::surface( } } - // *************************************************************************************** - // Into a Cylinder, disc or line auto g4Tubs = dynamic_cast(g4Solid); if (g4Tubs != nullptr) { From 71d16463872d8f280deb6c8c8b13b20b342105e3 Mon Sep 17 00:00:00 2001 From: cms Date: Wed, 23 Oct 2024 17:15:50 +0200 Subject: [PATCH 4/7] Adding Trap converter in Geant4Converters --- Plugins/Geant4/src/Geant4Converters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Geant4/src/Geant4Converters.cpp b/Plugins/Geant4/src/Geant4Converters.cpp index 9f97167b5a7..ac3b4a08fb8 100644 --- a/Plugins/Geant4/src/Geant4Converters.cpp +++ b/Plugins/Geant4/src/Geant4Converters.cpp @@ -404,7 +404,7 @@ std::shared_ptr Acts::Geant4PhysicalVolumeConverter::surface( if (forcedType == Surface::SurfaceType::Other || forcedType == Surface::SurfaceType::Plane) { auto [bounds, axes, original] = - Geant4ShapeConverter{}.trapezoidBounds_g4Trap(*g4Trap); + Geant4ShapeConverter{}.trapezoidBounds(*g4Trap); auto orientedToGlobal = axesOriented(toGlobal, axes); surface = Acts::Surface::makeShared(orientedToGlobal, std::move(bounds)); From aff6611bb5e4f89674823d3f94da2e36e84a2d6a Mon Sep 17 00:00:00 2001 From: cms Date: Wed, 23 Oct 2024 17:36:46 +0200 Subject: [PATCH 5/7] Adding Trap converter in Geant4Converters --- .../Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp index 03043427820..b05b1c4b787 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp @@ -16,17 +16,11 @@ #include #include - namespace CLHEP { class Hep3Vector; class HepRotation; } // namespace CLHEP -#include "/home/cms/software/geant4/install_dir/include/Geant4/G4RotationMatrix.hh" -#include "/home/cms/software/geant4/install_dir/include/Geant4/G4ThreeVector.hh" -#include "/home/cms/software/geant4/install_dir/include/Geant4/G4Transform3D.hh" - - class G4Box; class G4Material; class G4Trd; From f16ac93aa7aba8438076aacb0b910b663072c709 Mon Sep 17 00:00:00 2001 From: cms Date: Fri, 25 Oct 2024 08:38:14 +0200 Subject: [PATCH 6/7] Adding G4Trap converter in Geant4Converters and its test-case --- Plugins/Geant4/src/Geant4Converters.cpp | 24 +++---- .../Plugins/Geant4/Geant4ConvertersTests.cpp | 70 +++++++++++++++++++ 2 files changed, 82 insertions(+), 12 deletions(-) diff --git a/Plugins/Geant4/src/Geant4Converters.cpp b/Plugins/Geant4/src/Geant4Converters.cpp index ac3b4a08fb8..4e0ba107893 100644 --- a/Plugins/Geant4/src/Geant4Converters.cpp +++ b/Plugins/Geant4/src/Geant4Converters.cpp @@ -37,8 +37,8 @@ #include "G4RotationMatrix.hh" #include "G4ThreeVector.hh" #include "G4Transform3D.hh" -#include "G4Trd.hh" #include "G4Trap.hh" +#include "G4Trd.hh" #include "G4Tubs.hh" #include "G4VPhysicalVolume.hh" #include "G4VSolid.hh" @@ -249,10 +249,10 @@ Acts::Geant4ShapeConverter::trapezoidBounds(const G4Trap& g4Trap) { ActsScalar theta = static_cast(g4Trap.GetTheta()); ActsScalar z = static_cast(g4Trap.GetZHalfLength()); - ActsScalar hlX0 = (x1 + x2)*0.5; - ActsScalar hlX1 = 2*z*std::tan(theta)*std::cos(phi) + (x3+x4)*0.5; + ActsScalar hlX0 = (x1 + x2) * 0.5; + ActsScalar hlX1 = 2 * z * std::tan(theta) * std::cos(phi) + (x3 + x4) * 0.5; ActsScalar hlY0 = y1; - ActsScalar hlY1 = y2 + 2*z*std::tan(theta)*std::sin(phi); + ActsScalar hlY1 = y2 + 2 * z * std::tan(theta) * std::sin(phi); ActsScalar hlZ = z; std::vector dXYZ = {(hlX0 + hlX1) * 0.5, (hlY0 + hlY1) * 0.5, @@ -269,26 +269,26 @@ Acts::Geant4ShapeConverter::trapezoidBounds(const G4Trap& g4Trap) { std::array rAxes = {}; switch (minPos) { case 0: { - halfLengthXminY = std::min(hlY0,hlY1); - halfLengthXmaxY = std::max(hlY0,hlY1); + halfLengthXminY = std::min(hlY0, hlY1); + halfLengthXmaxY = std::max(hlY0, hlY1); halfLengthY = hlZ; rAxes = {1, 2}; } break; case 1: { - halfLengthXminY = std::min(hlX0,hlX1); - halfLengthXmaxY = std::max(hlX0,hlX1); + halfLengthXminY = std::min(hlX0, hlX1); + halfLengthXmaxY = std::max(hlX0, hlX1); halfLengthY = hlZ; rAxes = {0, -2}; } break; case 2: { if (std::abs(hlY0 - hlY1) < std::abs(hlX0 - hlX1)) { - halfLengthXminY = std::min(hlX0,hlX1); - halfLengthXmaxY = std::max(hlX0,hlX1); + halfLengthXminY = std::min(hlX0, hlX1); + halfLengthXmaxY = std::max(hlX0, hlX1); halfLengthY = (hlY0 + hlY1) * 0.5; rAxes = {0, 1}; } else { - halfLengthXminY = std::min(hlY0,hlY1); - halfLengthXmaxY = std::max(hlY0,hlY1); + halfLengthXminY = std::min(hlY0, hlY1); + halfLengthXmaxY = std::max(hlY0, hlY1); halfLengthY = (hlX0 + hlX1) * 0.5; rAxes = {-1, 0}; } diff --git a/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp b/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp index c748921b4d0..5b9c5ee4188 100644 --- a/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp +++ b/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp @@ -210,6 +210,76 @@ BOOST_AUTO_TEST_CASE(Geant4TrapzoidConversion) { CHECK_CLOSE_ABS(thicknessY, 2., 10e-10); } +BOOST_AUTO_TEST_CASE(Geant4TrapzoidConversion) { + // Standard Trap: XY are already well defined + G4Trap trapXY("trapXY", 2, 0.523599, 0.785398, 125, 200, 125, 0.174533, 50, 125, 50, 0.174533); + auto [boundsXY, axesXY, thicknessZ] = + Acts::Geant4ShapeConverter{}.TrapezoidBounds(trapXY); + CHECK_CLOSE_ABS( + boundsXY->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 51, + 10e-10); + CHECK_CLOSE_ABS( + boundsXY->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 125, + 10e-10); + CHECK_CLOSE_ABS( + boundsXY->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 125, + 10e-10); + auto refXY = std::array{0, 1}; + BOOST_CHECK(axesXY == refXY); + CHECK_CLOSE_ABS(thicknessZ, 4., 10e-10); + + // Flipped, yX are the coordinates + G4Trap trapyX("trapyX", 2, 0.523599, 0.785398, 50, 125, 50, 0.174533, 125, 200, 125, 0.174533); + auto [boundsyX, axesyX, thicknessZ2] = + Acts::Geant4ShapeConverter{}.trapezoidBounds(trapyX); + CHECK_CLOSE_ABS( + boundsyX->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 87, + 10e-10); + CHECK_CLOSE_ABS( + boundsyX->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 164, + 10e-10); + CHECK_CLOSE_ABS( + boundsyX->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 88, + 10e-10); + auto refyX = std::array{-1, 0}; + BOOST_CHECK(axesyX == refyX); + CHECK_CLOSE_ABS(thicknessZ2, 4., 10e-10); + + // YZ span the trapezoid + G4Trap trapYZ("trapYZ", 200, 0.523599, 0.785398, 140, 2, 2, 0.174533, 120, 2, 2, 0.174533); + auto [boundsYZ, axesYZ, thicknessX] = + Acts::Geant4ShapeConverter{}.trapezoidBounds(trapYZ); + CHECK_CLOSE_ABS( + boundsYZ->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 140., + 10e-10); + CHECK_CLOSE_ABS( + boundsYZ->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 283., + 10e-10); + CHECK_CLOSE_ABS( + boundsYZ->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 200., + 10e-10); + auto refYZ = std::array{1, 2}; + BOOST_CHECK(axesYZ == refYZ); + CHECK_CLOSE_ABS(thicknessX, 166, 10e-10); + + // Xz span the trapezoid + G4Trap trapXz("trapXz", 200, 0.523599, 0.785398, 2, 150, 100, 0.174533, 2, 150, 100, 0.174533); + auto [boundsXz, axesXz, thicknessY] = + Acts::Geant4ShapeConverter{}.trapezoidBounds(trapXz); + CHECK_CLOSE_ABS( + boundsXz->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 125., + 10e-10); + CHECK_CLOSE_ABS( + boundsXz->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 288., + 10e-10); + CHECK_CLOSE_ABS( + boundsXz->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 200., + 10e-10); + auto refXz = std::array{0, -2}; + BOOST_CHECK(axesXz == refXz); + CHECK_CLOSE_ABS(thicknessY, 166, 10e-10); +} + BOOST_AUTO_TEST_CASE(Geant4PlanarConversion) { G4Box boxXY("boxXY", 23., 34., 1.); auto pBoundsBox = From d1bc9fee8710136012e2612a0a0aba83e9445e43 Mon Sep 17 00:00:00 2001 From: cms Date: Tue, 5 Nov 2024 10:32:50 +0100 Subject: [PATCH 7/7] Adding G4Trap converter in Geant4Converters and its test-case --- .../include/Acts/Plugins/Geant4/Geant4Converters.hpp | 4 ++++ .../Plugins/Geant4/Geant4ConvertersTests.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp index b05b1c4b787..d2f43044f7b 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4Converters.hpp @@ -21,6 +21,10 @@ class Hep3Vector; class HepRotation; } // namespace CLHEP +namespace HepGeom { +class Transform3D; +} + class G4Box; class G4Material; class G4Trd; diff --git a/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp b/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp index 5b9c5ee4188..80083144e80 100644 --- a/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp +++ b/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp @@ -212,7 +212,8 @@ BOOST_AUTO_TEST_CASE(Geant4TrapzoidConversion) { BOOST_AUTO_TEST_CASE(Geant4TrapzoidConversion) { // Standard Trap: XY are already well defined - G4Trap trapXY("trapXY", 2, 0.523599, 0.785398, 125, 200, 125, 0.174533, 50, 125, 50, 0.174533); + G4Trap trapXY("trapXY", 2, 0.523599, 0.785398, 125, 200, 125, 0.174533, 50, + 125, 50, 0.174533); auto [boundsXY, axesXY, thicknessZ] = Acts::Geant4ShapeConverter{}.TrapezoidBounds(trapXY); CHECK_CLOSE_ABS( @@ -229,7 +230,8 @@ BOOST_AUTO_TEST_CASE(Geant4TrapzoidConversion) { CHECK_CLOSE_ABS(thicknessZ, 4., 10e-10); // Flipped, yX are the coordinates - G4Trap trapyX("trapyX", 2, 0.523599, 0.785398, 50, 125, 50, 0.174533, 125, 200, 125, 0.174533); + G4Trap trapyX("trapyX", 2, 0.523599, 0.785398, 50, 125, 50, 0.174533, 125, + 200, 125, 0.174533); auto [boundsyX, axesyX, thicknessZ2] = Acts::Geant4ShapeConverter{}.trapezoidBounds(trapyX); CHECK_CLOSE_ABS( @@ -246,7 +248,8 @@ BOOST_AUTO_TEST_CASE(Geant4TrapzoidConversion) { CHECK_CLOSE_ABS(thicknessZ2, 4., 10e-10); // YZ span the trapezoid - G4Trap trapYZ("trapYZ", 200, 0.523599, 0.785398, 140, 2, 2, 0.174533, 120, 2, 2, 0.174533); + G4Trap trapYZ("trapYZ", 200, 0.523599, 0.785398, 140, 2, 2, 0.174533, 120, 2, + 2, 0.174533); auto [boundsYZ, axesYZ, thicknessX] = Acts::Geant4ShapeConverter{}.trapezoidBounds(trapYZ); CHECK_CLOSE_ABS( @@ -263,7 +266,8 @@ BOOST_AUTO_TEST_CASE(Geant4TrapzoidConversion) { CHECK_CLOSE_ABS(thicknessX, 166, 10e-10); // Xz span the trapezoid - G4Trap trapXz("trapXz", 200, 0.523599, 0.785398, 2, 150, 100, 0.174533, 2, 150, 100, 0.174533); + G4Trap trapXz("trapXz", 200, 0.523599, 0.785398, 2, 150, 100, 0.174533, 2, + 150, 100, 0.174533); auto [boundsXz, axesXz, thicknessY] = Acts::Geant4ShapeConverter{}.trapezoidBounds(trapXz); CHECK_CLOSE_ABS(