LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
makeOneTo01dataFrom.h
Go to the documentation of this file.
1 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_MAKEONETO01DATAFROM_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_MAKEONETO01DATAFROM_H
13 
14 // LArSoft libraries
15 #include "larcorealg/CoreUtils/ContainerMeta.h" // util::collection_value_t
17 
18 // framework libraries
20 
21 // C/C++ standard libraries
22 #include <cstdlib> // std::size_t
23 #include <utility> // std::forward()
24 
25 namespace proxy {
26 
27  // --- BEGIN LArSoftProxiesAssociatedData ------------------------------------
30 
31  //----------------------------------------------------------------------------
32  //--- one-to-(zero/one) associations
33  //----------------------------------------------------------------------------
65  template <typename Tag, typename Assns>
66  auto makeOneTo01dataFrom(Assns const& assns, std::size_t minSize = 0)
67  {
68  return proxy::makeOneTo01data<Tag>(assns, minSize);
69  }
70 
71  template <typename Assns>
72  auto makeOneTo01dataFrom(Assns const& assns, std::size_t minSize = 0)
73  {
74  return proxy::makeOneTo01data(assns, minSize);
75  }
76 
98  template <typename Main, typename Aux, typename Metadata, typename Tag, typename Event>
99  auto makeOneTo01dataFrom(Event const& event, art::InputTag const& tag, std::size_t minSize = 0);
100 
101  template <typename Main, typename Aux, typename Metadata, typename Event>
102  auto makeOneTo01dataFrom(Event const& event, art::InputTag const& tag, std::size_t minSize = 0)
103  {
104  return makeOneTo01dataFrom<Main, Aux, Metadata, Aux, Event>(event, tag, minSize);
105  }
106 
131  template <typename Aux, typename Metadata, typename Tag, typename Handle, typename Event>
132  auto makeOneTo01dataFrom(Handle&& handle, Event const& event, art::InputTag const& tag);
133 
134  template <typename Aux, typename Metadata, typename Handle, typename Event>
135  auto makeOneTo01dataFrom(Handle&& handle, Event const& event, art::InputTag const& tag)
136  {
137  return makeOneTo01dataFrom<Aux, Metadata, Aux, Handle, Event>(
138  std::forward<Handle>(handle), event, tag);
139  }
140 
155  template <typename Tag, typename MainColl, typename Assns>
156  auto makeOneTo01dataFrom(MainColl const& mainColl, Assns const& assns)
157  {
158  return proxy::makeOneTo01data<Tag>(assns, mainColl.size());
159  }
160 
161  template <typename MainColl, typename Assns>
162  auto makeOneTo01dataFrom(MainColl const& mainColl, Assns const& assns)
163  {
164  return proxy::makeOneTo01data<typename Assns::right_t>(mainColl, assns);
165  }
166 
168  // --- END LArSoftProxiesAssociatedData --------------------------------------
169 
170 } // namespace proxy
171 
172 //------------------------------------------------------------------------------
173 //--- template implementation
174 //------------------------------------------------------------------------------
175 namespace proxy {
176 
177  //----------------------------------------------------------------------------
178  //--- makeOneTo01dataFrom() implementations
179  //----------------------------------------------------------------------------
180  template <typename Main, typename Aux, typename Metadata, typename Tag, typename Event>
181  auto makeOneTo01dataFrom(Event const& event,
182  art::InputTag const& tag,
183  std::size_t minSize /* = 0 */
184  )
185  {
186  using Main_t = Main;
187  using Aux_t = Aux;
188  using Metadata_t = Metadata;
190  using Assns_t = typename AssociatedData_t::assns_t;
191 
192  return makeOneTo01dataFrom<Tag>(*(event.template getValidHandle<Assns_t>(tag)), minSize);
193 
194  } // makeOneTo01dataFrom(tag)
195 
196  //----------------------------------------------------------------------------
197  template <typename Aux, typename Metadata, typename Tag, typename Handle, typename Event>
198  auto makeOneTo01dataFrom(Handle&& handle, Event const& event, art::InputTag const& tag)
199  {
200  // Handle::value_type is the main data product type (a collection)
202  using Aux_t = Aux;
203  using Metadata_t = Metadata;
204  return makeOneTo01dataFrom<Main_t, Aux_t, Metadata_t, Tag>(event, tag, handle->size());
205  } // makeOneTo01dataFrom(handle)
206 
207  //----------------------------------------------------------------------------
208 
209 } // namespace proxy
210 
211 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_MAKEONETO01DATAFROM_H
auto makeOneTo01dataFrom(Assns const &assns, std::size_t minSize=0)
Processes and returns an one-to-(zero/one) associated data object.
auto makeOneTo01data(Assns const &assns, std::size_t minSize=0)
Processes and returns an one-to-(zero/one) associated data object.
Definition: OneTo01Data.h:264
Auxiliary data from one-to-(zero-or-one) sequential association.
Object for one-to-zero/or/one associated data interface.
Definition: OneTo01Data.h:68
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
typename collection_value_type< Coll >::type collection_value_t
Type contained in the collection Coll.
Definition: ContainerMeta.h:62
C++ metaprogramming utilities for dealing with containers.
Event finding and building.