29 std::cout <<
"----> Running Algorithm Tool: " << this->
GetInstanceName() <<
", " << this->
GetType() << std::endl;
42 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
48 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
50 if (usedKeyClusters.count(pKeyCluster))
53 TensorType::ElementList elementList;
54 overlapTensor.GetConnectedElements(pKeyCluster,
true, elementList);
56 for (
const TensorType::Element &element : elementList)
57 usedKeyClusters.insert(element.GetClusterU());
59 if (elementList.size() < 2)
65 if (!protoParticleVector.empty())
80 unsigned int highestHitCount(0);
81 float bestChiSquared(std::numeric_limits<float>::max());
82 const Cluster *pBestClusterU(
nullptr), *pBestClusterV(
nullptr), *pBestClusterW(
nullptr);
84 for (
const TensorType::Element &element : elementList)
86 const Cluster *
const pClusterU(element.GetClusterU()), *
const pClusterV(element.GetClusterV()), *
const pClusterW(element.GetClusterW());
88 if (usedClusters.count(pClusterU) || usedClusters.count(pClusterV) || usedClusters.count(pClusterW))
91 const float chiSquared(element.GetOverlapResult().GetReducedChi2());
96 const unsigned int hitSum(pClusterU->GetNCaloHits() + pClusterV->GetNCaloHits() + pClusterW->
GetNCaloHits());
98 if ((hitSum > highestHitCount) || ((hitSum == highestHitCount) && (chiSquared < bestChiSquared)))
100 bestChiSquared = chiSquared;
101 highestHitCount = hitSum;
102 pBestClusterU = pClusterU;
103 pBestClusterV = pClusterV;
104 pBestClusterW = pClusterW;
108 if (pBestClusterU && pBestClusterV && pBestClusterW)
111 usedClusters.insert(pBestClusterU);
112 usedClusters.insert(pBestClusterV);
113 usedClusters.insert(pBestClusterW);
119 protoParticleVector.push_back(protoParticle);
131 return STATUS_CODE_SUCCESS;
#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.
float m_maxGoodMatchReducedChiSquared
The maximum reduced chi squared value of a good 1:1:1 match.
AmbiguousDeltaRayTool()
Default constructor.
bool Run(ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void ExamineConnectedElements(TensorType &overlapTensor) const
Identify ambiguous matches (e.g. 3:2:1) and, if possible, create pfos out of the best 1:1:1 cluster m...
void PickOutGoodMatches(const TensorType::ElementList &elementList, pandora::ClusterSet &usedClusters, ProtoParticleVector &protoParticleVector) const
Identify the best 1:1:1 match in a group of connected elements and from it create a pfo.
ThreeViewDeltaRayMatchingAlgorithm::MatchingType::TensorType TensorType
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
bool CreatePfos(ProtoParticleVector &protoParticleVector)
Create delta ray pfos maxmising completeness by searching for and merging in any stray clusters.
ThreeViewDeltaRayMatchingAlgorithm class.
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
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.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::vector< ProtoParticle > ProtoParticleVector
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
std::vector< const Cluster * > ClusterVector
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.