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" 153 template<
class PRODUCER,
class T,
class U>
156 std::vector<T>
const&
a,
210 template<
class PRODUCER,
class T,
class U>
213 std::vector<T>
const&
a,
216 size_t indx=UINT_MAX)
235 template<
class PRODUCER,
class T,
class U>
237 PRODUCER
const& prod,
263 template<
class PRODUCER,
class T,
class U>
265 PRODUCER
const& prod,
267 std::vector<T>
const& a,
270 size_t indx = UINT_MAX
293 template<
class PRODUCER,
class T,
class U>
295 PRODUCER
const& prod,
321 template<
class PRODUCER,
class T,
class U>
323 PRODUCER
const& prod,
325 std::vector<T>
const& a,
328 size_t indx = UINT_MAX
359 template<
class PRODUCER,
class T,
class U>
361 PRODUCER
const& prod,
363 std::vector<T>
const& a,
364 std::vector<U>
const& b,
368 size_t indx = UINT_MAX
398 template<
class PRODUCER,
class T,
class U>
400 PRODUCER
const& prod,
402 std::vector<T>
const& a,
403 std::vector<U>
const& b,
405 std::vector<size_t>
const&
indices,
406 size_t indx = UINT_MAX
448 template <
typename PRODUCER,
typename T,
typename U,
typename Iter>
450 PRODUCER
const& prod,
454 Iter from_second_index,
515 template <
typename PRODUCER,
typename T,
typename U,
typename D>
517 PRODUCER
const& prod,
525 template <
typename PRODUCER,
typename T,
typename U,
typename D>
527 PRODUCER
const& prod,
538 template <
typename PRODUCER,
typename T,
typename U,
typename D>
541 std::vector<T>
const& a,
600 template<
class PRODUCER,
class T,
class U>
604 std::vector<T>
const&
a,
611 if (indx == UINT_MAX) indx = a.size()-1;
623 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
632 template<
class PRODUCER,
class T,
class U>
646 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
656 template<
class PRODUCER,
class T,
class U>
658 PRODUCER
const& prod,
660 std::vector<T>
const&
a,
665 if(indx == UINT_MAX) indx = a.size() - 1;
668 art::ProductID aid = prod.template getProductID< std::vector<T> >();
674 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
683 template<
class PRODUCER,
class T,
class U>
697 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
706 template<
class PRODUCER,
class T,
class U>
708 PRODUCER
const& prod,
710 std::vector<T>
const&
a,
716 if (indx == UINT_MAX) indx = a.size() - 1;
719 art::ProductID aid = prod.template getProductID< std::vector<T> >();
725 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
734 template<
class PRODUCER,
class T,
class U>
738 std::vector<T>
const&
a,
739 std::vector<U>
const& ,
746 if(indx == UINT_MAX) indx = a.size() - 1;
755 for(
size_t i = startU; i < endU; ++i){
762 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
771 template<
class PRODUCER,
class T,
class U>
773 PRODUCER
const& prod,
775 std::vector<T>
const&
a,
776 std::vector<U>
const& ,
778 std::vector<size_t>
const&
indices,
782 if(indx == UINT_MAX) indx = a.size() - 1;
785 art::ProductID aid = prod.template getProductID< std::vector<T> >();
786 art::ProductID bid = prod.template getProductID< std::vector<U> >();
789 for(
size_t index: indices){
796 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
805 template <
typename PRODUCER,
typename T,
typename U,
typename Iter>
807 PRODUCER
const& prod,
811 Iter from_second_index,
820 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
821 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
831 while (from_second_index != to_second_index) {
832 art::Ptr<U> second_ptr(second_id, *from_second_index, getter);
839 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
849 template <
typename PRODUCER,
typename T,
typename U,
typename D>
851 PRODUCER
const& prod,
866 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
871 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
879 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
886 template <
typename PRODUCER,
typename T,
typename U,
typename D>
888 PRODUCER
const& prod,
903 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
908 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
912 assn.
addSingle(first_ptr, second_ptr, data);
916 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
925 template <
typename PRODUCER,
typename T,
typename U,
typename D>
928 std::vector<T>
const&
a,
934 if (indx == UINT_MAX) indx = a.size()-1;
945 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
962 std::vector<const U*> notAssociated;
964 art::FindOne<T> fa(b, evt, label);
966 for(
size_t u = 0; u < b->size(); ++u){
970 notAssociated.push_back(ptr.
get());
974 return notAssociated;
987 std::vector< art::Ptr<U> > notAssociated;
989 art::FindOneP<T> fa(b, evt, label);
991 for(
size_t u = 0; u < b->size(); ++u){
995 notAssociated.push_back(ptr);
999 return notAssociated;
1007 std::vector<size_t> associated_index(index_p->size());
1008 for(
auto const& pair : *
h)
1009 associated_index.at(pair.first.key()) = pair.second.key();
1010 return associated_index;
1016 std::vector<const U*> associated_pointer(index_p->size());
1017 for(
auto const& pair : *
h)
1018 associated_pointer.at(pair.first.key()) = &(*(pair.second));
1019 return associated_pointer;
1025 std::vector< std::vector<size_t> > associated_indices(index_p->size());
1026 for(
auto const& pair : *
h)
1027 associated_indices.at(pair.first.key()).
push_back(pair.second.key());
1028 return associated_indices;
1034 std::vector< std::vector<const U*> > associated_pointers(index_p->size());
1035 for(
auto const& pair : *
h)
1036 associated_pointers.at(pair.first.key()).
push_back( &(*(pair.second)) );
1037 return associated_pointers;
1041 #endif //ASSOCIATIONUTIL_H
Namespace for general, non-LArSoft-specific utilities.
ProductID getProductID(std::string const &instance_name="") const
std::vector< const U * > GetAssociatedVectorOneP(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
std::vector< size_t > GetAssociatedVectorOneI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
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.
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.
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.
std::vector< art::Ptr< U > > FindUNotAssociatedToTP(art::Handle< U > b, art::Event const &evt, std::string const &label)
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< const U * > FindUNotAssociatedToT(art::Handle< U > b, art::Event const &evt, std::string const &label)
cet::coded_exception< error, detail::translate > exception
std::vector< std::vector< const U * > > GetAssociatedVectorManyP(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)