72 #ifndef ASSOCIATIONUTIL_H 73 #define ASSOCIATIONUTIL_H 88 #include "canvas/Persistency/Common/FindMany.h" 89 #include "canvas/Persistency/Common/FindManyP.h" 90 #include "canvas/Persistency/Common/FindOneP.h" 91 #include "canvas/Persistency/Common/FindOne.h" 155 template<
class PRODUCER,
class T,
class U>
158 std::vector<T>
const&
a,
213 template<
class PRODUCER,
class T,
class U>
216 std::vector<T>
const&a,
219 size_t indx=UINT_MAX)
238 template<
class PRODUCER,
class T,
class U>
240 PRODUCER
const& prod,
266 template<
class PRODUCER,
class T,
class U>
268 PRODUCER
const& prod,
270 std::vector<T>
const& a,
273 size_t indx = UINT_MAX
296 template<
class PRODUCER,
class T,
class U>
298 PRODUCER
const& prod,
324 template<
class PRODUCER,
class T,
class U>
326 PRODUCER
const& prod,
328 std::vector<T>
const& a,
331 size_t indx = UINT_MAX
362 template<
class PRODUCER,
class T,
class U>
364 PRODUCER
const& prod,
366 std::vector<T>
const& a,
367 std::vector<U>
const& b,
371 size_t indx = UINT_MAX
401 template<
class PRODUCER,
class T,
class U>
403 PRODUCER
const& prod,
405 std::vector<T>
const& a,
406 std::vector<U>
const& b,
408 std::vector<size_t>
const&
indices,
409 size_t indx = UINT_MAX
451 template <
typename PRODUCER,
typename T,
typename U,
typename Iter>
453 PRODUCER
const& prod,
457 Iter from_second_index,
518 template <
typename PRODUCER,
typename T,
typename U,
typename D>
520 PRODUCER
const& prod,
528 template <
typename PRODUCER,
typename T,
typename U,
typename D>
530 PRODUCER
const& prod,
592 template<
class PRODUCER,
class T,
class U>
596 std::vector<T>
const&
a,
603 if (indx == UINT_MAX) indx = a.size()-1;
613 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
622 template<
class PRODUCER,
class T,
class U>
636 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
646 template<
class PRODUCER,
class T,
class U>
650 std::vector<T>
const&
a,
655 if(indx == UINT_MAX) indx = a.size() - 1;
664 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
673 template<
class PRODUCER,
class T,
class U>
687 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
696 template<
class PRODUCER,
class T,
class U>
700 std::vector<T>
const&
a,
706 if (indx == UINT_MAX) indx = a.size() - 1;
715 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
724 template<
class PRODUCER,
class T,
class U>
728 std::vector<T>
const&
a,
729 std::vector<U>
const& ,
736 if(indx == UINT_MAX) indx = a.size() - 1;
743 for(
size_t i = startU; i < endU; ++i){
750 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
759 template<
class PRODUCER,
class T,
class U>
761 PRODUCER
const& prod,
763 std::vector<T>
const&
a,
764 std::vector<U>
const& ,
766 std::vector<size_t>
const&
indices,
770 if(indx == UINT_MAX) indx = a.size() - 1;
773 art::ProductID aid = prod.template getProductID< std::vector<T> >();
774 art::ProductID bid = prod.template getProductID< std::vector<U> >();
777 for(
size_t index: indices){
784 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
793 template <
typename PRODUCER,
typename T,
typename U,
typename Iter>
795 PRODUCER
const& prod,
799 Iter from_second_index,
808 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
809 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
819 while (from_second_index != to_second_index) {
820 art::Ptr<U> second_ptr(second_id, *from_second_index, getter);
827 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
837 template <
typename PRODUCER,
typename T,
typename U,
typename D>
839 PRODUCER
const& prod,
854 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
859 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
867 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
874 template <
typename PRODUCER,
typename T,
typename U,
typename D>
876 PRODUCER
const& prod,
891 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
896 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
900 assn.
addSingle(first_ptr, second_ptr, data);
904 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
922 std::vector<const U*> notAssociated;
924 art::FindOne<T> fa(b, evt, label);
926 for(
size_t u = 0; u < b->size(); ++u){
930 notAssociated.push_back(ptr.
get());
934 return notAssociated;
947 std::vector< art::Ptr<U> > notAssociated;
949 art::FindOneP<T> fa(b, evt, label);
951 for(
size_t u = 0; u < b->size(); ++u){
955 notAssociated.push_back(ptr);
959 return notAssociated;
967 std::vector<size_t> associated_index(index_p->size());
968 for(
auto const& pair : *
h)
969 associated_index.at(pair.first.key()) = pair.second.key();
970 return associated_index;
976 std::vector<const U*> associated_pointer(index_p->size());
977 for(
auto const& pair : *
h)
978 associated_pointer.at(pair.first.key()) = &(*(pair.second));
979 return associated_pointer;
985 std::vector< std::vector<size_t> > associated_indices(index_p->size());
986 for(
auto const& pair : *
h)
987 associated_indices.at(pair.first.key()).push_back(pair.second.key());
988 return associated_indices;
994 std::vector< std::vector<const U*> > associated_pointers(index_p->size());
995 for(
auto const& pair : *
h)
996 associated_pointers.at(pair.first.key()).push_back( &(*(pair.second)) );
997 return associated_pointers;
1001 #endif //ASSOCIATIONUTIL_H
Namespace for general, non-LArSoft-specific utilities.
ProductID getProductID(std::string const &instance_name="") const
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
std::vector< const U * > GetAssociatedVectorOneP(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
std::vector< art::Ptr< U > > FindUNotAssociatedToTP(art::Handle< U > b, art::Event const &evt, std::string const &label)
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.
EDProductGetter const * productGetter(ProductID const pid) const
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
std::vector< const U * > FindUNotAssociatedToT(art::Handle< U > b, art::Event const &evt, std::string const &label)
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
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.
Physics generators for neutrinos, cosmic rays, and others.
std::vector< size_t > GetAssociatedVectorOneI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
std::vector< std::vector< const U * > > GetAssociatedVectorManyP(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
cet::coded_exception< error, detail::translate > exception
h
training ###############################