LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LArHierarchyHelper::MCMatches Class Reference

MCMatches class. More...

#include "LArHierarchyHelper.h"

Public Member Functions

 MCMatches (const MCHierarchy::Node *pMCParticle)
 Constructor. More...
 
void AddRecoMatch (const RecoHierarchy::Node *pReco, const int nSharedHits)
 Add a reconstructed node as a match for this MC node. More...
 
const MCHierarchy::NodeGetMC () const
 Retrieve the MC node. More...
 
const RecoHierarchy::NodeVectorGetRecoMatches () const
 Retrieve the vector of matched reco nodes. More...
 
unsigned int GetSharedHits (const RecoHierarchy::Node *pReco) const
 Retrieve the number of shared hits in the match. More...
 
float GetPurity (const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
 Retrieve the purity of the match. More...
 
float GetPurity (const RecoHierarchy::Node *pReco, const pandora::HitType view, const bool adcWeighted=false) const
 Retrieve the purity of the match. More...
 
float GetCompleteness (const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
 Retrieve the completeness of the match. More...
 
float GetCompleteness (const RecoHierarchy::Node *pReco, const pandora::HitType view, const bool adcWeighted=false) const
 Retrieve the completeness of the match. More...
 
size_t GetNRecoMatches () const
 Get the number of reco nodes matched (both above and below quality cut thresholds) to the MC node. More...
 
bool IsQuality (const QualityCuts &qualityCuts) const
 Get whether this match passes quality cuts. More...
 

Private Member Functions

float GetPurity (const pandora::CaloHitVector &intersection, const pandora::CaloHitList &recoHits, const bool adcWeighted) const
 Core purity calculation given intersecting hits and reco hits. More...
 
float GetCompleteness (const pandora::CaloHitVector &intersection, const pandora::CaloHitList &mcHits, const bool adcWeighted) const
 Core completeness calculation given intersecting hits and MC hits. More...
 

Private Attributes

const MCHierarchy::Nodem_pMCParticle
 MC node associated with any matches. More...
 
RecoHierarchy::NodeVector m_recoNodes
 Matched reco nodes. More...
 
pandora::IntVector m_sharedHits
 Number of shared hits for each match. More...
 

Detailed Description

MCMatches class.

Definition at line 604 of file LArHierarchyHelper.h.

Constructor & Destructor Documentation

lar_content::LArHierarchyHelper::MCMatches::MCMatches ( const MCHierarchy::Node pMCParticle)

Constructor.

Parameters
pMCParticleThe MCParticle being matched

Definition at line 1088 of file LArHierarchyHelper.cc.

1088  :
1089  m_pMCParticle{pMCParticle}
1090 {
1091 }
const MCHierarchy::Node * m_pMCParticle
MC node associated with any matches.

Member Function Documentation

void lar_content::LArHierarchyHelper::MCMatches::AddRecoMatch ( const RecoHierarchy::Node pReco,
const int  nSharedHits 
)

Add a reconstructed node as a match for this MC node.

Parameters
pRecoThe reconstructed node that matches this MC node
nSharedHitsThe number of hits shared betweeb reco and MC nodes

Definition at line 1095 of file LArHierarchyHelper.cc.

References m_recoNodes, and m_sharedHits.

Referenced by lar_content::LArHierarchyHelper::MatchInfo::Match().

1096 {
1097  m_recoNodes.emplace_back(pReco);
1098  m_sharedHits.emplace_back(nSharedHits);
1099 }
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
pandora::IntVector m_sharedHits
Number of shared hits for each match.
float lar_content::LArHierarchyHelper::MCMatches::GetCompleteness ( const RecoHierarchy::Node pReco,
const bool  adcWeighted = false 
) const

Retrieve the completeness of the match.

Parameters
pRecoThe reco node to consider
adcWeightedWhether or not to weight completeness according to the charge contribution
Returns
The completeness of the match

Definition at line 1154 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCHierarchy::Node::GetCaloHits(), lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetCaloHits(), GetPurity(), m_pMCParticle, and m_recoNodes.

Referenced by IsQuality().

1155 {
1156  auto iter{std::find(m_recoNodes.begin(), m_recoNodes.end(), pReco)};
1157  if (iter == m_recoNodes.end())
1158  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1159 
1160  const CaloHitList &recoHits{pReco->GetCaloHits()};
1161  const CaloHitList &mcHits{m_pMCParticle->GetCaloHits()};
1162  CaloHitVector intersection;
1163  std::set_intersection(mcHits.begin(), mcHits.end(), recoHits.begin(), recoHits.end(), std::back_inserter(intersection));
1164 
1165  return this->GetCompleteness(intersection, mcHits, adcWeighted);
1166 }
const MCHierarchy::Node * m_pMCParticle
MC node associated with any matches.
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
const pandora::CaloHitList & GetCaloHits() const
Retrieve the CaloHits associated with this node.
float GetCompleteness(const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
Retrieve the completeness of the match.
float lar_content::LArHierarchyHelper::MCMatches::GetCompleteness ( const RecoHierarchy::Node pReco,
const pandora::HitType  view,
const bool  adcWeighted = false 
) const

Retrieve the completeness of the match.

Parameters
pRecoThe reco node to consider
viewThe view for which purity should be calculated
adcWeightedWhether or not to weight completeness according to the charge contribution
Returns
The completeness of the match
float lar_content::LArHierarchyHelper::MCMatches::GetCompleteness ( const pandora::CaloHitVector &  intersection,
const pandora::CaloHitList &  mcHits,
const bool  adcWeighted 
) const
private

Core completeness calculation given intersecting hits and MC hits.

Parameters
intersectionThe intersecting reco and MC hits
mcHitsThe MC hits
adcWeightedWhether or not to weight completeness according to the charge contribution
Returns
The completeness of the match
const LArHierarchyHelper::MCHierarchy::Node * lar_content::LArHierarchyHelper::MCMatches::GetMC ( ) const
inline

Retrieve the MC node.

Returns
The MC node

Definition at line 987 of file LArHierarchyHelper.h.

Referenced by lar_content::LArHierarchyHelper::MatchInfo::Match().

988 {
989  return m_pMCParticle;
990 }
const MCHierarchy::Node * m_pMCParticle
MC node associated with any matches.
size_t lar_content::LArHierarchyHelper::MCMatches::GetNRecoMatches ( ) const
inline

Get the number of reco nodes matched (both above and below quality cut thresholds) to the MC node.

Returns
The number of reco nodes matched to the MC node

Definition at line 1001 of file LArHierarchyHelper.h.

1002 {
1003  return m_recoNodes.size();
1004 }
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
float lar_content::LArHierarchyHelper::MCMatches::GetPurity ( const RecoHierarchy::Node pReco,
const bool  adcWeighted = false 
) const

Retrieve the purity of the match.

Parameters
pRecoThe reco node to consider
adcWeightedWhether or not to weight purity according to the charge contribution
Returns
The purity of the match

Definition at line 1115 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCHierarchy::Node::GetCaloHits(), lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetCaloHits(), m_pMCParticle, and m_recoNodes.

Referenced by GetCompleteness(), and IsQuality().

1116 {
1117  auto iter{std::find(m_recoNodes.begin(), m_recoNodes.end(), pReco)};
1118  if (iter == m_recoNodes.end())
1119  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1120 
1121  const CaloHitList &recoHits{pReco->GetCaloHits()};
1122  const CaloHitList &mcHits{m_pMCParticle->GetCaloHits()};
1123  CaloHitVector intersection;
1124  std::set_intersection(mcHits.begin(), mcHits.end(), recoHits.begin(), recoHits.end(), std::back_inserter(intersection));
1125 
1126  return this->GetPurity(intersection, recoHits, adcWeighted);
1127 }
const MCHierarchy::Node * m_pMCParticle
MC node associated with any matches.
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
const pandora::CaloHitList & GetCaloHits() const
Retrieve the CaloHits associated with this node.
float GetPurity(const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
Retrieve the purity of the match.
float lar_content::LArHierarchyHelper::MCMatches::GetPurity ( const RecoHierarchy::Node pReco,
const pandora::HitType  view,
const bool  adcWeighted = false 
) const

Retrieve the purity of the match.

Parameters
pRecoThe reco node to consider
viewThe view for which purity should be calculated
adcWeightedWhether or not to weight purity according to the charge contribution
Returns
The purity of the match
float lar_content::LArHierarchyHelper::MCMatches::GetPurity ( const pandora::CaloHitVector &  intersection,
const pandora::CaloHitList &  recoHits,
const bool  adcWeighted 
) const
private

Core purity calculation given intersecting hits and reco hits.

Parameters
intersectionThe intersecting reco and MC hits
recoHitsThe reco hits
adcWeightedWhether or not to weight purity according to the charge contribution
Returns
The purity of the match
const LArHierarchyHelper::RecoHierarchy::NodeVector & lar_content::LArHierarchyHelper::MCMatches::GetRecoMatches ( ) const
inline

Retrieve the vector of matched reco nodes.

Returns
The vector of matched reco nodes

Definition at line 994 of file LArHierarchyHelper.h.

995 {
996  return m_recoNodes;
997 }
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
unsigned int lar_content::LArHierarchyHelper::MCMatches::GetSharedHits ( const RecoHierarchy::Node pReco) const

Retrieve the number of shared hits in the match.

Parameters
pRecoThe reco node to consider
Returns
The number of shared hits

Definition at line 1103 of file LArHierarchyHelper.cc.

References m_recoNodes, and m_sharedHits.

1104 {
1105  auto iter{std::find(m_recoNodes.begin(), m_recoNodes.end(), pReco)};
1106  if (iter == m_recoNodes.end())
1107  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1108  int index = iter - m_recoNodes.begin();
1109 
1110  return static_cast<int>(m_sharedHits[index]);
1111 }
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
pandora::IntVector m_sharedHits
Number of shared hits for each match.
bool lar_content::LArHierarchyHelper::MCMatches::IsQuality ( const QualityCuts qualityCuts) const

Get whether this match passes quality cuts.

Parameters
qualityCutsThe quality cuts to pass
Returns
Whether or not this match passes quality cuts

Definition at line 1249 of file LArHierarchyHelper.cc.

References GetCompleteness(), GetPurity(), lar_content::LArHierarchyHelper::QualityCuts::m_minCompleteness, lar_content::LArHierarchyHelper::QualityCuts::m_minPurity, and m_recoNodes.

1250 {
1251  if (m_recoNodes.empty())
1252  return false;
1253 
1254  int nAboveThreshold{0};
1255  if (m_recoNodes.size() != 1)
1256  {
1257  for (const LArHierarchyHelper::RecoHierarchy::Node *const pNode : m_recoNodes)
1258  if (this->GetCompleteness(pNode) > 0.1f)
1259  ++nAboveThreshold;
1260  if (nAboveThreshold != 1)
1261  return false;
1262  }
1263 
1264  if (this->GetPurity(m_recoNodes.front()) < qualityCuts.m_minPurity)
1265  return false;
1266 
1267  if (this->GetCompleteness(m_recoNodes.front()) < qualityCuts.m_minCompleteness)
1268  return false;
1269 
1270  return true;
1271 }
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
float GetPurity(const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
Retrieve the purity of the match.
float GetCompleteness(const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
Retrieve the completeness of the match.

Member Data Documentation

const MCHierarchy::Node* lar_content::LArHierarchyHelper::MCMatches::m_pMCParticle
private

MC node associated with any matches.

Definition at line 726 of file LArHierarchyHelper.h.

Referenced by GetCompleteness(), and GetPurity().

RecoHierarchy::NodeVector lar_content::LArHierarchyHelper::MCMatches::m_recoNodes
private

Matched reco nodes.

Definition at line 727 of file LArHierarchyHelper.h.

Referenced by AddRecoMatch(), GetCompleteness(), GetPurity(), GetSharedHits(), and IsQuality().

pandora::IntVector lar_content::LArHierarchyHelper::MCMatches::m_sharedHits
private

Number of shared hits for each match.

Definition at line 728 of file LArHierarchyHelper.h.

Referenced by AddRecoMatch(), and GetSharedHits().


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