9 #include "Pandora/AlgorithmHeaders.h"
20 ConnectedRemnantsTool::ConnectedRemnantsTool() : m_maxClusterSeparation(10.f)
28 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
29 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
38 return (particlesMade || mergesMade);
46 ClusterSet usedClusters;
50 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
52 if (!pKeyCluster->IsAvailable())
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())
108 throw StatusCodeException(STATUS_CODE_FAILURE);
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)
145 PANDORA_RETURN_RESULT_IF_AND_IF(
146 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxClusterSeparation",
m_maxClusterSeparation));
148 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.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
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.
BEGIN_PROLOG could also be cout
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.