9 #include <boost/test/unit_test.hpp>
29 std::vector<GsfComponent> cmps = {
30 {1. / 3., BoundVector::Constant(-2.), BoundSquareMatrix::Identity()},
31 {1. / 3., BoundVector::Constant(+0.), BoundSquareMatrix::Identity()},
32 {1. / 3., BoundVector::Constant(+1.), BoundSquareMatrix::Identity()},
33 {1. / 3., BoundVector::Constant(+4.), BoundSquareMatrix::Identity()}};
35 const auto proj = [](
auto &
a) -> decltype(
auto) {
return a; };
36 detail::SymmetricKLDistanceMatrix mat(cmps,
proj);
38 const auto [
i,
j] = mat.minDistancePair();
40 BOOST_CHECK(std::max(
i,
j) == 2);
44 std::vector<GsfComponent> cmps = {
45 {1. / 3., BoundVector::Constant(-2.), BoundSquareMatrix::Identity()},
46 {1. / 3., BoundVector::Constant(+0.), BoundSquareMatrix::Identity()},
47 {1. / 3., BoundVector::Constant(+1.), BoundSquareMatrix::Identity()},
48 {1. / 3., BoundVector::Constant(+4.), BoundSquareMatrix::Identity()}};
50 const auto proj = [](
auto &
a) -> decltype(
auto) {
return a; };
51 const std::size_t cmp_to_mask = 2;
53 detail::SymmetricKLDistanceMatrix mat_full(cmps,
proj);
54 mat_full.maskAssociatedDistances(cmp_to_mask);
56 cmps.erase(cmps.begin() + cmp_to_mask);
57 detail::SymmetricKLDistanceMatrix mat_small(cmps,
proj);
59 const auto [full_i, full_j] = mat_full.minDistancePair();
60 const auto [small_i, small_j] = mat_small.minDistancePair();
62 BOOST_CHECK(
std::min(full_i, full_j) == 0);
63 BOOST_CHECK(std::max(full_i, full_j) == 1);
64 BOOST_CHECK(full_i == small_i);
65 BOOST_CHECK(full_j == small_j);
69 std::vector<GsfComponent> cmps = {
70 {1. / 3., BoundVector::Constant(-2.), BoundSquareMatrix::Identity()},
71 {1. / 3., BoundVector::Constant(+0.), BoundSquareMatrix::Identity()},
72 {1. / 3., BoundVector::Constant(+1.), BoundSquareMatrix::Identity()},
73 {1. / 3., BoundVector::Constant(+4.), BoundSquareMatrix::Identity()}};
75 const auto proj = [](
auto &
a) -> decltype(
auto) {
return a; };
76 detail::SymmetricKLDistanceMatrix mat(cmps,
proj);
79 const auto [
i,
j] = mat.minDistancePair();
81 BOOST_CHECK(std::max(
i,
j) == 2);
84 cmps[3].boundPars = BoundVector::Constant(0.1);
85 mat.recomputeAssociatedDistances(3, cmps,
proj);
88 const auto [
i,
j] = mat.minDistancePair();
90 BOOST_CHECK(std::max(
i,
j) == 3);
93 cmps[0].boundPars = BoundVector::Constant(1.01);
94 mat.recomputeAssociatedDistances(0, cmps,
proj);
97 const auto [
i,
j] = mat.minDistancePair();
99 BOOST_CHECK(std::max(
i,
j) == 2);
104 auto meanAndSumOfWeights = [](
const auto &cmps) {
105 const auto mean = std::accumulate(
106 cmps.begin(), cmps.end(), Acts::BoundVector::Zero().eval(),
111 const double sumOfWeights = std::accumulate(
112 cmps.begin(), cmps.end(), 0.0,
113 [](
auto sum,
const auto &
cmp) {
return sum +
cmp.weight; });
119 auto surface = Acts::Surface::makeShared<PlaneSurface>(
Vector3{0, 0, 0},
121 const std::size_t NComps = 4;
122 std::vector<GsfComponent> cmps;
124 for (
auto i = 0ul;
i < NComps; ++
i) {
127 a.
boundCov = BoundSquareMatrix::Identity();
138 const auto [mean0, sumOfWeights0] = meanAndSumOfWeights(cmps);
141 BOOST_CHECK_CLOSE(sumOfWeights0, 1.0, 1.
e-8);
146 BOOST_CHECK(cmps.size() == 2);
148 std::sort(cmps.begin(), cmps.end(), [](
const auto &
a,
const auto &
b) {
151 BOOST_CHECK_CLOSE(cmps[0].boundPars[eBoundQOverP], 1.0_GeV, 1.
e-8);
152 BOOST_CHECK_CLOSE(cmps[1].boundPars[eBoundQOverP], 4.0_GeV, 1.
e-8);
154 const auto [mean1, sumOfWeights1] = meanAndSumOfWeights(cmps);
156 BOOST_CHECK_CLOSE(mean1[eBoundQOverP], 2.5_GeV, 1.
e-8);
157 BOOST_CHECK_CLOSE(sumOfWeights1, 1.0, 1.
e-8);
162 BOOST_CHECK(cmps.size() == 1);
163 BOOST_CHECK_CLOSE(cmps[0].boundPars[eBoundQOverP], 2.5_GeV, 1.
e-8);
164 BOOST_CHECK_CLOSE(cmps[0].weight, 1.0, 1.
e-8);