17 #include "art/Framework/Core/EDAnalyzer.h"
18 #include "art/Framework/Core/ModuleMacros.h"
19 #include "art/Framework/Principal/Event.h"
20 #include "art/Framework/Principal/Handle.h"
21 #include "canvas/Utilities/InputTag.h"
24 #include "messagefacility/MessageLogger/MessageLogger.h"
25 #include "fhiclcpp/types/Atom.h"
26 #include "fhiclcpp/types/Name.h"
27 #include "fhiclcpp/types/Comment.h"
30 #include "boost/test/unit_test.hpp"
34 #include <type_traits>
55 (
"tag of the recob::SpacePoint and recob::PointCharge data products.")
63 : art::EDAnalyzer(config)
74 virtual void analyze(art::Event
const& event)
override;
91 (art::Event
const& event)
const
97 mf::LogVerbatim(
"ProxyTest")
98 <<
"No points in '" << pointsTag.encode() <<
"'";
102 mf::LogVerbatim log(
"ProxyTest");
103 for (
auto point: points) {
104 log <<
"\nPoint at " << point.position() <<
" (ID=" << point.ID()
106 if (point.hasCharge()) log <<
"charge " << point.charge();
107 else log <<
"no charge";
110 mf::LogVerbatim(
"ProxyTest") <<
"Collection '" << pointsTag.encode()
111 <<
"' contains " << points.size() <<
" points.";
118 (art::Event
const& event)
121 auto const& expectedSpacePoints
122 = *(
event.getValidHandle<std::vector<recob::SpacePoint>>(pointsTag));
124 auto const& expectedCharges
125 = *(
event.getValidHandle<std::vector<recob::PointCharge>>(pointsTag));
127 mf::LogInfo(
"ProxyTest")
128 <<
"Starting test on " << expectedSpacePoints.size() <<
" points and "
129 << expectedCharges.size() <<
" charges from '"
130 << pointsTag.encode() <<
"'";
133 assert(expectedSpacePoints.size() == expectedCharges.size());
139 BOOST_TEST(points.empty() == expectedSpacePoints.empty());
140 BOOST_TEST(points.size() == expectedSpacePoints.size());
142 decltype(
auto) spacePoints = points.spacePoints();
144 (std::addressof(spacePoints) == std::addressof(expectedSpacePoints));
145 BOOST_TEST(spacePoints.size() == expectedSpacePoints.size());
147 decltype(
auto) charges = points.charges();
148 BOOST_TEST(std::addressof(charges) == std::addressof(expectedCharges));
149 BOOST_TEST(charges.size() == expectedCharges.size());
151 std::size_t iExpectedPoint = 0;
152 for (
auto pointProxy: points) {
153 auto const& expectedSpacePoint = expectedSpacePoints[iExpectedPoint];
154 auto const& expectedChargeInfo = expectedCharges[iExpectedPoint];
159 (std::addressof(spacePointRef) == std::addressof(expectedSpacePoint));
161 (std::addressof(pointProxy.point()) == std::addressof(expectedSpacePoint));
163 BOOST_TEST(pointProxy.ID() == expectedSpacePoint.ID());
164 BOOST_TEST(pointProxy.hasCharge() == expectedChargeInfo.hasCharge());
165 BOOST_TEST(pointProxy.charge() == expectedChargeInfo.charge());
169 std::is_lvalue_reference<decltype(chargeInfo)>(),
170 "Copy of parallel data element!"
173 (std::addressof(chargeInfo) == std::addressof(expectedChargeInfo));
177 BOOST_TEST(iExpectedPoint == expectedSpacePoints.size());
auto getChargedSpacePoints(Event const &event, art::InputTag inputTag, Args &&...withArgs)
Creates and returns a proxy to space points with associated charge.
Runs a test of proxy::ChargedSpacePoints interface.
virtual void analyze(art::Event const &event) override
art::EDAnalyzer::Table< Config > Parameters
Information about charge reconstructed in the active volume.
art::InputTag pointsTag
Tag for the input.
Offers proxy::ChargedSpacePoints and proxy::SpacePointWithCharge class for recob::SpacePoint with rec...
ChargedSpacePointProxyTest & operator=(ChargedSpacePointProxyTest const &)=delete
void proxyUsageExample(art::Event const &event) const
An example of how to access the information via proxy.
Utilities to extend the interface of geometry vectors.
BEGIN_PROLOG vertical distance to the surface Name
void testChargedSpacePoints(art::Event const &event)
Performs the actual test.
fhicl::Atom< art::InputTag > pointsTag
ChargedSpacePointProxyTest(Parameters const &config)
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Charge reconstructed in the active volume.