30 #include "boost/test/unit_test.hpp" 34 #include <type_traits> 55 (
"tag of the recob::SpacePoint and recob::PointCharge data products.")
98 <<
"No points in '" <<
pointsTag.encode() <<
"'";
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";
111 <<
"' contains " << points.size() <<
" points.";
121 auto const& expectedSpacePoints
122 = *(
event.getValidHandle<std::vector<recob::SpacePoint>>(
pointsTag));
124 auto const& expectedCharges
125 = *(
event.getValidHandle<std::vector<recob::PointCharge>>(
pointsTag));
128 <<
"Starting test on " << expectedSpacePoints.size() <<
" points and " 129 << expectedCharges.size() <<
" charges from '" 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());
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Utilities to extend the interface of geometry vectors.
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
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
ChannelGroupService::Name Name
Information about charge reconstructed in the active volume.
EDAnalyzer(fhicl::ParameterSet const &pset)
art::InputTag pointsTag
Tag for the input.
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Offers proxy::ChargedSpacePoints and proxy::SpacePointWithCharge class for recob::SpacePoint with rec...
ChargedSpacePointProxyTest & operator=(ChargedSpacePointProxyTest const &)=delete
#define DEFINE_ART_MODULE(klass)
void proxyUsageExample(art::Event const &event) const
An example of how to access the information via proxy.
void testChargedSpacePoints(art::Event const &event)
Performs the actual test.
fhicl::Atom< art::InputTag > pointsTag
ChargedSpacePointProxyTest(Parameters const &config)
Event finding and building.
Charge reconstructed in the active volume.