72 #ifndef ASSOCIATIONUTIL_H 73 #define ASSOCIATIONUTIL_H 154 template<
class PRODUCER,
class T,
class U>
157 std::vector<T>
const&a,
160 std::string a_instance,
212 template<
class PRODUCER,
class T,
class U>
215 std::vector<T>
const&a,
218 size_t indx=UINT_MAX)
219 {
return CreateAssn(prod, evt, a, b, assn, std::string(), indx); }
237 template<
class PRODUCER,
class T,
class U>
239 PRODUCER
const& prod,
265 template<
class PRODUCER,
class T,
class U>
267 PRODUCER
const& prod,
269 std::vector<T>
const& a,
272 size_t indx = UINT_MAX
295 template<
class PRODUCER,
class T,
class U>
297 PRODUCER
const& prod,
323 template<
class PRODUCER,
class T,
class U>
325 PRODUCER
const& prod,
327 std::vector<T>
const& a,
330 size_t indx = UINT_MAX
361 template<
class PRODUCER,
class T,
class U>
363 PRODUCER
const& prod,
365 std::vector<T>
const& a,
366 std::vector<U>
const& b,
370 size_t indx = UINT_MAX
400 template<
class PRODUCER,
class T,
class U>
402 PRODUCER
const& prod,
404 std::vector<T>
const& a,
405 std::vector<U>
const& b,
407 std::vector<size_t>
const&
indices,
408 size_t indx = UINT_MAX
450 template <
typename PRODUCER,
typename T,
typename U,
typename Iter>
452 PRODUCER
const& prod,
456 Iter from_second_index,
517 template <
typename PRODUCER,
typename T,
typename U,
typename D>
519 PRODUCER
const& prod,
527 template <
typename PRODUCER,
typename T,
typename U,
typename D>
529 PRODUCER
const& prod,
548 std::string
const& label);
559 std::string
const& label);
590 template<
class PRODUCER,
class T,
class U>
592 PRODUCER
const& prod,
594 std::vector<T>
const& a,
597 std::string a_instance,
601 if (indx == UINT_MAX) indx = a.size()-1;
604 art::ProductID aid = prod.template getProductID< std::vector<T>>( a_instance);
611 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
620 template<
class PRODUCER,
class T,
class U>
634 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
644 template<
class PRODUCER,
class T,
class U>
646 PRODUCER
const& prod,
648 std::vector<T>
const& a,
653 if(indx == UINT_MAX) indx = a.size() - 1;
656 art::ProductID aid = prod.template getProductID< std::vector<T> >();
662 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
671 template<
class PRODUCER,
class T,
class U>
685 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
694 template<
class PRODUCER,
class T,
class U>
696 PRODUCER
const& prod,
698 std::vector<T>
const& a,
704 if (indx == UINT_MAX) indx = a.size() - 1;
707 art::ProductID aid = prod.template getProductID< std::vector<T> >();
713 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
722 template<
class PRODUCER,
class T,
class U>
724 PRODUCER
const& prod,
726 std::vector<T>
const& a,
727 std::vector<U>
const& ,
734 if(indx == UINT_MAX) indx = a.size() - 1;
737 art::ProductID aid = prod.template getProductID< std::vector<T> >();
738 art::ProductID bid = prod.template getProductID< std::vector<U> >();
741 for(
size_t i = startU; i < endU; ++i){
748 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
757 template<
class PRODUCER,
class T,
class U>
759 PRODUCER
const& prod,
761 std::vector<T>
const& a,
762 std::vector<U>
const& ,
764 std::vector<size_t>
const&
indices,
768 if(indx == UINT_MAX) indx = a.size() - 1;
771 art::ProductID aid = prod.template getProductID< std::vector<T> >();
772 art::ProductID bid = prod.template getProductID< std::vector<U> >();
775 for(
size_t index: indices){
782 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
791 template <
typename PRODUCER,
typename T,
typename U,
typename Iter>
793 PRODUCER
const& prod,
797 Iter from_second_index,
806 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
807 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
817 while (from_second_index != to_second_index) {
818 art::Ptr<U> second_ptr(second_id, *from_second_index, getter);
825 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
835 template <
typename PRODUCER,
typename T,
typename U,
typename D>
837 PRODUCER
const& prod,
852 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
857 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
861 assn.
addSingle(first_ptr, second_ptr, std::move(data));
865 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
872 template <
typename PRODUCER,
typename T,
typename U,
typename D>
874 PRODUCER
const& prod,
889 art::ProductID first_id = prod.template getProductID< std::vector<T> >();
894 art::ProductID second_id = prod.template getProductID< std::vector<U> >();
898 assn.
addSingle(first_ptr, second_ptr, data);
902 <<
"unable to create requested art:Assns, exception thrown: " <<
e;
913 std::string
const& label)
920 std::vector<const U*> notAssociated;
924 for(
size_t u = 0; u < b->size(); ++u){
925 cet::maybe_ref<T const> t(fa.at(u));
928 notAssociated.push_back(ptr.
get());
932 return notAssociated;
938 std::string
const& label)
945 std::vector< art::Ptr<U> > notAssociated;
949 for(
size_t u = 0; u < b->size(); ++u){
950 cet::maybe_ref<T const> t(fa.at(u));
953 notAssociated.push_back(ptr);
957 return notAssociated;
965 std::vector<size_t> associated_index(index_p->size());
966 for(
auto const& pair : *h)
967 associated_index.at(pair.first.key()) = pair.second.key();
968 return associated_index;
974 std::vector<const U*> associated_pointer(index_p->size());
975 for(
auto const& pair : *h)
976 associated_pointer.at(pair.first.key()) = &(*(pair.second));
977 return associated_pointer;
983 std::vector< std::vector<size_t> > associated_indices(index_p->size());
984 for(
auto const& pair : *h)
985 associated_indices.at(pair.first.key()).push_back(pair.second.key());
986 return associated_indices;
992 std::vector< std::vector<const U*> > associated_pointers(index_p->size());
993 for(
auto const& pair : *h)
994 associated_pointers.at(pair.first.key()).push_back( &(*(pair.second)) );
995 return associated_pointers;
999 #endif //ASSOCIATIONUTIL_H
Namespace for general, non-LArSoft-specific utilities.
std::vector< const U * > GetAssociatedVectorOneP(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
EDProductGetter const * productGetter(ProductID const) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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.
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)