LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT > Class Template Reference

#include "IPRHelper.h"

Public Types

using shared_exception_t = std::shared_ptr< art::Exception const >
 

Public Member Functions

 IPRHelper (EVENT const &e, InputTag const &tag)
 
template<typename Acoll , typename Bcoll >
shared_exception_t operator() (Acoll const &aColl, Bcoll &bColl) const
 
template<typename Acoll , typename Bcoll >
shared_exception_t operator() (Acoll const &aColl, Bcoll &bColl, dataColl_t &dColl) const
 
template<typename Acoll , typename Bcoll >
auto operator() (Acoll const &aColl, Bcoll &bColl) const -> shared_exception_t
 
template<typename Acoll , typename Bcoll >
auto operator() (Acoll const &aColl, Bcoll &bColl, dataColl_t &dColl) const -> shared_exception_t
 

Private Types

using dataColl_t = std::conditional_t< std::is_void_v< Data >, IPRHelperDef, DATACOLL >
 

Private Attributes

EVENT const & event_
 
InputTag const assnsTag_
 

Detailed Description

template<typename ProdA, typename ProdB, typename Data, typename DATACOLL, typename EVENT>
class art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >

Definition at line 50 of file IPRHelper.h.

Member Typedef Documentation

template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
using art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::dataColl_t = std::conditional_t<std::is_void_v<Data>, IPRHelperDef, DATACOLL>
private

Definition at line 128 of file IPRHelper.h.

template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
using art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::shared_exception_t = std::shared_ptr<art::Exception const>

Definition at line 131 of file IPRHelper.h.

Constructor & Destructor Documentation

template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::IPRHelper ( EVENT const &  e,
InputTag const &  tag 
)
inline

Definition at line 133 of file IPRHelper.h.

References art::detail::safe_input_tag< ProdA, ProdB, Data >::tag.

133 : event_{e}, assnsTag_{tag} {}
InputTag const assnsTag_
Definition: IPRHelper.h:153
EVENT const & event_
Definition: IPRHelper.h:152
Float_t e
Definition: plot.C:35

Member Function Documentation

template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
template<typename Acoll , typename Bcoll >
shared_exception_t art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::operator() ( Acoll const &  aColl,
Bcoll &  bColl 
) const
template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
template<typename Acoll , typename Bcoll >
shared_exception_t art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::operator() ( Acoll const &  aColl,
Bcoll &  bColl,
dataColl_t dColl 
) const
template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
template<typename Acoll , typename Bcoll >
auto art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::operator() ( Acoll const &  aColl,
Bcoll &  bColl 
) const -> shared_exception_t
inline

Definition at line 164 of file IPRHelper.h.

167 {
168  IPRHelperDef dummy;
169  return (*this)(aColl, bColl, dummy);
170 }
template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
template<typename Acoll , typename Bcoll >
auto art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::operator() ( Acoll const &  aColl,
Bcoll &  bColl,
dataColl_t dColl 
) const -> shared_exception_t

Definition at line 205 of file IPRHelper.h.

References util::cbegin(), util::cend(), util::counter(), e, art::ensurePointer(), art::detail::DataCollHelper< DATA >::init(), and art::detail::BcollHelper< ProdB >::init().

209 {
210  detail::BcollHelper<ProdB> bh(assnsTag_);
211  detail::DataCollHelper<Data> dh;
212  typename EVENT::template HandleT<Assns<ProdA, ProdB, Data>> assnsHandle;
213  event_.getByLabel(assnsTag_, assnsHandle);
214  if (!assnsHandle.isValid()) {
215  return assnsHandle.whyFailed(); // Failed to get Assns product.
216  }
217  bh.init(aColl.size(), bColl);
218  dh.init(aColl.size(), dColl);
219  // Answer cache.
220  std::unordered_multimap<typename Ptr<ProdA>::const_pointer,
221  std::pair<Ptr<ProdB>, ptrdiff_t>>
222  lookupCache;
223  ptrdiff_t counter{0};
224  for (auto const& apair : *assnsHandle) {
225  if (apair.first.isAvailable()) {
226  lookupCache.emplace(
227  apair.first.get(),
228  typename decltype(lookupCache)::mapped_type(apair.second, counter));
229  }
230  ++counter;
231  }
232  // Now use the cache.
233  size_t bIndex{0};
234  using std::cbegin;
235  using std::cend;
236  for (auto i = cbegin(aColl), e = cend(aColl); i != e; ++i, ++bIndex) {
237  auto foundItems = lookupCache.equal_range(
239  if (foundItems.first != lookupCache.cend()) {
240  std::for_each(
241  foundItems.first,
242  foundItems.second,
243  [&bh, &dh, &bColl, bIndex, &assnsHandle, &dColl](auto const& itemPair) {
244  bh.fill(bIndex, itemPair.second.first, bColl);
245  dh.fill(itemPair.second.second, *assnsHandle, bIndex, dColl);
246  });
247  }
248  }
249  return shared_exception_t();
250 }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
InputTag const assnsTag_
Definition: IPRHelper.h:153
EVENT const & event_
Definition: IPRHelper.h:152
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:295
std::shared_ptr< art::Exception const > shared_exception_t
Definition: IPRHelper.h:131
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:85
Float_t e
Definition: plot.C:35
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
T const * const_pointer
Definition: Ptr.h:80
WANTED_POINTER ensurePointer(InputIterator it)
Definition: ensurePointer.h:77

Member Data Documentation

template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
InputTag const art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::assnsTag_
private

Definition at line 153 of file IPRHelper.h.

template<typename ProdA , typename ProdB , typename Data , typename DATACOLL , typename EVENT >
EVENT const& art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::event_
private

Definition at line 152 of file IPRHelper.h.


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