LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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
16 #include "larcorealg/CoreUtils/ContainerMeta.h" // util::collection_value_t, ...
17 
18 // framework libraries
21 
22 // C/C++ standard
23 #include <utility> // std::forward()
24 #include <cstdlib> // std::size_t
25 
26 
27 namespace proxy {
28 
29 
30  // --- BEGIN Associated data infrastructure ----------------------------------
33 
34  template <typename Tag, typename Assns>
35  auto makeAssociatedDataFrom(Assns const& assns, std::size_t minSize = 0)
36  { return proxy::makeAssociatedData<Tag>(assns, minSize); }
37 
38  template <typename Assns>
39  auto makeAssociatedDataFrom(Assns const& assns, std::size_t minSize = 0)
40  { return makeAssociatedDataFrom<typename Assns::right_t>(assns, minSize); }
41 
67  template <
68  typename Main, typename Aux, typename Metadata, typename Tag,
69  typename Event
70  >
72  (Event const& event, art::InputTag const& tag, std::size_t minSize = 0);
73 
74  template <typename Main, typename Aux, typename Metadata, typename Event>
76  (Event const& event, art::InputTag const& tag, std::size_t minSize = 0)
77  {
78  return makeAssociatedDataFrom<Main, Aux, Metadata, Aux, Event>
79  (event, tag, minSize);
80  }
81 
82  template <typename Main, typename Aux, typename Event>
84  (Event const& event, art::InputTag const& tag, std::size_t minSize = 0)
85  {
86  return makeAssociatedDataFrom<Main, Aux, void, Aux, Event>
87  (event, tag, minSize);
88  }
89 
115  template <
116  typename Aux, typename Metadata, typename Tag,
117  typename Handle, typename Event
118  >
120  (Handle&& handle, Event const& event, art::InputTag const& tag);
121 
122  template <typename Aux, typename Metadata, typename Handle, typename Event>
124  (Handle&& handle, Event const& event, art::InputTag const& tag)
125  {
126  return makeAssociatedDataFrom<Aux, Metadata, Aux, Handle, Event>
127  (std::forward<Handle>(handle), event, tag);
128  }
129 
130  template <typename Aux, typename Handle, typename Event>
132  (Handle&& handle, Event const& event, art::InputTag const& tag)
133  {
134  return makeAssociatedDataFrom<Aux, void, Aux, Handle, Event>
135  (std::forward<Handle>(handle), event, tag);
136  }
137 
138 
153  template <typename Tag, typename MainColl, typename Assns>
154  auto makeAssociatedDataFrom(MainColl const& mainColl, Assns const& assns)
155  { return proxy::makeAssociatedData<Tag>(assns, mainColl.size()); }
156 
157  template <typename MainColl, typename Assns>
158  auto makeAssociatedDataFrom(MainColl const& mainColl, Assns const& assns)
159  { return makeAssociatedDataFrom<typename Assns::right_t>(mainColl, assns); }
160 
161 
162  //----------------------------------------------------------------------------
163 
165  // --- END Associated data infrastructure ------------------------------------
166 
167 
168 } // namespace proxy
169 
170 
171 //------------------------------------------------------------------------------
172 //--- template implementation
173 //------------------------------------------------------------------------------
174 namespace proxy {
175 
176 
177  //----------------------------------------------------------------------------
178  //--- makeAssociatedDataFrom() implementations
179  //----------------------------------------------------------------------------
180  template <
181  typename Main, typename Aux, typename Metadata, typename Tag,
182  typename Event
183  >
185  Event const& event, art::InputTag const& tag, std::size_t minSize /* = 0 */
186  )
187  {
188  using Main_t = Main;
189  using Aux_t = Aux;
190  using Metadata_t = Metadata;
191  using AssociatedData_t
193  using Assns_t = typename AssociatedData_t::assns_t;
194 
195  return
196  makeAssociatedDataFrom<Tag>(*(event.template getValidHandle<Assns_t>(tag)));
197 
198  } // makeAssociatedDataFrom(tag)
199 
200 
201  //----------------------------------------------------------------------------
202  template <
203  typename Aux, typename Metadata, typename Tag,
204  typename Handle, typename Event
205  >
207  (Handle&& handle, Event const& event, art::InputTag const& tag)
208  {
209  // Handle::value_type is the main data product type (a collection)
211  using Aux_t = Aux;
212  using Metadata_t = Metadata;
213  return makeAssociatedDataFrom<Main_t, Aux_t, Metadata_t, Tag>
214  (event, tag, handle->size());
215  } // makeAssociatedDataFrom(handle)
216 
217 
218 } // namespace proxy
219 
220 
221 #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:65
C++ metaprogramming utilities for dealing with containers.
Event finding and building.