getCollection.h
Go to the documentation of this file.
1 /**
2  * @file lardata/RecoBaseProxy/ProxyBase/getCollection.h
3  * @brief Creation of a collection proxy.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date July 27, 2017
6  * @see lardata/RecoBaseProxy/ProxyBase.h
7  *
8  * This library is header-only.
9  */
10 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_GETCOLLECTION_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_GETCOLLECTION_H
13 
14 // LArSoft libraries
16 
17 // C/C++ standard
18 #include <utility> // std::forward()
19 
20 
21 namespace proxy {
22 
23  // ---------------------------------------------------------------------------
24  /**
25  * @brief Creates a proxy to a data product collection.
26  * @tparam CollProxy type of target main collection proxy
27  * @tparam Event type of event to read data from
28  * @tparam OptionalArgs type of optional arguments
29  * @param event event to read data from
30  * @param optionalArgs optional arguments for construction of the proxy
31  * @return a collection proxy object
32  * @ingroup LArSoftProxyBase
33  * @see @ref LArSoftProxyBase "ways to merge more data into a proxy"
34  *
35  * This function delivers a collection proxy related to `CollProxy`.
36  *
37  * The @ref LArSoftProxyQuirks "type of proxy delivered is arbitrary"
38  * and usually not `CollProxy`.
39  * The type of the collection proxy must be explicitly specified, e.g.:
40  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
41  * auto tracks = proxy::getCollection<proxy::Tracks>
42  * (event, tag, withAssociated<recob::Hits>());
43  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44  * In this case, two optional arguments are passed: the input tag to the main
45  * collection, and then `withAssociated<recob::Hits>()`. The meaning of both
46  * is decided depending on the collection proxy being created, but it's common
47  * to have the first argument be the input tag to the main collection, as in
48  * this example.
49  * `withAssociated()` is one of the ways for a proxy to have
50  * @ref LArSoftProxyDefinitionAuxiliaryData "auxiliary data" "merged" into.
51  * The options to @ref LArSoftProxyDefinitionMerging "merge" this data are
52  * collected in the @ref LArSoftProxyBase "proxy interface documentation".
53  *
54  * The collection proxy name is arbitrary, but it's custom to have it live in
55  * `proxy` namespace and have the same name as the base object, made plural:
56  * a proxy to a `recob::Track` collection data product will have a proxy
57  * called `proxy::Tracks`.
58  *
59  * Note that a proxy need to be explicitly supported in order to be available.
60  * Nevertheless, a generic implementation is supported to create a proxy of a
61  * data product which is a C++ vector, so that:
62  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
63  * auto tracks = proxy::getCollection<std::vector<recob::Track>>
64  * (event, tag, withAssociated<recob::Hits>());
65  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66  * will have an outcome similar to the previous example. In this case, though,
67  * all the specific track interface that went into `proxy::Tracks` proxy will
68  * not be available.
69  *
70  * The implementation of this feature is documented in
71  * @ref LArSoftProxyCollections "its own doxygen module".
72  *
73  *
74  * Customization
75  * ==============
76  *
77  * To control which type of collection proxy is produced for the type
78  * `CollProxy`, the class `CollectionProxyMaker` may be specialised.
79  *
80  */
81  template <typename CollProxy, typename Event, typename... OptionalArgs>
82  auto getCollection(Event const& event, OptionalArgs&&... optionalArgs)
83  {
85  (event, std::forward<OptionalArgs>(optionalArgs)...);
86  }
87 
88 
89  // ---------------------------------------------------------------------------
90 
91 
92 } // namespace proxy
93 
94 
95 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_GETCOLLECTION_H
Infrastructure for the creation of a collection proxy.
static auto make(Event const &event, art::InputTag const &tag, WithArgs &&...withArgs)
Creates and returns a collection proxy based on CollProxy and with the requested associated data...
Definition: types.h:32
auto getCollection(Event const &event, OptionalArgs &&...optionalArgs)
Creates a proxy to a data product collection.
Definition: getCollection.h:82
Event finding and building.