File indexing completed on 2025-01-18 09:13:04
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0014 #include "ActsFatras/Digitization/ChannelMerger.hpp"
0015 #include "ActsFatras/Digitization/DigitizationData.hpp"
0016
0017 #include <array>
0018 #include <map>
0019 #include <unordered_set>
0020 #include <utility>
0021 #include <vector>
0022
0023 BOOST_AUTO_TEST_SUITE(Digitization)
0024
0025 BOOST_AUTO_TEST_CASE(ChannelMerger1D) {
0026
0027 ActsFatras::Cell cell0(5, 10.5);
0028 ActsFatras::Cell cell1(6, 11.5);
0029 ActsFatras::Cell cell2(7, 12.5);
0030
0031 using Channel1D = ActsFatras::Channel<double, 1>;
0032
0033
0034 std::vector<Channel1D> channels = {{{cell0}, 1., {5}},
0035 {{cell1}, 1., {5}},
0036 {{cell2}, 1., {5}},
0037 {{cell0}, 0.5, {6}}};
0038
0039 BOOST_CHECK_EQUAL(channels.size(), 4u);
0040 auto mergedChannels = ActsFatras::mergeChannels(channels);
0041 BOOST_CHECK_EQUAL(mergedChannels.size(), 3u);
0042
0043 std::unordered_set<unsigned int> mergedLinks = {5, 6};
0044
0045 for (const auto& ch : mergedChannels) {
0046 if (ch.cellId[0].first == 5) {
0047
0048 CHECK_CLOSE_ABS(ch.value, 1.5, Acts::s_epsilon);
0049
0050 BOOST_CHECK_EQUAL(ch.links.size(), 2u);
0051 BOOST_CHECK(ch.links == mergedLinks);
0052 }
0053 }
0054 }
0055
0056 BOOST_AUTO_TEST_CASE(ChannelMerger2D) {
0057
0058 ActsFatras::Cell cell00(5, 10.5);
0059 ActsFatras::Cell cell01(6, 11.5);
0060 ActsFatras::Cell cell02(7, 12.5);
0061
0062
0063 ActsFatras::Cell cell10(10, 0.5);
0064 ActsFatras::Cell cell11(10, 0.5);
0065 ActsFatras::Cell cell12(11, 1.5);
0066
0067 using Channel2D = ActsFatras::Channel<double, 2>;
0068
0069 std::vector<Channel2D> channels = {{{cell00, cell10}, 1., {5}},
0070 {{cell01, cell11}, 1., {5}},
0071 {{cell02, cell12}, 1., {5}},
0072 {{cell01, cell11}, 0.5, {6}}};
0073
0074 BOOST_CHECK_EQUAL(channels.size(), 4u);
0075 auto mergedChannels = ActsFatras::mergeChannels(channels);
0076 BOOST_CHECK_EQUAL(mergedChannels.size(), 3u);
0077
0078 std::unordered_set<unsigned int> mergedLinks = {5, 6};
0079
0080 for (const auto& ch : mergedChannels) {
0081 if (ch.cellId[0].first == 6) {
0082
0083 CHECK_CLOSE_ABS(ch.value, 1.5, Acts::s_epsilon);
0084
0085 BOOST_CHECK_EQUAL(ch.links.size(), 2u);
0086 BOOST_CHECK(ch.links == mergedLinks);
0087 }
0088 }
0089 }
0090
0091 BOOST_AUTO_TEST_SUITE_END()