29 std::cout <<
"----> Running Algorithm Tool: " << this->
GetInstanceName() <<
", " << this->
GetType() << std::endl;
41 bool particleCreated(
false);
45 particleCreated =
false;
48 overlapMatrix.GetSortedKeyClusters(sortedKeyClusters);
52 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
54 if (usedKeyClusters.count(pKeyCluster))
57 MatrixType::ElementList elementList;
58 overlapMatrix.GetConnectedElements(pKeyCluster,
true, elementList);
60 for (
const MatrixType::Element &element : elementList)
61 usedKeyClusters.insert(element.GetCluster1());
65 particleCreated =
true;
69 }
while (particleCreated);
76 unsigned int highestHitCount(0);
77 float bestChiSquared(std::numeric_limits<float>::max());
78 auto bestElementIter(elementList.end());
80 for (
auto iter = elementList.begin(); iter != elementList.end(); ++iter)
82 const MatrixType::Element &element(*iter);
83 const float chiSquared(element.GetOverlapResult().GetReducedChiSquared());
84 const Cluster *
const pCluster1(element.GetCluster1()), *
const pCluster2(element.GetCluster2());
85 const unsigned int hitSum(pCluster1->GetNCaloHits() + pCluster2->
GetNCaloHits());
87 if ((hitSum > highestHitCount) || ((hitSum == highestHitCount) && (chiSquared < bestChiSquared)))
89 bestChiSquared = chiSquared;
90 highestHitCount = hitSum;
91 bestElementIter = iter;
95 if (bestElementIter != elementList.end())
108 return STATUS_CODE_SUCCESS;
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
TwoViewDeltaRayMatchingAlgorithm::MatchingType::MatrixType MatrixType
bool Run(TwoViewDeltaRayMatchingAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
Run the algorithm tool.
void ExamineConnectedElements(MatrixType &overlapMatrix) const
Identify ambiguous matches (e.g. 3:2:1) and, if possible, create pfos out of the best 1:1:1 cluster m...
TwoViewAmbiguousDeltaRayTool()
Default constructor.
bool PickOutGoodMatches(const MatrixType::ElementList &elementList) const
Identify the best 1:1:1 match in a group of connected elements and from it create a pfo.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
TwoViewDeltaRayMatchingAlgorithm class.
bool CreatePfo(const MatrixType::Element &element)
Create delta ray pfos out of a given element, merging the third view clusters together and adding in ...
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.
std::vector< const Cluster * > ClusterVector
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.