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

MatchInfo class. More...

#include "LArHierarchyHelper.h"

Public Member Functions

 MatchInfo (const MCHierarchy &mcHierarchy, const RecoHierarchy &recoHierarchy)
 Default constructor. More...
 
 MatchInfo (const MCHierarchy &mcHierarchy, const RecoHierarchy &recoHierarchy, const QualityCuts &qualityCuts)
 Constructor. More...
 
void Match ()
 Match the nodes in the MC and reco hierarchies. More...
 
const MCMatchesVectorGetMatches (const pandora::MCParticle *const pRoot) const
 Retrieve the vector of matches (this will include null matches - i.e. MC nodes with no corresponding reco) More...
 
const RecoHierarchy::NodeVectorGetUnmatchedReco () const
 Retrieve the vector of unmatched reco nodes. More...
 
unsigned int GetNMCNodes (const pandora::MCParticle *const pRoot) const
 Retrieve the number of MC nodes available to match. More...
 
unsigned int GetNNeutrinoMCNodes (const pandora::MCParticle *const pRoot) const
 Retrieve the number of neutrino interaction derived MC nodes available to match. More...
 
unsigned int GetNCosmicRayMCNodes (const pandora::MCParticle *const pRoot) const
 Retrieve the number of cosmic ray derived MC nodes available to match. More...
 
unsigned int GetNTestBeamMCNodes (const pandora::MCParticle *const pRoot) const
 Retrieve the number of test beam derived MC nodes available to match. More...
 
const MCHierarchyGetMCHierarchy () const
 Retrieve the MC hierarchy used for the matching. More...
 
const RecoHierarchyGetRecoHierarchy () const
 Retrieve the reco hierarchy used for the matching. More...
 
void GetRootMCParticles (pandora::MCParticleList &rootMCParticles) const
 Retrieve the root MC particles of the interaction hierarchies. More...
 
const QualityCutsGetQualityCuts () const
 Retrieve the quality cuts for matching. More...
 
const pandora::CaloHitList GetSelectedRecoHits (const RecoHierarchy::Node *pRecoNode, const pandora::CaloHitList &allMCHits) const
 Get the selected reco node hits that are contained in the allMCHits list. More...
 
void Print (const MCHierarchy &mcHierarchy) const
 Prints information about which reco nodes are matched to the MC nodes, information about hit sharing, purity and completeness. More...
 

Private Attributes

const MCHierarchym_mcHierarchy
 The MC hierarchy for the matching procedure. More...
 
const RecoHierarchym_recoHierarchy
 The Reco hierarchy for the matching procedure. More...
 
InteractionInfo m_matches
 The map between an interaction and the vector of good matches from MC to reco. More...
 
RecoHierarchy::NodeVector m_unmatchedReco
 The vector of unmatched reco nodes. More...
 
QualityCuts m_qualityCuts
 The quality cuts to be applied to matches. More...
 

Detailed Description

MatchInfo class.

Definition at line 762 of file LArHierarchyHelper.h.

Constructor & Destructor Documentation

lar_content::LArHierarchyHelper::MatchInfo::MatchInfo ( const MCHierarchy mcHierarchy,
const RecoHierarchy recoHierarchy 
)

Default constructor.

Parameters
mcHierarchyThe MC hierarchy
recoHierarchyThe reco hierarchy

Definition at line 1293 of file LArHierarchyHelper.cc.

1293  :
1294  MatchInfo(mcHierarchy, recoHierarchy, QualityCuts())
1295 {
1296 }
MatchInfo(const MCHierarchy &mcHierarchy, const RecoHierarchy &recoHierarchy)
Default constructor.
lar_content::LArHierarchyHelper::MatchInfo::MatchInfo ( const MCHierarchy mcHierarchy,
const RecoHierarchy recoHierarchy,
const QualityCuts qualityCuts 
)

Constructor.

Parameters
mcHierarchyThe MC hierarchy
recoHierarchyThe reco hierarchy
qualityCutsThe quality cuts to be applied to matched nodes

Definition at line 1300 of file LArHierarchyHelper.cc.

References m_qualityCuts, and m_recoHierarchy.

1300  :
1301  m_mcHierarchy{mcHierarchy},
1302  m_recoHierarchy{recoHierarchy},
1303  m_qualityCuts{qualityCuts}
1304 {
1305 }
QualityCuts m_qualityCuts
The quality cuts to be applied to matches.
const MCHierarchy & m_mcHierarchy
The MC hierarchy for the matching procedure.
const RecoHierarchy & m_recoHierarchy
The Reco hierarchy for the matching procedure.

Member Function Documentation

const LArHierarchyHelper::MCMatchesVector & lar_content::LArHierarchyHelper::MatchInfo::GetMatches ( const pandora::MCParticle *const  pRoot) const
inline

Retrieve the vector of matches (this will include null matches - i.e. MC nodes with no corresponding reco)

Parameters
pRootThe root of the interaction hierarchy
Returns
The vector of matches

Definition at line 1052 of file LArHierarchyHelper.h.

Referenced by Print(), lar_content::HierarchyValidationAlgorithm::Run(), and lar_content::HierarchyMonitoringAlgorithm::Run().

1053 {
1054  if (m_matches.find(pRoot) == m_matches.end())
1055  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
1056 
1057  return m_matches.at(pRoot);
1058 }
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
const LArHierarchyHelper::MCHierarchy & lar_content::LArHierarchyHelper::MatchInfo::GetMCHierarchy ( ) const
inline

Retrieve the MC hierarchy used for the matching.

Returns
The MCHierarchy used for matching

Definition at line 1069 of file LArHierarchyHelper.h.

Referenced by lar_content::HierarchyMonitoringAlgorithm::Run().

1070 {
1071  return m_mcHierarchy;
1072 }
const MCHierarchy & m_mcHierarchy
The MC hierarchy for the matching procedure.
unsigned int lar_content::LArHierarchyHelper::MatchInfo::GetNCosmicRayMCNodes ( const pandora::MCParticle *const  pRoot) const

Retrieve the number of cosmic ray derived MC nodes available to match.

Parameters
pRootThe root of the interaction hierarchy
Returns
The number of MC nodes available to match

Definition at line 1460 of file LArHierarchyHelper.cc.

References m_matches.

Referenced by Print().

1461 {
1462  if (m_matches.find(pRoot) == m_matches.end())
1463  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1464 
1465  unsigned int nNodes{0};
1466  for (const MCMatches &match : m_matches.at(pRoot))
1467  {
1468  const MCHierarchy::Node *pNode{match.GetMC()};
1469  if (pNode->IsCosmicRay())
1470  ++nNodes;
1471  }
1472 
1473  return nNodes;
1474 }
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
unsigned int lar_content::LArHierarchyHelper::MatchInfo::GetNMCNodes ( const pandora::MCParticle *const  pRoot) const

Retrieve the number of MC nodes available to match.

Parameters
pRootThe root of the interaction hierarchy
Returns
The number of MC nodes available to match

Definition at line 1432 of file LArHierarchyHelper.cc.

References m_matches.

Referenced by lar_content::HierarchyValidationAlgorithm::Run().

1433 {
1434  if (m_matches.find(pRoot) == m_matches.end())
1435  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1436 
1437  return static_cast<unsigned int>(m_matches.at(pRoot).size());
1438 }
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
unsigned int lar_content::LArHierarchyHelper::MatchInfo::GetNNeutrinoMCNodes ( const pandora::MCParticle *const  pRoot) const

Retrieve the number of neutrino interaction derived MC nodes available to match.

Parameters
pRootThe root of the interaction hierarchy
Returns
The number of MC nodes available to match

Definition at line 1442 of file LArHierarchyHelper.cc.

References m_matches.

Referenced by Print().

1443 {
1444  if (m_matches.find(pRoot) == m_matches.end())
1445  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1446 
1447  unsigned int nNodes{0};
1448  for (const MCMatches &match : m_matches.at(pRoot))
1449  {
1450  const MCHierarchy::Node *pNode{match.GetMC()};
1451  if (!(pNode->IsCosmicRay() || pNode->IsTestBeamParticle()))
1452  ++nNodes;
1453  }
1454 
1455  return nNodes;
1456 }
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
unsigned int lar_content::LArHierarchyHelper::MatchInfo::GetNTestBeamMCNodes ( const pandora::MCParticle *const  pRoot) const

Retrieve the number of test beam derived MC nodes available to match.

Parameters
pRootThe root of the interaction hierarchy
Returns
The number of MC nodes available to match

Definition at line 1478 of file LArHierarchyHelper.cc.

References m_matches.

Referenced by Print().

1479 {
1480  if (m_matches.find(pRoot) == m_matches.end())
1481  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
1482 
1483  unsigned int nNodes{0};
1484  for (const MCMatches &match : m_matches.at(pRoot))
1485  {
1486  const MCHierarchy::Node *pNode{match.GetMC()};
1487  if (pNode->IsTestBeamParticle())
1488  ++nNodes;
1489  }
1490 
1491  return nNodes;
1492 }
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
const LArHierarchyHelper::QualityCuts & lar_content::LArHierarchyHelper::MatchInfo::GetQualityCuts ( ) const
inline

Retrieve the quality cuts for matching.

Returns
The quality cuts

Definition at line 1083 of file LArHierarchyHelper.h.

Referenced by lar_content::HierarchyMonitoringAlgorithm::Run(), and lar_content::HierarchyValidationAlgorithm::Run().

1084 {
1085  return m_qualityCuts;
1086 }
QualityCuts m_qualityCuts
The quality cuts to be applied to matches.
const LArHierarchyHelper::RecoHierarchy & lar_content::LArHierarchyHelper::MatchInfo::GetRecoHierarchy ( ) const
inline

Retrieve the reco hierarchy used for the matching.

Returns
The RecoHierarchy used for matching

Definition at line 1076 of file LArHierarchyHelper.h.

Referenced by lar_content::HierarchyMonitoringAlgorithm::Run(), and lar_content::HierarchyValidationAlgorithm::Run().

1077 {
1078  return m_recoHierarchy;
1079 }
const RecoHierarchy & m_recoHierarchy
The Reco hierarchy for the matching procedure.
void lar_content::LArHierarchyHelper::MatchInfo::GetRootMCParticles ( pandora::MCParticleList &  rootMCParticles) const

Retrieve the root MC particles of the interaction hierarchies.

Parameters
rootMCParticlesThe output list of root MC particles

Definition at line 1638 of file LArHierarchyHelper.cc.

References m_matches.

Referenced by lar_content::HierarchyMonitoringAlgorithm::Run(), and lar_content::HierarchyValidationAlgorithm::Run().

1639 {
1640  for (auto iter = m_matches.begin(); iter != m_matches.end(); ++iter)
1641  rootMCParticles.emplace_back(iter->first);
1642 }
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
const CaloHitList lar_content::LArHierarchyHelper::MatchInfo::GetSelectedRecoHits ( const RecoHierarchy::Node pRecoNode,
const pandora::CaloHitList &  allMCHits 
) const

Get the selected reco node hits that are contained in the allMCHits list.

Parameters
pRecoNodeThe reco node pointer
allMCHitsThe CaloHit list of all of the MC particles that will be used for the selection
Returns
The selected reco calo hits

Definition at line 1496 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetCaloHits().

Referenced by Match().

1497 {
1498  // Select all of the reco node hit Ids that overlap with the allMCHits Ids
1499  CaloHitList selectedHits;
1500  if (pRecoNode)
1501  {
1502  const CaloHitList recoHits{pRecoNode->GetCaloHits()};
1503  for (const CaloHit *pRecoHit : recoHits)
1504  {
1505  const int recoId = reinterpret_cast<intptr_t>(pRecoHit->GetParentAddress());
1506  for (const CaloHit *pMCHit : allMCHits)
1507  {
1508  const int mcId = reinterpret_cast<intptr_t>(pMCHit->GetParentAddress());
1509  if (recoId == mcId)
1510  {
1511  selectedHits.emplace_back(pRecoHit);
1512  break;
1513  }
1514  }
1515  }
1516  }
1517  return selectedHits;
1518 }
const LArHierarchyHelper::RecoHierarchy::NodeVector & lar_content::LArHierarchyHelper::MatchInfo::GetUnmatchedReco ( ) const
inline

Retrieve the vector of unmatched reco nodes.

Definition at line 1062 of file LArHierarchyHelper.h.

Referenced by Print().

1063 {
1064  return m_unmatchedReco;
1065 }
RecoHierarchy::NodeVector m_unmatchedReco
The vector of unmatched reco nodes.
void lar_content::LArHierarchyHelper::MatchInfo::Match ( )

Match the nodes in the MC and reco hierarchies.

Definition at line 1309 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCMatches::AddRecoMatch(), util::begin(), util::end(), lar_content::LArHierarchyHelper::MCHierarchy::Node::GetCaloHits(), lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetCaloHits(), lar_content::LArHierarchyHelper::MCHierarchy::GetFlattenedNodes(), lar_content::LArHierarchyHelper::RecoHierarchy::GetFlattenedNodes(), lar_content::LArHierarchyHelper::MCMatches::GetMC(), lar_content::LArHierarchyHelper::MCHierarchy::GetRootMCParticles(), lar_content::LArHierarchyHelper::RecoHierarchy::GetRootPfos(), GetSelectedRecoHits(), m_matches, m_mcHierarchy, m_qualityCuts, m_recoHierarchy, lar_content::LArHierarchyHelper::QualityCuts::m_selectRecoHits, and m_unmatchedReco.

Referenced by lar_content::LArHierarchyHelper::MatchHierarchies().

1310 {
1311  MCParticleList rootMCParticles;
1312  m_mcHierarchy.GetRootMCParticles(rootMCParticles);
1313  PfoList rootPfos;
1314  m_recoHierarchy.GetRootPfos(rootPfos);
1315  std::map<const MCHierarchy::Node *, MCMatches> mcToMatchMap;
1316 
1317  for (const MCParticle *const pRootMC : rootMCParticles)
1318  {
1319  MCHierarchy::NodeVector mcNodes;
1320  m_mcHierarchy.GetFlattenedNodes(pRootMC, mcNodes);
1321 
1322  // Get all of the hits from the MC nodes (for selecting reco hits)
1323  CaloHitList allMCHits;
1324  for (const MCHierarchy::Node *pMCNode : mcNodes)
1325  {
1326  const CaloHitList &mcHits{pMCNode->GetCaloHits()};
1327  allMCHits.insert(allMCHits.begin(), mcHits.begin(), mcHits.end());
1328  }
1329 
1330  for (const ParticleFlowObject *const pRootPfo : rootPfos)
1331  {
1332  RecoHierarchy::NodeVector recoNodes;
1333  m_recoHierarchy.GetFlattenedNodes(pRootPfo, recoNodes);
1334 
1335  std::sort(mcNodes.begin(), mcNodes.end(),
1336  [](const MCHierarchy::Node *lhs, const MCHierarchy::Node *rhs)
1337  { return lhs->GetCaloHits().size() > rhs->GetCaloHits().size(); });
1338  std::sort(recoNodes.begin(), recoNodes.end(),
1339  [](const RecoHierarchy::Node *lhs, const RecoHierarchy::Node *rhs)
1340  { return lhs->GetCaloHits().size() > rhs->GetCaloHits().size(); });
1341 
1342  for (const RecoHierarchy::Node *pRecoNode : recoNodes)
1343  {
1344  // Get the selected list of reco hits that overlap with all of the MC hits
1345  // or just use all of the hits in the reco node
1346  const CaloHitList selectedRecoHits = (m_qualityCuts.m_selectRecoHits == true)
1348  : pRecoNode->GetCaloHits();
1349 
1350  const MCHierarchy::Node *pBestNode{nullptr};
1351  size_t bestSharedHits{0};
1352  for (const MCHierarchy::Node *pMCNode : mcNodes)
1353  {
1354  if (!pMCNode->IsReconstructable())
1355  continue;
1356  const CaloHitList &mcHits{pMCNode->GetCaloHits()};
1357  CaloHitVector intersection;
1358  std::set_intersection(
1359  mcHits.begin(), mcHits.end(), selectedRecoHits.begin(), selectedRecoHits.end(), std::back_inserter(intersection));
1360 
1361  if (!intersection.empty())
1362  {
1363  const size_t sharedHits{intersection.size()};
1364  if (sharedHits > bestSharedHits)
1365  {
1366  bestSharedHits = sharedHits;
1367  pBestNode = pMCNode;
1368  }
1369  }
1370  }
1371  if (pBestNode)
1372  {
1373  auto iter{mcToMatchMap.find(pBestNode)};
1374  if (iter != mcToMatchMap.end())
1375  {
1376  MCMatches &match(iter->second);
1377  match.AddRecoMatch(pRecoNode, static_cast<int>(bestSharedHits), selectedRecoHits);
1378  }
1379  else
1380  {
1381  MCMatches match(pBestNode);
1382  match.AddRecoMatch(pRecoNode, static_cast<int>(bestSharedHits), selectedRecoHits);
1383  mcToMatchMap.insert(std::make_pair(pBestNode, match));
1384  }
1385  }
1386  else
1387  {
1388  m_unmatchedReco.emplace_back(pRecoNode);
1389  }
1390  }
1391  }
1392  }
1393 
1394  for (auto [pMCNode, matches] : mcToMatchMap)
1395  {
1396  // We need to figure out which MC interaction hierarchy the matches belongs to
1397  for (const MCParticle *const pRootMC : rootMCParticles)
1398  {
1399  MCHierarchy::NodeVector mcNodes;
1400  m_mcHierarchy.GetFlattenedNodes(pRootMC, mcNodes);
1401  if (std::find(mcNodes.begin(), mcNodes.end(), pMCNode) != mcNodes.end())
1402  {
1403  m_matches[pRootMC].emplace_back(matches);
1404  break;
1405  }
1406  }
1407  }
1408 
1409  const auto predicate = [](const MCMatches &lhs, const MCMatches &rhs)
1410  { return lhs.GetMC()->GetCaloHits().size() > rhs.GetMC()->GetCaloHits().size(); };
1411 
1412  for (const MCParticle *const pRootMC : rootMCParticles)
1413  {
1414  std::sort(m_matches[pRootMC].begin(), m_matches[pRootMC].end(), predicate);
1415 
1416  MCHierarchy::NodeVector mcNodes;
1417  m_mcHierarchy.GetFlattenedNodes(pRootMC, mcNodes);
1418 
1419  for (const MCHierarchy::Node *pMCNode : mcNodes)
1420  {
1421  if (pMCNode->IsReconstructable() && mcToMatchMap.find(pMCNode) == mcToMatchMap.end())
1422  {
1423  MCMatches match(pMCNode);
1424  m_matches[pRootMC].emplace_back(match);
1425  }
1426  }
1427  }
1428 }
void GetRootMCParticles(pandora::MCParticleList &rootMCParticles) const
Retrieve the root MC particles of the interaction hierarchies.
void GetFlattenedNodes(const pandora::MCParticle *const pRoot, NodeVector &nodeVector) const
Retrieve a flat vector of the ndoes in the hierarchy.
QualityCuts m_qualityCuts
The quality cuts to be applied to matches.
const pandora::CaloHitList GetSelectedRecoHits(const RecoHierarchy::Node *pRecoNode, const pandora::CaloHitList &allMCHits) const
Get the selected reco node hits that are contained in the allMCHits list.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
const bool m_selectRecoHits
Whether to only use reco hits that overlap with the MC particle hits.
const MCHierarchy & m_mcHierarchy
The MC hierarchy for the matching procedure.
const RecoHierarchy & m_recoHierarchy
The Reco hierarchy for the matching procedure.
void GetRootPfos(pandora::PfoList &rootPfos) const
Retrieve the root particle flow objects of the interaction hierarchies.
void GetFlattenedNodes(const pandora::ParticleFlowObject *const pRoot, NodeVector &nodeVector) const
Retrieve a flat vector of the nodes in the hierarchy.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
RecoHierarchy::NodeVector m_unmatchedReco
The vector of unmatched reco nodes.
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
void lar_content::LArHierarchyHelper::MatchInfo::Print ( const MCHierarchy mcHierarchy) const

Prints information about which reco nodes are matched to the MC nodes, information about hit sharing, purity and completeness.

Parameters
mcHierarchyThe MC hierarchy

Definition at line 1522 of file LArHierarchyHelper.cc.

References f, lar_content::LArInteractionTypeHelper::GetInteractionDescriptor(), lar_content::LArHierarchyHelper::MCHierarchy::Node::GetLeadingMCParticle(), GetMatches(), GetNCosmicRayMCNodes(), GetNNeutrinoMCNodes(), GetNTestBeamMCNodes(), lar_content::LArHierarchyHelper::MCHierarchy::Node::GetParticleId(), lar_content::LArHierarchyHelper::MCHierarchy::GetRootMCParticles(), GetUnmatchedReco(), lar_content::LArMCParticleHelper::IsBeamParticle(), lar_content::LArMCParticleHelper::IsCosmicRay(), lar_content::LArMCParticleHelper::IsNeutrino(), m_matches, lar_content::LArMCParticleHelper::SortByMomentum(), and util::to_string().

Referenced by lar_content::HierarchyMonitoringAlgorithm::Run(), and lar_content::HierarchyValidationAlgorithm::Run().

1523 {
1524  MCParticleList rootMCParticles;
1525  mcHierarchy.GetRootMCParticles(rootMCParticles);
1526 
1527  for (const MCParticle *const pRootMC : rootMCParticles)
1528  {
1529  const LArHierarchyHelper::MCMatchesVector &matches{this->GetMatches(pRootMC)};
1530 
1531  MCParticleList primaries;
1532  for (const LArHierarchyHelper::MCMatches &match : matches)
1533  {
1534  const LArHierarchyHelper::MCHierarchy::Node *pMCNode{match.GetMC()};
1535  if (pMCNode->GetHierarchyTier() == 1)
1536  {
1537  const MCParticle *const pLeadingMC{pMCNode->GetLeadingMCParticle()};
1538  primaries.emplace_back(pLeadingMC);
1539  }
1540  }
1541  if (primaries.size() == 0)
1542  continue;
1543  primaries.sort(LArMCParticleHelper::SortByMomentum);
1544  const InteractionDescriptor descriptor{LArInteractionTypeHelper::GetInteractionDescriptor(primaries)};
1545 
1546  const LArMCParticle *const pLArRoot{dynamic_cast<const LArMCParticle *const>(pRootMC)};
1547  if (pLArRoot)
1548  std::cout << "=== MC Interaction : PDG " << std::to_string(pLArRoot->GetParticleId())
1549  << " Energy: " << std::to_string(pLArRoot->GetEnergy()) << " Type: " << descriptor.ToString() << std::endl;
1550  else
1551  std::cout << "=== MC Interaction : PDG " << std::to_string(pRootMC->GetParticleId())
1552  << " Energy: " << std::to_string(pRootMC->GetEnergy()) << " Type: " << descriptor.ToString() << std::endl;
1553 
1554  unsigned int nNeutrinoMCParticles{this->GetNNeutrinoMCNodes(pRootMC)}, nNeutrinoRecoParticles{0};
1555  unsigned int nCosmicMCParticles{this->GetNCosmicRayMCNodes(pRootMC)}, nCosmicRecoParticles{0};
1556  unsigned int nTestBeamMCParticles{this->GetNTestBeamMCNodes(pRootMC)}, nTestBeamRecoParticles{0};
1557  std::cout << " === Matches ===" << std::endl;
1558  std::cout << std::fixed << std::setprecision(2);
1559  for (const MCMatches &match : m_matches.at(pRootMC))
1560  {
1561  const MCHierarchy::Node *pMCNode{match.GetMC()};
1562  const int pdg{pMCNode->GetParticleId()};
1563  const size_t mcHits{pMCNode->GetCaloHits().size()};
1564  const std::string tag{pMCNode->IsTestBeamParticle() ? "(Beam) " : pMCNode->IsCosmicRay() ? "(Cosmic) " : ""};
1565  std::cout << " MC " << tag << pdg << " hits " << mcHits << std::endl;
1566  const RecoHierarchy::NodeVector &nodeVector{match.GetRecoMatches()};
1567 
1568  for (const RecoHierarchy::Node *pRecoNode : nodeVector)
1569  {
1570  const CaloHitList recoHits = match.GetSelectedRecoHits(pRecoNode);
1571  const unsigned int nRecoHits{static_cast<unsigned int>(recoHits.size())};
1572  const unsigned int sharedHits{match.GetSharedHits(pRecoNode)};
1573  const float purity{match.GetPurity(pRecoNode)};
1574  const float completeness{match.GetCompleteness(pRecoNode)};
1575  if (completeness > 0.1f)
1576  std::cout << " Matched " << sharedHits << " out of " << nRecoHits << " with purity " << purity << " and completeness "
1577  << completeness << std::endl;
1578  else
1579  std::cout << " (Below threshold) " << sharedHits << " out of " << nRecoHits << " with purity " << purity
1580  << " and completeness " << completeness << std::endl;
1581  }
1582  if (nodeVector.empty())
1583  {
1584  std::cout << " Unmatched" << std::endl;
1585  }
1586  else if (match.IsQuality(this->GetQualityCuts()))
1587  {
1588  if (pMCNode->IsTestBeamParticle())
1589  ++nTestBeamRecoParticles;
1590  else if (pMCNode->IsCosmicRay())
1591  ++nCosmicRecoParticles;
1592  else
1593  ++nNeutrinoRecoParticles;
1594  }
1595  }
1596 
1597  if (LArMCParticleHelper::IsNeutrino(pRootMC))
1598  {
1599  std::cout << " Neutrino Interaction Summary:" << std::endl;
1600  if (nNeutrinoMCParticles)
1601  {
1602  std::cout << " Good final state particles: " << nNeutrinoRecoParticles << " of " << nNeutrinoMCParticles << " : "
1603  << (100 * nNeutrinoRecoParticles / static_cast<float>(nNeutrinoMCParticles)) << "%" << std::endl;
1604  }
1605  }
1606  else if (LArMCParticleHelper::IsCosmicRay(pRootMC))
1607  {
1608  std::cout << " Cosmic Ray Interaction Summary:" << std::endl;
1609  std::cout << std::fixed << std::setprecision(1);
1610  if (nCosmicMCParticles)
1611  {
1612  std::cout << " Good cosmics: " << nCosmicRecoParticles << " of " << nCosmicMCParticles << " : "
1613  << (100 * nCosmicRecoParticles / static_cast<float>(nCosmicMCParticles)) << "%" << std::endl;
1614  }
1615  }
1616  else if (LArMCParticleHelper::IsBeamParticle(pRootMC))
1617  {
1618  std::cout << " Test Beam Interaction Summary:" << std::endl;
1619  std::cout << std::fixed << std::setprecision(1);
1620  if (nTestBeamMCParticles)
1621  {
1622  std::cout << " Good test beam particles: " << nTestBeamRecoParticles << " of " << nTestBeamMCParticles << " : "
1623  << (100 * nTestBeamRecoParticles / static_cast<float>(nTestBeamMCParticles)) << "%" << std::endl;
1624  }
1625  if (nCosmicMCParticles)
1626  {
1627  std::cout << " Matched cosmics: " << nCosmicRecoParticles << " of " << nCosmicMCParticles << " : "
1628  << (100 * nCosmicRecoParticles / static_cast<float>(nCosmicMCParticles)) << "%" << std::endl;
1629  }
1630  }
1631  if (!this->GetUnmatchedReco().empty())
1632  std::cout << " Unmatched reco: " << this->GetUnmatchedReco().size() << std::endl;
1633  }
1634 }
const MCMatchesVector & GetMatches(const pandora::MCParticle *const pRoot) const
Retrieve the vector of matches (this will include null matches - i.e. MC nodes with no corresponding ...
TFile f
Definition: plotHisto.C:6
unsigned int GetNTestBeamMCNodes(const pandora::MCParticle *const pRoot) const
Retrieve the number of test beam derived MC nodes available to match.
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
const RecoHierarchy::NodeVector & GetUnmatchedReco() const
Retrieve the vector of unmatched reco nodes.
std::vector< MCMatches > MCMatchesVector
unsigned int GetNNeutrinoMCNodes(const pandora::MCParticle *const pRoot) const
Retrieve the number of neutrino interaction derived MC nodes available to match.
static InteractionDescriptor GetInteractionDescriptor(const pandora::MCParticleList &mcPrimaryList)
Get the interaction descriptor of an event.
static bool IsNeutrino(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is a neutrino or antineutrino.
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
unsigned int GetNCosmicRayMCNodes(const pandora::MCParticle *const pRoot) const
Retrieve the number of cosmic ray derived MC nodes available to match.

Member Data Documentation

InteractionInfo lar_content::LArHierarchyHelper::MatchInfo::m_matches
private

The map between an interaction and the vector of good matches from MC to reco.

Definition at line 887 of file LArHierarchyHelper.h.

Referenced by GetNCosmicRayMCNodes(), GetNMCNodes(), GetNNeutrinoMCNodes(), GetNTestBeamMCNodes(), GetRootMCParticles(), Match(), and Print().

const MCHierarchy& lar_content::LArHierarchyHelper::MatchInfo::m_mcHierarchy
private

The MC hierarchy for the matching procedure.

Definition at line 885 of file LArHierarchyHelper.h.

Referenced by Match().

QualityCuts lar_content::LArHierarchyHelper::MatchInfo::m_qualityCuts
private

The quality cuts to be applied to matches.

Definition at line 889 of file LArHierarchyHelper.h.

Referenced by Match(), and MatchInfo().

const RecoHierarchy& lar_content::LArHierarchyHelper::MatchInfo::m_recoHierarchy
private

The Reco hierarchy for the matching procedure.

Definition at line 886 of file LArHierarchyHelper.h.

Referenced by Match(), and MatchInfo().

RecoHierarchy::NodeVector lar_content::LArHierarchyHelper::MatchInfo::m_unmatchedReco
private

The vector of unmatched reco nodes.

Definition at line 888 of file LArHierarchyHelper.h.

Referenced by Match().


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