From 15f73cfb2008fbb7ccbdac562ba95e5f41092d67 Mon Sep 17 00:00:00 2001 From: Fabian Klimpel <fklimpel@cern.ch> Date: Mon, 15 Apr 2019 17:14:56 +0200 Subject: [PATCH] Rebase and MR comments --- Core/include/Acts/Geometry/TrackingVolume.hpp | 3 +++ Core/src/Geometry/CuboidVolumeBuilder.cpp | 2 +- Core/src/Geometry/TrackingVolume.cpp | 4 +++- .../Geometry/CuboidVolumeBuilderTests.cpp | 15 ++++++++------- Tests/Core/Propagator/StepperTests.cpp | 19 +++++++++++-------- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index 0207c6dbd..5076d4231 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -497,6 +497,9 @@ private: /// The volume based material the TrackingVolume consists of std::shared_ptr<const IVolumeMaterial> m_volumeMaterial{nullptr}; + /// Remember the mother volume + const TrackingVolume* m_motherVolume{nullptr}; + // the boundary surfaces std::vector<TrackingVolumeBoundaryPtr> m_boundarySurfaces; diff --git a/Core/src/Geometry/CuboidVolumeBuilder.cpp b/Core/src/Geometry/CuboidVolumeBuilder.cpp index 0bf48ac5f..f3201d7c8 100644 --- a/Core/src/Geometry/CuboidVolumeBuilder.cpp +++ b/Core/src/Geometry/CuboidVolumeBuilder.cpp @@ -156,7 +156,7 @@ std::shared_ptr<Acts::TrackingVolume> Acts::CuboidVolumeBuilder::buildVolume( trackVolume = TrackingVolume::create(std::make_shared<const Transform3D>(trafo), bounds, - cfg.material, + cfg.volumeMaterial, nullptr, nullptr, cfg.trackingVolumes, diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index c21e3d15c..a3055da9d 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -460,6 +460,7 @@ void Acts::TrackingVolume::closeGeometry( auto mutableVolumesIter = std::const_pointer_cast<TrackingVolume>(volumesIter); mutableVolumesIter->closeGeometry(materialDecorator, volumeMap, vol); + mutableVolumesIter->setMotherVolume(this); } } @@ -467,7 +468,8 @@ void Acts::TrackingVolume::closeGeometry( for (auto& volumesIter : m_confinedDenseVolumes) { auto mutableVolumesIter = std::const_pointer_cast<TrackingVolume>(volumesIter); - mutableVolumesIter->closeGeometry(surfaceMaterialMap, volumeMap, vol); + mutableVolumesIter->closeGeometry(materialDecorator, volumeMap, vol); + mutableVolumesIter->setMotherVolume(this); } } } diff --git a/Tests/Core/Geometry/CuboidVolumeBuilderTests.cpp b/Tests/Core/Geometry/CuboidVolumeBuilderTests.cpp index 414b604a0..74ff3f3ed 100644 --- a/Tests/Core/Geometry/CuboidVolumeBuilderTests.cpp +++ b/Tests/Core/Geometry/CuboidVolumeBuilderTests.cpp @@ -31,6 +31,7 @@ #include "Acts/Geometry/TrackingGeometryBuilder.hpp" #include "Acts/Utilities/Definitions.hpp" #include "Acts/Utilities/Units.hpp" +#include "Acts/Material/HomogeneousVolumeMaterial.hpp" using namespace Acts::UnitLiterals; @@ -282,8 +283,8 @@ namespace Test { cvCfg1.position = {1.1 * units::_m, 0., 0.}; cvCfg1.length = {10. * units::_cm, 10. * units::_cm, 10. * units::_cm}; cvCfg1.name = "Confined volume1"; - cvCfg1.material = std::make_shared<const Material>( - Material(352.8, 407., 9.012, 4., 1.848e-3)); + cvCfg1.volumeMaterial = std::shared_ptr<const IVolumeMaterial>( + new HomogeneousVolumeMaterial(Material(352.8, 407., 9.012, 4., 1.848e-3))); CuboidVolumeBuilder::VolumeConfig cvCfg2; cvCfg2.position = {0.9 * units::_m, 0., 0.}; cvCfg2.length = {10. * units::_cm, 10. * units::_cm, 10. * units::_cm}; @@ -350,16 +351,16 @@ namespace Test { if (stepResult.position[i].x() >= 0.85 * units::_m && stepResult.position[i].x() < 0.95 * units::_m) { BOOST_TEST(stepResult.volume[i]->volumeName() == cvCfg2.name); - BOOST_TEST(stepResult.volume[i]->material() == nullptr); + BOOST_TEST(stepResult.volume[i]->volumeMaterial() == nullptr); } else { if (stepResult.position[i].x() >= 1.05 * units::_m && stepResult.position[i].x() < 1.15 * units::_m) { BOOST_TEST(stepResult.volume[i]->volumeName() == cvCfg1.name); - BOOST_TEST(stepResult.volume[i]->material() != nullptr); + BOOST_TEST(stepResult.volume[i]->volumeMaterial() != nullptr); } else { if (stepResult.position[i].x() < 2. * units::_m) { BOOST_TEST(stepResult.volume[i]->volumeName() == vCfg.name); - BOOST_TEST(stepResult.volume[i]->material() == nullptr); + BOOST_TEST(stepResult.volume[i]->volumeMaterial() == nullptr); } } } @@ -386,8 +387,8 @@ namespace Test { cvCfg1.position = {0.1 * units::_m, 0.4 * units::_m, 0.4 * units::_m}; cvCfg1.length = {10. * units::_cm, 10. * units::_cm, 10. * units::_cm}; cvCfg1.name = "Confined volume1"; - cvCfg1.material = std::make_shared<const Material>( - Material(352.8, 407., 9.012, 4., 1.848e-3)); + cvCfg1.volumeMaterial = std::shared_ptr<const IVolumeMaterial>( + new HomogeneousVolumeMaterial(Material(352.8, 407., 9.012, 4., 1.848e-3))); // Volume that is missed but far away such that it may be hit CuboidVolumeBuilder::VolumeConfig cvCfg2; cvCfg2.position = {1.9 * units::_m, -0.4 * units::_m, -0.4 * units::_m}; diff --git a/Tests/Core/Propagator/StepperTests.cpp b/Tests/Core/Propagator/StepperTests.cpp index 552d88065..ecd2a85f1 100644 --- a/Tests/Core/Propagator/StepperTests.cpp +++ b/Tests/Core/Propagator/StepperTests.cpp @@ -31,6 +31,9 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" +#include "Acts/Material/HomogeneousSurfaceMaterial.hpp" +#include "Acts/Material/ISurfaceMaterial.hpp" +#include "Acts/Material/IVolumeMaterial.hpp" namespace tt = boost::test_tools; using namespace Acts::UnitLiterals; @@ -633,7 +636,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { sConf1.rotation.col(2) = zPos; sConf1.rBounds = std::make_shared<const RectangleBounds>( RectangleBounds(0.5 * units::_m, 0.5 * units::_m)); - sConf1.surMat = std::shared_ptr<const SurfaceMaterial>( + sConf1.surMat = std::shared_ptr<const ISurfaceMaterial>( new HomogeneousSurfaceMaterial(matProp)); sConf1.thickness = 1. * units::_mm; CuboidVolumeBuilder::LayerConfig lConf1; @@ -646,7 +649,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { sConf2.rotation.col(2) = zPos; sConf2.rBounds = std::make_shared<const RectangleBounds>( RectangleBounds(0.5 * units::_m, 0.5 * units::_m)); - sConf2.surMat = std::shared_ptr<const SurfaceMaterial>( + sConf2.surMat = std::shared_ptr<const ISurfaceMaterial>( new HomogeneousSurfaceMaterial(matProp)); sConf2.thickness = 1. * units::_mm; CuboidVolumeBuilder::LayerConfig lConf2; @@ -655,14 +658,14 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { CuboidVolumeBuilder::VolumeConfig muConf1; muConf1.position = {2.3 * units::_m, 0., 0.}; muConf1.length = {20. * units::_cm, 20. * units::_cm, 20. * units::_cm}; - muConf1.material = std::make_shared<const Material>( - Material(352.8, 407., 9.012, 4., 1.848e-3)); + muConf1.volumeMaterial = std::shared_ptr<const IVolumeMaterial>( + new HomogeneousVolumeMaterial(Material(352.8, 407., 9.012, 4., 1.848e-3))); muConf1.name = "MDT1"; CuboidVolumeBuilder::VolumeConfig muConf2; muConf2.position = {2.7 * units::_m, 0., 0.}; muConf2.length = {20. * units::_cm, 20. * units::_cm, 20. * units::_cm}; - muConf2.material = std::make_shared<const Material>( - Material(352.8, 407., 9.012, 4., 1.848e-3)); + muConf2.volumeMaterial = std::shared_ptr<const IVolumeMaterial>( + new HomogeneousVolumeMaterial(Material(352.8, 407., 9.012, 4., 1.848e-3))); muConf2.name = "MDT2"; CuboidVolumeBuilder::VolumeConfig vConf1; @@ -673,8 +676,8 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { CuboidVolumeBuilder::VolumeConfig vConf2; vConf2.position = {1.5 * units::_m, 0., 0.}; vConf2.length = {1. * units::_m, 1. * units::_m, 1. * units::_m}; - vConf2.material = std::make_shared<const Material>( - Material(352.8, 407., 9.012, 4., 1.848e-3)); + vConf2.volumeMaterial = std::shared_ptr<const IVolumeMaterial>( + new HomogeneousVolumeMaterial(Material(352.8, 407., 9.012, 4., 1.848e-3))); vConf2.name = "Calorimeter"; CuboidVolumeBuilder::VolumeConfig vConf3; vConf3.position = {2.5 * units::_m, 0., 0.}; -- GitLab