Static Public Member Functions | List of all members
dune_ana::DUNEAnaPFParticleUtils Class Reference

DUNEAnaPFParticleUtils class. More...

#include <DUNEAnaPFParticleUtils.h>

Inheritance diagram for dune_ana::DUNEAnaPFParticleUtils:
dune_ana::DUNEAnaUtilsBase

Static Public Member Functions

static std::vector< art::Ptr< anab::T0 > > GetT0 (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
 Get the T0(s) associated with the particle. More...
 
static std::vector< art::Ptr< anab::CosmicTag > > GetCosmicTag (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
 Get the Cosmic Tag(s) associated with the particle. More...
 
static std::vector< art::Ptr< recob::PFParticle > > GetChildParticles (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
 Get the child particles (one step down in the hierarchy) of this particle. More...
 
static std::vector< art::Ptr< recob::Hit > > GetHits (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
 Get the hits associated to this particle. More...
 
static std::vector< art::Ptr< recob::Hit > > GetViewHits (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label, const unsigned short &view)
 Get the hits associated to this particle in a given view. More...
 
static std::vector< art::Ptr< recob::SpacePoint > > GetSpacePoints (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
 Get the spacepoints associated to this particle. More...
 
static art::Ptr< recob::TrackGetTrack (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &trackLabel)
 Get the track associated to this particle. Should only be called if IsTrack method succeeds. More...
 
static art::Ptr< recob::ShowerGetShower (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &showerLabel)
 Get the shower associated to this particle. Should only be called if IsShower method succeeds. More...
 
static art::Ptr< recob::VertexGetVertex (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel)
 Get the vertex associated to this particle. More...
 
static art::Ptr< recob::SliceGetSlice (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel)
 Get the slice associated to this particle. More...
 
static art::Ptr< larpandoraobj::PFParticleMetadataGetMetadata (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
 Get the metadata associated to this particle. More...
 
static bool IsTrack (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &trackLabel)
 Check if this particle has an associated track. More...
 
static bool IsShower (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &showerLabel)
 Check if this particle has an associated shower. More...
 
static bool IsClearCosmic (const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel)
 Check if this particle is a clear cosmic ray. More...
 
static bool IsNeutrino (const art::Ptr< recob::PFParticle > &pParticle)
 Check if this particle is a neutrino. More...
 

Additional Inherited Members

- Static Private Member Functions inherited from dune_ana::DUNEAnaUtilsBase
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

DUNEAnaPFParticleUtils class.

Definition at line 37 of file DUNEAnaPFParticleUtils.h.

Member Function Documentation

std::vector< art::Ptr< recob::PFParticle > > dune_ana::DUNEAnaPFParticleUtils::GetChildParticles ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string label 
)
static

Get the child particles (one step down in the hierarchy) of this particle.

Parameters
pParticleparticle for which we want the child particles
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
vector of art::Ptrs to the child particles

Definition at line 43 of file DUNEAnaPFParticleUtils.cxx.

44 {
45  auto theseParticles = evt.getHandle<std::vector<recob::PFParticle>>(label);
46  bool success = theseParticles.isValid();
47 
48  if (!success)
49  {
50  mf::LogError("LArPandora") << " Failed to find product with label " << label << " ... returning empty vector" << std::endl;
51  return std::vector<art::Ptr<recob::PFParticle>>();
52  }
53 
54  std::vector<art::Ptr<recob::PFParticle>> children;
55 
56  for (unsigned int iPart = 0; iPart < theseParticles->size(); ++iPart)
57  {
58  if (theseParticles->at(iPart).Parent() == pParticle.key())
59  {
60  art::Ptr<recob::PFParticle> pChild(theseParticles,iPart);
61  children.push_back(pChild);
62  }
63  }
64 
65  return children;
66 }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
key_type key() const noexcept
Definition: Ptr.h:216
QTextStream & endl(QTextStream &s)
std::vector< art::Ptr< anab::CosmicTag > > dune_ana::DUNEAnaPFParticleUtils::GetCosmicTag ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string label 
)
static

Get the Cosmic Tag(s) associated with the particle.

Parameters
pParticleparticle for which we want the cosmic tag
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
vector of art::Ptrs to the cosmic tag(s)

Definition at line 36 of file DUNEAnaPFParticleUtils.cxx.

37 {
38  return DUNEAnaPFParticleUtils::GetAssocProductVector<anab::CosmicTag>(pParticle,evt,label,label);
39 }
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< art::Ptr< recob::Hit > > dune_ana::DUNEAnaPFParticleUtils::GetHits ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string label 
)
static

Get the hits associated to this particle.

Parameters
pParticleparticle for which we want the hits
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
vector of art::Ptrs to the hits

Definition at line 70 of file DUNEAnaPFParticleUtils.cxx.

71 {
72  // There isn't a direct association between PFParticles and hits, so we go via clusters
73  const std::vector<art::Ptr<recob::Cluster>> theseClusters = DUNEAnaPFParticleUtils::GetAssocProductVector<recob::Cluster>(pParticle,evt,label,label);
74 
75  std::vector<art::Ptr<recob::Hit>> theseHits;
76  for (const art::Ptr<recob::Cluster> pCluster : theseClusters)
77  {
78  const std::vector<art::Ptr<recob::Hit>> tempHits = DUNEAnaPFParticleUtils::GetAssocProductVector<recob::Hit>(pCluster,evt,label,label);
79  theseHits.insert(theseHits.end(),tempHits.begin(),tempHits.end());
80  }
81  return theseHits;
82 }
TCEvent evt
Definition: DataStructs.cxx:7
art::Ptr< larpandoraobj::PFParticleMetadata > dune_ana::DUNEAnaPFParticleUtils::GetMetadata ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string label 
)
static

Get the metadata associated to this particle.

Parameters
pParticleparticle for which we want the slice
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
art::Ptr to the metadata

Definition at line 158 of file DUNEAnaPFParticleUtils.cxx.

159 {
160  return DUNEAnaPFParticleUtils::GetAssocProduct<larpandoraobj::PFParticleMetadata>(pParticle,evt,label,label);
161 }
TCEvent evt
Definition: DataStructs.cxx:7
art::Ptr< recob::Shower > dune_ana::DUNEAnaPFParticleUtils::GetShower ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string pParticleLabel,
const std::string showerLabel 
)
static

Get the shower associated to this particle. Should only be called if IsShower method succeeds.

Parameters
pParticleparticle for which we want the shower
evtis the underlying art event
particleLabelis the label for the PFParticle producer
trackLabelis the label for the Shower producer
Returns
art::Ptr to the shower

Definition at line 122 of file DUNEAnaPFParticleUtils.cxx.

123 {
124  return DUNEAnaPFParticleUtils::GetAssocProduct<recob::Shower>(pParticle,evt,particleLabel,showerLabel);
125 }
TCEvent evt
Definition: DataStructs.cxx:7
art::Ptr< recob::Slice > dune_ana::DUNEAnaPFParticleUtils::GetSlice ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string pParticleLabel 
)
static

Get the slice associated to this particle.

Parameters
pParticleparticle for which we want the slice
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
art::Ptr to the slice

Definition at line 136 of file DUNEAnaPFParticleUtils.cxx.

137 {
139  std::map<std::string,float> metaMap = pMetadata->GetPropertiesMap();
140 
141  unsigned int sliceIndex;
142  std::map<std::string,float>::iterator mapItr = metaMap.find("SliceIndex");
143 
144  if (mapItr == metaMap.end())
145  {
146  throw cet::exception("DUNEAna") << " DUNEAnaPFParticleUtils::GetSlice --- No associated slice found";
147  }
148  else
149  {
150  sliceIndex = mapItr->second;
151  }
152 
153  return DUNEAnaPFParticleUtils::GetProductVector<recob::Slice>(evt,label).at(sliceIndex);
154 }
intermediate_table::iterator iterator
const PropertiesMap & GetPropertiesMap() const
static art::Ptr< larpandoraobj::PFParticleMetadata > GetMetadata(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
Get the metadata associated to this particle.
TCEvent evt
Definition: DataStructs.cxx:7
Definition: fwd.h:31
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< art::Ptr< recob::SpacePoint > > dune_ana::DUNEAnaPFParticleUtils::GetSpacePoints ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string label 
)
static

Get the spacepoints associated to this particle.

Parameters
pParticleparticle for which we want the spacepoints
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
vector of art::Ptrs to the spacepoints

Definition at line 108 of file DUNEAnaPFParticleUtils.cxx.

109 {
110  return DUNEAnaPFParticleUtils::GetAssocProductVector<recob::SpacePoint>(pParticle,evt,label,label);
111 }
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< art::Ptr< anab::T0 > > dune_ana::DUNEAnaPFParticleUtils::GetT0 ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string label 
)
static

Get the T0(s) associated with the particle.

Parameters
pParticleparticle for which we want the T0
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
vector of art::Ptrs to the T0(s)

Definition at line 29 of file DUNEAnaPFParticleUtils.cxx.

30 {
31  return DUNEAnaPFParticleUtils::GetAssocProductVector<anab::T0>(pParticle,evt,label,label);
32 }
TCEvent evt
Definition: DataStructs.cxx:7
art::Ptr< recob::Track > dune_ana::DUNEAnaPFParticleUtils::GetTrack ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string pParticleLabel,
const std::string trackLabel 
)
static

Get the track associated to this particle. Should only be called if IsTrack method succeeds.

Parameters
pParticleparticle for which we want the track
evtis the underlying art event
particleLabelis the label for the PFParticle producer
trackLabelis the label for the Track producer
Returns
art::Ptr to the track

Definition at line 115 of file DUNEAnaPFParticleUtils.cxx.

116 {
117  return DUNEAnaPFParticleUtils::GetAssocProduct<recob::Track>(pParticle,evt,particleLabel,trackLabel);
118 }
TCEvent evt
Definition: DataStructs.cxx:7
art::Ptr< recob::Vertex > dune_ana::DUNEAnaPFParticleUtils::GetVertex ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string pParticleLabel 
)
static

Get the vertex associated to this particle.

Parameters
pParticleparticle for which we want the vertex
evtis the underlying art event
labelis the label for the PFParticle producer
Returns
art::Ptr to the vertex

Definition at line 129 of file DUNEAnaPFParticleUtils.cxx.

130 {
131  return DUNEAnaPFParticleUtils::GetAssocProduct<recob::Vertex>(pParticle,evt,particleLabel,particleLabel);
132 }
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< art::Ptr< recob::Hit > > dune_ana::DUNEAnaPFParticleUtils::GetViewHits ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string label,
const unsigned short &  view 
)
static

Get the hits associated to this particle in a given view.

Parameters
pParticleparticle for which we want the hits
evtis the underlying art event
labelis the label for the PFParticle producer
viewis the view for which we want the hits
Returns
vector of art::Ptrs to the hits

Definition at line 86 of file DUNEAnaPFParticleUtils.cxx.

87 {
88  // There isn't a direct association between PFParticles and hits, so we go via clusters
89  const std::vector<art::Ptr<recob::Cluster>> theseClusters = DUNEAnaPFParticleUtils::GetAssocProductVector<recob::Cluster>(pParticle,evt,label,label);
90 
91  std::vector<art::Ptr<recob::Hit>> theseHits;
92  for (const art::Ptr<recob::Cluster> pCluster : theseClusters)
93  {
94  const std::vector<art::Ptr<recob::Hit>> tempHits = DUNEAnaPFParticleUtils::GetAssocProductVector<recob::Hit>(pCluster,evt,label,label);
95  for(const art::Ptr<recob::Hit> pHit : tempHits)
96  {
97  if (pHit->View() == view)
98  {
99  theseHits.push_back(pHit);
100  }
101  }
102  }
103  return theseHits;
104 }
TCEvent evt
Definition: DataStructs.cxx:7
bool dune_ana::DUNEAnaPFParticleUtils::IsClearCosmic ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string pParticleLabel 
)
static

Check if this particle is a clear cosmic ray.

Parameters
pParticleparticle for which we want the clear cosmic confirmation
evtis the underlying art event
particleLabelis the label for the PFParticle producer
Returns
bool stating if the object is a clear cosmic ray

Definition at line 184 of file DUNEAnaPFParticleUtils.cxx.

185 {
186  const art::Ptr<larpandoraobj::PFParticleMetadata> pMetadata = DUNEAnaPFParticleUtils::GetMetadata(pParticle,evt,particleLabel);
187 
188  std::map<std::string,float> metaMap = pMetadata->GetPropertiesMap();
189 
190  return metaMap.find("IsClearCosmic") != metaMap.end();
191 }
const PropertiesMap & GetPropertiesMap() const
static art::Ptr< larpandoraobj::PFParticleMetadata > GetMetadata(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &label)
Get the metadata associated to this particle.
Definition: fwd.h:31
bool dune_ana::DUNEAnaPFParticleUtils::IsNeutrino ( const art::Ptr< recob::PFParticle > &  pParticle)
static

Check if this particle is a neutrino.

Parameters
pParticleparticle for which we want the neutrino confirmation
Returns
bool stating if the object is a neutrino

Definition at line 195 of file DUNEAnaPFParticleUtils.cxx.

196 {
197  const int pdg = pParticle->PdgCode();
198  return ((std::abs(pdg) == 12) || (std::abs(pdg) == 14) || (std::abs(pdg) ==16));
199 }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
T abs(T value)
bool dune_ana::DUNEAnaPFParticleUtils::IsShower ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string pParticleLabel,
const std::string showerLabel 
)
static

Check if this particle has an associated shower.

Parameters
pParticleparticle for which we want the shower-like confirmation
evtis the underlying art event
particleLabelis the label for the PFParticle producer
showerLabelis the label for the shower producer
Returns
bool stating if the object is shower-like

Definition at line 175 of file DUNEAnaPFParticleUtils.cxx.

176 {
177  const std::vector<art::Ptr<recob::Shower>> theseShowers = DUNEAnaPFParticleUtils::GetAssocProductVector<recob::Shower>(pParticle,evt,particleLabel,showerLabel);
178 
179  return !theseShowers.empty();
180 }
TCEvent evt
Definition: DataStructs.cxx:7
bool dune_ana::DUNEAnaPFParticleUtils::IsTrack ( const art::Ptr< recob::PFParticle > &  pParticle,
const art::Event evt,
const std::string pParticleLabel,
const std::string trackLabel 
)
static

Check if this particle has an associated track.

Parameters
pParticleparticle for which we want the track-like confirmation
evtis the underlying art event
particleLabelis the label for the PFParticle producer
trackLabelis the label for the track producer
Returns
bool stating if the object is track-like

Definition at line 165 of file DUNEAnaPFParticleUtils.cxx.

166 {
167  // This function needs to fail if GetTrack would fail
168  const std::vector<art::Ptr<recob::Track>> theseTracks = DUNEAnaPFParticleUtils::GetAssocProductVector<recob::Track>(pParticle,evt,particleLabel,trackLabel);
169 
170  return !theseTracks.empty();
171 }
TCEvent evt
Definition: DataStructs.cxx:7

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