LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ClusterParamsImportWrapper.h
Go to the documentation of this file.
1 
10 #ifndef CLUSTERPARAMSARTWRAPPER_H
11 #define CLUSTERPARAMSARTWRAPPER_H
12 
13 // C/C++ standard libraries
14 #include <stdexcept> // std::logic_error
15 #include <utility> // std::forward()
16 
17 // LArSoft libraries
18 #include "lardata/Utilities/Dereference.h" // util::make_pointer()
19 
20 namespace util {
21  class GeometryUtilities;
22 }
23 
24 namespace recob {
25  class Hit;
26 }
27 
29 namespace cluster {
30 
43  template <class Algo>
44  class ClusterParamsImportWrapper : public Algo {
45  public:
46  using ClusterParamsAlg_t = Algo;
47 
49  template <typename... Args>
50  ClusterParamsImportWrapper(Args... args) : ClusterParamsAlg_t(std::forward<Args>(args)...)
51  {}
52 
58 
68  template <typename Iter>
69  void ImportHits(util::GeometryUtilities const& gser, Iter begin, Iter end)
70  {
71  std::vector<recob::Hit const*> hits;
72  std::transform(begin, end, std::back_inserter(hits), [](auto value) {
74  });
75  ClusterParamsAlg_t::SetHitsFromPointers(gser, hits);
76  } // ImportHits()
77 
94  template <typename Iter, typename Convert>
95  void ImportHits(Iter begin, Iter end, Convert converter)
96  {
97  std::vector<recob::Hit const*> hits;
98  std::transform(begin, end, std::back_inserter(hits), [converter](auto value) {
99  return lar::util::make_pointer(converter(value));
100  });
101  ClusterParamsAlg_t::SetHits(hits);
102  } // ImportHits()
103 
112  template <typename Cont>
113  void ImportHits(util::GeometryUtilities const& gser, Cont cont)
114  {
115  ImportHits(gser, std::begin(cont), std::end(cont));
116  }
117 
133  template <typename Cont, typename Convert>
134  void ImportHits(util::GeometryUtilities const& gser, Cont cont, Convert converter)
135  {
136  ImportHits(gser, std::begin(cont), std::end(cont), converter);
137  }
138 
140 
141  }; //class ClusterParamsImportWrapper
142 
143 } //namespace cluster
144 
145 #endif // CLUSTERPARAMSARTWRAPPER_H
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
Reconstruction base classes.
details::make_pointer_class< T, details::has_dereference_class< T >::value >::pointer_type make_pointer(T &v)
Returns a pointer to the value of argument, or the argument itself.
Definition: Dereference.h:279
void ImportHits(util::GeometryUtilities const &gser, Cont cont)
Calls SetHits() with the hits in the sequence.
STL namespace.
Cluster finding and building.
void ImportHits(util::GeometryUtilities const &gser, Iter begin, Iter end)
Calls SetHits() with the hits in the sequence.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void hits()
Definition: readHits.C:15
Wrapper for ClusterParamsAlgBase objects to accept diverse input.
double value
Definition: spectrum.C:18
void ImportHits(util::GeometryUtilities const &gser, Cont cont, Convert converter)
Calls SetHits() with the result of converted hits.
void ImportHits(Iter begin, Iter end, Convert converter)
Calls SetHits() with the result of converted hits.
ClusterParamsImportWrapper(Args...args)
Constructor: just forwards all the stuff to the wrapped class.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69