Functions | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX) |
Creates a single one-to-one association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, size_t indx=UINT_MAX) |
Creates a single one-to-one association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, art::Ptr< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn) |
Creates a single one-to-one association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::PtrVector< U > const &b, art::Assns< T, U > &assn, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, art::Ptr< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, std::vector< size_t > const &indices, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<typename PRODUCER , typename T , typename U , typename Iter > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, art::Assns< T, U > &assn, size_t first_index, Iter from_second_index, Iter to_second_index) |
Creates a single one-to-many association. More... | |
template<class T , class U > | |
std::vector< const U * > | FindUNotAssociatedToT (art::Handle< U > b, art::Event const &evt, std::string const &label) |
template<class T , class U > | |
std::vector< art::Ptr< U > > | FindUNotAssociatedToTP (art::Handle< U > b, art::Event const &evt, std::string const &label) |
template<class T , class U > | |
std::vector< size_t > | GetAssociatedVectorOneI (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<class T , class U > | |
std::vector< const U * > | GetAssociatedVectorOneP (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<class T , class U > | |
std::vector< std::vector< size_t > > | GetAssociatedVectorManyI (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<class T , class U > | |
std::vector< std::vector< const U * > > | GetAssociatedVectorManyP (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<typename PRODUCER , typename T , typename U , typename D > | |
bool | CreateAssnD (PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data) |
Creates a single one-to-one association with associated data. More... | |
template<typename PRODUCER , typename T , typename U , typename D > | |
bool | CreateAssnD (PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t const &data) |
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
art::Ptr< U > const & | b, | ||
art::Assns< U, T > & | assn, | ||
std::string | a_instance, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-one association.
T | type of the new object to associate |
U | type of the object already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::Ptr to the (new) object to be associated to the one in a |
assn | reference to association object where the new one will be put |
a_instance | name of the instance that will be used for a in evt |
indx | index of the element in a to be associated with b (default: the last element) |
As example of usage: create a wire/raw digit association. This code should live in the art::EDProduce::produce() method. The raw::RawDigit product was created already by a DigitModuleLabel module. The code is supposed to produce one recob::Wire for each existing raw::RawDigit, and contextually associate the new wire to the source digit. We are also assuming that there might be different RawDigit sets produced by the same producer: we identify the one we care of by the string spill_name and we create wires and associations with the same label for convenience.
// this is the original list of digits, thawed from the event art::Handle< std::vector<raw::RawDigit>> digitVecHandle; evt.getByLabel(DigitModuleLabel, spill_name, digitVecHandle); // the collection of wires that will be written as data product std::unique_ptr<std::vector<recob::Wire>> wirecol(new std::vector<recob::Wire>); // ... and an association set std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire>> WireDigitAssn (new art::Assns<raw::RawDigit,recob::Wire>); for(size_t iDigit = 0; iDigit < digitVecHandle->size(); ++iDigit) { // turn the digit into a art::Ptr: art::Ptr<raw::RawDigit> digit_ptr(digitVecHandle, iDigit); // store the wire in its final position in the data product; // the new wire is currently the last of the list wirecol->push_back(std::move(wire)); // add an association between the last object in wirecol // (that we just inserted) and digit_ptr if (!evgb::util::CreateAssn(*this, evt, *wirecol, digit_ptr, *WireDigitAssn, spill_name)) { throw art::Exception(art::errors::ProductRegistrationFailure) << "Can't associate wire #" << (wirecol->size() - 1) << " with raw digit #" << digit_ptr.key(); } // if failed to add association } // for digits evt.put(std::move(wirecol), spill_name); evt.put(std::move(WireDigitAssn), spill_name);
Definition at line 593 of file EVGBAssociationUtil.h.
|
inline |
Creates a single one-to-one association.
T | type of the new object to associate |
U | type of the object already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::Ptr to the (new) object to be associated to the one in a |
assn | reference to association object where the new one will be put |
indx | index of the element in a to be associated with b (default: the last element) |
The instance name of the product a will be in is assumed empty. Example of usage:
// this is the original list of digits, thawed from the event art::Handle< std::vector<raw::RawDigit>> digitVecHandle; evt.getByLabel(DigitModuleLabel, digitVecHandle); // the collection of wires that will be written as data product std::unique_ptr<std::vector<recob::Wire>> wirecol(new std::vector<recob::Wire>); // ... and an association set std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire>> WireDigitAssn (new art::Assns<raw::RawDigit,recob::Wire>); for(size_t iDigit = 0; iDigit < digitVecHandle->size(); ++iDigit) { // turn the digit into a art::Ptr: art::Ptr<raw::RawDigit> digit_ptr(digitVecHandle, iDigit); // store the wire in its final position in the data product; // the new wire is currently the last of the list wirecol->push_back(std::move(wire)); // add an association between the last object in wirecol // (that we just inserted) and digit_ptr if (!evgb::util::CreateAssn(*this, evt, *wirecol, digit_ptr, *WireDigitAssn)) { throw art::Exception(art::errors::ProductRegistrationFailure) << "Can't associate wire #" << (wirecol->size() - 1) << " with raw digit #" << digit_ptr.key(); } // if failed to add association } // for digits evt.put(std::move(wirecol)); evt.put(std::move(WireDigitAssn));
Definition at line 214 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Ptr< T > const & | a, | ||
art::Ptr< U > const & | b, | ||
art::Assns< U, T > & | assn | ||
) |
Creates a single one-to-one association.
T | type of one object to associate |
U | type of the other object to associate |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | art::Ptr to the first object in the association |
b | art::Ptr to the object to be associated to the one in a |
assn | reference to association object where the new one will be put |
This is the simplest way ever. Neither the event not the producer references are used.
Definition at line 623 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
art::PtrVector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::PtrVector to the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 647 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Ptr< T > const & | a, | ||
std::vector< art::Ptr< U >> const & | b, | ||
art::Assns< T, U > & | assn | ||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | art::Ptr to the item to be associated with many |
b | vector to art::Ptr to the (new) objects to be associated to a |
assn | reference to association object where the new one will be put |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 674 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
std::vector< art::Ptr< U >> const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector to art::Ptr to the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 697 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
std::vector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | startU, | ||
size_t | endU, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector of the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
startU | index in b of the first element to be associated to the one in a |
endU | index in b after the last element to be associated to the one in a |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
Use this when the objects in b are not yet stored in the event and are in a std::vector collection instead.
The method gets the product id for those as well as for the element in a. Also specify the range of entries to use from the std::vector collection of U objects.
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 725 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
std::vector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
std::vector< size_t > const & | indices, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector of the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
indices | indices of the elements in b to be associated to the one in a |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
Use this when the objects in b are not yet stored in the event and are in a std::vector collection instead.
The method gets the product id for those as well as for the element in a. Also specify the entries to use from the std::vector collection of U objects.
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 760 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Assns< T, U > & | assn, | ||
size_t | first_index, | ||
Iter | from_second_index, | ||
Iter | to_second_index | ||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
Iter | iterator to size_t-compatible elements |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
assn | reference to association object where the new one will be put |
first_index | index of the object of type T to be associated to all the others |
from_second_index | iterator pointing to the first of the indices of U type objects to be associated to the one of the first type |
to_second_index | iterator pointing after the last of the indices of U type objects to be associated to the one of the first type |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Use this if the objects that have to be associated to the one of type T are sparse, spread across a to-be-data-product, but you have a list of the indices in the data product of the elements to associate to the one of type T. In other words, given that you have a data product "a" of type std::vector<T>
and a data product "b" of type std::vector<U>
, this method creates an association between
a[first_index]and
b[*(from_second_index)], another between a[first_index]
and b[*(from_second_index + 1)]
, etc.
The surprising concept here is that you don't need to specify neither of the collections of T or U elements. The data product is uniquely defined by its type, producer, process and product label. Here we assume that the type of the products are std::vector<T>
and std::vector<U>
, and that the products have empty product labels, and that the producer is prod for both of them.
Definition at line 794 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssnD | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Assns< T, U, D > & | assn, | ||
size_t | first_index, | ||
size_t | second_index, | ||
typename art::Assns< T, U, D >::data_t && | data | ||
) |
Creates a single one-to-one association with associated data.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
D | type of the "metadata" coupled to this pair association |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
assn | reference to association object where the new one will be put |
first_index | index of the object of type T to be associated |
second_index | index of the object of type U to be associated |
data | "metadata" to be store in this association |
Use this if you want some metadata to travel together with the association. An example may be the order of the second element within a list:
size_t a_index = 2; std::vector<size_t> b_indices{ 6, 9, 18, 12 }; for (size_t i = 0; i < b_indices.size(); ++i) CreateAssn(prod, evt, assn, a_index, b_index[i], i);
In this way, the association between the element #2 of "a" (a vector that is not specified – nor needed – in this snippet of code) and the element #18 will be remembered as being the third (metadata value of 2). In this example metadata is of type size_t
the association would be declared as art::Assn<A, B, size_t>
. A FindMany query of that association might look like:
art::Handle<std::vector<A>> a_list; // read this from the event art::FindMany<B, size_t> Query(a_list, event, ModuleLabel); // search for the last of the objects associated to the third element: size_t a_index = 2; // this means third element std::vector<size_t const*> const& metadata = Query.data(a_index); size_t largest_index = 0, last_item = 0; for (size_t iB = 0; iB < metadata.size(); ++iB) { if (largest_index >= *(metadata[iB])) continue; largest_index = *(metadata[iB]); last_item = iB; } // for iB B const& lastB = Query.at(last_item);
In alternative, the elements and their metadata can be fetched simultaneously with:
std::vector<art::Ptr<B>> const& Bs; std::vector<size_t const*> const& metadata; size_t a_index = 2; // this means third element size_t nMatches = Query.get(a_index, Bs, metadata);
Definition at line 838 of file EVGBAssociationUtil.h.
bool evgb::util::CreateAssnD | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Assns< T, U, D > & | assn, | ||
size_t | first_index, | ||
size_t | second_index, | ||
typename art::Assns< T, U, D >::data_t const & | data | ||
) |
Definition at line 875 of file EVGBAssociationUtil.h.
|
inline |
Definition at line 913 of file EVGBAssociationUtil.h.
|
inline |
Definition at line 938 of file EVGBAssociationUtil.h.
|
inline |
Definition at line 982 of file EVGBAssociationUtil.h.
|
inline |
Definition at line 991 of file EVGBAssociationUtil.h.
|
inline |
Definition at line 964 of file EVGBAssociationUtil.h.
|
inline |
Definition at line 973 of file EVGBAssociationUtil.h.