LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
AssociatedDataProxyMaker.h
Go to the documentation of this file.
1 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_ASSOCIATEDDATAPROXYMAKER_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_ASSOCIATEDDATAPROXYMAKER_H
13 
14 // LArSoft libraries
16 
17 // framework libraries
19 
20 // C/C++ standard libraries
21 #include <type_traits> // std::is_convertible<>
22 #include <utility> // std::forward()
23 
24 namespace proxy {
25 
26  // --- BEGIN Associated data infrastructure ----------------------------------
29 
30  //----------------------------------------------------------------------------
31  //--- one-to-many associations
32  //----------------------------------------------------------------------------
46  template <typename Main, typename Aux, typename Metadata, typename AuxTag = Aux>
48 
50  using data_tag = AuxTag;
51 
53  using main_element_t = Main;
54 
56  using aux_element_t = Aux;
57 
59  using metadata_t = Metadata;
60 
64 
67 
86  template <typename Event, typename Handle, typename MainArgs>
87  static auto make(Event const& event, Handle&& mainHandle, MainArgs const& mainArgs)
88  {
89  return createFromTag(event, std::forward<Handle>(mainHandle), art::InputTag(mainArgs));
90  }
91 
106  template <typename Event, typename Handle, typename MainArgs>
107  static auto make(Event const& event,
108  Handle&& mainHandle,
109  MainArgs const&,
110  art::InputTag const& auxInputTag)
111  {
112  return createFromTag(event, std::forward<Handle>(mainHandle), auxInputTag);
113  }
114 
127  template <typename Event, typename Handle, typename MainArgs, typename Assns>
128  static auto make(Event const&, Handle&&, MainArgs const&, Assns const& assns)
129  {
130  static_assert(std::is_convertible<typename Assns::right_t, aux_element_t>(),
131  "Improper right type for association.");
132  return makeAssociatedDataFrom<data_tag>(assns);
133  }
134 
135  private:
136  template <typename Event, typename Handle>
137  static auto createFromTag(Event const& event,
138  Handle&& mainHandle,
139  art::InputTag const& auxInputTag)
140  {
141  return makeAssociatedDataFrom<main_element_t, aux_element_t, metadata_t, data_tag>(
142  event, auxInputTag, mainHandle->size());
143  }
144 
145  }; // struct AssociatedDataProxyMakerBase<>
146 
147  //--------------------------------------------------------------------------
179  template <typename Main, typename Aux, typename Metadata, typename CollProxy, typename Tag = Aux>
180  class AssociatedDataProxyMaker : public AssociatedDataProxyMakerBase<Main, Aux, Metadata, Tag> {
181  //
182  // Note that this implementation is here only to document how to derive
183  // a AssociatedDataProxyMaker (specialization) from
184  // AssociatedDataProxyMakerBase. It's just mirroring the base class.
185  //
187 
188  public:
190  using typename base_t::main_element_t;
191 
193  using typename base_t::aux_element_t;
194 
196  using typename base_t::metadata_t;
197 
199  using typename base_t::aux_collection_proxy_t;
200 
202  using typename base_t::assns_t;
203 
224  template <typename Event, typename Handle, typename MainArgs, typename... Args>
225  static auto make(Event const& event, Handle&& mainHandle, MainArgs const& margs, Args&&... args)
226  {
227  return base_t::make(
228  event, std::forward<Handle>(mainHandle), margs, std::forward<Args>(args)...);
229  }
230 
231  }; // struct AssociatedDataProxyMaker<>
232 
234  // --- END Associated data infrastructure ------------------------------------
235 
236  //----------------------------------------------------------------------------
237  namespace details {
238 
239  template <typename Aux, typename Metadata /* = void */, typename AuxTag /* = Aux */
240  >
242  template <typename CollProxy>
243  using maker_t = AssociatedDataProxyMaker<typename CollProxy::main_element_t,
244  Aux,
245  Metadata,
246  CollProxy,
247  AuxTag>;
248  };
249 
250  } // namespace details
251 
252 } // namespace proxy
253 
254 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_ASSOCIATEDDATAPROXYMAKER_H
static auto createFromTag(Event const &event, Handle &&mainHandle, art::InputTag const &auxInputTag)
std::unique_ptr< InputSource > make(fhicl::ParameterSet const &conf, InputSourceDescription &desc)
static auto make(Event const &event, Handle &&mainHandle, MainArgs const &, art::InputTag const &auxInputTag)
Create a association proxy collection using the specified tag.
static auto make(Event const &event, Handle &&mainHandle, MainArgs const &margs, Args &&...args)
Create a association proxy collection using main collection tag.
Aux aux_element_t
Type of the auxiliary associated datum ("right").
Object to draft associated data interface.
typename aux_collection_proxy_t::assns_t assns_t
Type of art association being used as input.
Helper functions to create an AssociatedData object.
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
Creates an associated data wrapper for the specified types.
static auto make(Event const &event, Handle &&mainHandle, MainArgs const &mainArgs)
Create a association proxy collection using main collection tag.
Tag data_tag
Tag labelling the associated data we are going to produce.
art::Assns< Main, Aux, Metadata > assns_t
Type of art association.
static auto make(Event const &, Handle &&, MainArgs const &, Assns const &assns)
Create a association proxy collection using the specified tag.
Creates an associated data wrapper for the specified types.
Event finding and building.