9 #include "Pandora/AlgorithmHeaders.h" 18 AmbiguousDeltaRayTool::AmbiguousDeltaRayTool() :
19 m_maxGoodMatchReducedChiSquared(1.
f)
29 if (PandoraContentApi::GetSettings(*m_pParentAlgorithm)->ShouldDisplayAlgorithmInfo())
30 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
45 ClusterSet usedClusters;
46 ClusterSet usedKeyClusters;
49 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
51 if (usedKeyClusters.count(pKeyCluster))
57 for (
const TensorType::Element &element : elementList)
58 usedKeyClusters.insert(element.GetClusterU());
60 if (elementList.size() < 2)
66 if (!protoParticleVector.empty())
81 unsigned int highestHitCount(0);
82 float bestChiSquared(std::numeric_limits<float>::max());
83 const Cluster *pBestClusterU(
nullptr), *pBestClusterV(
nullptr), *pBestClusterW(
nullptr);
85 for (
const TensorType::Element &element : elementList)
87 const Cluster *
const pClusterU(element.GetClusterU()), *
const pClusterV(element.GetClusterV()), *
const pClusterW(element.GetClusterW());
89 if (usedClusters.count(pClusterU) || usedClusters.count(pClusterV) || usedClusters.count(pClusterW))
92 const float chiSquared(element.GetOverlapResult().GetReducedChi2());
97 const unsigned int hitSum(pClusterU->GetNCaloHits() + pClusterV->GetNCaloHits() + pClusterW->GetNCaloHits());
99 if ((hitSum > highestHitCount) || ((hitSum == highestHitCount) && (chiSquared < bestChiSquared)))
101 bestChiSquared = chiSquared;
102 highestHitCount = hitSum;
103 pBestClusterU = pClusterU;
104 pBestClusterV = pClusterV;
105 pBestClusterW = pClusterW;
109 if (pBestClusterU && pBestClusterV && pBestClusterW)
112 usedClusters.insert(pBestClusterU);
113 usedClusters.insert(pBestClusterV);
114 usedClusters.insert(pBestClusterW);
120 protoParticleVector.push_back(protoParticle);
129 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
132 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.
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...
bool Run(ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.