Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TwoViewSimpleTracksTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
19 m_minMatchedFraction(0.2f),
20 m_minMatchingScore(0.9f),
21 m_minMatchedSamplingPoints(5),
22 m_minXOverlapFraction(0.5f)
23{
24}
25
26//------------------------------------------------------------------------------------------------------------------------------------------
27
29{
31 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
32
33 ProtoParticleVector protoParticleVector;
34 this->FindBestTrack(overlapMatrix, protoParticleVector);
35
36 return pAlgorithm->CreateThreeDParticles(protoParticleVector);
37}
38
39//------------------------------------------------------------------------------------------------------------------------------------------
40
41void TwoViewSimpleTracksTool::FindBestTrack(const MatrixType &overlapMatrix, ProtoParticleVector &protoParticleVector) const
42{
43 ClusterVector sortedKeyClusters;
44 overlapMatrix.GetSortedKeyClusters(sortedKeyClusters);
45
46 for (const Cluster *const pKeyCluster : sortedKeyClusters)
47 {
48 if (!pKeyCluster->IsAvailable())
49 continue;
50
51 unsigned int n0(0), n1(0);
52 MatrixType::ElementList elementList;
53 overlapMatrix.GetConnectedElements(pKeyCluster, true, elementList, n0, n1);
54
55 if (elementList.empty())
56 continue;
57
58 for (MatrixType::ElementList::const_reverse_iterator iIter = elementList.rbegin(); iIter != elementList.rend(); ++iIter)
59 {
60 if (this->PassesElementCuts(iIter))
61 {
62 if ((nullptr == iIter->GetCluster1()) || (nullptr == iIter->GetCluster2()))
63 continue;
64
65 ProtoParticle protoParticle;
66 protoParticle.m_clusterList.push_back(iIter->GetCluster1());
67 protoParticle.m_clusterList.push_back(iIter->GetCluster2());
68 protoParticleVector.push_back(protoParticle);
69
70 return;
71 }
72 }
73 }
74}
75
76//------------------------------------------------------------------------------------------------------------------------------------------
77
78bool TwoViewSimpleTracksTool::PassesElementCuts(MatrixType::ElementList::const_reverse_iterator eIter) const
79{
80 if (!eIter->GetOverlapResult().IsInitialized())
81 return false;
82
83 if (eIter->GetOverlapResult().GetLocallyMatchedFraction() < m_minMatchedFraction)
84 return false;
85
86 if (eIter->GetOverlapResult().GetMatchingScore() < m_minMatchingScore)
87 return false;
88
89 if (eIter->GetOverlapResult().GetNMatchedReUpsampledSamplingPoints() < m_minMatchedSamplingPoints)
90 return false;
91
92 const TwoViewXOverlap &xOverlap(eIter->GetOverlapResult().GetTwoViewXOverlap());
93
95 {
96 return false;
97 }
98
99 return true;
100}
101
102//------------------------------------------------------------------------------------------------------------------------------------------
103
105{
107 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchedFraction", m_minMatchedFraction));
108
110 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchingScore", m_minMatchingScore));
111
112 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
113 XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
114
116 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlapFraction", m_minXOverlapFraction));
117
118 return STATUS_CODE_SUCCESS;
119}
120
121} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
#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.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
TwoViewTransverseTracksAlgorithm::MatchingType::MatrixType MatrixType
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
float m_minMatchingScore
The min global matching score for particle creation.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
bool Run(TwoViewTransverseTracksAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
Run the algorithm tool.
bool PassesElementCuts(MatrixType::ElementList::const_reverse_iterator eIter) const
Whether a provided (iterator to a) matrix element passes the selection cuts for particle creation.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void FindBestTrack(const MatrixType &overlapMatrix, ProtoParticleVector &protoParticleVector) const
Find best track match as a simple way to (try to) resolve ambiguities in the matrix.
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
float GetXOverlapFraction0() const
Get the fraction of the view 0 cluster that overlaps in x.
float GetXOverlapFraction1() const
Get the fraction of the view 1 cluster that overlaps in x.
Cluster class.
Definition Cluster.h:31
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
StatusCode
The StatusCode enum.