All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ChargedSpacePointProxyTest Class Reference

Runs a test of proxy::ChargedSpacePoints interface. More...

Inheritance diagram for ChargedSpacePointProxyTest:

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 ChargedSpacePointProxyTest (Parameters const &config)
 
 ChargedSpacePointProxyTest (ChargedSpacePointProxyTest const &)=delete
 
 ChargedSpacePointProxyTest (ChargedSpacePointProxyTest &&)=delete
 
ChargedSpacePointProxyTestoperator= (ChargedSpacePointProxyTest const &)=delete
 
ChargedSpacePointProxyTestoperator= (ChargedSpacePointProxyTest &&)=delete
 
virtual void analyze (art::Event const &event) override
 

Private Member Functions

void proxyUsageExample (art::Event const &event) const
 An example of how to access the information via proxy. More...
 
void testChargedSpacePoints (art::Event const &event)
 Performs the actual test. More...
 

Private Attributes

art::InputTag pointsTag
 Tag for the input. More...
 

Detailed Description

Runs a test of proxy::ChargedSpacePoints interface.

This module is that it uses Boost unit test library, and as such it must be run with lar_ut instead of lar.

Definition at line 45 of file ChargedSpacePointProxyTest_module.cc.

Member Typedef Documentation

using ChargedSpacePointProxyTest::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 60 of file ChargedSpacePointProxyTest_module.cc.

Constructor & Destructor Documentation

ChargedSpacePointProxyTest::ChargedSpacePointProxyTest ( Parameters const &  config)
inlineexplicit

Definition at line 62 of file ChargedSpacePointProxyTest_module.cc.

63  : art::EDAnalyzer(config)
64  , pointsTag(config().pointsTag())
65  {}
art::InputTag pointsTag
Tag for the input.
ChargedSpacePointProxyTest::ChargedSpacePointProxyTest ( ChargedSpacePointProxyTest const &  )
delete
ChargedSpacePointProxyTest::ChargedSpacePointProxyTest ( ChargedSpacePointProxyTest &&  )
delete

Member Function Documentation

void ChargedSpacePointProxyTest::analyze ( art::Event const &  event)
overridevirtual

Definition at line 183 of file ChargedSpacePointProxyTest_module.cc.

183  {
184 
185  // usage example (supposed to be educational)
186  proxyUsageExample(event);
187 
188  // actual test
189  testChargedSpacePoints(event);
190 
191 } // ChargedSpacePointProxyTest::analyze()
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.
ChargedSpacePointProxyTest& ChargedSpacePointProxyTest::operator= ( ChargedSpacePointProxyTest const &  )
delete
ChargedSpacePointProxyTest& ChargedSpacePointProxyTest::operator= ( ChargedSpacePointProxyTest &&  )
delete
void ChargedSpacePointProxyTest::proxyUsageExample ( art::Event const &  event) const
private

An example of how to access the information via proxy.

Definition at line 91 of file ChargedSpacePointProxyTest_module.cc.

92 {
93 
94  auto points = proxy::getChargedSpacePoints(event, pointsTag);
95 
96  if (points.empty()) {
97  mf::LogVerbatim("ProxyTest")
98  << "No points in '" << pointsTag.encode() << "'";
99  return;
100  }
101 
102  mf::LogVerbatim log("ProxyTest");
103  for (auto point: points) {
104  log << "\nPoint at " << point.position() << " (ID=" << point.ID()
105  << ") has ";
106  if (point.hasCharge()) log << "charge " << point.charge();
107  else log << "no charge";
108  } // for point
109 
110  mf::LogVerbatim("ProxyTest") << "Collection '" << pointsTag.encode()
111  << "' contains " << points.size() << " points.";
112 
113 } // ChargedSpacePointProxyTest::proxyUsageExample()
auto getChargedSpacePoints(Event const &event, art::InputTag inputTag, Args &&...withArgs)
Creates and returns a proxy to space points with associated charge.
art::InputTag pointsTag
Tag for the input.
void ChargedSpacePointProxyTest::testChargedSpacePoints ( art::Event const &  event)
private

Performs the actual test.

Definition at line 118 of file ChargedSpacePointProxyTest_module.cc.

119 {
120 
121  auto const& expectedSpacePoints
122  = *(event.getValidHandle<std::vector<recob::SpacePoint>>(pointsTag));
123 
124  auto const& expectedCharges
125  = *(event.getValidHandle<std::vector<recob::PointCharge>>(pointsTag));
126 
127  mf::LogInfo("ProxyTest")
128  << "Starting test on " << expectedSpacePoints.size() << " points and "
129  << expectedCharges.size() << " charges from '"
130  << pointsTag.encode() << "'";
131 
132  // this assertion fails on invalid input (test bug)
133  assert(expectedSpacePoints.size() == expectedCharges.size());
134 
135  auto points = proxy::getChargedSpacePoints(event, pointsTag);
136 
137  static_assert(points.has<recob::PointCharge>(), "recob::Charge not found!!!");
138 
139  BOOST_TEST(points.empty() == expectedSpacePoints.empty());
140  BOOST_TEST(points.size() == expectedSpacePoints.size());
141 
142  decltype(auto) spacePoints = points.spacePoints();
143  BOOST_TEST
144  (std::addressof(spacePoints) == std::addressof(expectedSpacePoints));
145  BOOST_TEST(spacePoints.size() == expectedSpacePoints.size());
146 
147  decltype(auto) charges = points.charges();
148  BOOST_TEST(std::addressof(charges) == std::addressof(expectedCharges));
149  BOOST_TEST(charges.size() == expectedCharges.size());
150 
151  std::size_t iExpectedPoint = 0;
152  for (auto pointProxy: points) {
153  auto const& expectedSpacePoint = expectedSpacePoints[iExpectedPoint];
154  auto const& expectedChargeInfo = expectedCharges[iExpectedPoint];
155 
156  recob::SpacePoint const& spacePointRef = *pointProxy;
157 
158  BOOST_TEST
159  (std::addressof(spacePointRef) == std::addressof(expectedSpacePoint));
160  BOOST_TEST
161  (std::addressof(pointProxy.point()) == std::addressof(expectedSpacePoint));
162  BOOST_TEST(pointProxy.position() == geo::vect::makePointFromCoords(expectedSpacePoint.XYZ()));
163  BOOST_TEST(pointProxy.ID() == expectedSpacePoint.ID());
164  BOOST_TEST(pointProxy.hasCharge() == expectedChargeInfo.hasCharge());
165  BOOST_TEST(pointProxy.charge() == expectedChargeInfo.charge());
166 
167  decltype(auto) chargeInfo = pointProxy.get<recob::PointCharge>();
168  static_assert(
169  std::is_lvalue_reference<decltype(chargeInfo)>(),
170  "Copy of parallel data element!"
171  );
172  BOOST_TEST
173  (std::addressof(chargeInfo) == std::addressof(expectedChargeInfo));
174 
175  ++iExpectedPoint;
176  } // for
177  BOOST_TEST(iExpectedPoint == expectedSpacePoints.size());
178 
179 } // ChargedSpacePointProxyTest::testChargedSpacePoints()
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
auto getChargedSpacePoints(Event const &event, art::InputTag inputTag, Args &&...withArgs)
Creates and returns a proxy to space points with associated charge.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
art::InputTag pointsTag
Tag for the input.
for($it=0;$it< $RaceTrack_number;$it++)
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Charge reconstructed in the active volume.
Definition: PointCharge.h:31

Member Data Documentation

art::InputTag ChargedSpacePointProxyTest::pointsTag
private

Tag for the input.

Definition at line 77 of file ChargedSpacePointProxyTest_module.cc.


The documentation for this class was generated from the following file: