LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
makeAssociatedDataFrom.h
Go to the documentation of this file.
1 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_MAKEASSOCIATEDDATAFROM_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_MAKEASSOCIATEDDATAFROM_H
13 
14 // LArSoft libraries
15 #include "larcorealg/CoreUtils/ContainerMeta.h" // util::collection_value_t, ...
17 
18 // framework libraries
21 
22 // C/C++ standard
23 #include <cstdlib> // std::size_t
24 #include <utility> // std::forward()
25 
26 namespace proxy {
27 
28  // --- BEGIN Associated data infrastructure ----------------------------------
31 
32  template <typename Tag, typename Assns>
33  auto makeAssociatedDataFrom(Assns const& assns, std::size_t minSize = 0)
34  {
35  return proxy::makeAssociatedData<Tag>(assns, minSize);
36  }
37 
38  template <typename Assns>
39  auto makeAssociatedDataFrom(Assns const& assns, std::size_t minSize = 0)
40  {
41  return makeAssociatedDataFrom<typename Assns::right_t>(assns, minSize);
42  }
43 
69  template <typename Main, typename Aux, typename Metadata, typename Tag, typename Event>
70  auto makeAssociatedDataFrom(Event const& event,
71  art::InputTag const& tag,
72  std::size_t minSize = 0);
73 
74  template <typename Main, typename Aux, typename Metadata, typename Event>
75  auto makeAssociatedDataFrom(Event const& event, art::InputTag const& tag, std::size_t minSize = 0)
76  {
77  return makeAssociatedDataFrom<Main, Aux, Metadata, Aux, Event>(event, tag, minSize);
78  }
79 
80  template <typename Main, typename Aux, typename Event>
81  auto makeAssociatedDataFrom(Event const& event, art::InputTag const& tag, std::size_t minSize = 0)
82  {
83  return makeAssociatedDataFrom<Main, Aux, void, Aux, Event>(event, tag, minSize);
84  }
85 
111  template <typename Aux, typename Metadata, typename Tag, typename Handle, typename Event>
112  auto makeAssociatedDataFrom(Handle&& handle, Event const& event, art::InputTag const& tag);
113 
114  template <typename Aux, typename Metadata, typename Handle, typename Event>
115  auto makeAssociatedDataFrom(Handle&& handle, Event const& event, art::InputTag const& tag)
116  {
117  return makeAssociatedDataFrom<Aux, Metadata, Aux, Handle, Event>(
118  std::forward<Handle>(handle), event, tag);
119  }
120 
121  template <typename Aux, typename Handle, typename Event>
122  auto makeAssociatedDataFrom(Handle&& handle, Event const& event, art::InputTag const& tag)
123  {
124  return makeAssociatedDataFrom<Aux, void, Aux, Handle, Event>(
125  std::forward<Handle>(handle), event, tag);
126  }
127 
142  template <typename Tag, typename MainColl, typename Assns>
143  auto makeAssociatedDataFrom(MainColl const& mainColl, Assns const& assns)
144  {
145  return proxy::makeAssociatedData<Tag>(assns, mainColl.size());
146  }
147 
148  template <typename MainColl, typename Assns>
149  auto makeAssociatedDataFrom(MainColl const& mainColl, Assns const& assns)
150  {
151  return makeAssociatedDataFrom<typename Assns::right_t>(mainColl, assns);
152  }
153 
154  //----------------------------------------------------------------------------
155 
157  // --- END Associated data infrastructure ------------------------------------
158 
159 } // namespace proxy
160 
161 //------------------------------------------------------------------------------
162 //--- template implementation
163 //------------------------------------------------------------------------------
164 namespace proxy {
165 
166  //----------------------------------------------------------------------------
167  //--- makeAssociatedDataFrom() implementations
168  //----------------------------------------------------------------------------
169  template <typename Main, typename Aux, typename Metadata, typename Tag, typename Event>
170  auto makeAssociatedDataFrom(Event const& event,
171  art::InputTag const& tag,
172  std::size_t minSize /* = 0 */
173  )
174  {
175  using Main_t = Main;
176  using Aux_t = Aux;
177  using Metadata_t = Metadata;
179  using Assns_t = typename AssociatedData_t::assns_t;
180 
181  return makeAssociatedDataFrom<Tag>(*(event.template getValidHandle<Assns_t>(tag)));
182 
183  } // makeAssociatedDataFrom(tag)
184 
185  //----------------------------------------------------------------------------
186  template <typename Aux, typename Metadata, typename Tag, typename Handle, typename Event>
187  auto makeAssociatedDataFrom(Handle&& handle, Event const& event, art::InputTag const& tag)
188  {
189  // Handle::value_type is the main data product type (a collection)
191  using Aux_t = Aux;
192  using Metadata_t = Metadata;
193  return makeAssociatedDataFrom<Main_t, Aux_t, Metadata_t, Tag>(event, tag, handle->size());
194  } // makeAssociatedDataFrom(handle)
195 
196 } // namespace proxy
197 
198 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_MAKEASSOCIATEDDATAFROM_H
auto makeAssociatedDataFrom(Assns const &assns, std::size_t minSize=0)
Auxiliary data from one-to-many sequential association.
Object to draft associated data interface.
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.