Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
MatchedEndPointsTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18MatchedEndPointsTool::MatchedEndPointsTool() : m_minMatchedFraction(0.8f), m_maxEndPointChi2(3.f)
19{
20}
21
22//------------------------------------------------------------------------------------------------------------------------------------------
23
25{
27 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
28
29 ProtoParticleVector protoParticleVector;
30 this->FindMatchedTracks(overlapTensor, protoParticleVector);
31
32 const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
33 return particlesMade;
34}
35
36//------------------------------------------------------------------------------------------------------------------------------------------
37
38void MatchedEndPointsTool::FindMatchedTracks(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
39{
40 ClusterSet usedClusters;
41 ClusterVector sortedKeyClusters;
42 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
43
44 for (const Cluster *const pKeyCluster : sortedKeyClusters)
45 {
46 if (!pKeyCluster->IsAvailable())
47 continue;
48
49 unsigned int nU(0), nV(0), nW(0);
50 TensorType::ElementList elementList;
51 overlapTensor.GetConnectedElements(pKeyCluster, true, elementList, nU, nV, nW);
52
53 if (nU * nV * nW == 0)
54 continue;
55
56 std::sort(elementList.begin(), elementList.end(), MatchedEndPointsTool::SortByChiSquared);
57
58 for (TensorType::ElementList::const_iterator iter = elementList.begin(); iter != elementList.end(); ++iter)
59 {
60 if (usedClusters.count(iter->GetClusterU()) || usedClusters.count(iter->GetClusterV()) || usedClusters.count(iter->GetClusterW()))
61 continue;
62
63 if (iter->GetOverlapResult().GetMatchedFraction() < m_minMatchedFraction)
64 continue;
65
66 if (std::max(iter->GetOverlapResult().GetInnerChi2(), iter->GetOverlapResult().GetOuterChi2()) > m_maxEndPointChi2)
67 continue;
68
69 ProtoParticle protoParticle;
70 protoParticle.m_clusterList.push_back(iter->GetClusterU());
71 protoParticle.m_clusterList.push_back(iter->GetClusterV());
72 protoParticle.m_clusterList.push_back(iter->GetClusterW());
73 protoParticleVector.push_back(protoParticle);
74
75 usedClusters.insert(iter->GetClusterU());
76 usedClusters.insert(iter->GetClusterV());
77 usedClusters.insert(iter->GetClusterW());
78 }
79 }
80}
81
82//------------------------------------------------------------------------------------------------------------------------------------------
83
84bool MatchedEndPointsTool::SortByChiSquared(const TensorType::Element &lhs, const TensorType::Element &rhs)
85{
86 return (lhs.GetOverlapResult().GetInnerChi2() + lhs.GetOverlapResult().GetOuterChi2() <
87 rhs.GetOverlapResult().GetInnerChi2() + rhs.GetOverlapResult().GetOuterChi2());
88}
89
90//------------------------------------------------------------------------------------------------------------------------------------------
91
93{
95 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchedFraction", m_minMatchedFraction));
96
97 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxEndPointChi2", m_maxEndPointChi2));
98
99 return STATUS_CODE_SUCCESS;
100}
101
102} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the matched end points 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.
ThreeViewLongitudinalTracksAlgorithm::MatchingType::TensorType TensorType
static bool SortByChiSquared(const TensorType::Element &lhs, const TensorType::Element &rhs)
Sort tensor elements by chi-squared.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
bool Run(ThreeViewLongitudinalTracksAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
void FindMatchedTracks(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
Find matched tracks, hidden by ambiguities in the tensor.
float m_maxEndPointChi2
The max chi2 of matched vertex and end points for particle creation.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
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
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.