Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChannelMergerTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ChannelMergerTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
16 
17 #include <array>
18 #include <map>
19 #include <unordered_set>
20 #include <utility>
21 #include <vector>
22 
23 BOOST_AUTO_TEST_SUITE(Digitization)
24 
25 BOOST_AUTO_TEST_CASE(ChannelMerger1D) {
26  // Some cells
27  ActsFatras::Cell cell0(5, 10.5);
28  ActsFatras::Cell cell1(6, 11.5);
29  ActsFatras::Cell cell2(7, 12.5);
30 
32 
33  // Digital clustering test
34  std::vector<Channel1D> channels = {{{cell0}, 1., {5}},
35  {{cell1}, 1., {5}},
36  {{cell2}, 1., {5}},
37  {{cell0}, 0.5, {6}}};
38 
39  BOOST_CHECK_EQUAL(channels.size(), 4u);
40  auto mergedChannels = ActsFatras::mergeChannels(channels);
41  BOOST_CHECK_EQUAL(mergedChannels.size(), 3u);
42 
43  std::unordered_set<unsigned int> mergedLinks = {5, 6};
44  // Find the merged one and check the merged value
45  for (const auto& ch : mergedChannels) {
46  if (ch.cellId[0].first == 5) {
47  // Check if the channel value is merged
48  CHECK_CLOSE_ABS(ch.value, 1.5, Acts::s_epsilon);
49  // check if the channel links are merged
50  BOOST_CHECK_EQUAL(ch.links.size(), 2u);
51  BOOST_CHECK(ch.links == mergedLinks);
52  }
53  }
54 }
55 
56 BOOST_AUTO_TEST_CASE(ChannelMerger2D) {
57  // Some cells in 0 direction
58  ActsFatras::Cell cell00(5, 10.5);
59  ActsFatras::Cell cell01(6, 11.5);
60  ActsFatras::Cell cell02(7, 12.5);
61 
62  // Some cells in 1 direction
63  ActsFatras::Cell cell10(10, 0.5);
64  ActsFatras::Cell cell11(10, 0.5);
65  ActsFatras::Cell cell12(11, 1.5);
66 
68 
69  std::vector<Channel2D> channels = {{{cell00, cell10}, 1., {5}},
70  {{cell01, cell11}, 1., {5}},
71  {{cell02, cell12}, 1., {5}},
72  {{cell01, cell11}, 0.5, {6}}};
73 
74  BOOST_CHECK_EQUAL(channels.size(), 4u);
75  auto mergedChannels = ActsFatras::mergeChannels(channels);
76  BOOST_CHECK_EQUAL(mergedChannels.size(), 3u);
77 
78  std::unordered_set<unsigned int> mergedLinks = {5, 6};
79  // Find the merged one and check the merged value
80  for (const auto& ch : mergedChannels) {
81  if (ch.cellId[0].first == 6) {
82  // Check if the channel value is merged
83  CHECK_CLOSE_ABS(ch.value, 1.5, Acts::s_epsilon);
84  // check if the channel links are merged
85  BOOST_CHECK_EQUAL(ch.links.size(), 2u);
86  BOOST_CHECK(ch.links == mergedLinks);
87  }
88  }
89 }
90 
91 BOOST_AUTO_TEST_SUITE_END()