Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TwoViewAmbiguousDeltaRayTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
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(overlapMatrix);
32
33 // ATTN: Prevent tensor tool loop running again
34 return false;
35}
36
37//------------------------------------------------------------------------------------------------------------------------------------------
38
40{
41 bool particleCreated(false);
42
43 do
44 {
45 particleCreated = false;
46
47 ClusterVector sortedKeyClusters;
48 overlapMatrix.GetSortedKeyClusters(sortedKeyClusters);
49
50 ClusterSet usedKeyClusters;
51
52 for (const Cluster *const pKeyCluster : sortedKeyClusters)
53 {
54 if (usedKeyClusters.count(pKeyCluster))
55 continue;
56
57 MatrixType::ElementList elementList;
58 overlapMatrix.GetConnectedElements(pKeyCluster, true, elementList);
59
60 for (const MatrixType::Element &element : elementList)
61 usedKeyClusters.insert(element.GetCluster1());
62
63 if (this->PickOutGoodMatches(elementList))
64 {
65 particleCreated = true;
66 break;
67 }
68 }
69 } while (particleCreated);
70}
71
72//------------------------------------------------------------------------------------------------------------------------------------------
73
74bool TwoViewAmbiguousDeltaRayTool::PickOutGoodMatches(const MatrixType::ElementList &elementList) const
75{
76 unsigned int highestHitCount(0);
77 float bestChiSquared(std::numeric_limits<float>::max());
78 auto bestElementIter(elementList.end());
79
80 for (auto iter = elementList.begin(); iter != elementList.end(); ++iter)
81 {
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());
86
87 if ((hitSum > highestHitCount) || ((hitSum == highestHitCount) && (chiSquared < bestChiSquared)))
88 {
89 bestChiSquared = chiSquared;
90 highestHitCount = hitSum;
91 bestElementIter = iter;
92 }
93 }
94
95 if (bestElementIter != elementList.end())
96 {
97 m_pParentAlgorithm->CreatePfo(*bestElementIter);
98 return true;
99 }
100
101 return false;
102}
103
104//------------------------------------------------------------------------------------------------------------------------------------------
105
107{
108 return STATUS_CODE_SUCCESS;
109}
110
111} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the two view delta ray merge tool class.
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...
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.
bool CreatePfo(const MatrixType::Element &element)
Create delta ray pfos out of a given element, merging the third view clusters together and adding in ...
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
std::vector< const Cluster * > ClusterVector
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.