diff --git a/tests/common/tests/kalman_fitting_telescope_test.hpp b/tests/common/tests/kalman_fitting_telescope_test.hpp index 36014a1b9..85fe81788 100644 --- a/tests/common/tests/kalman_fitting_telescope_test.hpp +++ b/tests/common/tests/kalman_fitting_telescope_test.hpp @@ -19,20 +19,35 @@ namespace traccc { -/// Combinatorial Kalman Finding Test with Sparse tracks -class KalmanFittingTelescopeTests : public KalmanFittingTests { +/// Kalman Fitting Test with Telescope Detector +/// +/// Test parameters: +/// (1) name +/// (2) origin +/// (3) origin stddev +/// (4) momentum range +/// (5) eta range +/// (6) phi range +/// (7) particle type +/// (8) number of tracks per event +/// (9) number of events +/// (10) random charge +/// (11) offset from origin of the first plane in mm +/// (12) Number of planes +/// (13) Spacing between planes in mm +class KalmanFittingTelescopeTests + : public KalmanFittingTests, + public testing::WithParamInterface, std::array, + std::array, std::array, + std::array, detray::pdg_particle, unsigned int, + unsigned int, bool, scalar, unsigned int, scalar>> { public: /// Plane alignment direction (aligned to x-axis) static const inline detray::detail::ray traj{ {0, 0, 0}, 0, {1, 0, 0}, -1}; - /// Position of planes (in mm unit) - /// @NOTE: Increasing the number of planes will make - /// test_ckf_combinatorics_telescope take too much time - static const inline std::vector plane_positions = { - 0.f, 20.f, 40.f, 60.f, 80.f, 100.f, 120.f, 140.f, 160.f}; - /// B field value and its type static constexpr vector3 B{2 * detray::unit::T, 0, 0}; @@ -62,7 +77,7 @@ class KalmanFittingTelescopeTests : public KalmanFittingTests { // The nubmer of track states is supposed be equal to the number // of planes - ASSERT_EQ(track_states_per_track.size(), plane_positions.size()); + ASSERT_EQ(track_states_per_track.size(), std::get<11>(GetParam())); } protected: @@ -70,11 +85,23 @@ class KalmanFittingTelescopeTests : public KalmanFittingTests { vecmem::host_memory_resource host_mr; + const scalar offset = std::get<10>(GetParam()); + const unsigned int n_planes = std::get<11>(GetParam()); + const scalar spacing = std::get<12>(GetParam()); + + std::vector plane_positions; + for (unsigned int i = 0; i < n_planes; i++) { + plane_positions.push_back(offset * unit::mm + + static_cast(i) * spacing * + unit::mm); + } + detray::tel_det_config<> tel_cfg{rectangle}; tel_cfg.positions(plane_positions); tel_cfg.module_material(mat); tel_cfg.mat_thickness(thickness); tel_cfg.pilot_track(traj); + tel_cfg.envelope(offset * 2.f); // Create telescope detector auto [det, name_map] = build_telescope_detector(host_mr, tel_cfg); diff --git a/tests/common/tests/kalman_fitting_test.hpp b/tests/common/tests/kalman_fitting_test.hpp index 02fa6ddb2..df75a10e1 100644 --- a/tests/common/tests/kalman_fitting_test.hpp +++ b/tests/common/tests/kalman_fitting_test.hpp @@ -31,26 +31,7 @@ namespace traccc { -/// Kalman Fitting Test with Telescope Geometry -/// -/// Test parameters: -/// (1) name -/// (2) origin -/// (3) origin stddev -/// (4) momentum range -/// (5) eta range -/// (6) phi range -/// (7) particle type -/// (8) number of tracks per event -/// (9) number of events -/// (10) random charge -class KalmanFittingTests - : public ::testing::TestWithParam, std::array, - std::array, std::array, - std::array, detray::pdg_particle, unsigned int, - unsigned int, bool>> { - +class KalmanFittingTests : public testing::Test { public: /// Type declarations using host_detector_type = detray::detector, std::array, + std::array, std::array, + std::array, detray::pdg_particle, unsigned int, + unsigned int, bool>> { public: /// Number of barrel layers diff --git a/tests/common/tests/kalman_fitting_wire_chamber_test.hpp b/tests/common/tests/kalman_fitting_wire_chamber_test.hpp index 180da2de5..598315a93 100644 --- a/tests/common/tests/kalman_fitting_wire_chamber_test.hpp +++ b/tests/common/tests/kalman_fitting_wire_chamber_test.hpp @@ -20,8 +20,26 @@ namespace traccc { -/// Combinatorial Kalman Finding Test with Sparse tracks -class KalmanFittingWireChamberTests : public KalmanFittingTests { +/// Kalman Fitting Test with Wire Chamber +/// +/// Test parameters: +/// (1) name +/// (2) origin +/// (3) origin stddev +/// (4) momentum range +/// (5) eta range +/// (6) phi range +/// (7) particle type +/// (8) number of tracks per event +/// (9) number of events +/// (10) random charge +class KalmanFittingWireChamberTests + : public KalmanFittingTests, + public testing::WithParamInterface, std::array, + std::array, std::array, + std::array, detray::pdg_particle, unsigned int, + unsigned int, bool>> { public: /// Number of layers diff --git a/tests/cpu/test_ckf_combinatorics_telescope.cpp b/tests/cpu/test_ckf_combinatorics_telescope.cpp index f72684653..40d62c3ad 100644 --- a/tests/cpu/test_ckf_combinatorics_telescope.cpp +++ b/tests/cpu/test_ckf_combinatorics_telescope.cpp @@ -172,7 +172,7 @@ TEST_P(CpuCkfCombinatoricsTelescopeTests, Run) { // Make sure that the number of found tracks = n_track ^ (n_planes + 1) ASSERT_TRUE(track_candidates.size() > track_candidates_limit.size()); ASSERT_EQ(track_candidates.size(), - std::pow(n_truth_tracks, plane_positions.size() + 1)); + std::pow(n_truth_tracks, std::get<11>(GetParam()) + 1)); ASSERT_EQ(track_candidates_limit.size(), n_truth_tracks * cfg_limit.max_num_branches_per_seed); } @@ -181,21 +181,19 @@ TEST_P(CpuCkfCombinatoricsTelescopeTests, Run) { // Testing two identical tracks INSTANTIATE_TEST_SUITE_P( CpuCkfCombinatoricsTelescopeValidation0, CpuCkfCombinatoricsTelescopeTests, - ::testing::Values(std::make_tuple("telescope_combinatorics_twin", - std::array{0.f, 0.f, 0.f}, - std::array{0.f, 0.f, 0.f}, - std::array{100.f, 100.f}, - std::array{0.f, 0.f}, - std::array{0.f, 0.f}, - detray::muon(), 2, 1, false))); + ::testing::Values(std::make_tuple( + "telescope_combinatorics_twin", std::array{0.f, 0.f, 0.f}, + std::array{0.f, 0.f, 0.f}, + std::array{100.f, 100.f}, std::array{0.f, 0.f}, + std::array{0.f, 0.f}, detray::muon(), 2, 1, false, + 20.f, 9u, 20.f))); // Testing three identical tracks INSTANTIATE_TEST_SUITE_P( CpuCkfCombinatoricsTelescopeValidation1, CpuCkfCombinatoricsTelescopeTests, - ::testing::Values(std::make_tuple("telescope_combinatorics_trio", - std::array{0.f, 0.f, 0.f}, - std::array{0.f, 0.f, 0.f}, - std::array{100.f, 100.f}, - std::array{0.f, 0.f}, - std::array{0.f, 0.f}, - detray::muon(), 3, 1, false))); + ::testing::Values(std::make_tuple( + "telescope_combinatorics_trio", std::array{0.f, 0.f, 0.f}, + std::array{0.f, 0.f, 0.f}, + std::array{100.f, 100.f}, std::array{0.f, 0.f}, + std::array{0.f, 0.f}, detray::muon(), 3, 1, false, + 20.f, 9u, 20.f))); diff --git a/tests/cpu/test_ckf_sparse_tracks_telescope.cpp b/tests/cpu/test_ckf_sparse_tracks_telescope.cpp index 595f57122..084fcd46b 100644 --- a/tests/cpu/test_ckf_sparse_tracks_telescope.cpp +++ b/tests/cpu/test_ckf_sparse_tracks_telescope.cpp @@ -209,43 +209,39 @@ TEST_P(CkfSparseTrackTelescopeTests, Run) { INSTANTIATE_TEST_SUITE_P( CkfSparseTrackTelescopeValidation0, CkfSparseTrackTelescopeTests, - ::testing::Values(std::make_tuple("telescope_single_tracks", - std::array{0.f, 0.f, 0.f}, - std::array{0.f, 200.f, 200.f}, - std::array{1.f, 1.f}, - std::array{0.f, 0.f}, - std::array{0.f, 0.f}, - detray::muon(), 1, 5000, false))); + ::testing::Values(std::make_tuple( + "telescope_single_tracks", std::array{0.f, 0.f, 0.f}, + std::array{0.f, 200.f, 200.f}, + std::array{1.f, 1.f}, std::array{0.f, 0.f}, + std::array{0.f, 0.f}, detray::muon(), 1, 5000, + false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( CkfSparseTrackTelescopeValidation1, CkfSparseTrackTelescopeTests, - ::testing::Values(std::make_tuple("telescope_double_tracks", - std::array{0.f, 0.f, 0.f}, - std::array{0.f, 200.f, 200.f}, - std::array{1.f, 1.f}, - std::array{0.f, 0.f}, - std::array{0.f, 0.f}, - detray::muon(), 2, 2500, false))); + ::testing::Values(std::make_tuple( + "telescope_double_tracks", std::array{0.f, 0.f, 0.f}, + std::array{0.f, 200.f, 200.f}, + std::array{1.f, 1.f}, std::array{0.f, 0.f}, + std::array{0.f, 0.f}, detray::muon(), 2, 2500, + false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( CkfSparseTrackTelescopeValidation2, CkfSparseTrackTelescopeTests, - ::testing::Values(std::make_tuple("telescope_quadra_tracks", - std::array{0.f, 0.f, 0.f}, - std::array{0.f, 200.f, 200.f}, - std::array{1.f, 1.f}, - std::array{0.f, 0.f}, - std::array{0.f, 0.f}, - detray::muon(), 4, 1250, false))); + ::testing::Values(std::make_tuple( + "telescope_quadra_tracks", std::array{0.f, 0.f, 0.f}, + std::array{0.f, 200.f, 200.f}, + std::array{1.f, 1.f}, std::array{0.f, 0.f}, + std::array{0.f, 0.f}, detray::muon(), 4, 1250, + false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( CkfSparseTrackTelescopeValidation3, CkfSparseTrackTelescopeTests, - ::testing::Values(std::make_tuple("telescope_decade_tracks", - std::array{0.f, 0.f, 0.f}, - std::array{0.f, 200.f, 200.f}, - std::array{1.f, 1.f}, - std::array{0.f, 0.f}, - std::array{0.f, 0.f}, - detray::muon(), 10, 500, false))); + ::testing::Values(std::make_tuple( + "telescope_decade_tracks", std::array{0.f, 0.f, 0.f}, + std::array{0.f, 200.f, 200.f}, + std::array{1.f, 1.f}, std::array{0.f, 0.f}, + std::array{0.f, 0.f}, detray::muon(), 10, 500, + false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( CkfSparseTrackTelescopeValidation4, CkfSparseTrackTelescopeTests, @@ -255,4 +251,5 @@ INSTANTIATE_TEST_SUITE_P( std::array{1.f, 1.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::muon(), 10, 500, true))); + detray::muon(), 10, 500, true, + 20.f, 9u, 20.f))); diff --git a/tests/cpu/test_kalman_fitter_telescope.cpp b/tests/cpu/test_kalman_fitter_telescope.cpp index 5cc3e4e80..f58fd80dc 100644 --- a/tests/cpu/test_kalman_fitter_telescope.cpp +++ b/tests/cpu/test_kalman_fitter_telescope.cpp @@ -187,7 +187,7 @@ INSTANTIATE_TEST_SUITE_P( "telescope_1_GeV_0_phi_muon", std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{1.f, 1.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::muon(), 100, 100, false))); + detray::muon(), 100, 100, false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( KalmanFitTelescopeValidation1, KalmanFittingTelescopeTests, @@ -196,7 +196,7 @@ INSTANTIATE_TEST_SUITE_P( std::array{0.f, 0.f, 0.f}, std::array{10.f, 10.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, detray::muon(), 100, 100, - false))); + false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( KalmanFitTelescopeValidation2, KalmanFittingTelescopeTests, @@ -205,7 +205,7 @@ INSTANTIATE_TEST_SUITE_P( std::array{0.f, 0.f, 0.f}, std::array{100.f, 100.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, detray::muon(), 100, 100, - false))); + false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( KalmanFitTelescopeValidation3, KalmanFittingTelescopeTests, @@ -214,7 +214,7 @@ INSTANTIATE_TEST_SUITE_P( std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{1.f, 1.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::antimuon(), 100, 100, false))); + detray::antimuon(), 100, 100, false, 20.f, 9u, 20.f))); INSTANTIATE_TEST_SUITE_P( KalmanFitTelescopeValidation4, KalmanFittingTelescopeTests, @@ -223,4 +223,4 @@ INSTANTIATE_TEST_SUITE_P( std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{1.f, 1.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::antimuon(), 100, 100, true))); + detray::antimuon(), 100, 100, true, 20.f, 9u, 20.f))); diff --git a/tests/cuda/test_ckf_combinatorics_telescope.cpp b/tests/cuda/test_ckf_combinatorics_telescope.cpp index 871d0acc8..f8cc3a4a5 100644 --- a/tests/cuda/test_ckf_combinatorics_telescope.cpp +++ b/tests/cuda/test_ckf_combinatorics_telescope.cpp @@ -231,7 +231,7 @@ TEST_P(CudaCkfCombinatoricsTelescopeTests, Run) { ASSERT_TRUE(track_candidates_cuda.size() > track_candidates_limit_cuda.size()); ASSERT_EQ(track_candidates_cuda.size(), - std::pow(n_truth_tracks, plane_positions.size() + 1)); + std::pow(n_truth_tracks, std::get<11>(GetParam()) + 1)); ASSERT_EQ(track_candidates_limit_cuda.size(), n_truth_tracks * cfg_limit.max_num_branches_per_seed); } @@ -246,11 +246,13 @@ INSTANTIATE_TEST_SUITE_P( std::array{100.f, 100.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::muon(), 2, 1, false), + detray::muon(), 2, 1, false, 20.f, + 9u, 20.f), std::make_tuple("telescope_combinatorics_trio", std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{100.f, 100.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::muon(), 3, 1, false))); + detray::muon(), 3, 1, false, 20.f, + 9u, 20.f))); diff --git a/tests/cuda/test_kalman_fitter_telescope.cpp b/tests/cuda/test_kalman_fitter_telescope.cpp index cff0402d3..76364a25f 100644 --- a/tests/cuda/test_kalman_fitter_telescope.cpp +++ b/tests/cuda/test_kalman_fitter_telescope.cpp @@ -222,38 +222,41 @@ TEST_P(KalmanFittingTelescopeTests, Run) { INSTANTIATE_TEST_SUITE_P( CUDAKalmanFitTelescopeValidation, KalmanFittingTelescopeTests, ::testing::Values( - std::make_tuple("cuda_telescope_1_GeV_0_phi", - std::array{0.f, 0.f, 0.f}, - std::array{0.f, 0.f, 0.f}, - std::array{1.f, 1.f}, - std::array{0.f, 0.f}, - std::array{0.f, 0.f}, - detray::muon(), 100, 100, false), + std::make_tuple( + "cuda_telescope_1_GeV_0_phi", std::array{0.f, 0.f, 0.f}, + std::array{0.f, 0.f, 0.f}, + std::array{1.f, 1.f}, std::array{0.f, 0.f}, + std::array{0.f, 0.f}, detray::muon(), 100, 100, + false, 20.f, 9u, 20.f), std::make_tuple("cuda_telescope_10_GeV_0_phi", std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{10.f, 10.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::muon(), 100, 100, false), + detray::muon(), 100, 100, false, 20.f, 9u, + 20.f), std::make_tuple("cuda_telescope_100_GeV_0_phi", std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{100.f, 100.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::muon(), 100, 100, false), + detray::muon(), 100, 100, false, 20.f, 9u, + 20.f), std::make_tuple("cuda_telescope_1_GeV_0_phi_antimuon", std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{1.f, 1.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::antimuon(), 100, 100, false), + detray::antimuon(), 100, 100, false, 20.f, 9u, + 20.f), std::make_tuple("cuda_telescope_1_GeV_0_phi_random_charge", std::array{0.f, 0.f, 0.f}, std::array{0.f, 0.f, 0.f}, std::array{1.f, 1.f}, std::array{0.f, 0.f}, std::array{0.f, 0.f}, - detray::muon(), 100, 100, true))); + detray::muon(), 100, 100, true, 20.f, 9u, + 20.f)));