9 #include <boost/test/unit_test.hpp>
27 using namespace ActsExamples;
28 using namespace Acts::Test;
39 const std::size_t nMeasurements = 3;
43 std::uniform_int_distribution<unsigned> disti(1, 10);
44 std::uniform_real_distribution<double> distf(0.0, 1.0);
46 for (
auto i = 0ul;
i < nMeasurements; ++
i) {
48 sourceLinksOriginal.insert(sl);
59 measOriginal.push_back(
m);
67 const auto o = disti(gen);
70 Seg2D{Acts::Vector2::Random(), Acts::Vector2::Random()}, distf(gen));
73 Seg2D{Acts::Vector2::Random(), Acts::Vector2::Random()}, distf(gen));
74 if (distf(gen) < 0.5) {
77 Seg2D{Acts::Vector2::Random(), Acts::Vector2::Random()}, distf(gen));
83 Seg2D{Acts::Vector2::Random(), Acts::Vector2::Random()}, distf(gen));
88 clusterOriginal.push_back(cl);
91 mapOriginal.insert(std::pair<Index, Index>{
i, disti(gen)});
111 writeTool.write(writer);
129 const auto [measRead, clusterRead, mapRead, sourceLinksRead] =
130 readTool.read(reader);
135 auto checkMeasurementClose = [](
const auto &m1,
const auto &
m2) {
138 if constexpr (SizeA == SizeB) {
144 std::is_same_v<std::decay_t<decltype(measRead)>, decltype(measOriginal)>);
145 BOOST_REQUIRE(measRead.size() == measOriginal.size());
146 for (
const auto &[
a,
b] :
Acts::zip(measRead, measOriginal)) {
147 std::visit(checkMeasurementClose,
a,
b);
150 static_assert(std::is_same_v<std::decay_t<decltype(clusterRead)>,
151 decltype(clusterOriginal)>);
152 BOOST_REQUIRE(clusterRead.size() == clusterOriginal.size());
153 for (
auto [
a,
b] :
Acts::zip(clusterRead, clusterOriginal)) {
154 BOOST_REQUIRE(
a.sizeLoc0 ==
b.sizeLoc0);
155 BOOST_REQUIRE(
a.sizeLoc1 ==
b.sizeLoc1);
157 for (
const auto &ca :
a.channels) {
158 auto match = [&](
const auto &
cb) {
159 return ca.bin ==
cb.bin &&
160 std::abs(ca.activation -
cb.activation) < 1.e-4;
163 BOOST_CHECK(std::any_of(
b.channels.begin(),
b.channels.end(), match));
168 std::is_same_v<std::decay_t<decltype(mapRead)>, decltype(mapOriginal)>);
169 BOOST_REQUIRE(mapRead.size() == mapOriginal.size());
170 for (
const auto &[
a,
b] :
Acts::zip(mapRead, mapOriginal)) {
171 BOOST_REQUIRE(
a ==
b);
174 static_assert(std::is_same_v<std::decay_t<decltype(sourceLinksRead)>,
175 decltype(sourceLinksOriginal)>);
176 BOOST_REQUIRE(sourceLinksRead.size() == sourceLinksOriginal.size());
177 for (
const auto &[
a,
b] :
Acts::zip(sourceLinksRead, sourceLinksOriginal)) {
178 BOOST_REQUIRE(
a.geometryId() ==
b.geometryId());
179 BOOST_REQUIRE(
a.index() ==
b.index());