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:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

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
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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...
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

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

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.

65  {}
art::InputTag pointsTag
Tag for the input.
static Config * config
Definition: config.cpp:1054
ChargedSpacePointProxyTest::ChargedSpacePointProxyTest ( ChargedSpacePointProxyTest const &  )
delete
ChargedSpacePointProxyTest::ChargedSpacePointProxyTest ( ChargedSpacePointProxyTest &&  )
delete

Member Function Documentation

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

Implements art::EDAnalyzer.

Definition at line 183 of file ChargedSpacePointProxyTest_module.cc.

183  {
184 
185  // usage example (supposed to be educational)
187 
188  // actual test
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.
Event finding and building.
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 
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()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
auto getChargedSpacePoints(Event const &event, art::InputTag inputTag, Args &&...withArgs)
Creates and returns a proxy to space points with associated charge.
std::string encode() const
Definition: InputTag.cc:97
art::InputTag pointsTag
Tag for the input.
Event finding and building.
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 
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()
auto getChargedSpacePoints(Event const &event, art::InputTag inputTag, Args &&...withArgs)
Creates and returns a proxy to space points with associated charge.
Reconstruction base classes.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
STL namespace.
std::string encode() const
Definition: InputTag.cc:97
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()).
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
for(std::string line;std::getline(inFile, line);)
Definition: regex_t.cc:37
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
Event finding and building.
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: