Static Protected Member Functions | List of all members
dune_ana::DUNEAnaUtilsBase Class Reference

DUNEAnaUtilsBase class containing some template functions. More...

#include <DUNEAnaUtilsBase.h>

Inheritance diagram for dune_ana::DUNEAnaUtilsBase:
dune_ana::DUNEAnaClusterUtils dune_ana::DUNEAnaEventUtils dune_ana::DUNEAnaHitUtils dune_ana::DUNEAnaPFParticleUtils dune_ana::DUNEAnaShowerUtils dune_ana::DUNEAnaSliceUtils dune_ana::DUNEAnaSpacePointUtils dune_ana::DUNEAnaTrackUtils

Static Protected Member Functions

template<typename T >
static std::vector< art::Ptr< T > > GetProductVector (const art::Event &evt, const std::string &label)
 
template<typename T , typename U >
static std::vector< art::Ptr< T > > GetAssocProductVector (const art::Ptr< U > &part, const art::Event &evt, const std::string &label, const std::string &assocLabel)
 
template<typename T , typename U >
static art::Ptr< T > GetAssocProduct (const art::Ptr< U > &part, const art::Event &evt, const std::string &label, const std::string &assocLabel)
 

Detailed Description

DUNEAnaUtilsBase class containing some template functions.

Definition at line 25 of file DUNEAnaUtilsBase.h.

Member Function Documentation

template<typename T , typename U >
art::Ptr< T > dune_ana::DUNEAnaUtilsBase::GetAssocProduct ( const art::Ptr< U > &  part,
const art::Event evt,
const std::string label,
const std::string assocLabel 
)
staticprotected

Definition at line 70 of file DUNEAnaUtilsBase.h.

71 {
72  std::vector<art::Ptr<T>> associatedProducts = DUNEAnaUtilsBase::GetAssocProductVector<T>(pProd,evt,label,assocLabel);
73  if (associatedProducts.empty())
74  {
75  throw cet::exception("DUNEAna") << "DUNEAnaUtilsBase::GetAssocProduct --- No associated object found";
76  }
77  return associatedProducts.at(0);
78 }
TCEvent evt
Definition: DataStructs.cxx:7
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T , typename U >
std::vector< art::Ptr< T > > dune_ana::DUNEAnaUtilsBase::GetAssocProductVector ( const art::Ptr< U > &  part,
const art::Event evt,
const std::string label,
const std::string assocLabel 
)
staticprotected

Definition at line 53 of file DUNEAnaUtilsBase.h.

54 {
55  auto products = evt.getHandle<std::vector<U>>(label);
56  bool success = products.isValid();
57 
58  if (!success)
59  {
60  mf::LogError("DUNEAna") << " Failed to find product with label " << label << " ... returning empty vector" << std::endl;
61  return std::vector<art::Ptr<T>>();
62  }
63 
64  const art::FindManyP<T> findParticleAssocs(products,evt,assocLabel);
65 
66  return findParticleAssocs.at(pProd.key());
67 }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
QTextStream & endl(QTextStream &s)
template<typename T >
std::vector< art::Ptr< T > > dune_ana::DUNEAnaUtilsBase::GetProductVector ( const art::Event evt,
const std::string label 
)
staticprotected

Definition at line 34 of file DUNEAnaUtilsBase.h.

35 {
36  auto theseProds = evt.getHandle<std::vector<T>>(label);
37  bool success = theseProds.isValid();
38 
39  if (!success)
40  {
41  mf::LogError("DUNEAna") << " Failed to find product with label " << label << " ... returning empty vector" << std::endl;
42  return std::vector<art::Ptr<T>>();
43  }
44 
45  // We need to convert these to art pointers
46  std::vector<art::Ptr<T>> productVector;
47  art::fill_ptr_vector(productVector,theseProds);
48 
49  return productVector;
50 }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)

The documentation for this class was generated from the following file: