29 const PfoList *pMuonPfoList(
nullptr);
33 if (!pMuonPfoList || pMuonPfoList->empty())
34 return STATUS_CODE_SUCCESS;
36 const PfoList *pDeltaRayPfoList(
nullptr);
40 if (!pDeltaRayPfoList || pDeltaRayPfoList->empty())
41 return STATUS_CODE_SUCCESS;
46 PfoVector deltaRayPfoVector(pDeltaRayPfoList->begin(), pDeltaRayPfoList->end());
51 if (!pPfo->GetParentPfoList().empty())
60 this->
AssignToParentPfo(pMuonPfoList, pDeltaRayPfoList, pPfo, pParentPfo, pfoLengthMap);
63 return STATUS_CODE_SUCCESS;
81 const PfoLengthMap::const_iterator currentIter(pfoLengthMap.find(pPfo));
83 if (currentIter == pfoLengthMap.end())
88 for (
auto &entry : pfoLengthMap)
89 allPfoVector.push_back(entry.first);
91 const float lengthSquared(currentIter->second);
96 if (pTestParent == pPfo)
99 const PfoLengthMap::const_iterator testIter(pfoLengthMap.find(pTestParent));
101 if (testIter == pfoLengthMap.end())
104 if (testIter->second < lengthSquared)
107 float distance(std::numeric_limits<float>::max());
109 if (this->
GetTwoDSeparation(pPfo, pTestParent, distance) == STATUS_CODE_NOT_FOUND)
112 if (distance < bestDistance)
114 pParentPfo = pTestParent;
115 bestDistance = distance;
124 ClusterList clusterListU1, clusterListV1, clusterListW1;
125 ClusterList clusterListU2, clusterListV2, clusterListW2;
135 float numViews(0.f), distance(0.f);
137 if (!clusterListU1.empty() && !clusterListU2.empty())
143 if (!clusterListV1.empty() && !clusterListV2.empty())
149 if (!clusterListW1.empty() && !clusterListW2.empty())
155 if (numViews < std::numeric_limits<float>::epsilon())
156 return STATUS_CODE_NOT_FOUND;
158 separation = distance / numViews;
160 return STATUS_CODE_SUCCESS;
168 if (std::find(pMuonPfoList->begin(), pMuonPfoList->end(), pParentPfo) != pMuonPfoList->end())
171 if (std::find(pDeltaRayPfoList->begin(), pDeltaRayPfoList->end(), pParentPfo) != pDeltaRayPfoList->end())
178 for (
const Cluster *
const pCluster : pfoClusters)
191 const PfoLengthMap::const_iterator iter(pfoLengthMap.find(pPfoToRemove));
193 if (iter == pfoLengthMap.end())
196 pfoLengthMap.erase(iter);
213 return STATUS_CODE_SUCCESS;
Header file for the delta ray parent class.
Header file for the cluster helper class.
Header file for the pfo helper class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static pandora::StatusCode AddToPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Add a cluster to a particle flow object.
static pandora::StatusCode SetPfoParentDaughterRelationship(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pParentPfo, const pandora::ParticleFlowObject *const pDaughterPfo)
Set parent-daughter particle flow object relationship.
static pandora::StatusCode Delete(const pandora::Algorithm &algorithm, const T *const pT)
Delete an object from the current list.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
std::string m_deltaRayPfoListName
The list of reconstructed delta ray pfos.
std::map< const pandora::ParticleFlowObject *, float > PfoLengthMap
std::string m_muonPfoListName
The list of reconstructed muon pfos.
void AssignToParentPfo(const pandora::PfoList *const muonPfoList, const pandora::PfoList *const deltaRayPfoList, const pandora::ParticleFlowObject *const pPfo, const pandora::ParticleFlowObject *const pParentPfo, PfoLengthMap &pfoLengthMap) const
Apply parent-child link (if parent is a cosmic ray create parent-child link else merge the delta ray ...
pandora::StatusCode GetTwoDSeparation(const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2, float &separation) const
Get distance between two Pfos using 2D clusters.
float m_distanceForMatching
The maximum separation of a delta ray pfo from its parent.
DeltaRayParentAlgorithm()
Default constructor.
void FindParentPfo(const PfoLengthMap &pfoLengthMap, const pandora::ParticleFlowObject *const pPfo, const pandora::ParticleFlowObject *&pParentPfo) const
Identify the parent pfo of a given delta ray pfo (can be either a cosmic ray or delta ray pfo)
void InitialisePfoLengthMap(const pandora::PfoList *const muonPfoList, const pandora::PfoList *const deltaRayPfoList, PfoLengthMap &pfoLengthMap) const
Initialise the delta ray pfo length map.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
pandora::StatusCode Run()
Run the algorithm.
void UpdatePfoLengthMap(const pandora::PfoList &pfosToRemove, const pandora::ParticleFlowObject *const pPfoToAdd, PfoLengthMap &pfoLengthMap) const
Update the pfo length map after a parent-child delta ray merge.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 2D clusters.
ParticleFlowObject class.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< const ParticleFlowObject * > PfoVector
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList