29 #define BOOST_TEST_MODULE ( PointIsolationAlg_test ) 30 #include "boost/test/unit_test.hpp" 59 using Point_t = std::array<Coord_t, 3U>;
61 PointIsolationAlg_t::Configuration_t
config;
63 config.rangeX = { -2., +2. };
64 config.rangeY = { -2., +2. };
65 config.rangeZ = { -2., +2. };
67 std::vector<Point_t> points;
70 PointIsolationAlg_t algo(config);
73 points.push_back({{ +1., +1., +1. }});
76 result = algo.removeIsolatedPoints(points);
77 std::sort(result.begin(), result.end());
78 BOOST_TEST(result == expected, boost::test_tools::per_element());
82 points.push_back({{ -1., -1., -1. }});
85 result = algo.removeIsolatedPoints(points);
86 std::sort(result.begin(), result.end());
87 BOOST_TEST(result == expected, boost::test_tools::per_element());
91 points.push_back({{ +0.5, +1.0, +1.0 }});
92 expected.insert(expected.end(), { 0U, 2U });
93 std::sort(expected.begin(), expected.end());
95 result = algo.removeIsolatedPoints(points);
96 std::sort(result.begin(), result.end());
97 BOOST_TEST(result == expected, boost::test_tools::per_element());
101 points.push_back({{ -0.5, -1.0, -1.0 }});
102 expected.insert(expected.end(), { 1U, 3U });
103 std::sort(expected.begin(), expected.end());
105 result = algo.removeIsolatedPoints(points);
106 std::sort(result.begin(), result.end());
107 BOOST_TEST(result == expected, boost::test_tools::per_element());
134 template <
typename T>
140 using Point_t = std::array<Coord_t, 3U>;
142 std::vector<Point_t> points;
143 points.reserve(1 + 1 * nShells);
146 while (nShells-- > 0) {
147 points.push_back({{
distance, 0., 0. }});
148 points.push_back({{ -
distance, 0., 0. }});
149 points.push_back({{ 0.,
distance, 0. }});
150 points.push_back({{ 0., -
distance, 0. }});
151 points.push_back({{ 0., 0.,
distance }});
152 points.push_back({{ 0., 0., -
distance }});
157 points.push_back({{ 0., 0., 0. }});
182 using Point_t = std::array<Coord_t, 3U>;
187 constexpr
Coord_t starRadius = 1.;
188 std::vector<Point_t> points = CreateStarOfPoints<Coord_t>(levels, starRadius);
193 PointIsolationAlg_t::Configuration_t
config;
195 config.rangeX = { -2., +2. };
196 config.rangeY = { -2., +2. };
197 config.rangeZ = { -2., +2. };
198 PointIsolationAlg_t algo(config);
203 constexpr
unsigned int nSemiDirections = 6;
205 const Coord_t epsilonStep = starRadius / (2 << levels);
206 double baseRadius = starRadius;
210 size_t const maxExpectedPoints = 1 + levels * nSemiDirections;
211 assert(maxExpectedPoints == points.size());
213 std::vector<size_t> expectedBase(maxExpectedPoints);
214 std::iota(expectedBase.begin(), expectedBase.end(), 0U);
223 unsigned int level = levels;
228 config.radius2 =
cet::square(baseRadius + epsilonStep);
229 algo.reconfigure(config);
232 (
"[" << level <<
"] testing with radius " << (baseRadius + epsilonStep));
235 unsigned int const nExpected = (level > 1)? (1 + level * nSemiDirections): 0;
238 (expectedBase.end() - nExpected, expectedBase.end());
240 std::vector<size_t>
result = algo.removeIsolatedPoints(points);
241 BOOST_TEST(result.size() ==
expected.size());
243 std::sort(result.begin(), result.end());
245 BOOST_TEST(result ==
expected, boost::test_tools::per_element());
247 }
while (--level > 0);
Algorithm to detect isolated space points.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >> Point_t
enum geo::coordinates Coord_t
auto CreateStarOfPoints(unsigned int nShells, T distance=T(1)) -> decltype(auto)
Creates a "star" disposition of points.
void PointIsolationTest2(unsigned int levels)
Tests various isolation radii on a star-distributed set of points.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
Algorithm(s) dealing with point isolation in space.
void PointIsolationTest1()
Low-multiplicity unit test.
BOOST_AUTO_TEST_CASE(PointIsolationAlgTest)