9 #include "Pandora/AlgorithmHeaders.h" 18 AmbiguousDeltaRayTool::AmbiguousDeltaRayTool() : m_maxGoodMatchReducedChiSquared(1.
f)
28 if (PandoraContentApi::GetSettings(*m_pParentAlgorithm)->ShouldDisplayAlgorithmInfo())
29 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() <<
std::endl;
44 ClusterSet usedClusters;
45 ClusterSet usedKeyClusters;
48 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
50 if (usedKeyClusters.count(pKeyCluster))
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);
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);
128 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
131 return STATUS_CODE_SUCCESS;
std::vector< ProtoParticle > ProtoParticleVector
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 GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
std::vector< Element > ElementList
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
ThreeViewDeltaRayMatchingAlgorithm class.
static int max(int a, int b)
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool CreatePfos(ProtoParticleVector &protoParticleVector)
Create delta ray pfos maxmising completeness by searching for and merging in any stray clusters...
float m_maxGoodMatchReducedChiSquared
The maximum reduced chi squared value of a good 1:1:1 match.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
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...
QTextStream & endl(QTextStream &s)
bool Run(ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.