LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
MatchedEndPointsTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 MatchedEndPointsTool::MatchedEndPointsTool() :
19  m_minMatchedFraction(0.8f),
20  m_maxEndPointChi2(3.f)
21 {
22 }
23 
24 //------------------------------------------------------------------------------------------------------------------------------------------
25 
27 {
28  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
29  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
30 
31  ProtoParticleVector protoParticleVector;
32  this->FindMatchedTracks(overlapTensor, protoParticleVector);
33 
34  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
35  return particlesMade;
36 }
37 
38 //------------------------------------------------------------------------------------------------------------------------------------------
39 
40 void MatchedEndPointsTool::FindMatchedTracks(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
41 {
42  ClusterSet usedClusters;
43  ClusterVector sortedKeyClusters;
44  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
45 
46  for (const Cluster *const pKeyCluster : sortedKeyClusters)
47  {
48  if (!pKeyCluster->IsAvailable())
49  continue;
50 
51  unsigned int nU(0), nV(0), nW(0);
52  TensorType::ElementList elementList;
53  overlapTensor.GetConnectedElements(pKeyCluster, true, elementList, nU, nV, nW);
54 
55  if (nU * nV * nW == 0)
56  continue;
57 
58  std::sort(elementList.begin(), elementList.end(), MatchedEndPointsTool::SortByChiSquared);
59 
60  for (TensorType::ElementList::const_iterator iter = elementList.begin(); iter != elementList.end(); ++iter)
61  {
62  if (usedClusters.count(iter->GetClusterU()) || usedClusters.count(iter->GetClusterV()) || usedClusters.count(iter->GetClusterW()))
63  continue;
64 
65  if (iter->GetOverlapResult().GetMatchedFraction() < m_minMatchedFraction)
66  continue;
67 
68  if (std::max(iter->GetOverlapResult().GetInnerChi2(),iter->GetOverlapResult().GetOuterChi2()) > m_maxEndPointChi2)
69  continue;
70 
71  ProtoParticle protoParticle;
72  protoParticle.m_clusterListU.push_back(iter->GetClusterU());
73  protoParticle.m_clusterListV.push_back(iter->GetClusterV());
74  protoParticle.m_clusterListW.push_back(iter->GetClusterW());
75  protoParticleVector.push_back(protoParticle);
76 
77  usedClusters.insert(iter->GetClusterU());
78  usedClusters.insert(iter->GetClusterV());
79  usedClusters.insert(iter->GetClusterW());
80  }
81  }
82 }
83 
84 //------------------------------------------------------------------------------------------------------------------------------------------
85 
86 bool MatchedEndPointsTool::SortByChiSquared(const TensorType::Element &lhs, const TensorType::Element &rhs)
87 {
88  return (lhs.GetOverlapResult().GetInnerChi2() + lhs.GetOverlapResult().GetOuterChi2() <
89  rhs.GetOverlapResult().GetInnerChi2() + rhs.GetOverlapResult().GetOuterChi2());
90 }
91 
92 //------------------------------------------------------------------------------------------------------------------------------------------
93 
94 StatusCode MatchedEndPointsTool::ReadSettings(const TiXmlHandle xmlHandle)
95 {
96  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
97  "MinMatchedFraction", m_minMatchedFraction));
98 
99  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
100  "MaxEndPointChi2", m_maxEndPointChi2));
101 
102  return STATUS_CODE_SUCCESS;
103 }
104 
105 } // namespace lar_content
std::vector< ProtoParticle > ProtoParticleVector
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
bool Run(ThreeDLongitudinalTracksAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
TFile f
Definition: plotHisto.C:6
pandora::ClusterList m_clusterListW
List of 2D W clusters in a 3D proto particle.
float m_maxEndPointChi2
The max chi2 of matched vertex and end points for particle creation.
Int_t max
Definition: plot.C:27
void FindMatchedTracks(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
Find matched tracks, hidden by ambiguities in the tensor.
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
pandora::ClusterList m_clusterListV
List of 2D V clusters in a 3D proto particle.
pandora::ClusterList m_clusterListU
List of 2D U clusters in a 3D proto particle.
static bool SortByChiSquared(const TensorType::Element &lhs, const TensorType::Element &rhs)
Sort tensor elements by chi-squared.
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
Header file for the matched end points tool class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)