9 #include "Helpers/MCParticleHelper.h"
11 #include "Objects/CaloHit.h"
12 #include "Objects/Cluster.h"
13 #include "Objects/MCParticle.h"
15 #include "Pandora/PdgTable.h"
16 #include "Pandora/StatusCodes.h"
32 m_minPrimaryGoodHits(15),
33 m_minHitsForGoodView(5),
34 m_minPrimaryGoodViews(2),
35 m_selectInputHits(
true),
36 m_maxPhotonPropagation(2.5f),
37 m_minHitSharingFraction(0.9f),
38 m_foldBackHierarchy(
true)
50 return fCriteria(pPrimaryMCParticle);
52 catch (
const StatusCodeException &)
66 return fCriteria(pLeadingMCParticle);
68 catch (
const StatusCodeException &)
121 const LArMCParticle *
const pLArMCParticle(dynamic_cast<const LArMCParticle *>(pMCParticle));
125 std::cout <<
"LArMCParticleHelper::GetNuanceCode - Error: Can't cast to LArMCParticle" << std::endl;
126 throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
134 if ((nuance == 0) || (nuance == 2000) || (nuance == 2001) || (nuance == 3000))
137 const int absoluteParticleId(
std::abs(pMCParticle->GetParticleId()));
138 return ((NU_E == absoluteParticleId) || (NU_MU == absoluteParticleId) || (NU_TAU == absoluteParticleId));
149 catch (
const StatusCodeException &)
164 catch (
const StatusCodeException &)
175 const MCParticle *pParentMCParticle = pMCParticle;
178 while (pParentMCParticle->GetParentList().empty() ==
false)
180 if (1 != pParentMCParticle->GetParentList().size())
181 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
183 pParentMCParticle = *(pParentMCParticle->GetParentList().begin());
194 const int absoluteParticleId(
std::abs(pMCParticle->GetParticleId()));
196 if ((E_MINUS == absoluteParticleId) || (MU_MINUS == absoluteParticleId) || (PI_PLUS == absoluteParticleId) || (K_PLUS == absoluteParticleId) ||
197 (SIGMA_MINUS == absoluteParticleId) || (SIGMA_PLUS == absoluteParticleId) || (HYPERON_MINUS == absoluteParticleId) ||
198 (PROTON == absoluteParticleId) || (PHOTON == absoluteParticleId) || (NEUTRON == absoluteParticleId))
208 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
211 trueNeutrinos.push_back(pMCParticle);
221 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
224 trueTestBeamParticles.push_back(pMCParticle);
234 const MCParticle *pParentMCParticle = pMCParticle;
236 while (pParentMCParticle->GetParentList().empty() ==
false)
238 if (1 != pParentMCParticle->GetParentList().size())
239 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
241 pParentMCParticle = *(pParentMCParticle->GetParentList().begin());
244 return pParentMCParticle;
251 for (
const MCParticle *pDaughterMCParticle : pMCParticle->GetDaughterList())
253 if (std::find(descendentMCParticleList.begin(), descendentMCParticleList.end(), pDaughterMCParticle) == descendentMCParticleList.end())
255 descendentMCParticleList.emplace_back(pDaughterMCParticle);
264 MCParticleList &leadingShowerParticles, MCParticleList &leadingNeutrons)
266 for (
const MCParticle *pDaughterMCParticle : pMCParticle->GetDaughterList())
268 if (std::find(descendentTrackParticles.begin(), descendentTrackParticles.end(), pDaughterMCParticle) == descendentTrackParticles.end())
270 const int pdg{
std::abs(pDaughterMCParticle->GetParticleId())};
271 if (
pdg == E_MINUS ||
pdg == PHOTON)
273 leadingShowerParticles.emplace_back(pDaughterMCParticle);
275 else if (
pdg == NEUTRON)
277 leadingNeutrons.emplace_back(pDaughterMCParticle);
281 descendentTrackParticles.emplace_back(pDaughterMCParticle);
292 const MCParticleList &parentMCParticleList = pMCParticle->GetParentList();
293 if (parentMCParticleList.empty())
295 if (parentMCParticleList.size() != 1)
296 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
298 const MCParticle *pParentMCParticle = *parentMCParticleList.begin();
299 if (std::find(ancestorMCParticleList.begin(), ancestorMCParticleList.end(), pParentMCParticle) == ancestorMCParticleList.end())
301 ancestorMCParticleList.push_back(pParentMCParticle);
310 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
313 mcPrimaryVector.push_back(pMCParticle);
323 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
329 mcLeadingVector.push_back(pMCParticle);
343 const MCParticle *pParentMCParticle = pMCParticle;
344 mcVector.push_back(pParentMCParticle);
346 while (!pParentMCParticle->GetParentList().empty())
348 if (1 != pParentMCParticle->GetParentList().size())
349 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
351 pParentMCParticle = *(pParentMCParticle->GetParentList().begin());
352 mcVector.push_back(pParentMCParticle);
356 for (MCParticleVector::const_reverse_iterator iter = mcVector.rbegin(), iterEnd = mcVector.rend(); iter != iterEnd; ++iter)
358 const MCParticle *
const pNextParticle = *iter;
361 return pNextParticle;
364 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
380 const MCParticle *pParentMCParticle = pMCParticle;
381 mcVector.push_back(pParentMCParticle);
383 while (!pParentMCParticle->GetParentList().empty())
385 if (1 != pParentMCParticle->GetParentList().size())
386 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
388 pParentMCParticle = *(pParentMCParticle->GetParentList().begin());
389 mcVector.push_back(pParentMCParticle);
392 int hierarchyTier(0);
393 const MCParticle *pLeadingMCParticle(
nullptr);
396 for (MCParticleVector::const_reverse_iterator iter = mcVector.rbegin(), iterEnd = mcVector.rend(); iter != iterEnd; ++iter)
398 const MCParticle *
const pNextParticle = *iter;
404 if (hierarchyTier <= hierarchyTierLimit)
405 pLeadingMCParticle = pNextParticle;
410 if (!pLeadingMCParticle)
411 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
413 return pLeadingMCParticle;
420 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
425 mcPrimaryMap[pMCParticle] = pPrimaryMCParticle;
427 catch (
const StatusCodeException &)
437 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
442 mcLeadingMap[pMCParticle] = pLeadingMCParticle;
444 catch (
const StatusCodeException &)
454 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
456 mcToSelfMap[pMCParticle] = pMCParticle;
464 ClusterList clusterList;
466 return MCParticleHelper::GetMainMCParticle(&clusterList);
474 const float momentumLhs(pLhs->GetMomentum().GetMagnitudeSquared());
475 const float momentumRhs(pRhs->GetMomentum().GetMagnitudeSquared());
477 if (std::fabs(momentumLhs - momentumRhs) > std::numeric_limits<float>::epsilon())
478 return (momentumLhs > momentumRhs);
481 if (std::fabs(pLhs->GetEnergy() - pRhs->GetEnergy()) > std::numeric_limits<float>::epsilon())
482 return (pLhs->GetEnergy() < pRhs->GetEnergy());
485 if (pLhs->GetParticleId() != pRhs->GetParticleId())
486 return (pLhs->GetParticleId() < pRhs->GetParticleId());
489 const float positionLhs(pLhs->GetVertex().GetMagnitudeSquared());
490 const float positionRhs(pRhs->GetVertex().GetMagnitudeSquared());
492 return (positionLhs < positionRhs);
500 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
504 const MCParticle *
const pHitParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
505 const MCParticle *pTargetParticle(pHitParticle);
508 if (!mcToTargetMCMap.empty())
510 MCRelationMap::const_iterator mcIter = mcToTargetMCMap.find(pHitParticle);
512 if (mcToTargetMCMap.end() == mcIter)
515 pTargetParticle = mcIter->second;
518 mcToTrueHitListMap[pTargetParticle].push_back(pCaloHit);
519 hitToMCMap[pCaloHit] = pTargetParticle;
521 catch (StatusCodeException &statusCodeException)
523 if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
524 throw statusCodeException;
541 CaloHitList selectedCaloHitList;
557 std::copy(pMCParticleList->begin(), pMCParticleList->end(), std::back_inserter(targetMCVector));
580 CaloHitList selectedCaloHitList;
596 std::copy(pMCParticleList->begin(), pMCParticleList->end(), std::back_inserter(targetMCVector));
607 for (
const MCParticle *
const pMCParticle : candidateTargets)
613 if (selectedMCParticlesToHitsMap.find(pParentMCParticle) == selectedMCParticlesToHitsMap.end())
615 CaloHitList caloHitList;
616 selectedMCParticlesToHitsMap.insert(MCContributionMap::value_type(pParentMCParticle, caloHitList));
627 pfoList,
MCContributionMapVector({selectedMCParticleToHitsMap}), pfoToReconstructable2DHitsMap, foldBackHierarchy);
636 pfoList,
MCContributionMapVector({selectedMCParticleToHitsMap}), pfoToReconstructable2DHitsMap, foldBackHierarchy);
644 for (
const ParticleFlowObject *
const pPfo : pfoList)
646 CaloHitList pfoHitList;
649 if (!pfoToReconstructable2DHitsMap.insert(PfoContributionMap::value_type(pPfo, pfoHitList)).second)
650 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
659 for (
const ParticleFlowObject *
const pPfo : pfoList)
661 CaloHitList pfoHitList;
664 if (!pfoToReconstructable2DHitsMap.insert(PfoContributionMap::value_type(pPfo, pfoHitList)).second)
665 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
675 PfoVector sortedPfos;
676 for (
const auto &mapEntry : pfoToReconstructable2DHitsMap)
677 sortedPfos.push_back(mapEntry.first);
680 for (
const ParticleFlowObject *
const pPfo : sortedPfos)
682 for (
const MCContributionMap &mcParticleToHitsMap : selectedMCParticleToHitsMaps)
685 for (
const auto &mapEntry : mcParticleToHitsMap)
686 sortedMCParticles.push_back(mapEntry.first);
687 std::sort(sortedMCParticles.begin(), sortedMCParticles.end(), PointerLessThan<MCParticle>());
689 for (
const MCParticle *
const pMCParticle : sortedMCParticles)
692 if (pfoToMCParticleHitSharingMap.find(pPfo) == pfoToMCParticleHitSharingMap.end())
694 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
696 if (mcParticleToPfoHitSharingMap.find(pMCParticle) == mcParticleToPfoHitSharingMap.end())
697 if (!mcParticleToPfoHitSharingMap.insert(MCParticleToPfoHitSharingMap::value_type(pMCParticle,
PfoToSharedHitsVector())).second)
698 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
704 if (std::any_of(mcHitPairs.begin(), mcHitPairs.end(),
706 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
708 if (std::any_of(pfoHitPairs.begin(), pfoHitPairs.end(), [&](
const PfoCaloHitListPair &pair) {
return (pair.first == pPfo); }))
709 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
712 const CaloHitList sharedHits(
715 if (!sharedHits.empty())
721 return ((a.second.size() != b.second.size()) ? a.second.size() > b.second.size()
726 return ((a.second.size() != b.second.size()) ? a.second.size() > b.second.size() :
LArPfoHelper::SortByNHits(a.first, b.first));
747 for (
const Cluster *
const pCluster : clusterList)
749 CaloHitList caloHitList;
752 if (!clusterToReconstructable2DHitsMap.insert(ClusterContributionMap::value_type(pCluster, caloHitList)).second)
753 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
765 switch (pLArMCParticle->GetProcess())
786 switch (pLArMCParticle->GetProcess())
809 switch (pLArMCParticle->GetProcess())
828 switch (pLArMCParticle->GetProcess())
850 switch (pLArMCParticle->GetProcess())
887 switch (pLArMCParticle->GetProcess())
909 switch (pLArMCParticle->GetProcess())
930 switch (pLArMCParticle->GetProcess())
946 CaloHitList sharedHits;
948 for (
const CaloHit *
const pCaloHit : hitListA)
950 if (std::find(hitListB.begin(), hitListB.end(), pCaloHit) != hitListB.end())
951 sharedHits.push_back(pCaloHit);
961 CartesianVector childDirection{pMCChild->GetEndpoint() - pMCChild->GetVertex()};
962 if (childDirection.GetMagnitude() < std::numeric_limits<float>::epsilon())
964 childDirection = childDirection.GetUnitVector();
966 const MCParticle *pMCUpstream{pMCParent};
969 CartesianVector parentDirection{pMCUpstream->GetEndpoint() - pMCUpstream->GetVertex()};
970 if (parentDirection.GetMagnitude() > std::numeric_limits<float>::epsilon())
972 parentDirection = parentDirection.GetUnitVector();
973 return parentDirection.GetDotProduct(childDirection) >= cosAngleTolerance;
977 const MCParticleList &parentList{pMCUpstream->GetParentList()};
978 const size_t size{parentList.size()};
980 pMCUpstream = parentList.front();
995 const MCContributionMapVector &selectedMCParticleToHitsMaps, CaloHitList &reconstructableCaloHitList2D,
const bool foldBackHierarchy)
1002 if (foldBackHierarchy)
1008 pfoList.push_back(pPfo);
1017 const MCContributionMapVector &selectedMCParticleToHitsMaps, CaloHitList &reconstructableCaloHitList2D,
const bool foldBackHierarchy)
1023 if (foldBackHierarchy)
1028 pfoList.push_back(pPfo);
1037 pfoList.push_back(pPfo);
1046 const PfoList &pfoList,
const MCContributionMapVector &selectedMCParticleToHitsMaps, CaloHitList &reconstructableCaloHitList2D)
1048 CaloHitList caloHitList2D;
1057 for (
const CaloHit *
const pCaloHit : caloHitList2D)
1059 bool isTargetHit(
false);
1060 for (
const MCContributionMap &mcParticleToHitsMap : selectedMCParticleToHitsMaps)
1063 for (
const MCContributionMap::value_type &mapEntry : mcParticleToHitsMap)
1065 if (std::find(mapEntry.second.begin(), mapEntry.second.end(), pCaloHit) != mapEntry.second.end())
1076 reconstructableCaloHitList2D.push_back(pCaloHit);
1085 const CaloHitList &isolatedCaloHitList{pCluster->GetIsolatedCaloHitList()};
1086 CaloHitList caloHitList;
1087 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
1088 for (
const CaloHit *pCaloHit : isolatedCaloHitList)
1089 caloHitList.push_back(pCaloHit);
1092 for (
const CaloHit *
const pCaloHit : caloHitList)
1094 bool isTargetHit{
false};
1097 for (
const MCContributionMap::value_type &mapEntry : mcParticleToHitsMap)
1099 if (std::find(mapEntry.second.begin(), mapEntry.second.end(), pCaloHit) != mapEntry.second.end())
1110 reconstructableCaloHitList2D.push_back(pCaloHit);
1117 CaloHitList &selectedCaloHitList,
const bool selectInputHits,
const float maxPhotonPropagation)
1119 if (!selectInputHits)
1121 selectedCaloHitList.insert(selectedCaloHitList.end(), pCaloHitList->begin(), pCaloHitList->end());
1125 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
1129 const MCParticle *
const pHitParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
1131 LArMCParticleHelper::MCRelationMap::const_iterator mcIter = mcToTargetMCMap.find(pHitParticle);
1133 if (mcToTargetMCMap.end() == mcIter)
1139 if (
PassMCParticleChecks(pPrimaryParticle, pPrimaryParticle, pHitParticle, maxPhotonPropagation))
1140 selectedCaloHitList.push_back(pCaloHit);
1142 catch (
const StatusCodeException &)
1152 const MCParticle *pCurrentParticle = pMCParticle;
1153 while (!pCurrentParticle->GetParentList().empty())
1155 if (pCurrentParticle->GetParentList().size() > 1)
1156 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
1158 const MCParticle *pParent = *(pCurrentParticle->GetParentList().begin());
1159 const bool found{isChargeSensitive ? pParent->GetParticleId() == pdg :
std::abs(pParent->GetParticleId()) ==
std::abs(pdg)};
1162 pCurrentParticle = pParent;
1173 MCParticleList queue;
1174 mcParticleList.emplace_back(pRoot);
1175 queue.emplace_back(pRoot);
1177 while (!queue.empty())
1179 const MCParticleList &daughters{queue.front()->GetDaughterList()};
1181 for (
const MCParticle *pDaughter : daughters)
1183 mcParticleList.emplace_back(pDaughter);
1184 queue.emplace_back(pDaughter);
1195 for (
const MCParticle *
const pMCTarget : candidateTargets)
1197 MCContributionMap::const_iterator trueHitsIter = mcToTrueHitListMap.find(pMCTarget);
1198 if (mcToTrueHitListMap.end() == trueHitsIter)
1201 const CaloHitList &caloHitList(trueHitsIter->second);
1204 CaloHitList goodCaloHitList;
1211 unsigned int nGoodViews(0);
1224 if (!selectedMCParticlesToHitsMap.insert(MCContributionMap::value_type(pMCTarget, caloHitList)).second)
1225 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
1232 CaloHitList &selectedGoodCaloHitList,
const bool selectInputHits,
const float minHitSharingFraction)
1234 if (!selectInputHits)
1236 selectedGoodCaloHitList.insert(selectedGoodCaloHitList.end(), pSelectedCaloHitList->begin(), pSelectedCaloHitList->end());
1240 for (
const CaloHit *
const pCaloHit : *pSelectedCaloHitList)
1243 for (
const auto &mapEntry : pCaloHit->GetMCParticleWeightMap())
1244 mcParticleVector.push_back(mapEntry.first);
1245 std::sort(mcParticleVector.begin(), mcParticleVector.end(), PointerLessThan<MCParticle>());
1247 MCParticleWeightMap targetWeightMap;
1249 for (
const MCParticle *
const pMCParticle : mcParticleVector)
1251 const float weight(pCaloHit->GetMCParticleWeightMap().at(pMCParticle));
1252 LArMCParticleHelper::MCRelationMap::const_iterator mcIter = mcToTargetMCMap.find(pMCParticle);
1254 if (mcToTargetMCMap.end() != mcIter)
1255 targetWeightMap[mcIter->second] += weight;
1259 for (
const auto &mapEntry : targetWeightMap)
1260 mcTargetVector.push_back(mapEntry.first);
1261 std::sort(mcTargetVector.begin(), mcTargetVector.end(), PointerLessThan<MCParticle>());
1263 const MCParticle *pBestTargetParticle(
nullptr);
1264 float bestTargetWeight(0.f), targetWeightSum(0.f);
1266 for (
const MCParticle *
const pTargetMCParticle : mcTargetVector)
1268 const float targetWeight(targetWeightMap.at(pTargetMCParticle));
1269 targetWeightSum += targetWeight;
1271 if (targetWeight > bestTargetWeight)
1273 bestTargetWeight = targetWeight;
1274 pBestTargetParticle = pTargetMCParticle;
1278 if (!pBestTargetParticle || (targetWeightSum < std::numeric_limits<float>::epsilon()) || ((bestTargetWeight / targetWeightSum) < minHitSharingFraction))
1281 selectedGoodCaloHitList.push_back(pCaloHit);
1290 for (
const MCParticle *
const pMCParticle : inputMCParticles)
1294 if (!fCriteria(pMCParticle))
1310 selectedParticles.push_back(pMCParticle);
1317 const MCParticle *
const pHitMCParticle,
const float maxPhotonPropagation)
1319 if (NEUTRON ==
std::abs(pThisMCParticle->GetParticleId()))
1322 if ((PHOTON == pThisMCParticle->GetParticleId()) && (PHOTON != pOriginalPrimary->GetParticleId()) &&
1323 (E_MINUS !=
std::abs(pOriginalPrimary->GetParticleId())))
1325 if ((pThisMCParticle->GetEndpoint() - pThisMCParticle->GetVertex()).GetMagnitude() > maxPhotonPropagation)
1329 if (pThisMCParticle == pHitMCParticle)
1332 for (
const MCParticle *
const pDaughterMCParticle : pThisMCParticle->GetDaughterList())
1334 if (
PassMCParticleChecks(pOriginalPrimary, pDaughterMCParticle, pHitMCParticle, maxPhotonPropagation))
static bool IsVisible(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is visible (i.e. long-lived charged particle)
static bool PassMCParticleChecks(const pandora::MCParticle *const pOriginalPrimary, const pandora::MCParticle *const pThisMCParticle, const pandora::MCParticle *const pHitMCParticle, const float maxPhotonPropagation)
Whether it is possible to navigate from a primary mc particle to a downstream mc particle without "pa...
unsigned int m_minPrimaryGoodViews
the minimum number of primary good views
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static bool IsNuclear(const pandora::MCParticle *const pMCParticle)
Check whether or not an MC particle comes from a nuclear interaction process.
Header file for the pfo helper class.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
bool m_selectInputHits
whether to select input hits
std::pair< const pandora::MCParticle *, pandora::CaloHitList > MCParticleCaloHitListPair
static void GetTestBeamHierarchyPfoToReconstructable2DHitsMap(const pandora::PfoList &pfoList, const MCContributionMap &selectedMCParticleToHitsMap, PfoContributionMap &pfoToReconstructable2DHitsMap, const bool foldBackHierarchy)
Get mapping from Pfo in reconstructed test beam hierarchy to reconstructable 2D hits (=good hits belo...
static bool IsPrimary(const pandora::MCParticle *const pMCParticle)
Whether a provided mc particle matches the implemented definition of being primary.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
static void GetLeadingMCParticleList(const pandora::MCParticleList *const pMCParticleList, pandora::MCParticleVector &mcLeadingVector)
Get vector of leading MC particles from an input list of MC particles.
static bool IsLeadingBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a leading beam MCParticle.
unsigned int m_minPrimaryGoodHits
the minimum number of primary good Hits
int GetNuanceCode() const
Get the nuance code.
static void GetPfoToReconstructable2DHitsMap(const pandora::PfoList &pfoList, const MCContributionMap &selectedMCParticleToHitsMap, PfoContributionMap &pfoToReconstructable2DHitsMap, const bool foldBackHierarchy)
Get mapping from Pfo to reconstructable 2D hits (=good hits belonging to a selected reconstructable M...
std::unordered_map< const pandora::CaloHit *, const pandora::MCParticle * > CaloHitToMCMap
static int GetHierarchyTier(const pandora::MCParticle *const pMCParticle)
Determine the position in the hierarchy for the MCParticle.
static void GetPfoMCParticleHitSharingMaps(const PfoContributionMap &pfoToReconstructable2DHitsMap, const MCContributionMapVector &selectedMCParticleToHitsMaps, PfoToMCParticleHitSharingMap &pfoToMCParticleHitSharingMap, MCParticleToPfoHitSharingMap &mcParticleToPfoHitSharingMap)
Get the mappings from Pfo -> pair (reconstructable MCparticles, number of reconstructable 2D hits sha...
std::size_t size(FixedBins< T, C > const &) noexcept
static const pandora::MCParticle * GetPrimaryMCParticle(const pandora::MCParticle *const pMCParticle)
Get the primary parent mc particle.
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
std::vector< PfoCaloHitListPair > PfoToSharedHitsVector
static void SelectGoodCaloHits(const pandora::CaloHitList *const pSelectedCaloHitList, const MCRelationMap &mcToTargetMCMap, pandora::CaloHitList &selectedGoodCaloHitList, const bool selectInputHits, const float minHitSharingFraction)
Apply further selection criteria to end up with a collection of "good" calo hits that can be use to d...
bool m_foldBackHierarchy
whether to fold the hierarchy back to the primary (neutrino) or leading particles (test beam) ...
static void SelectReconstructableTestBeamHierarchyMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters ¶meters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles in the relevant hierarchy that match given criteria...
static void GetMCPrimaryMap(const pandora::MCParticleList *const pMCParticleList, MCRelationMap &mcPrimaryMap)
Get mapping from individual mc particles (in a provided list) and their primary parent mc particles...
static bool IsPairProduction(const pandora::MCParticle *const pMCParticle)
Check whether or not an MC particle comes from a pair production process.
Header file for the lar monitoring helper helper class.
static const pandora::MCParticle * GetMainMCParticle(const pandora::ParticleFlowObject *const pPfo)
Find the mc particle making the largest contribution to 2D clusters in a specified pfo...
static unsigned int GetNuanceCode(const pandora::MCParticle *const pMCParticle)
Get the nuance code of an MCParticle.
unsigned int m_minHitsForGoodView
the minimum number of Hits for a good view
static const pandora::MCParticle * GetLeadingMCParticle(const pandora::MCParticle *const pMCParticle, const int hierarchyTierLimit=1)
Get the leading particle in the hierarchy, for use at ProtoDUNE.
float m_maxPhotonPropagation
the maximum photon propagation length
static void SelectParticlesByHitCount(const pandora::MCParticleVector &candidateTargets, const MCContributionMap &mcToTrueHitListMap, const MCRelationMap &mcToTargetMCMap, const PrimaryParameters ¶meters, MCContributionMap &selectedMCParticlesToHitsMap)
Filter an input vector of MCParticles to ensure they have sufficient good hits to be reconstructable...
static void CollectReconstructableTestBeamHierarchy2DHits(const pandora::ParticleFlowObject *const pPfo, const MCContributionMapVector &selectedMCParticleToHitsMaps, pandora::CaloHitList &reconstructableCaloHitList2D, const bool foldBackHierarchy)
For a given Pfo, collect the hits which are reconstructable (=good hits belonging to a selected recon...
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.
static bool IsInelasticScatter(const pandora::MCParticle *const pMCParticle)
Check whether or not an MC particle came from an inelastic scattering process.
static bool IsLeading(const pandora::MCParticle *const pMCParticle)
Whether a provided mc particle matches the implemented definition of being leading.
static void SelectReconstructableMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters ¶meters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles that match given criteria.
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
static void GetMCToSelfMap(const pandora::MCParticleList *const pMCParticleList, MCRelationMap &mcToSelfMap)
Get mapping from individual mc particles (in a provided list) to themselves (to be used when not fold...
Header file for the lar monte carlo particle helper helper class.
Header file for the cluster helper class.
static void GetMCParticleToCaloHitMatches(const pandora::CaloHitList *const pCaloHitList, const MCRelationMap &mcToTargetMCMap, CaloHitToMCMap &hitToMCMap, MCContributionMap &mcToTrueHitListMap)
Match calo hits to their parent particles.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
std::unordered_map< const pandora::Cluster *, pandora::CaloHitList > ClusterContributionMap
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
static bool IsTriggeredBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary triggered beam MCParticle.
float m_minHitSharingFraction
the minimum Hit sharing fraction
static void GetMCLeadingMap(const pandora::MCParticleList *const pMCParticleList, MCRelationMap &mcLeadingMap)
Get mapping from individual mc particles (in a provided list) and their leading parent mc particles...
static bool IsDecay(const pandora::MCParticle *const pMCParticle)
Check whether or not an MC particle comes from a decay process.
std::vector< MCContributionMap > MCContributionMapVector
static bool AreTopologicallyContinuous(const pandora::MCParticle *const pMCParent, const pandora::MCParticle *const pMCChild, const float cosAngleTolerance)
Determine if two MC particles are topologically continuous within a given tolerance. If the parent does not travel any distance, a travelling parent is sought and the comparison made between this and the child. If no travelling parent can be found, the particles are treated as continuous.
static bool IsBremsstrahlung(const pandora::MCParticle *const pMCParticle)
static void GetPrimaryMCParticleList(const pandora::MCParticleList *const pMCParticleList, pandora::MCParticleVector &mcPrimaryVector)
Get vector of primary MC particles from an input list of MC particles.
static bool DoesPrimaryMeetCriteria(const pandora::MCParticle *const pMCParticle, std::function< bool(const pandora::MCParticle *const)> fCriteria)
Returns true if passed particle whose primary meets the passed criteria.
static void GetAllAncestorMCParticles(const pandora::MCParticle *const pMCParticle, pandora::MCParticleList &ancestorMCParticleList)
Get all ancestor mc particles.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
static void CollectReconstructable2DHits(const pandora::ParticleFlowObject *const pPfo, const MCContributionMapVector &selectedMCParticleToHitsMaps, pandora::CaloHitList &reconstructableCaloHitList2D, const bool foldBackHierarchy)
For a given Pfo, collect the hits which are reconstructable (=good hits belonging to a selected recon...
static void GetTrueNeutrinos(const pandora::MCParticleList *const pMCParticleList, pandora::MCParticleVector &trueNeutrinos)
Get neutrino MC particles from an input MC particle list.
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
static bool IsCapture(const pandora::MCParticle *const pMCParticle)
Check whether or not an MC particle comes from a capture process.
static void GetIsolatedCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of isolated calo hits of a particular hit type from a list of pfos.
PrimaryParameters()
Constructor.
static void GetClusterToReconstructable2DHitsMap(const pandora::ClusterList &clusterList, const MCContributionMap &selectedMCToHitsMap, ClusterContributionMap &clusterToReconstructable2DHitsMap)
Get mapping from cluster to reconstructable 2D hits (=good hits belonging to a selected reconstructab...
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
static bool IsIonisation(const pandora::MCParticle *const pMCParticle)
Check whether or not an MC particle comes from an ionisation process.
static bool DoesLeadingMeetCriteria(const pandora::MCParticle *const pMCParticle, std::function< bool(const pandora::MCParticle *const)> fCriteria)
Returns true if passed particle whose leading meets the passed criteria.
std::vector< MCParticleCaloHitListPair > MCParticleToSharedHitsVector
static void SelectParticlesMatchingCriteria(const pandora::MCParticleVector &inputMCParticles, std::function< bool(const pandora::MCParticle *const)> fCriteria, pandora::MCParticleVector &selectedParticles, const PrimaryParameters ¶meters, const bool isTestBeam)
Select mc particles matching given criteria from an input list.
static void GetTrueTestBeamParticles(const pandora::MCParticleList *const pMCParticleList, pandora::MCParticleVector &trueTestBeamParticles)
Get triggered test beam MC particles from an input MC particle list.
static bool IsDescendentOf(const pandora::MCParticle *const pMCParticle, const int pdg, const bool isChargeSensitive=false)
Determine if the MC particle is a descendent of a particle with the given PDG code.
std::unordered_map< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoContributionMap
static void GetAllDescendentMCParticles(const pandora::MCParticle *const pMCParticle, pandora::MCParticleList &descendentMCParticleList)
Get all descendent mc particles.
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
static pandora::CaloHitList GetSharedHits(const pandora::CaloHitList &hitListA, const pandora::CaloHitList &hitListB)
Get the hits in the intersection of two hit lists.
static bool IsBeamNeutrinoFinalState(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary neutrino final state MCParticle.
static unsigned int CountHitsByType(const pandora::HitType hitType, const pandora::CaloHitList &caloHitList)
Count the number of calo hits, in a provided list, of a specified type.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap
static void GetBreadthFirstHierarchyRepresentation(const pandora::MCParticle *const pMCParticle, pandora::MCParticleList &mcParticleList)
Retrieve a linearised representation of the MC particle hierarchy in breadth first order...
static bool IsElasticScatter(const pandora::MCParticle *const pMCParticle)
Check whether or not an MC particle came from an elastic scattering process.
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true
BEGIN_PROLOG could also be cout
std::map< const pandora::ParticleFlowObject *, MCParticleToSharedHitsVector > PfoToMCParticleHitSharingMap
static bool IsNeutrino(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is a neutrino or antineutrino.
static void SelectCaloHits(const pandora::CaloHitList *const pCaloHitList, const MCRelationMap &mcToTargetMCMap, pandora::CaloHitList &selectedCaloHitList, const bool selectInputHits, const float maxPhotonPropagation)
Select a subset of calo hits representing those that represent "reconstructable" regions of the event...