LArSoft
v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
|
Query object collecting a list of associated objects. More...
#include "FindManyInChainP.h"
Public Types | |
using | Target_t = Target |
Type of the associated objects. More... | |
using | TargetPtr_t = art::Ptr< Target_t > |
Pointer to associated objects. More... | |
using | TargetPtrCollection_t = std::vector< TargetPtr_t > |
Type returned by at() method. More... | |
Public Member Functions | |
template<typename Source , typename Event , typename... InputTags> | |
FindManyInChainP (Source &&source, Event const &event, InputTags...tags) | |
Constructor: extracts target objects associated to all objects under the specified handle. More... | |
std::size_t | size () const noexcept |
Returns the number of Source objects we have information about. More... | |
TargetPtrCollection_t const & | at (std::size_t i) const |
Returns all the Target objects associated to specified object. More... | |
Static Public Member Functions | |
template<typename Source , typename Event , typename... InputTags> | |
static std::vector< TargetPtrCollection_t > | find (Source &&source, Event const &event, InputTags...tags) |
Returns target objects associated to all objects contained in the specified source. More... | |
Private Attributes | |
std::vector< TargetPtrCollection_t > | results |
Stored results. More... | |
Query object collecting a list of associated objects.
Target | type of objects to be fetched |
Intermediate | types of objects connecting to Target by association |
This query object collects information about all objects of type Target
associated to each specified object of type Source
. The Source
type is implicitly specified in the constructor. For example, each recob::Shower
object is expected to be associated to a number of recob::Cluster
objects, and each one of these clusters must be associated to recob::Hit
objects. To retrieve all the hit objects associated to a shower collection (not recommended):
In this example, it is explicitly stated that the producer of the shower associations to clusters is the same as the producer of the showers, as the same input tag showerTag
is used. It is also implicitly assumed that the same producer which created the associated clusters is also responsible for the creation of the associations between clusters and hits.
The example shows the similarity with art::FindManyP
. In fact, this object has a similar interface, and a similar functionality too. Nevertheless, prefer using the static member find()
and then using its result directly, as it has a more complete interface:
This is the recommended approach, as long as lar::FindManyInChainP()
has to be called only once.
Definition at line 109 of file FindManyInChainP.h.
using lar::FindManyInChainP< Target, Intermediate >::Target_t = Target |
Type of the associated objects.
Definition at line 112 of file FindManyInChainP.h.
using lar::FindManyInChainP< Target, Intermediate >::TargetPtr_t = art::Ptr<Target_t> |
Pointer to associated objects.
Definition at line 113 of file FindManyInChainP.h.
using lar::FindManyInChainP< Target, Intermediate >::TargetPtrCollection_t = std::vector<TargetPtr_t> |
Type returned by at()
method.
Definition at line 117 of file FindManyInChainP.h.
|
inline |
Constructor: extracts target objects associated to all objects under the specified handle.
Source | type of source: art Handle or collection of art pointers |
Event | type of event to be used (either art or gallery Event ) |
InputTags | a variable number of art::InputTag objects |
source | art Handle or collection of art pointers to source objects |
event | the event to read associations and objects from |
tags | input tags for each one of the required associations |
This constructor finds the associated objects as in find()
, and stored the result. Access to it will be performed e.g. by the at()
method.
Definition at line 135 of file FindManyInChainP.h.
TargetPtrCollection_t const& lar::FindManyInChainP< Target, Intermediate >::at | ( | std::size_t | i | ) | const |
Returns all the Target
objects associated to specified object.
i | index of the source object to query |
Target
objects std::out_of_range | if the specified index is not valid |
The specified index matches the index of the element in the collection this query object was constructed with. For example:
the showerHits
will pertain the iShower
-th recob::Shower
(shower
) on each iteration of the loop.
The returned sequence points to objects convertible to art pointers to Target
(e.g., art::Ptr<Target>
). The order of the objects in this sequence is not defined. The same Target
object may appear more than once if two intermediate objects are associated to the same target (or intermediate object of tier closer to the target). This sequence is of an unspecified type, guaranteed to support std::begin()
, std::end()
, size()
method and to be iterable in a range-for loop. For example, it may be a STL vector returned by constant reference.
|
static |
Returns target objects associated to all objects contained in the specified source.
Source | type of source: art Handle or collection of art pointers |
Event | type of event to be used (either art or gallery Event ) |
InputTags | a variable number of art::InputTag objects |
source | art Handle or collection of art pointers to source objects |
event | the event to read associations and objects from |
tags | input tags for each one of the required associations |
This methods returns a collection with an entry for each of the elements pointed by the specified handle, in the same order as they are extracted from the source collection.
The input tag arguments must be convertible to art::InputTag
type. The first tag identifies the data product containing the associations between the Source
collection (the same pointed by source
) and the first Intermediate
class. The second tag likewise points to the data product containing the associations between the first and the second Intermediate
classes. The last tag, finally, points to the data product containing the associations between the last Intermediate
class and the Target
class. If one tag is not specified, it is assumed that the same class that produced the Intermediate
(or Source
) data product also produced the association to the next Intermediate
(or Target
) data product. Note that:
lar::SameAsData
tag
|
noexcept |
Returns the number of Source
objects we have information about.
|
private |
Stored results.
Definition at line 225 of file FindManyInChainP.h.