29 std::cout <<
"----> Running Algorithm Tool: " << this->
GetInstanceName() <<
", " << this->
GetType() << std::endl;
38 return (particlesMade || mergesMade);
48 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
50 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
52 if (!pKeyCluster->IsAvailable())
55 TensorType::ElementList connectedElements;
56 overlapTensor.GetConnectedElements(pKeyCluster,
true, connectedElements);
59 this->
GetClusters(connectedElements, usedClusters, clusterVectorU, clusterVectorV, clusterVectorW);
61 if (clusterVectorU.empty() || clusterVectorV.empty() || clusterVectorW.empty())
64 usedClusters.insert(clusterVectorU.begin(), clusterVectorU.end());
65 usedClusters.insert(clusterVectorV.begin(), clusterVectorV.end());
66 usedClusters.insert(clusterVectorW.begin(), clusterVectorW.end());
71 const Cluster *
const pClusterU = clusterVectorU.front();
72 const Cluster *
const pClusterV = clusterVectorV.front();
73 const Cluster *
const pClusterW = clusterVectorW.front();
79 protoParticleVector.push_back(protoParticle);
81 this->
FillMergeMap(pClusterU, clusterVectorU, clusterMergeMap);
82 this->
FillMergeMap(pClusterV, clusterVectorV, clusterMergeMap);
83 this->
FillMergeMap(pClusterW, clusterVectorW, clusterMergeMap);
92 for (
const TensorType::Element &element : elementList)
94 if (usedClusters.count(element.GetClusterU()) || usedClusters.count(element.GetClusterV()) || usedClusters.count(element.GetClusterW()))
97 clusterVectorU.push_back(element.GetClusterU());
98 clusterVectorV.push_back(element.GetClusterV());
99 clusterVectorW.push_back(element.GetClusterW());
107 if (clusterVector.empty())
110 for (
const Cluster *
const pSecondCluster : clusterVector)
112 if (pFirstCluster == pSecondCluster)
115 ClusterList &clusterList(clusterMergeMap[pFirstCluster]);
117 if (clusterList.end() == std::find(clusterList.begin(), clusterList.end(), pSecondCluster))
118 clusterList.push_back(pSecondCluster);
126 for (
const Cluster *
const pCluster1 : clusterVector)
128 for (
const Cluster *
const pCluster2 : clusterVector)
130 if (pCluster1 == pCluster2)
148 return STATUS_CODE_SUCCESS;
Header file for the cluster helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
void FindConnectedShowers(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector, ClusterMergeMap &clusterMergeMap) const
Identify candidate particles.
void FillMergeMap(const pandora::Cluster *const pCluster, const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Fill map of clusters to be merged.
float m_maxClusterSeparation
ConnectedRemnantsTool()
Default constructor.
bool Run(ThreeViewRemnantsAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
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.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
virtual bool MakeClusterMerges(const ClusterMergeMap &clusterMergeMap)
Merge clusters together.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
ThreeViewRemnantsAlgorithm::MatchingType::TensorType TensorType
ThreeViewRemnantsAlgorithm class.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const std::string & GetType() const
Get the type.
const std::string & GetInstanceName() const
Get the instance name.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
std::vector< ProtoParticle > ProtoParticleVector
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.