LArSoft  v10_04_05
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, const pandora::CaloHitList &selectedRecoHits)
 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...
 
const pandora::CaloHitList GetSelectedRecoHits (const RecoHierarchy::Node *pReco) const
 Retrieve the selected hits for the given reco node. 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...
 
SelectedRecoHitsMap m_selectedRecoHitsMap
 Map storing the selected CaloHits for a given reco node. More...
 

Detailed Description

MCMatches class.

Definition at line 618 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 1093 of file LArHierarchyHelper.cc.

1093  :
1094  m_pMCParticle{pMCParticle}
1095 {
1096 }
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,
const pandora::CaloHitList &  selectedRecoHits 
)

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 between reco and MC nodes
selectedRecoHitsThe reco node hits that are selected from the MC particle hits

Definition at line 1100 of file LArHierarchyHelper.cc.

References m_recoNodes, m_selectedRecoHitsMap, and m_sharedHits.

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

1101 {
1102  m_recoNodes.emplace_back(pReco);
1103  m_sharedHits.emplace_back(nSharedHits);
1104  m_selectedRecoHitsMap.insert(std::make_pair(pReco, selectedRecoHits));
1105 }
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
pandora::IntVector m_sharedHits
Number of shared hits for each match.
SelectedRecoHitsMap m_selectedRecoHitsMap
Map storing the selected CaloHits for a given reco node.
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 1171 of file LArHierarchyHelper.cc.

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

Referenced by IsQuality().

1172 {
1173  auto iter{std::find(m_recoNodes.begin(), m_recoNodes.end(), pReco)};
1174  if (iter == m_recoNodes.end())
1175  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1176 
1177  const CaloHitList recoHits = LArHierarchyHelper::MCMatches::GetSelectedRecoHits(pReco);
1178  const CaloHitList &mcHits{m_pMCParticle->GetCaloHits()};
1179  CaloHitVector intersection;
1180  std::set_intersection(mcHits.begin(), mcHits.end(), recoHits.begin(), recoHits.end(), std::back_inserter(intersection));
1181 
1182  return this->GetCompleteness(intersection, mcHits, adcWeighted);
1183 }
const pandora::CaloHitList GetSelectedRecoHits(const RecoHierarchy::Node *pReco) const
Retrieve the selected hits for the given reco node.
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 1030 of file LArHierarchyHelper.h.

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

1031 {
1032  return m_pMCParticle;
1033 }
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 1044 of file LArHierarchyHelper.h.

1045 {
1046  return m_recoNodes.size();
1047 }
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 1132 of file LArHierarchyHelper.cc.

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

Referenced by GetCompleteness(), and IsQuality().

1133 {
1134  auto iter{std::find(m_recoNodes.begin(), m_recoNodes.end(), pReco)};
1135  if (iter == m_recoNodes.end())
1136  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1137 
1138  const CaloHitList recoHits = LArHierarchyHelper::MCMatches::GetSelectedRecoHits(pReco);
1139  const CaloHitList &mcHits{m_pMCParticle->GetCaloHits()};
1140  CaloHitVector intersection;
1141  std::set_intersection(mcHits.begin(), mcHits.end(), recoHits.begin(), recoHits.end(), std::back_inserter(intersection));
1142 
1143  return this->GetPurity(intersection, recoHits, adcWeighted);
1144 }
const pandora::CaloHitList GetSelectedRecoHits(const RecoHierarchy::Node *pReco) const
Retrieve the selected hits for the given reco node.
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 1037 of file LArHierarchyHelper.h.

1038 {
1039  return m_recoNodes;
1040 }
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
const CaloHitList lar_content::LArHierarchyHelper::MCMatches::GetSelectedRecoHits ( const RecoHierarchy::Node pReco) const

Retrieve the selected hits for the given reco node.

Parameters
pRecoThe reco node pointer
Returns
The list of selected calo reco hits

Definition at line 1109 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetCaloHits(), and m_selectedRecoHitsMap.

Referenced by GetCompleteness(), and GetPurity().

1110 {
1111  auto iter{m_selectedRecoHitsMap.find(pReco)};
1112  if (iter != m_selectedRecoHitsMap.end())
1113  return iter->second;
1114  else
1115  return pReco->GetCaloHits();
1116 }
SelectedRecoHitsMap m_selectedRecoHitsMap
Map storing the selected CaloHits for a given reco node.
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 1120 of file LArHierarchyHelper.cc.

References m_recoNodes, and m_sharedHits.

1121 {
1122  auto iter{std::find(m_recoNodes.begin(), m_recoNodes.end(), pReco)};
1123  if (iter == m_recoNodes.end())
1124  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1125  int index = iter - m_recoNodes.begin();
1126 
1127  return static_cast<int>(m_sharedHits[index]);
1128 }
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 1266 of file LArHierarchyHelper.cc.

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

1267 {
1268  if (m_recoNodes.empty())
1269  return false;
1270 
1271  int nAboveThreshold{0};
1272  if (m_recoNodes.size() != 1)
1273  {
1274  for (const LArHierarchyHelper::RecoHierarchy::Node *const pNode : m_recoNodes)
1275  if (this->GetCompleteness(pNode) > 0.1f)
1276  ++nAboveThreshold;
1277  if (nAboveThreshold != 1)
1278  return false;
1279  }
1280 
1281  if (this->GetPurity(m_recoNodes.front()) < qualityCuts.m_minPurity)
1282  return false;
1283 
1284  if (this->GetCompleteness(m_recoNodes.front()) < qualityCuts.m_minCompleteness)
1285  return false;
1286 
1287  return true;
1288 }
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 750 of file LArHierarchyHelper.h.

Referenced by GetCompleteness(), and GetPurity().

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

Matched reco nodes.

Definition at line 751 of file LArHierarchyHelper.h.

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

SelectedRecoHitsMap lar_content::LArHierarchyHelper::MCMatches::m_selectedRecoHitsMap
private

Map storing the selected CaloHits for a given reco node.

Definition at line 753 of file LArHierarchyHelper.h.

Referenced by AddRecoMatch(), and GetSelectedRecoHits().

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

Number of shared hits for each match.

Definition at line 752 of file LArHierarchyHelper.h.

Referenced by AddRecoMatch(), and GetSharedHits().


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