8 #ifndef DUNE_ANA_UTILS_BASE_H 9 #define DUNE_ANA_UTILS_BASE_H 13 #include "canvas/Persistency/Common/FindManyP.h" 37 bool success = theseProds.isValid();
41 mf::LogError(
"DUNEAna") <<
" Failed to find product with label " << label <<
" ... returning empty vector" <<
std::endl;
42 return std::vector<art::Ptr<T>>();
46 std::vector<art::Ptr<T>> productVector;
56 bool success = products.isValid();
60 mf::LogError(
"DUNEAna") <<
" Failed to find product with label " << label <<
" ... returning empty vector" <<
std::endl;
61 return std::vector<art::Ptr<T>>();
64 const art::FindManyP<T> findParticleAssocs(products,evt,assocLabel);
66 return findParticleAssocs.at(pProd.
key());
72 std::vector<art::Ptr<T>> associatedProducts = DUNEAnaUtilsBase::GetAssocProductVector<T>(pProd,
evt,
label,assocLabel);
73 if (associatedProducts.empty())
75 throw cet::exception(
"DUNEAna") <<
"DUNEAnaUtilsBase::GetAssocProduct --- No associated object found";
77 return associatedProducts.at(0);
83 #endif // DUNE_ANA_PFPARTICLE_UTILS_H DUNEAnaUtilsBase class containing some template functions.
static std::vector< art::Ptr< T > > GetProductVector(const art::Event &evt, const std::string &label)
Handle< PROD > getHandle(SelectorBase const &) const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
static art::Ptr< T > GetAssocProduct(const art::Ptr< U > &part, const art::Event &evt, const std::string &label, const std::string &assocLabel)
key_type key() const noexcept
static std::vector< art::Ptr< T > > GetAssocProductVector(const art::Ptr< U > &part, const art::Event &evt, const std::string &label, const std::string &assocLabel)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)