LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::TwoViewLongTracksTool Class Reference

TwoViewLongTracksTool class. More...

#include "TwoViewLongTracksTool.h"

Inheritance diagram for lar_content::TwoViewLongTracksTool:
lar_content::TransverseMatrixTool

Public Types

typedef TwoViewTransverseTracksAlgorithm::MatchingType::MatrixType MatrixType
 
typedef std::vector< MatrixType::ElementList::const_iteratorIteratorList
 

Public Member Functions

 TwoViewLongTracksTool ()
 Default constructor. More...
 
bool Run (TwoViewTransverseTracksAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
 Run the algorithm tool. More...
 

Static Public Member Functions

static bool HasLongDirectConnections (IteratorList::const_iterator iIter, const IteratorList &iteratorList)
 Whether a long element shares clusters with any other long elements. More...
 
static bool IsLongerThanDirectConnections (IteratorList::const_iterator iIter, const MatrixType::ElementList &elementList, const unsigned int minMatchedSamplingPointRatio, const pandora::ClusterSet &usedClusters)
 Whether a long element is significantly longer that other elements with which it shares a cluster. More...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void FindLongTracks (const MatrixType &overlapMatrix, ProtoParticleVector &protoParticleVector) const
 Find long tracks, hidden by simple ambiguities in the matrix. More...
 
void SelectLongElements (const MatrixType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
 Select a list of long track-like elements from a set of connected matrix elements. More...
 

Private Attributes

float m_minMatchedFraction
 The min matched sampling point fraction for particle creation. More...
 
float m_minMatchingScore
 The min global matching score for particle creation. More...
 
unsigned int m_minMatchedSamplingPoints
 The min number of matched sampling points for particle creation. More...
 
float m_minXOverlapFraction
 The min x overlap fraction (in each view) for particle creation. More...
 
unsigned int m_minMatchedSamplingPointRatio
 The min ratio between 1st and 2nd highest msps for simple ambiguity resolution. More...
 

Detailed Description

TwoViewLongTracksTool class.

Definition at line 19 of file TwoViewLongTracksTool.h.

Member Typedef Documentation

Constructor & Destructor Documentation

lar_content::TwoViewLongTracksTool::TwoViewLongTracksTool ( )

Default constructor.

Definition at line 18 of file TwoViewLongTracksTool.cc.

18  :
20  m_minMatchingScore(0.95f),
24 {
25 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
float m_minMatchingScore
The min global matching score for particle creation.
TFile f
Definition: plotHisto.C:6
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.

Member Function Documentation

void lar_content::TwoViewLongTracksTool::FindLongTracks ( const MatrixType overlapMatrix,
ProtoParticleVector protoParticleVector 
) const
private

Find long tracks, hidden by simple ambiguities in the matrix.

Parameters
overlapMatrixthe overlap matrix
protoParticleVectorto receive the list of proto particles

Definition at line 84 of file TwoViewLongTracksTool.cc.

References lar_content::OverlapMatrix< T >::GetConnectedElements(), lar_content::OverlapMatrix< T >::GetSortedKeyClusters(), HasLongDirectConnections(), IsLongerThanDirectConnections(), lar_content::ProtoParticle::m_clusterList, m_minMatchedSamplingPointRatio, and SelectLongElements().

Referenced by Run().

85 {
86  ClusterSet usedClusters;
87  ClusterVector sortedKeyClusters;
88  overlapMatrix.GetSortedKeyClusters(sortedKeyClusters);
89 
90  for (const Cluster *const pKeyCluster : sortedKeyClusters)
91  {
92  if (!pKeyCluster->IsAvailable())
93  continue;
94 
95  unsigned int n0(0), n1(0);
96  MatrixType::ElementList elementList;
97  overlapMatrix.GetConnectedElements(pKeyCluster, true, elementList, n0, n1);
98 
99  IteratorList iteratorList;
100  this->SelectLongElements(elementList, usedClusters, iteratorList);
101 
102  // Check that elements are not directly connected and are significantly longer than any other directly connected elements
103  for (IteratorList::const_iterator iIter = iteratorList.begin(), iIterEnd = iteratorList.end(); iIter != iIterEnd; ++iIter)
104  {
105  if (TwoViewLongTracksTool::HasLongDirectConnections(iIter, iteratorList))
106  continue;
107 
109  continue;
110 
111  ProtoParticle protoParticle;
112  protoParticle.m_clusterList.push_back((*iIter)->GetCluster1());
113  protoParticle.m_clusterList.push_back((*iIter)->GetCluster2());
114  protoParticleVector.push_back(protoParticle);
115 
116  usedClusters.insert((*iIter)->GetCluster1());
117  usedClusters.insert((*iIter)->GetCluster2());
118  }
119  }
120 }
intermediate_table::const_iterator const_iterator
static bool HasLongDirectConnections(IteratorList::const_iterator iIter, const IteratorList &iteratorList)
Whether a long element shares clusters with any other long elements.
static bool IsLongerThanDirectConnections(IteratorList::const_iterator iIter, const MatrixType::ElementList &elementList, const unsigned int minMatchedSamplingPointRatio, const pandora::ClusterSet &usedClusters)
Whether a long element is significantly longer that other elements with which it shares a cluster...
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
void SelectLongElements(const MatrixType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
Select a list of long track-like elements from a set of connected matrix elements.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::vector< MatrixType::ElementList::const_iterator > IteratorList
bool lar_content::TwoViewLongTracksTool::HasLongDirectConnections ( IteratorList::const_iterator  iIter,
const IteratorList iteratorList 
)
static

Whether a long element shares clusters with any other long elements.

Parameters
iIterspecifies the long element under consideration
iteratorListlist of iterators to other long elements
Returns
boolean

Definition at line 29 of file TwoViewLongTracksTool.cc.

Referenced by FindLongTracks().

30 {
31  for (IteratorList::const_iterator iIter2 = iteratorList.begin(), iIter2End = iteratorList.end(); iIter2 != iIter2End; ++iIter2)
32  {
33  if (iIter == iIter2)
34  continue;
35 
36  if (((*iIter)->GetCluster1() == (*iIter2)->GetCluster1()) || ((*iIter)->GetCluster2() == (*iIter2)->GetCluster2()))
37  return true;
38  }
39 
40  return false;
41 }
intermediate_table::const_iterator const_iterator
bool lar_content::TwoViewLongTracksTool::IsLongerThanDirectConnections ( IteratorList::const_iterator  iIter,
const MatrixType::ElementList elementList,
const unsigned int  minMatchedSamplingPointRatio,
const pandora::ClusterSet &  usedClusters 
)
static

Whether a long element is significantly longer that other elements with which it shares a cluster.

Parameters
iIterspecifies the long element under consideration
elementListthe full list of connected matrix elements
minMatchedSamplingPointRatiothe min ratio between 1st and 2nd highest msps for simple ambiguity resolution
usedClustersthe list of clusters already marked as to be added to a pfo

Definition at line 45 of file TwoViewLongTracksTool.cc.

Referenced by FindLongTracks().

47 {
48  const unsigned int nMatchedReUpsampledSamplingPoints((*iIter)->GetOverlapResult().GetNMatchedReUpsampledSamplingPoints());
49 
50  for (MatrixType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
51  {
52  if ((*iIter) == eIter)
53  continue;
54 
55  if (usedClusters.count(eIter->GetCluster1()) || usedClusters.count(eIter->GetCluster2()))
56  continue;
57 
58  if (((*iIter)->GetCluster1() != eIter->GetCluster1()) && ((*iIter)->GetCluster2() != eIter->GetCluster2()))
59  continue;
60 
61  if (nMatchedReUpsampledSamplingPoints < minMatchedSamplingPointRatio * eIter->GetOverlapResult().GetNMatchedReUpsampledSamplingPoints())
62  return false;
63  }
64 
65  return true;
66 }
intermediate_table::const_iterator const_iterator
StatusCode lar_content::TwoViewLongTracksTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 152 of file TwoViewLongTracksTool.cc.

References m_minMatchedFraction, m_minMatchedSamplingPointRatio, m_minMatchedSamplingPoints, m_minMatchingScore, and m_minXOverlapFraction.

153 {
154  PANDORA_RETURN_RESULT_IF_AND_IF(
155  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchedFraction", m_minMatchedFraction));
156 
157  PANDORA_RETURN_RESULT_IF_AND_IF(
158  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchingScore", m_minMatchingScore));
159 
160  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
161  XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
162 
163  PANDORA_RETURN_RESULT_IF_AND_IF(
164  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlapFraction", m_minXOverlapFraction));
165 
166  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
167  XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPointRatio", m_minMatchedSamplingPointRatio));
168 
169  return STATUS_CODE_SUCCESS;
170 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
float m_minMatchingScore
The min global matching score for particle creation.
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
bool lar_content::TwoViewLongTracksTool::Run ( TwoViewTransverseTracksAlgorithm *const  pAlgorithm,
MatrixType overlapMatrix 
)
virtual

Run the algorithm tool.

Parameters
pAlgorithmaddress of the calling algorithm
overlapMatrixthe overlap matrix
Returns
whether changes have been made by the tool

Implements lar_content::TransverseMatrixTool.

Definition at line 70 of file TwoViewLongTracksTool.cc.

References lar_content::MatchingBaseAlgorithm::CreateThreeDParticles(), and FindLongTracks().

71 {
72  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
73  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
74 
75  ProtoParticleVector protoParticleVector;
76  this->FindLongTracks(overlapMatrix, protoParticleVector);
77 
78  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
79  return particlesMade;
80 }
std::vector< ProtoParticle > ProtoParticleVector
void FindLongTracks(const MatrixType &overlapMatrix, ProtoParticleVector &protoParticleVector) const
Find long tracks, hidden by simple ambiguities in the matrix.
void lar_content::TwoViewLongTracksTool::SelectLongElements ( const MatrixType::ElementList elementList,
const pandora::ClusterSet &  usedClusters,
IteratorList iteratorList 
) const
private

Select a list of long track-like elements from a set of connected matrix elements.

Parameters
elementListthe full list of connected matrix elements
usedClustersthe list of clusters already marked as to be added to a pfo
iteratorListto receive a list of iterators to long track-like elements

Definition at line 124 of file TwoViewLongTracksTool.cc.

References m_minMatchedFraction, m_minMatchedSamplingPoints, m_minMatchingScore, and m_minXOverlapFraction.

Referenced by FindLongTracks().

126 {
127  for (MatrixType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
128  {
129  if (usedClusters.count(eIter->GetCluster1()) || usedClusters.count(eIter->GetCluster2()))
130  continue;
131 
132  if (eIter->GetOverlapResult().GetLocallyMatchedFraction() < m_minMatchedFraction)
133  continue;
134 
135  if (eIter->GetOverlapResult().GetMatchingScore() < m_minMatchingScore)
136  continue;
137 
138  if (eIter->GetOverlapResult().GetNMatchedReUpsampledSamplingPoints() < m_minMatchedSamplingPoints)
139  continue;
140 
141  const TwoViewXOverlap &xOverlap(eIter->GetOverlapResult().GetTwoViewXOverlap());
142 
143  if ((xOverlap.GetXOverlapFraction0() > m_minXOverlapFraction) && (xOverlap.GetXOverlapFraction1() > m_minXOverlapFraction))
144  {
145  iteratorList.push_back(eIter);
146  }
147  }
148 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
float m_minMatchingScore
The min global matching score for particle creation.
intermediate_table::const_iterator const_iterator
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.

Member Data Documentation

float lar_content::TwoViewLongTracksTool::m_minMatchedFraction
private

The min matched sampling point fraction for particle creation.

Definition at line 70 of file TwoViewLongTracksTool.h.

Referenced by ReadSettings(), and SelectLongElements().

unsigned int lar_content::TwoViewLongTracksTool::m_minMatchedSamplingPointRatio
private

The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.

Definition at line 74 of file TwoViewLongTracksTool.h.

Referenced by FindLongTracks(), and ReadSettings().

unsigned int lar_content::TwoViewLongTracksTool::m_minMatchedSamplingPoints
private

The min number of matched sampling points for particle creation.

Definition at line 72 of file TwoViewLongTracksTool.h.

Referenced by ReadSettings(), and SelectLongElements().

float lar_content::TwoViewLongTracksTool::m_minMatchingScore
private

The min global matching score for particle creation.

Definition at line 71 of file TwoViewLongTracksTool.h.

Referenced by ReadSettings(), and SelectLongElements().

float lar_content::TwoViewLongTracksTool::m_minXOverlapFraction
private

The min x overlap fraction (in each view) for particle creation.

Definition at line 73 of file TwoViewLongTracksTool.h.

Referenced by ReadSettings(), and SelectLongElements().


The documentation for this class was generated from the following files: