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

MissingTrackSegmentTool class. More...

#include "MissingTrackSegmentTool.h"

Inheritance diagram for lar_content::MissingTrackSegmentTool:
lar_content::TransverseTensorTool

Classes

class  Particle
 Particle class. More...
 
class  SegmentOverlap
 SegmentOverlap class. More...
 

Public Types

typedef ThreeViewTransverseTracksAlgorithm::MatchingType::TensorType TensorType
 
typedef std::vector< TensorType::ElementList::const_iteratorIteratorList
 

Public Member Functions

 MissingTrackSegmentTool ()
 Default constructor. More...
 
bool Run (ThreeViewTransverseTracksAlgorithm *const pAlgorithm, TensorType &overlapTensor)
 Run the algorithm tool. More...
 

Private Types

typedef std::unordered_map< const pandora::Cluster *, SegmentOverlapSegmentOverlapMap
 
typedef std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void FindTracks (ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector, ClusterMergeMap &clusterMergeMap) const
 Find remaining tracks, hidden by missing track segments (and maybe other ambiguities) in the tensor. More...
 
void SelectElements (const TensorType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
 Select a list of the relevant elements from a set of connected tensor elements. More...
 
bool PassesParticleChecks (ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const TensorType::Element &element, pandora::ClusterSet &usedClusters, ClusterMergeMap &clusterMergeMap) const
 Whether a provided tensor element can be used to construct a pfo. More...
 
void GetCandidateClusters (ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, pandora::ClusterList &candidateClusters) const
 Get a list of candidate clusters, which may represent missing track segments for a provided particle. More...
 
void GetSlidingFitResultMap (ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const pandora::ClusterList &candidateClusterList, TwoDSlidingFitResultMap &slidingFitResultMap) const
 Get a sliding fit result map for the list of candidate clusters. More...
 
void GetSegmentOverlapMap (ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, const TwoDSlidingFitResultMap &slidingFitResultMap, SegmentOverlapMap &segmentOverlapMap) const
 Get a segment overlap map, describing overlap between a provided particle and all clusters in a sliding fit result map. More...
 
bool MakeDecisions (const Particle &particle, const TwoDSlidingFitResultMap &slidingFitResultMap, const SegmentOverlapMap &segmentOverlapMap, pandora::ClusterSet &usedClusters, ClusterMergeMap &clusterMergeMap) const
 Make decisions about whether to create a pfo for a provided particle and whether to make cluster merges. More...
 
bool PassesSamplingCuts (const SegmentOverlap &segmentOverlap) const
 Whether the segment overlap object passes cuts on matched sampling points, etc. More...
 
bool IsPossibleMerge (const pandora::Cluster *const pCluster, const Particle &particle, const SegmentOverlap &segmentOverlap, const TwoDSlidingFitResultMap &slidingFitResultMap) const
 Whether the cluster could be merged with the candidate particle. More...
 

Private Attributes

float m_minMatchedFraction
 The min matched sampling point fraction for particle creation. More...
 
unsigned int m_minMatchedSamplingPoints
 The min number of matched sampling points for particle creation. More...
 
unsigned int m_minMatchedSamplingPointRatio
 The min ratio between 1st and 2nd highest msps for simple ambiguity resolution. More...
 
float m_minInitialXOverlapFraction
 The min x overlap fraction (between long clusters and short cluster vs. shared overlap) More...
 
float m_minFinalXOverlapFraction
 The min x overlap fraction between extended short cluster and the long clusters. More...
 
unsigned int m_minCaloHitsInCandidateCluster
 The min no. of calo hits in a candidate cluster, for matching with long clusters. More...
 
float m_pseudoChi2Cut
 The pseudo chi2 cut to determine whether a sampling point is matched. More...
 
unsigned int m_makePfoMinSamplingPoints
 The min number of sampling points in order to be able to make pfo. More...
 
unsigned int m_makePfoMinMatchedSamplingPoints
 The min number of matched sampling points in order to be able to make pfo. More...
 
float m_makePfoMinMatchedFraction
 The min matched sampling point fraction in order to be able to make pfo. More...
 
float m_makePfoMaxImpactParameter
 The max transverse impact parameter in order to be able to make pfo. More...
 
float m_mergeMaxChi2PerSamplingPoint
 The max value of chi2 per sampling point in order to merge cluster with parent. More...
 
float m_mergeXContainmentTolerance
 The tolerance in determining whether candidate cluster is contained in x window. More...
 

Detailed Description

MissingTrackSegmentTool class.

Definition at line 21 of file MissingTrackSegmentTool.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster *, pandora::ClusterList> lar_content::MissingTrackSegmentTool::ClusterMergeMap
private

Definition at line 78 of file MissingTrackSegmentTool.h.

typedef std::unordered_map<const pandora::Cluster *, SegmentOverlap> lar_content::MissingTrackSegmentTool::SegmentOverlapMap
private

Definition at line 77 of file MissingTrackSegmentTool.h.

Constructor & Destructor Documentation

lar_content::MissingTrackSegmentTool::MissingTrackSegmentTool ( )

Default constructor.

Definition at line 25 of file MissingTrackSegmentTool.cc.

25  :
32  m_pseudoChi2Cut(1.f),
39 {
40 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minInitialXOverlapFraction
The min x overlap fraction (between long clusters and short cluster vs. shared overlap) ...
TFile f
Definition: plotHisto.C:6
unsigned int m_makePfoMinMatchedSamplingPoints
The min number of matched sampling points in order to be able to make pfo.
float m_makePfoMaxImpactParameter
The max transverse impact parameter in order to be able to make pfo.
unsigned int m_minCaloHitsInCandidateCluster
The min no. of calo hits in a candidate cluster, for matching with long clusters. ...
float m_pseudoChi2Cut
The pseudo chi2 cut to determine whether a sampling point is matched.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
unsigned int m_makePfoMinSamplingPoints
The min number of sampling points in order to be able to make pfo.
float m_minFinalXOverlapFraction
The min x overlap fraction between extended short cluster and the long clusters.
float m_mergeXContainmentTolerance
The tolerance in determining whether candidate cluster is contained in x window.
float m_makePfoMinMatchedFraction
The min matched sampling point fraction in order to be able to make pfo.
float m_mergeMaxChi2PerSamplingPoint
The max value of chi2 per sampling point in order to merge cluster with parent.

Member Function Documentation

void lar_content::MissingTrackSegmentTool::FindTracks ( ThreeViewTransverseTracksAlgorithm *const  pAlgorithm,
const TensorType overlapTensor,
ProtoParticleVector protoParticleVector,
ClusterMergeMap clusterMergeMap 
) const
private

Find remaining tracks, hidden by missing track segments (and maybe other ambiguities) in the tensor.

Parameters
pAlgorithmaddress of the calling algorithm
overlapTensorthe overlap tensor
protoParticleVectorto receive the list of proto particles
clusterMergeMapto receive the cluster merge map

Definition at line 61 of file MissingTrackSegmentTool.cc.

References lar_content::OverlapTensor< T >::GetConnectedElements(), lar_content::OverlapTensor< T >::GetSortedKeyClusters(), lar_content::LongTracksTool::HasLongDirectConnections(), lar_content::LongTracksTool::IsLongerThanDirectConnections(), lar_content::ProtoParticle::m_clusterList, m_minMatchedSamplingPointRatio, PassesParticleChecks(), and SelectElements().

Referenced by Run().

63 {
64  ClusterSet usedClusters;
65  ClusterVector sortedKeyClusters;
66  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
67 
68  for (const Cluster *const pKeyCluster : sortedKeyClusters)
69  {
70  if (!pKeyCluster->IsAvailable())
71  continue;
72 
73  unsigned int nU(0), nV(0), nW(0);
74  TensorType::ElementList elementList;
75  overlapTensor.GetConnectedElements(pKeyCluster, true, elementList, nU, nV, nW);
76 
77  IteratorList iteratorList;
78  this->SelectElements(elementList, usedClusters, iteratorList);
79 
80  for (IteratorList::const_iterator iIter = iteratorList.begin(), iIterEnd = iteratorList.end(); iIter != iIterEnd; ++iIter)
81  {
82  if (LongTracksTool::HasLongDirectConnections(iIter, iteratorList))
83  continue;
84 
86  continue;
87 
88  if (!this->PassesParticleChecks(pAlgorithm, *(*iIter), usedClusters, clusterMergeMap))
89  continue;
90 
91  ProtoParticle protoParticle;
92  protoParticle.m_clusterList.push_back((*iIter)->GetClusterU());
93  protoParticle.m_clusterList.push_back((*iIter)->GetClusterV());
94  protoParticle.m_clusterList.push_back((*iIter)->GetClusterW());
95  protoParticleVector.push_back(protoParticle);
96 
97  usedClusters.insert((*iIter)->GetClusterU());
98  usedClusters.insert((*iIter)->GetClusterV());
99  usedClusters.insert((*iIter)->GetClusterW());
100  }
101  }
102 }
std::vector< TensorType::ElementList::const_iterator > IteratorList
static bool IsLongerThanDirectConnections(IteratorList::const_iterator iIter, const TensorType::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...
intermediate_table::const_iterator const_iterator
bool PassesParticleChecks(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const TensorType::Element &element, pandora::ClusterSet &usedClusters, ClusterMergeMap &clusterMergeMap) const
Whether a provided tensor element can be used to construct a pfo.
void SelectElements(const TensorType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
Select a list of the relevant elements from a set of connected tensor elements.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
static bool HasLongDirectConnections(IteratorList::const_iterator iIter, const IteratorList &iteratorList)
Whether a long element shares clusters with any other long elements.
void lar_content::MissingTrackSegmentTool::GetCandidateClusters ( ThreeViewTransverseTracksAlgorithm *const  pAlgorithm,
const Particle particle,
pandora::ClusterList &  candidateClusters 
) const
private

Get a list of candidate clusters, which may represent missing track segments for a provided particle.

Parameters
pAlgorithmaddress of the calling algorithm
particlethe particle
candidateClustersto receive the list of candidate clusters

Definition at line 174 of file MissingTrackSegmentTool.cc.

References lar_content::NViewMatchingAlgorithm< T >::GetInputClusterList(), m_minCaloHitsInCandidateCluster, lar_content::MissingTrackSegmentTool::Particle::m_pShortCluster, and lar_content::MissingTrackSegmentTool::Particle::m_shortHitType.

Referenced by PassesParticleChecks().

176 {
177  const ClusterList &clusterList(pAlgorithm->GetInputClusterList(particle.m_shortHitType));
178 
179  for (ClusterList::const_iterator iter = clusterList.begin(), iterEnd = clusterList.end(); iter != iterEnd; ++iter)
180  {
181  const Cluster *const pCluster(*iter);
182 
183  if (pCluster == particle.m_pShortCluster)
184  continue;
185 
186  if (pCluster->GetNCaloHits() < m_minCaloHitsInCandidateCluster)
187  continue;
188 
189  candidateClusters.push_back(pCluster);
190  }
191 }
intermediate_table::const_iterator const_iterator
unsigned int m_minCaloHitsInCandidateCluster
The min no. of calo hits in a candidate cluster, for matching with long clusters. ...
void lar_content::MissingTrackSegmentTool::GetSegmentOverlapMap ( ThreeViewTransverseTracksAlgorithm *const  pAlgorithm,
const Particle particle,
const TwoDSlidingFitResultMap slidingFitResultMap,
SegmentOverlapMap segmentOverlapMap 
) const
private

Get a segment overlap map, describing overlap between a provided particle and all clusters in a sliding fit result map.

Parameters
pAlgorithmaddress of the calling algorithm
particlethe particle
slidingFitResultMapthe sliding fit result map
segmentOverlapMapto receive the segment overlap map

Definition at line 227 of file MissingTrackSegmentTool.cc.

References f, lar_content::NViewTrackMatchingAlgorithm< T >::GetCachedSlidingFitResult(), lar_content::MissingTrackSegmentTool::Particle::m_hitType1, lar_content::MissingTrackSegmentTool::Particle::m_hitType2, lar_content::MissingTrackSegmentTool::Particle::m_longMaxX, lar_content::MissingTrackSegmentTool::Particle::m_longMinX, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_matchedSamplingMaxX, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_matchedSamplingMinX, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_nMatchedSamplingPoints, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_nSamplingPoints, lar_content::MissingTrackSegmentTool::Particle::m_pCluster1, lar_content::MissingTrackSegmentTool::Particle::m_pCluster2, m_pseudoChi2Cut, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_pseudoChi2Sum, lar_content::MissingTrackSegmentTool::Particle::m_shortMaxX, lar_content::MissingTrackSegmentTool::Particle::m_shortMinX, lar_content::LArGeometryHelper::MergeTwoPositions(), n, lar_content::LArClusterHelper::SortByNHits(), and x.

Referenced by PassesParticleChecks().

229 {
230  const TwoDSlidingFitResult &fitResult1(pAlgorithm->GetCachedSlidingFitResult(particle.m_pCluster1));
231  const TwoDSlidingFitResult &fitResult2(pAlgorithm->GetCachedSlidingFitResult(particle.m_pCluster2));
232 
233  const float nPoints1(std::fabs(static_cast<float>(fitResult1.GetMaxLayer() - fitResult1.GetMinLayer())));
234  const float nPoints2(std::fabs(static_cast<float>(fitResult2.GetMaxLayer() - fitResult2.GetMinLayer())));
235 
236  const unsigned int nPoints(static_cast<unsigned int>(1.f + (nPoints1 + nPoints2) / 2.f));
237 
238  ClusterList clusterList;
239  for (const auto &mapEntry : slidingFitResultMap)
240  clusterList.push_back(mapEntry.first);
241  clusterList.sort(LArClusterHelper::SortByNHits);
242 
243  for (unsigned n = 0; n <= nPoints; ++n)
244  {
245  const float x(particle.m_longMinX + (particle.m_longMaxX - particle.m_longMinX) * static_cast<float>(n) / static_cast<float>(nPoints));
246 
247  if ((x > particle.m_shortMinX) && (x < particle.m_shortMaxX))
248  continue;
249 
250  CartesianVector fitVector1(0.f, 0.f, 0.f), fitVector2(0.f, 0.f, 0.f);
251 
252  if ((STATUS_CODE_SUCCESS != fitResult1.GetGlobalFitPositionAtX(x, fitVector1)) ||
253  (STATUS_CODE_SUCCESS != fitResult2.GetGlobalFitPositionAtX(x, fitVector2)))
254  {
255  continue;
256  }
257 
258  const float prediction(LArGeometryHelper::MergeTwoPositions(
259  this->GetPandora(), particle.m_hitType1, particle.m_hitType2, fitVector1.GetZ(), fitVector2.GetZ()));
260 
261  for (const Cluster *const pCluster : clusterList)
262  {
263  const TwoDSlidingFitResult &slidingFitResult(slidingFitResultMap.at(pCluster));
264  CartesianVector fitVector(0.f, 0.f, 0.f), fitDirection(0.f, 0.f, 0.f);
265 
266  if ((STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitPositionAtX(x, fitVector)) ||
267  (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirectionAtX(x, fitDirection)))
268  {
269  continue;
270  }
271 
272  const float delta((prediction - fitVector.GetZ()) * fitDirection.GetX());
273  const float pseudoChi2(delta * delta);
274 
275  SegmentOverlap &segmentOverlap(segmentOverlapMap[pCluster]);
276  ++segmentOverlap.m_nSamplingPoints;
277  segmentOverlap.m_pseudoChi2Sum += pseudoChi2;
278 
279  if (pseudoChi2 < m_pseudoChi2Cut)
280  {
281  ++segmentOverlap.m_nMatchedSamplingPoints;
282  segmentOverlap.m_matchedSamplingMinX = std::min(x, segmentOverlap.m_matchedSamplingMinX);
283  segmentOverlap.m_matchedSamplingMaxX = std::max(x, segmentOverlap.m_matchedSamplingMaxX);
284  }
285  }
286  }
287 }
Float_t x
Definition: compare.C:6
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
TFile f
Definition: plotHisto.C:6
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
Definition: Polygon2D.cxx:20
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
float m_pseudoChi2Cut
The pseudo chi2 cut to determine whether a sampling point is matched.
Char_t n[5]
void lar_content::MissingTrackSegmentTool::GetSlidingFitResultMap ( ThreeViewTransverseTracksAlgorithm *const  pAlgorithm,
const pandora::ClusterList &  candidateClusterList,
TwoDSlidingFitResultMap slidingFitResultMap 
) const
private

Get a sliding fit result map for the list of candidate clusters.

Parameters
pAlgorithmaddress of the calling algorithm
candidateClustersthe list of candidate clusters
slidingFitResultMapto receive the sliding fit result map

Definition at line 195 of file MissingTrackSegmentTool.cc.

References lar_content::NViewTrackMatchingAlgorithm< T >::GetCachedSlidingFitResult(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::NViewTrackMatchingAlgorithm< T >::GetSlidingFitWindow(), and lar_content::LArGeometryHelper::GetWirePitch().

Referenced by PassesParticleChecks().

197 {
198  for (ClusterList::const_iterator iter = candidateClusterList.begin(), iterEnd = candidateClusterList.end(); iter != iterEnd; ++iter)
199  {
200  const Cluster *const pCluster(*iter);
201 
202  try
203  {
204  const TwoDSlidingFitResult &slidingFitResult(pAlgorithm->GetCachedSlidingFitResult(pCluster));
205  (void)slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult));
206  continue;
207  }
208  catch (StatusCodeException &)
209  {
210  }
211 
212  try
213  {
214  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), LArClusterHelper::GetClusterHitType(pCluster)));
215  const TwoDSlidingFitResult slidingFitResult(pCluster, pAlgorithm->GetSlidingFitWindow(), slidingFitPitch);
216  (void)slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult));
217  continue;
218  }
219  catch (StatusCodeException &)
220  {
221  }
222  }
223 }
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
bool lar_content::MissingTrackSegmentTool::IsPossibleMerge ( const pandora::Cluster *const  pCluster,
const Particle particle,
const SegmentOverlap segmentOverlap,
const TwoDSlidingFitResultMap slidingFitResultMap 
) const
private

Whether the cluster could be merged with the candidate particle.

Parameters
pClusteraddress of the cluster
particlethe particle
segmentOverlapthe segment overlap
slidingFitResultMapthe sliding fit result map
Returns
boolean

Definition at line 356 of file MissingTrackSegmentTool.cc.

References lar_content::MissingTrackSegmentTool::Particle::m_longMaxX, lar_content::MissingTrackSegmentTool::Particle::m_longMinX, m_mergeMaxChi2PerSamplingPoint, m_mergeXContainmentTolerance, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_nSamplingPoints, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_pseudoChi2Sum, lar_content::MissingTrackSegmentTool::Particle::m_shortMaxX, and lar_content::MissingTrackSegmentTool::Particle::m_shortMinX.

Referenced by MakeDecisions().

358 {
359  if ((segmentOverlap.m_pseudoChi2Sum / static_cast<float>(segmentOverlap.m_nSamplingPoints)) > m_mergeMaxChi2PerSamplingPoint)
360  return false;
361 
362  TwoDSlidingFitResultMap::const_iterator fitIter = slidingFitResultMap.find(pCluster);
363 
364  if (slidingFitResultMap.end() == fitIter)
365  throw StatusCodeException(STATUS_CODE_FAILURE);
366 
367  float mergeMinX(std::numeric_limits<float>::max()), mergeMaxX(-std::numeric_limits<float>::max());
368  fitIter->second.GetMinAndMaxX(mergeMinX, mergeMaxX);
369 
370  // cluster should not be wider than the longest span
371  if ((mergeMinX < particle.m_longMinX - m_mergeXContainmentTolerance) || (mergeMaxX > particle.m_longMaxX + m_mergeXContainmentTolerance))
372  return false;
373 
374  // cluster should not overlap with the shortest span
375  if ((mergeMinX < particle.m_shortMaxX - m_mergeXContainmentTolerance) && (mergeMaxX > particle.m_shortMinX + m_mergeXContainmentTolerance))
376  return false;
377 
378  return true;
379 }
intermediate_table::const_iterator const_iterator
float m_mergeXContainmentTolerance
The tolerance in determining whether candidate cluster is contained in x window.
float m_mergeMaxChi2PerSamplingPoint
The max value of chi2 per sampling point in order to merge cluster with parent.
bool lar_content::MissingTrackSegmentTool::MakeDecisions ( const Particle particle,
const TwoDSlidingFitResultMap slidingFitResultMap,
const SegmentOverlapMap segmentOverlapMap,
pandora::ClusterSet &  usedClusters,
ClusterMergeMap clusterMergeMap 
) const
private

Make decisions about whether to create a pfo for a provided particle and whether to make cluster merges.

Parameters
particlethe particle
slidingFitResultMapthe sliding fit result map
segmentOverlapMapthe segment overlap map
usedClustersthe list of used clusters
clusterMergeMapto receive details of cluster merges clusterMergeMap
Returns
whether to make the particle

Definition at line 291 of file MissingTrackSegmentTool.cc.

References IsPossibleMerge(), lar_content::MissingTrackSegmentTool::Particle::m_longMaxX, lar_content::MissingTrackSegmentTool::Particle::m_longMinX, m_minFinalXOverlapFraction, lar_content::MissingTrackSegmentTool::Particle::m_pShortCluster, lar_content::MissingTrackSegmentTool::Particle::m_shortMaxX, lar_content::MissingTrackSegmentTool::Particle::m_shortMinX, PassesSamplingCuts(), and lar_content::LArClusterHelper::SortByNHits().

Referenced by PassesParticleChecks().

293 {
294  ClusterVector possibleMerges;
295  float shortMinX(particle.m_shortMinX), shortMaxX(particle.m_shortMaxX);
296  bool matchesACluster(false);
297 
298  ClusterVector sortedClusters;
299  for (const auto &mapEntry : segmentOverlapMap)
300  sortedClusters.push_back(mapEntry.first);
301  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
302 
303  for (const Cluster *const pCluster : sortedClusters)
304  {
305  const SegmentOverlap &segmentOverlap(segmentOverlapMap.at(pCluster));
306 
307  if (!this->PassesSamplingCuts(segmentOverlap))
308  continue;
309 
310  shortMinX = std::min(segmentOverlap.m_matchedSamplingMinX, shortMinX);
311  shortMaxX = std::max(segmentOverlap.m_matchedSamplingMaxX, shortMaxX);
312  matchesACluster = true;
313 
314  // Allow pfo construction if find hits in an unavailable cluster, but can't merge unavailable cluster into this pfo
315  if (!usedClusters.insert(pCluster).second || !pCluster->IsAvailable())
316  continue;
317 
318  if (!this->IsPossibleMerge(pCluster, particle, segmentOverlap, slidingFitResultMap))
319  continue;
320 
321  possibleMerges.push_back(pCluster);
322  }
323 
324  if (std::fabs(particle.m_longMaxX - particle.m_longMinX) < std::numeric_limits<float>::epsilon())
325  throw StatusCodeException(STATUS_CODE_FAILURE);
326 
327  if (!matchesACluster || possibleMerges.empty())
328  return false;
329 
330  if (((shortMaxX - shortMinX) / (particle.m_longMaxX - particle.m_longMinX)) < m_minFinalXOverlapFraction)
331  return false;
332 
333  ClusterList &clusterList(clusterMergeMap[particle.m_pShortCluster]);
334  clusterList.insert(clusterList.end(), possibleMerges.begin(), possibleMerges.end());
335  return true;
336 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
bool IsPossibleMerge(const pandora::Cluster *const pCluster, const Particle &particle, const SegmentOverlap &segmentOverlap, const TwoDSlidingFitResultMap &slidingFitResultMap) const
Whether the cluster could be merged with the candidate particle.
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
Definition: Polygon2D.cxx:20
float m_minFinalXOverlapFraction
The min x overlap fraction between extended short cluster and the long clusters.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool PassesSamplingCuts(const SegmentOverlap &segmentOverlap) const
Whether the segment overlap object passes cuts on matched sampling points, etc.
bool lar_content::MissingTrackSegmentTool::PassesParticleChecks ( ThreeViewTransverseTracksAlgorithm *const  pAlgorithm,
const TensorType::Element &  element,
pandora::ClusterSet &  usedClusters,
ClusterMergeMap clusterMergeMap 
) const
private

Whether a provided tensor element can be used to construct a pfo.

Parameters
pAlgorithmaddress of the calling algorithm
elementthe tensor element
usedClustersthe list of used clusters
clusterMergeMapto receive the cluster merge map

Definition at line 139 of file MissingTrackSegmentTool.cc.

References GetCandidateClusters(), GetSegmentOverlapMap(), GetSlidingFitResultMap(), and MakeDecisions().

Referenced by FindTracks().

141 {
142  try
143  {
144  const Particle particle(element);
145 
146  ClusterList candidateClusters;
147  this->GetCandidateClusters(pAlgorithm, particle, candidateClusters);
148 
149  if (candidateClusters.empty())
150  return false;
151 
152  TwoDSlidingFitResultMap slidingFitResultMap;
153  this->GetSlidingFitResultMap(pAlgorithm, candidateClusters, slidingFitResultMap);
154 
155  if (slidingFitResultMap.empty())
156  return false;
157 
158  SegmentOverlapMap segmentOverlapMap;
159  this->GetSegmentOverlapMap(pAlgorithm, particle, slidingFitResultMap, segmentOverlapMap);
160 
161  if (segmentOverlapMap.empty())
162  return false;
163 
164  return this->MakeDecisions(particle, slidingFitResultMap, segmentOverlapMap, usedClusters, clusterMergeMap);
165  }
166  catch (StatusCodeException &)
167  {
168  return false;
169  }
170 }
void GetSegmentOverlapMap(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, const TwoDSlidingFitResultMap &slidingFitResultMap, SegmentOverlapMap &segmentOverlapMap) const
Get a segment overlap map, describing overlap between a provided particle and all clusters in a slidi...
void GetCandidateClusters(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, pandora::ClusterList &candidateClusters) const
Get a list of candidate clusters, which may represent missing track segments for a provided particle...
bool MakeDecisions(const Particle &particle, const TwoDSlidingFitResultMap &slidingFitResultMap, const SegmentOverlapMap &segmentOverlapMap, pandora::ClusterSet &usedClusters, ClusterMergeMap &clusterMergeMap) const
Make decisions about whether to create a pfo for a provided particle and whether to make cluster merg...
std::unordered_map< const pandora::Cluster *, SegmentOverlap > SegmentOverlapMap
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
void GetSlidingFitResultMap(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const pandora::ClusterList &candidateClusterList, TwoDSlidingFitResultMap &slidingFitResultMap) const
Get a sliding fit result map for the list of candidate clusters.
bool lar_content::MissingTrackSegmentTool::PassesSamplingCuts ( const SegmentOverlap segmentOverlap) const
private

Whether the segment overlap object passes cuts on matched sampling points, etc.

Parameters
segmentOverlapthe segment overlap
Returns
boolean

Definition at line 340 of file MissingTrackSegmentTool.cc.

References m_makePfoMinMatchedFraction, m_makePfoMinMatchedSamplingPoints, m_makePfoMinSamplingPoints, lar_content::MissingTrackSegmentTool::SegmentOverlap::m_nMatchedSamplingPoints, and lar_content::MissingTrackSegmentTool::SegmentOverlap::m_nSamplingPoints.

Referenced by MakeDecisions().

341 {
342  if (0 == segmentOverlap.m_nSamplingPoints)
343  return false;
344 
345  if ((segmentOverlap.m_nSamplingPoints < m_makePfoMinSamplingPoints) || (segmentOverlap.m_nMatchedSamplingPoints < m_makePfoMinMatchedSamplingPoints))
346  return false;
347 
348  if ((static_cast<float>(segmentOverlap.m_nMatchedSamplingPoints) / static_cast<float>(segmentOverlap.m_nSamplingPoints)) < m_makePfoMinMatchedFraction)
349  return false;
350 
351  return true;
352 }
unsigned int m_makePfoMinMatchedSamplingPoints
The min number of matched sampling points in order to be able to make pfo.
unsigned int m_makePfoMinSamplingPoints
The min number of sampling points in order to be able to make pfo.
float m_makePfoMinMatchedFraction
The min matched sampling point fraction in order to be able to make pfo.
StatusCode lar_content::MissingTrackSegmentTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 421 of file MissingTrackSegmentTool.cc.

References m_makePfoMaxImpactParameter, m_makePfoMinMatchedFraction, m_makePfoMinMatchedSamplingPoints, m_makePfoMinSamplingPoints, m_mergeMaxChi2PerSamplingPoint, m_mergeXContainmentTolerance, m_minCaloHitsInCandidateCluster, m_minFinalXOverlapFraction, m_minInitialXOverlapFraction, m_minMatchedFraction, m_minMatchedSamplingPointRatio, m_minMatchedSamplingPoints, and m_pseudoChi2Cut.

422 {
423  PANDORA_RETURN_RESULT_IF_AND_IF(
424  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchedFraction", m_minMatchedFraction));
425 
426  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
427  XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
428 
429  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
430  XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPointRatio", m_minMatchedSamplingPointRatio));
431 
432  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
433  XmlHelper::ReadValue(xmlHandle, "MinInitialXOverlapFraction", m_minInitialXOverlapFraction));
434 
435  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
436  XmlHelper::ReadValue(xmlHandle, "MinFinalXOverlapFraction", m_minFinalXOverlapFraction));
437 
438  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
439  XmlHelper::ReadValue(xmlHandle, "MinCaloHitsInCandidateCluster", m_minCaloHitsInCandidateCluster));
440 
441  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PseudoChi2Cut", m_pseudoChi2Cut));
442 
443  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
444  XmlHelper::ReadValue(xmlHandle, "MakePfoMinSamplingPoints", m_makePfoMinSamplingPoints));
445 
446  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
447  XmlHelper::ReadValue(xmlHandle, "MakePfoMinMatchedSamplingPoints", m_makePfoMinMatchedSamplingPoints));
448 
449  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
450  XmlHelper::ReadValue(xmlHandle, "MakePfoMinMatchedFraction", m_makePfoMinMatchedFraction));
451 
452  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
453  XmlHelper::ReadValue(xmlHandle, "MakePfoMaxImpactParameter", m_makePfoMaxImpactParameter));
454 
455  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
456  XmlHelper::ReadValue(xmlHandle, "MergeMaxChi2PerSamplingPoint", m_mergeMaxChi2PerSamplingPoint));
457 
458  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
459  XmlHelper::ReadValue(xmlHandle, "MergeXContainmentTolerance", m_mergeXContainmentTolerance));
460 
461  return STATUS_CODE_SUCCESS;
462 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minInitialXOverlapFraction
The min x overlap fraction (between long clusters and short cluster vs. shared overlap) ...
unsigned int m_makePfoMinMatchedSamplingPoints
The min number of matched sampling points in order to be able to make pfo.
float m_makePfoMaxImpactParameter
The max transverse impact parameter in order to be able to make pfo.
unsigned int m_minCaloHitsInCandidateCluster
The min no. of calo hits in a candidate cluster, for matching with long clusters. ...
float m_pseudoChi2Cut
The pseudo chi2 cut to determine whether a sampling point is matched.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
unsigned int m_makePfoMinSamplingPoints
The min number of sampling points in order to be able to make pfo.
float m_minFinalXOverlapFraction
The min x overlap fraction between extended short cluster and the long clusters.
float m_mergeXContainmentTolerance
The tolerance in determining whether candidate cluster is contained in x window.
float m_makePfoMinMatchedFraction
The min matched sampling point fraction in order to be able to make pfo.
float m_mergeMaxChi2PerSamplingPoint
The max value of chi2 per sampling point in order to merge cluster with parent.
bool lar_content::MissingTrackSegmentTool::Run ( ThreeViewTransverseTracksAlgorithm *const  pAlgorithm,
TensorType overlapTensor 
)
virtual

Run the algorithm tool.

Parameters
pAlgorithmaddress of the calling algorithm
overlapTensorthe overlap tensor
Returns
whether changes have been made by the tool

Implements lar_content::TransverseTensorTool.

Definition at line 44 of file MissingTrackSegmentTool.cc.

References lar_content::MatchingBaseAlgorithm::CreateThreeDParticles(), FindTracks(), and lar_content::MatchingBaseAlgorithm::MakeClusterMerges().

45 {
46  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
47  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
48 
49  ProtoParticleVector protoParticleVector;
50  ClusterMergeMap clusterMergeMap;
51  this->FindTracks(pAlgorithm, overlapTensor, protoParticleVector, clusterMergeMap);
52 
53  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
54  const bool mergesMade(pAlgorithm->MakeClusterMerges(clusterMergeMap));
55 
56  return (particlesMade || mergesMade);
57 }
std::vector< ProtoParticle > ProtoParticleVector
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
void FindTracks(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector, ClusterMergeMap &clusterMergeMap) const
Find remaining tracks, hidden by missing track segments (and maybe other ambiguities) in the tensor...
void lar_content::MissingTrackSegmentTool::SelectElements ( const TensorType::ElementList elementList,
const pandora::ClusterSet &  usedClusters,
IteratorList iteratorList 
) const
private

Select a list of the relevant elements from a set of connected tensor elements.

Parameters
elementListthe full list of connected tensor 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 106 of file MissingTrackSegmentTool.cc.

References m_minInitialXOverlapFraction, m_minMatchedFraction, and m_minMatchedSamplingPoints.

Referenced by FindTracks().

108 {
109  for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
110  {
111  if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
112  continue;
113 
114  if (eIter->GetOverlapResult().GetMatchedFraction() < m_minMatchedFraction)
115  continue;
116 
117  if (eIter->GetOverlapResult().GetNMatchedSamplingPoints() < m_minMatchedSamplingPoints)
118  continue;
119 
120  const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
121  const float shortSpan(std::min(xOverlap.GetXSpanU(), std::min(xOverlap.GetXSpanV(), xOverlap.GetXSpanW())));
122  const float longSpan1(std::max(xOverlap.GetXSpanU(), std::max(xOverlap.GetXSpanV(), xOverlap.GetXSpanW())));
123  const float longSpan2(((xOverlap.GetXSpanU() > shortSpan) && (xOverlap.GetXSpanU() < longSpan1)) ? xOverlap.GetXSpanU()
124  : ((xOverlap.GetXSpanV() > shortSpan) && (xOverlap.GetXSpanV() < longSpan1)) ? xOverlap.GetXSpanV()
125  : xOverlap.GetXSpanW());
126 
127  if ((xOverlap.GetXOverlapSpan() < std::numeric_limits<float>::epsilon()) || (longSpan1 < std::numeric_limits<float>::epsilon()))
128  continue;
129 
130  if (((shortSpan / xOverlap.GetXOverlapSpan()) < m_minInitialXOverlapFraction) || ((longSpan2 / longSpan1) < m_minInitialXOverlapFraction))
131  continue;
132 
133  iteratorList.push_back(eIter);
134  }
135 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
intermediate_table::const_iterator const_iterator
float m_minInitialXOverlapFraction
The min x overlap fraction (between long clusters and short cluster vs. shared overlap) ...

Member Data Documentation

float lar_content::MissingTrackSegmentTool::m_makePfoMaxImpactParameter
private

The max transverse impact parameter in order to be able to make pfo.

Definition at line 190 of file MissingTrackSegmentTool.h.

Referenced by ReadSettings().

float lar_content::MissingTrackSegmentTool::m_makePfoMinMatchedFraction
private

The min matched sampling point fraction in order to be able to make pfo.

Definition at line 189 of file MissingTrackSegmentTool.h.

Referenced by PassesSamplingCuts(), and ReadSettings().

unsigned int lar_content::MissingTrackSegmentTool::m_makePfoMinMatchedSamplingPoints
private

The min number of matched sampling points in order to be able to make pfo.

Definition at line 188 of file MissingTrackSegmentTool.h.

Referenced by PassesSamplingCuts(), and ReadSettings().

unsigned int lar_content::MissingTrackSegmentTool::m_makePfoMinSamplingPoints
private

The min number of sampling points in order to be able to make pfo.

Definition at line 187 of file MissingTrackSegmentTool.h.

Referenced by PassesSamplingCuts(), and ReadSettings().

float lar_content::MissingTrackSegmentTool::m_mergeMaxChi2PerSamplingPoint
private

The max value of chi2 per sampling point in order to merge cluster with parent.

Definition at line 192 of file MissingTrackSegmentTool.h.

Referenced by IsPossibleMerge(), and ReadSettings().

float lar_content::MissingTrackSegmentTool::m_mergeXContainmentTolerance
private

The tolerance in determining whether candidate cluster is contained in x window.

Definition at line 193 of file MissingTrackSegmentTool.h.

Referenced by IsPossibleMerge(), and ReadSettings().

unsigned int lar_content::MissingTrackSegmentTool::m_minCaloHitsInCandidateCluster
private

The min no. of calo hits in a candidate cluster, for matching with long clusters.

Definition at line 184 of file MissingTrackSegmentTool.h.

Referenced by GetCandidateClusters(), and ReadSettings().

float lar_content::MissingTrackSegmentTool::m_minFinalXOverlapFraction
private

The min x overlap fraction between extended short cluster and the long clusters.

Definition at line 182 of file MissingTrackSegmentTool.h.

Referenced by MakeDecisions(), and ReadSettings().

float lar_content::MissingTrackSegmentTool::m_minInitialXOverlapFraction
private

The min x overlap fraction (between long clusters and short cluster vs. shared overlap)

Definition at line 181 of file MissingTrackSegmentTool.h.

Referenced by ReadSettings(), and SelectElements().

float lar_content::MissingTrackSegmentTool::m_minMatchedFraction
private

The min matched sampling point fraction for particle creation.

Definition at line 177 of file MissingTrackSegmentTool.h.

Referenced by ReadSettings(), and SelectElements().

unsigned int lar_content::MissingTrackSegmentTool::m_minMatchedSamplingPointRatio
private

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

Definition at line 179 of file MissingTrackSegmentTool.h.

Referenced by FindTracks(), and ReadSettings().

unsigned int lar_content::MissingTrackSegmentTool::m_minMatchedSamplingPoints
private

The min number of matched sampling points for particle creation.

Definition at line 178 of file MissingTrackSegmentTool.h.

Referenced by ReadSettings(), and SelectElements().

float lar_content::MissingTrackSegmentTool::m_pseudoChi2Cut
private

The pseudo chi2 cut to determine whether a sampling point is matched.

Definition at line 185 of file MissingTrackSegmentTool.h.

Referenced by GetSegmentOverlapMap(), and ReadSettings().


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