21 #define BOOST_TEST_MODULE ( PointIsolationAlg_test )
22 #include <boost/test/unit_test.hpp>
29 #include "cetlib/pow.h"
56 template <
typename Engine,
typename Coord =
float>
58 Engine&
generator,
unsigned int nPoints, std::vector<Coord>
const& radii
66 std::uniform_real_distribution<Coord_t> uniform(-1., +1.);
67 auto randomCoord = std::bind(uniform, generator);
69 using Point_t = std::array<Coord_t, 3U>;
70 std::vector<Point_t> points;
72 points.reserve(nPoints);
73 for (
unsigned int i = 0; i < nPoints; ++i)
74 points.push_back({{ randomCoord(), randomCoord(), randomCoord() }});
76 <<
"\n" << std::string(75,
'=')
77 <<
"\nTest with " << nPoints <<
" points"
78 <<
"\n" << std::string(72,
'-')
86 typename PointIsolationAlg_t::Configuration_t config;
87 config.rangeX = { -2., +2. };
88 config.rangeY = { -2., +2. };
89 config.rangeZ = { -2., +2. };
92 PointIsolationAlg_t algo(config);
105 config.radius2 = cet::square(radius);
106 algo.reconfigure(config);
108 std::cout <<
"Isolation radius: " << radius << std::endl;
115 = algo.bruteRemoveIsolatedPoints(points.begin(), points.end());
116 auto elapsed = timer.
elapsed();
117 std::sort(expected.begin(), expected.end());
118 std::cout <<
" brute force: " << elapsed <<
" ms"
125 auto actual = algo.removeIsolatedPoints(points);
127 std::sort(actual.begin(), actual.end());
128 std::cout <<
" regular: " << elapsed <<
" ms"
134 BOOST_TEST(actual == expected, boost::test_tools::per_element());
138 std::cout << std::string(72,
'-') << std::endl;
148 :
argc(boost::unit_test::framework::master_test_suite().
argc)
149 ,
argv(boost::unit_test::framework::master_test_suite().
argv)
159 auto seed = std::default_random_engine::default_seed;
162 std::istringstream sstr;
166 throw std::runtime_error
167 (
"Invalid seed specified: " + std::string(argv[1]));
176 std::vector<float>
const Radii { 0.05, 0.1, 0.5, 2.0 };
177 std::vector<unsigned int>
const DataSizes { 100, 10000 };
179 for (
unsigned int nPoints: DataSizes)
Algorithm to detect isolated space points.
enum geo::coordinates Coord_t
void restart()
Restarts the watch; previous time is forgotten.
recob::tracking::Point_t Point_t
Provides time interval measurements.
Class to take current wall clock time differences.
Algorithm(s) dealing with point isolation in space.
void PointIsolationTest(Engine &generator, unsigned int nPoints, std::vector< Coord > const &radii)
ElapsedTime_t elapsed() const
Returns the total time spent running since the last restart.
BOOST_FIXTURE_TEST_CASE(PointIsolationTestCase, ArgsFixture)
BEGIN_PROLOG could also be cout