Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
AmbiguousDeltaRayTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18AmbiguousDeltaRayTool::AmbiguousDeltaRayTool() : m_maxGoodMatchReducedChiSquared(1.f)
19{
20}
21
22//------------------------------------------------------------------------------------------------------------------------------------------
23
25{
26 m_pParentAlgorithm = pAlgorithm;
27
29 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
30
31 this->ExamineConnectedElements(overlapTensor);
32
33 // ATTN: Prevent tensor tool loop running again
34 return false;
35}
36
37//------------------------------------------------------------------------------------------------------------------------------------------
38
40{
41 ClusterVector sortedKeyClusters;
42 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
43
44 ClusterSet usedClusters;
45 ClusterSet usedKeyClusters;
46 ProtoParticleVector protoParticleVector;
47
48 for (const Cluster *const pKeyCluster : sortedKeyClusters)
49 {
50 if (usedKeyClusters.count(pKeyCluster))
51 continue;
52
53 TensorType::ElementList elementList;
54 overlapTensor.GetConnectedElements(pKeyCluster, true, elementList);
55
56 for (const TensorType::Element &element : elementList)
57 usedKeyClusters.insert(element.GetClusterU());
58
59 if (elementList.size() < 2)
60 continue;
61
62 this->PickOutGoodMatches(elementList, usedClusters, protoParticleVector);
63 }
64
65 if (!protoParticleVector.empty())
66 m_pParentAlgorithm->CreatePfos(protoParticleVector);
67}
68
69//------------------------------------------------------------------------------------------------------------------------------------------
70
72 const TensorType::ElementList &elementList, ClusterSet &usedClusters, ProtoParticleVector &protoParticleVector) const
73{
74 bool found(false);
75
76 do
77 {
78 found = false;
79
80 unsigned int highestHitCount(0);
81 float bestChiSquared(std::numeric_limits<float>::max());
82 const Cluster *pBestClusterU(nullptr), *pBestClusterV(nullptr), *pBestClusterW(nullptr);
83
84 for (const TensorType::Element &element : elementList)
85 {
86 const Cluster *const pClusterU(element.GetClusterU()), *const pClusterV(element.GetClusterV()), *const pClusterW(element.GetClusterW());
87
88 if (usedClusters.count(pClusterU) || usedClusters.count(pClusterV) || usedClusters.count(pClusterW))
89 continue;
90
91 const float chiSquared(element.GetOverlapResult().GetReducedChi2());
92
93 if (chiSquared > m_maxGoodMatchReducedChiSquared)
94 continue;
95
96 const unsigned int hitSum(pClusterU->GetNCaloHits() + pClusterV->GetNCaloHits() + pClusterW->GetNCaloHits());
97
98 if ((hitSum > highestHitCount) || ((hitSum == highestHitCount) && (chiSquared < bestChiSquared)))
99 {
100 bestChiSquared = chiSquared;
101 highestHitCount = hitSum;
102 pBestClusterU = pClusterU;
103 pBestClusterV = pClusterV;
104 pBestClusterW = pClusterW;
105 }
106 }
107
108 if (pBestClusterU && pBestClusterV && pBestClusterW)
109 {
110 found = true;
111 usedClusters.insert(pBestClusterU);
112 usedClusters.insert(pBestClusterV);
113 usedClusters.insert(pBestClusterW);
114
115 ProtoParticle protoParticle;
116 protoParticle.m_clusterList.push_back(pBestClusterU);
117 protoParticle.m_clusterList.push_back(pBestClusterV);
118 protoParticle.m_clusterList.push_back(pBestClusterW);
119 protoParticleVector.push_back(protoParticle);
120 }
121 } while (found);
122}
123
124//------------------------------------------------------------------------------------------------------------------------------------------
125
127{
128 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
129 XmlHelper::ReadValue(xmlHandle, "MaxGoodMatchReducedChiSquared", m_maxGoodMatchReducedChiSquared));
130
131 return STATUS_CODE_SUCCESS;
132}
133
134//------------------------------------------------------------------------------------------------------------------------------------------
135
136} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the ambiguous delta ray tool class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
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.
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.
Cluster class.
Definition Cluster.h:31
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
Definition Cluster.h:484
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const std::string & GetType() const
Get the type.
Definition Process.h:102
const std::string & GetInstanceName() const
Get the instance name.
Definition Process.h:109
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
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.