Simple test on a recob::Edge object.
More...
#include <array>
#include <iostream>
#include <algorithm>
#include <stdexcept>
#include "boost/test/unit_test.hpp"
#include "lardataobj/RecoBase/Edge.h"
#include "lardataobj/RecoBase/SpacePoint.h"
Go to the source code of this file.
Simple test on a recob::Edge object.
- Author
- Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
- Date
- July 6, 2017
- Version
- 1.0
This test simply creates recob::Edge objects and verifies that the values it can access are the right ones.
See http://www.boost.org/libs/test for the Boost test library home page.
Timing: version 1.0: ~1.5" (debug mode)
Definition in file Edge_test.cc.
#define BOOST_TEST_MODULE ( hit_test ) |
BOOST_AUTO_TEST_CASE |
( |
EdgeTests |
| ) |
|
Definition at line 290 of file Edge_test.cc.
void EdgeTestValueConstructor()
void EdgeTestSpacePointConstructor()
void EdgeTestDefaultConstructor()
BOOST_AUTO_TEST_CASE |
( |
EdgeDocumentationTests |
| ) |
|
Definition at line 296 of file Edge_test.cc.
void EdgeClassDocumentationTest()
void EdgeClassDocumentationTest |
( |
| ) |
|
Definition at line 235 of file Edge_test.cc.
240 std::array<double, 3U>
const error = {{ 0.1, 0.1, 0.1 }};
241 std::array<double, 3U>
const point = {{ 1.0, 1.0, 1.0 }};
242 std::vector<recob::SpacePoint> points;
243 for (
unsigned int i = 0; i < 10; ++i)
244 points.emplace_back(point.data(), error.data(), 1.0, i);
250 if (!std::is_sorted(points.begin(), points.end()))
251 throw std::runtime_error(
"Space points not sorted!");
254 auto const iFirstPoint = std::lower_bound
255 (points.begin(), points.end(), edge.FirstPointID());
257 if ((iFirstPoint == points.end()) || (iFirstPoint->ID() != edge.FirstPointID())) {
258 throw std::runtime_error
259 (
"First point not found: ID=" +
std::to_string(edge.FirstPointID()));
264 auto const iSecondPoint = std::lower_bound
265 (points.begin(), points.end(), edge.SecondPointID());
267 if ((iSecondPoint == points.end()) || (iSecondPoint->ID() != edge.SecondPointID())) {
268 throw std::runtime_error
269 (
"Second point not found: ID=" +
std::to_string(edge.SecondPointID()));
274 BOOST_TEST(&firstPoint == &points[3]);
275 BOOST_TEST(&secondPoint == &points[6]);
std::string to_string(ModuleType const mt)
Edge is an object containing the results of a Principal Components Analysis of a group of space point...
void EdgeTestDefaultConstructor |
( |
| ) |
|
Definition at line 46 of file Edge_test.cc.
85 BOOST_TEST(e.
ID() == EinvID);
88 BOOST_TEST(e.
Length() == 0.0);
91 BOOST_TEST(!(e < e.
ID()));
92 BOOST_TEST(!(e.
ID() <
e));
94 std::cout <<
"Printout of a default-constructed edge: " << e <<
std::endl;
static constexpr ID_t InvalidID
Special value for an invalid edge ID.
double Length() const
Returns the length of this edge [cm].
SpacePointID_t FirstPointID() const
Returns the ID of the SpacePoint this edge emanates from.
static constexpr ID_t InvalidID
Special value for an invalid ID.
ID_t ID() const
Returns the ID of this edge.
QTextStream & endl(QTextStream &s)
Edge is an object containing the results of a Principal Components Analysis of a group of space point...
SpacePointID_t SecondPointID() const
Returns the ID of the SpacePoint this edge ends on.
void EdgeTestSpacePointConstructor |
( |
| ) |
|
Definition at line 160 of file Edge_test.cc.
209 std::array<double, 3U>
const error = {{ 0.1, 0.1, 0.1 }};
210 std::array<double, 3U> point;
214 point = {{ 1.0, 1.0, 1.0 }};
219 point = {{ 4.0, 5.0, 13.0 }};
224 BOOST_TEST(
e.ID() == 0);
225 BOOST_TEST(
e.FirstPointID() == 0);
226 BOOST_TEST(
e.SecondPointID() == 1);
227 BOOST_CHECK_CLOSE(
e.Length(), 13.0, 1
e-4);
229 std::cout <<
"Printout of a spacepoint-constructed edge: " <<
e <<
std::endl;
QTextStream & endl(QTextStream &s)
Edge is an object containing the results of a Principal Components Analysis of a group of space point...
void EdgeTestValueConstructor |
( |
| ) |
|
Definition at line 99 of file Edge_test.cc.
139 BOOST_TEST(
e.ID() == 3);
140 BOOST_TEST(
e.FirstPointID() == 5);
141 BOOST_TEST(
e.SecondPointID() == 10);
142 BOOST_TEST(
e.Length() == 3.0);
144 BOOST_TEST(!(
e <
e));
145 BOOST_TEST(!(
e <
e.ID()));
146 BOOST_TEST(!(
e.ID() <
e));
148 std::cout <<
"Printout of a value-constructed edge: " <<
e <<
std::endl;
152 BOOST_TEST( (
e < o));
153 BOOST_TEST(!(o <
e));
154 BOOST_TEST( (
e < o.ID()));
155 BOOST_TEST(!(o.ID() <
e));
QTextStream & endl(QTextStream &s)
Edge is an object containing the results of a Principal Components Analysis of a group of space point...