diff --git a/tests/unit_tests/cpu/core_detector.cpp b/tests/unit_tests/cpu/core_detector.cpp index 3ab0fdf50..832e88b38 100644 --- a/tests/unit_tests/cpu/core_detector.cpp +++ b/tests/unit_tests/cpu/core_detector.cpp @@ -723,6 +723,7 @@ GTEST_TEST(detray_tools, detector_builder) { auto portal_generator = std::make_shared>(env); + vbuilder2->add_surfaces(trpz_factory, geo_ctx); vbuilder2->add_surfaces(portal_generator); // initial checks @@ -753,14 +754,14 @@ GTEST_TEST(detray_tools, detector_builder) { // Check the acceleration data structure link (indirectly) EXPECT_EQ(vol0.n_max_candidates(), 3u); - EXPECT_EQ(vol1.n_max_candidates(), 6u); + EXPECT_EQ(vol1.n_max_candidates(), 9u); - EXPECT_EQ(d.surface_lookup().size(), 9u); + EXPECT_EQ(d.surface_lookup().size(), 12u); EXPECT_EQ(d.mask_store().template size(), 0u); EXPECT_EQ(d.mask_store().template size(), 0u); EXPECT_EQ(d.mask_store().template size(), 0u); EXPECT_EQ(d.mask_store().template size(), 0u); EXPECT_EQ(d.mask_store().template size(), 3u); EXPECT_EQ(d.mask_store().template size(), 0u); - EXPECT_EQ(d.mask_store().template size(), 3u); + EXPECT_EQ(d.mask_store().template size(), 6u); } diff --git a/tests/unit_tests/cpu/tools_material_builder.cpp b/tests/unit_tests/cpu/tools_material_builder.cpp index 233610f21..0ab1223d4 100644 --- a/tests/unit_tests/cpu/tools_material_builder.cpp +++ b/tests/unit_tests/cpu/tools_material_builder.cpp @@ -228,14 +228,22 @@ GTEST_TEST(detray_tools, decorator_material_builder) { GTEST_TEST(detray_tools, detector_builder_with_material) { using namespace detray; + using transform3 = typename detector_t::transform3; using mask_id = typename detector_t::masks::id; using material_id = typename detector_t::materials::id; + // Surface factories + using trapezoid_factory = surface_factory>; + // detector builder detector_builder det_builder{}; + auto geo_ctx = typename detector_t::geometry_context{}; // Vanilla volume builder auto vbuilder = det_builder.new_volume(volume_id::e_cuboid); + const auto vol_idx{ + static_cast( + vbuilder->vol_index())}; // Add material auto mv_builder = @@ -245,6 +253,18 @@ GTEST_TEST(detray_tools, detector_builder_with_material) { typename detector_t::point3 t{0.f, 0.f, 20.f}; mv_builder->add_volume_placement(t); + // Add a senstive surface + auto trpz_factory = std::make_unique(); + // Add material to the surface + auto mat_sf_factory = + std::make_shared>(std::move(trpz_factory)); + + mat_sf_factory->push_back({surface_id::e_sensitive, + transform3(point3{0.f, 0.f, 1000.f}), vol_idx, + std::vector{1.f, 3.f, 2.f, 0.25f}}); + mat_sf_factory->add_material(material_id::e_slab, + {1.f * unit::mm, silicon()}); + // Add a portal box around the cuboid volume with a min distance of 'env' constexpr auto env{0.1f * unit::mm}; auto portal_generator = @@ -253,8 +273,6 @@ GTEST_TEST(detray_tools, detector_builder_with_material) { // Add homogeneous material to every portal auto mat_portal_factory = std::make_shared>( std::move(portal_generator)); - mat_portal_factory->add_material( - material_id::e_slab, {1.f * unit::mm, silicon()}); mat_portal_factory->add_material( material_id::e_slab, {2.f * unit::mm, silicon()}); mat_portal_factory->add_material( @@ -265,7 +283,10 @@ GTEST_TEST(detray_tools, detector_builder_with_material) { material_id::e_slab, {5.f * unit::mm, silicon()}); mat_portal_factory->add_material( material_id::e_slab, {6.f * unit::mm, silicon()}); + mat_portal_factory->add_material( + material_id::e_slab, {7.f * unit::mm, silicon()}); + mv_builder->add_surfaces(mat_sf_factory, geo_ctx); mv_builder->add_surfaces(mat_portal_factory); // @@ -285,9 +306,10 @@ GTEST_TEST(detray_tools, detector_builder_with_material) { EXPECT_TRUE(vol.transform() == trf); EXPECT_TRUE(d.transform_store()[0u] == trf); - EXPECT_EQ(d.surface_lookup().size(), 6u); + EXPECT_EQ(d.surface_lookup().size(), 7u); EXPECT_EQ(d.mask_store().template size(), 3u); - EXPECT_EQ(d.material_store().template size(), 6u); + EXPECT_EQ(d.mask_store().template size(), 1u); + EXPECT_EQ(d.material_store().template size(), 7u); // Check the material links for (const auto [idx, sf_desc] :