9 #include "Pandora/AlgorithmHeaders.h" 20 ConnectedRemnantsTool::ConnectedRemnantsTool() :
21 m_maxClusterSeparation(10.
f)
29 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
30 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
39 return (particlesMade || mergesMade);
47 ClusterSet usedClusters;
51 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
53 if (!pKeyCluster->IsAvailable())
60 this->
GetClusters(connectedElements, usedClusters, clusterVectorU, clusterVectorV, clusterVectorW);
62 if (clusterVectorU.empty() || clusterVectorV.empty() || clusterVectorW.empty())
65 usedClusters.insert(clusterVectorU.begin(), clusterVectorU.end());
66 usedClusters.insert(clusterVectorV.begin(), clusterVectorV.end());
67 usedClusters.insert(clusterVectorW.begin(), clusterVectorW.end());
72 const Cluster *
const pClusterU = clusterVectorU.front();
73 const Cluster *
const pClusterV = clusterVectorV.front();
74 const Cluster *
const pClusterW = clusterVectorW.front();
80 protoParticleVector.push_back(protoParticle);
82 this->
FillMergeMap(pClusterU, clusterVectorU, clusterMergeMap);
83 this->
FillMergeMap(pClusterV, clusterVectorV, clusterMergeMap);
84 this->
FillMergeMap(pClusterW, clusterVectorW, clusterMergeMap);
93 for (
const TensorType::Element &element : elementList)
95 if (usedClusters.count(element.GetClusterU()) || usedClusters.count(element.GetClusterV()) || usedClusters.count(element.GetClusterW()))
98 clusterVectorU.push_back(element.GetClusterU());
99 clusterVectorV.push_back(element.GetClusterV());
100 clusterVectorW.push_back(element.GetClusterW());
108 if (clusterVector.empty())
109 throw StatusCodeException(STATUS_CODE_FAILURE);
111 for (
const Cluster *
const pSecondCluster : clusterVector)
113 if (pFirstCluster == pSecondCluster)
116 ClusterList &clusterList(clusterMergeMap[pFirstCluster]);
118 if (clusterList.end() == std::find(clusterList.begin(), clusterList.end(), pSecondCluster))
119 clusterList.push_back(pSecondCluster);
127 for (
const Cluster *
const pCluster1 : clusterVector)
129 for (
const Cluster *
const pCluster2 : clusterVector)
131 if (pCluster1 == pCluster2)
146 PANDORA_RETURN_RESULT_IF_AND_IF(
147 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxClusterSeparation",
m_maxClusterSeparation));
149 return STATUS_CODE_SUCCESS;
std::vector< ProtoParticle > ProtoParticleVector
void FindConnectedShowers(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector, ClusterMergeMap &clusterMergeMap) const
Identify candidate particles.
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
float m_maxClusterSeparation
void FillMergeMap(const pandora::Cluster *const pCluster, const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Fill map of clusters to be merged.
std::vector< Element > ElementList
Header file for the cluster helper class.
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
virtual bool MakeClusterMerges(const ClusterMergeMap &clusterMergeMap)
Merge clusters together.
void GetClusters(const TensorType::ElementList &connectedElements, const pandora::ClusterSet &usedClusters, pandora::ClusterVector &clusterVectorU, pandora::ClusterVector &clusterVectorV, pandora::ClusterVector &clusterVectorW) const
Separate connected clusters into cluster lists by view.
bool IsConnected(const pandora::ClusterVector &clusterVector) const
Check whether all clusters in a list are spatially connected.
bool Run(ThreeViewRemnantsAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
ThreeViewRemnantsAlgorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.