LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 ThreeDTransverseTracksAlgorithm::TensorType TensorType
 
typedef std::vector< TensorType::ElementList::const_iteratorIteratorList
 

Public Member Functions

 MissingTrackSegmentTool ()
 Default constructor. More...
 
bool Run (ThreeDTransverseTracksAlgorithm *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 (ThreeDTransverseTracksAlgorithm *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 (ThreeDTransverseTracksAlgorithm *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 (ThreeDTransverseTracksAlgorithm *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 (ThreeDTransverseTracksAlgorithm *const pAlgorithm, const pandora::ClusterList &candidateClusterList, TwoDSlidingFitResultMap &slidingFitResultMap) const
 Get a sliding fit result map for the list of candidate clusters. More...
 
void GetSegmentOverlapMap (ThreeDTransverseTracksAlgorithm *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 ( ThreeDTransverseTracksAlgorithm *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 60 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_clusterListU, lar_content::ProtoParticle::m_clusterListV, lar_content::ProtoParticle::m_clusterListW, m_minMatchedSamplingPointRatio, PassesParticleChecks(), and SelectElements().

Referenced by Run().

62 {
63  ClusterSet usedClusters;
64  ClusterVector sortedKeyClusters;
65  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
66 
67  for (const Cluster *const pKeyCluster : sortedKeyClusters)
68  {
69  if (!pKeyCluster->IsAvailable())
70  continue;
71 
72  unsigned int nU(0), nV(0), nW(0);
73  TensorType::ElementList elementList;
74  overlapTensor.GetConnectedElements(pKeyCluster, true, elementList, nU, nV, nW);
75 
76  IteratorList iteratorList;
77  this->SelectElements(elementList, usedClusters, iteratorList);
78 
79  for (IteratorList::const_iterator iIter = iteratorList.begin(), iIterEnd = iteratorList.end(); iIter != iIterEnd; ++iIter)
80  {
81  if (LongTracksTool::HasLongDirectConnections(iIter, iteratorList))
82  continue;
83 
85  continue;
86 
87  if (!this->PassesParticleChecks(pAlgorithm, *(*iIter), usedClusters, clusterMergeMap))
88  continue;
89 
90  ProtoParticle protoParticle;
91  protoParticle.m_clusterListU.push_back((*iIter)->GetClusterU());
92  protoParticle.m_clusterListV.push_back((*iIter)->GetClusterV());
93  protoParticle.m_clusterListW.push_back((*iIter)->GetClusterW());
94  protoParticleVector.push_back(protoParticle);
95 
96  usedClusters.insert((*iIter)->GetClusterU());
97  usedClusters.insert((*iIter)->GetClusterV());
98  usedClusters.insert((*iIter)->GetClusterW());
99  }
100  }
101 }
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
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.
bool PassesParticleChecks(ThreeDTransverseTracksAlgorithm *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 lar_content::MissingTrackSegmentTool::GetCandidateClusters ( ThreeDTransverseTracksAlgorithm *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 171 of file MissingTrackSegmentTool.cc.

References lar_content::ThreeDBaseAlgorithm< T >::GetInputClusterListU(), lar_content::ThreeDBaseAlgorithm< T >::GetInputClusterListV(), lar_content::ThreeDBaseAlgorithm< T >::GetInputClusterListW(), m_minCaloHitsInCandidateCluster, lar_content::MissingTrackSegmentTool::Particle::m_pShortCluster, and lar_content::MissingTrackSegmentTool::Particle::m_shortHitType.

Referenced by PassesParticleChecks().

173 {
174  const ClusterList &clusterList((TPC_VIEW_U == particle.m_shortHitType) ? pAlgorithm->GetInputClusterListU() :
175  (TPC_VIEW_V == particle.m_shortHitType) ? pAlgorithm->GetInputClusterListV() : pAlgorithm->GetInputClusterListW());
176 
177  for (ClusterList::const_iterator iter = clusterList.begin(), iterEnd = clusterList.end(); iter != iterEnd; ++iter)
178  {
179  const Cluster *const pCluster(*iter);
180 
181  if (pCluster == particle.m_pShortCluster)
182  continue;
183 
184  if (pCluster->GetNCaloHits() < m_minCaloHitsInCandidateCluster)
185  continue;
186 
187  candidateClusters.push_back(pCluster);
188  }
189 }
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 ( ThreeDTransverseTracksAlgorithm *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 226 of file MissingTrackSegmentTool.cc.

References f, lar_content::ThreeDTracksBaseAlgorithm< 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, max, lar_content::LArGeometryHelper::MergeTwoPositions(), min, n, lar_content::LArClusterHelper::SortByNHits(), and x.

Referenced by PassesParticleChecks().

228 {
229  const TwoDSlidingFitResult &fitResult1(pAlgorithm->GetCachedSlidingFitResult(particle.m_pCluster1));
230  const TwoDSlidingFitResult &fitResult2(pAlgorithm->GetCachedSlidingFitResult(particle.m_pCluster2));
231 
232  const float nPoints1(std::fabs(static_cast<float>(fitResult1.GetMaxLayer() - fitResult1.GetMinLayer())));
233  const float nPoints2(std::fabs(static_cast<float>(fitResult2.GetMaxLayer() - fitResult2.GetMinLayer())));
234 
235  const unsigned int nPoints(static_cast<unsigned int>(1.f + (nPoints1 + nPoints2) / 2.f));
236 
237  ClusterList clusterList;
238  for (const auto &mapEntry : slidingFitResultMap) clusterList.push_back(mapEntry.first);
239  clusterList.sort(LArClusterHelper::SortByNHits);
240 
241  for (unsigned n = 0; n <= nPoints; ++n)
242  {
243  const float x(particle.m_longMinX + (particle.m_longMaxX - particle.m_longMinX) * static_cast<float>(n) / static_cast<float>(nPoints));
244 
245  if ((x > particle.m_shortMinX) && (x < particle.m_shortMaxX))
246  continue;
247 
248  CartesianVector fitVector1(0.f, 0.f, 0.f), fitVector2(0.f, 0.f, 0.f);
249 
250  if ((STATUS_CODE_SUCCESS != fitResult1.GetGlobalFitPositionAtX(x, fitVector1)) ||
251  (STATUS_CODE_SUCCESS != fitResult2.GetGlobalFitPositionAtX(x, fitVector2)))
252  {
253  continue;
254  }
255 
256  const float prediction(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), particle.m_hitType1, particle.m_hitType2, fitVector1.GetZ(), fitVector2.GetZ()));
257 
258  for (const Cluster *const pCluster : clusterList)
259  {
260  const TwoDSlidingFitResult &slidingFitResult(slidingFitResultMap.at(pCluster));
261  CartesianVector fitVector(0.f, 0.f, 0.f), fitDirection(0.f, 0.f, 0.f);
262 
263  if ((STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitPositionAtX(x, fitVector)) ||
264  (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirectionAtX(x, fitDirection)))
265  {
266  continue;
267  }
268 
269  const float delta((prediction - fitVector.GetZ()) * fitDirection.GetX());
270  const float pseudoChi2(delta * delta);
271 
272  SegmentOverlap &segmentOverlap(segmentOverlapMap[pCluster]);
273  ++segmentOverlap.m_nSamplingPoints;
274  segmentOverlap.m_pseudoChi2Sum += pseudoChi2;
275 
276  if (pseudoChi2 < m_pseudoChi2Cut)
277  {
278  ++segmentOverlap.m_nMatchedSamplingPoints;
279  segmentOverlap.m_matchedSamplingMinX = std::min(x, segmentOverlap.m_matchedSamplingMinX);
280  segmentOverlap.m_matchedSamplingMaxX = std::max(x, segmentOverlap.m_matchedSamplingMaxX);
281  }
282  }
283  }
284 }
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
Int_t max
Definition: plot.C:27
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
Definition: Polygon2D.cxx:18
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.
Int_t min
Definition: plot.C:26
Char_t n[5]
void lar_content::MissingTrackSegmentTool::GetSlidingFitResultMap ( ThreeDTransverseTracksAlgorithm *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 193 of file MissingTrackSegmentTool.cc.

References lar_content::ThreeDTracksBaseAlgorithm< T >::GetCachedSlidingFitResult(), lar_content::ThreeDTracksBaseAlgorithm< T >::GetSlidingFitWindow(), and lar_content::LArGeometryHelper::GetWireZPitch().

Referenced by PassesParticleChecks().

195 {
196  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
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 TwoDSlidingFitResult slidingFitResult(pCluster, pAlgorithm->GetSlidingFitWindow(), slidingFitPitch);
215  (void) slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult));
216  continue;
217  }
218  catch (StatusCodeException &)
219  {
220  }
221  }
222 }
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
intermediate_table::const_iterator const_iterator
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 352 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, lar_content::MissingTrackSegmentTool::Particle::m_shortMinX, and max.

Referenced by MakeDecisions().

354 {
355  if ((segmentOverlap.m_pseudoChi2Sum / static_cast<float>(segmentOverlap.m_nSamplingPoints)) > m_mergeMaxChi2PerSamplingPoint)
356  return false;
357 
358  TwoDSlidingFitResultMap::const_iterator fitIter = slidingFitResultMap.find(pCluster);
359 
360  if (slidingFitResultMap.end() == fitIter)
361  throw StatusCodeException(STATUS_CODE_FAILURE);
362 
363  float mergeMinX(std::numeric_limits<float>::max()), mergeMaxX(-std::numeric_limits<float>::max());
364  fitIter->second.GetMinAndMaxX(mergeMinX, mergeMaxX);
365 
366  // cluster should not be wider than the longest span
367  if ((mergeMinX < particle.m_longMinX - m_mergeXContainmentTolerance) || (mergeMaxX > particle.m_longMaxX + m_mergeXContainmentTolerance))
368  return false;
369 
370  // cluster should not overlap with the shortest span
371  if ((mergeMinX < particle.m_shortMaxX - m_mergeXContainmentTolerance) && (mergeMaxX > particle.m_shortMinX + m_mergeXContainmentTolerance))
372  return false;
373 
374  return true;
375 }
Int_t max
Definition: plot.C:27
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 288 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, max, min, PassesSamplingCuts(), and lar_content::LArClusterHelper::SortByNHits().

Referenced by PassesParticleChecks().

290 {
291  ClusterVector possibleMerges;
292  float shortMinX(particle.m_shortMinX), shortMaxX(particle.m_shortMaxX);
293  bool matchesACluster(false);
294 
295  ClusterVector sortedClusters;
296  for (const auto &mapEntry : segmentOverlapMap) sortedClusters.push_back(mapEntry.first);
297  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
298 
299  for (const Cluster *const pCluster : sortedClusters)
300  {
301  const SegmentOverlap &segmentOverlap(segmentOverlapMap.at(pCluster));
302 
303  if (!this->PassesSamplingCuts(segmentOverlap))
304  continue;
305 
306  shortMinX = std::min(segmentOverlap.m_matchedSamplingMinX, shortMinX);
307  shortMaxX = std::max(segmentOverlap.m_matchedSamplingMaxX, shortMaxX);
308  matchesACluster = true;
309 
310  // Allow pfo construction if find hits in an unavailable cluster, but can't merge unavailable cluster into this pfo
311  if (!usedClusters.insert(pCluster).second || !pCluster->IsAvailable())
312  continue;
313 
314  if (!this->IsPossibleMerge(pCluster, particle, segmentOverlap, slidingFitResultMap))
315  continue;
316 
317  possibleMerges.push_back(pCluster);
318  }
319 
320  if (std::fabs(particle.m_longMaxX - particle.m_longMinX) < std::numeric_limits<float>::epsilon())
321  throw StatusCodeException(STATUS_CODE_FAILURE);
322 
323  if (!matchesACluster || possibleMerges.empty())
324  return false;
325 
326  if (((shortMaxX - shortMinX) / (particle.m_longMaxX - particle.m_longMinX)) < m_minFinalXOverlapFraction)
327  return false;
328 
329  ClusterList &clusterList(clusterMergeMap[particle.m_pShortCluster]);
330  clusterList.insert(clusterList.end(), possibleMerges.begin(), possibleMerges.end());
331  return true;
332 }
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.
Int_t max
Definition: plot.C:27
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
Definition: Polygon2D.cxx:18
std::vector< art::Ptr< recob::Cluster > > ClusterVector
float m_minFinalXOverlapFraction
The min x overlap fraction between extended short cluster and the long clusters.
Int_t min
Definition: plot.C:26
bool PassesSamplingCuts(const SegmentOverlap &segmentOverlap) const
Whether the segment overlap object passes cuts on matched sampling points, etc.
bool lar_content::MissingTrackSegmentTool::PassesParticleChecks ( ThreeDTransverseTracksAlgorithm *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 136 of file MissingTrackSegmentTool.cc.

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

Referenced by FindTracks().

138 {
139  try
140  {
141  const Particle particle(element);
142 
143  ClusterList candidateClusters;
144  this->GetCandidateClusters(pAlgorithm, particle, candidateClusters);
145 
146  if (candidateClusters.empty())
147  return false;
148 
149  TwoDSlidingFitResultMap slidingFitResultMap;
150  this->GetSlidingFitResultMap(pAlgorithm, candidateClusters, slidingFitResultMap);
151 
152  if (slidingFitResultMap.empty())
153  return false;
154 
155  SegmentOverlapMap segmentOverlapMap;
156  this->GetSegmentOverlapMap(pAlgorithm, particle, slidingFitResultMap, segmentOverlapMap);
157 
158  if (segmentOverlapMap.empty())
159  return false;
160 
161  return this->MakeDecisions(particle, slidingFitResultMap, segmentOverlapMap, usedClusters, clusterMergeMap);
162  }
163  catch (StatusCodeException &)
164  {
165  return false;
166  }
167 }
void GetSlidingFitResultMap(ThreeDTransverseTracksAlgorithm *const pAlgorithm, const pandora::ClusterList &candidateClusterList, TwoDSlidingFitResultMap &slidingFitResultMap) const
Get a sliding fit result map for the list of candidate clusters.
void GetSegmentOverlapMap(ThreeDTransverseTracksAlgorithm *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(ThreeDTransverseTracksAlgorithm *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...
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
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
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 336 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().

337 {
338  if (0 == segmentOverlap.m_nSamplingPoints)
339  return false;
340 
341  if ((segmentOverlap.m_nSamplingPoints < m_makePfoMinSamplingPoints) || (segmentOverlap.m_nMatchedSamplingPoints < m_makePfoMinMatchedSamplingPoints))
342  return false;
343 
344  if ((static_cast<float>(segmentOverlap.m_nMatchedSamplingPoints) / static_cast<float>(segmentOverlap.m_nSamplingPoints)) < m_makePfoMinMatchedFraction)
345  return false;
346 
347  return true;
348 }
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 406 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.

407 {
408  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
409  "MinMatchedFraction", m_minMatchedFraction));
410 
411  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
412  "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
413 
414  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
415  "MinMatchedSamplingPointRatio", m_minMatchedSamplingPointRatio));
416 
417  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
418  "MinInitialXOverlapFraction", m_minInitialXOverlapFraction));
419 
420  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
421  "MinFinalXOverlapFraction", m_minFinalXOverlapFraction));
422 
423  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
424  "MinCaloHitsInCandidateCluster", m_minCaloHitsInCandidateCluster));
425 
426  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
427  "PseudoChi2Cut", m_pseudoChi2Cut));
428 
429  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
430  "MakePfoMinSamplingPoints", m_makePfoMinSamplingPoints));
431 
432  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
433  "MakePfoMinMatchedSamplingPoints", m_makePfoMinMatchedSamplingPoints));
434 
435  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
436  "MakePfoMinMatchedFraction", m_makePfoMinMatchedFraction));
437 
438  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
439  "MakePfoMaxImpactParameter", m_makePfoMaxImpactParameter));
440 
441  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
442  "MergeMaxChi2PerSamplingPoint", m_mergeMaxChi2PerSamplingPoint));
443 
444  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
445  "MergeXContainmentTolerance", m_mergeXContainmentTolerance));
446 
447  return STATUS_CODE_SUCCESS;
448 }
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 ( ThreeDTransverseTracksAlgorithm *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::ThreeDBaseAlgorithm< T >::CreateThreeDParticles(), FindTracks(), and lar_content::ThreeDBaseAlgorithm< T >::MakeClusterMerges().

45 {
46  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
47  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
48 
49  ProtoParticleVector protoParticleVector; ClusterMergeMap clusterMergeMap;
50  this->FindTracks(pAlgorithm, overlapTensor, protoParticleVector, clusterMergeMap);
51 
52  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
53  const bool mergesMade(pAlgorithm->MakeClusterMerges(clusterMergeMap));
54 
55  return (particlesMade || mergesMade);
56 }
std::vector< ProtoParticle > ProtoParticleVector
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
void FindTracks(ThreeDTransverseTracksAlgorithm *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 105 of file MissingTrackSegmentTool.cc.

References m_minInitialXOverlapFraction, m_minMatchedFraction, m_minMatchedSamplingPoints, max, and min.

Referenced by FindTracks().

106 {
107  for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
108  {
109  if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
110  continue;
111 
112  if (eIter->GetOverlapResult().GetMatchedFraction() < m_minMatchedFraction)
113  continue;
114 
115  if (eIter->GetOverlapResult().GetNMatchedSamplingPoints() < m_minMatchedSamplingPoints)
116  continue;
117 
118  const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
119  const float shortSpan(std::min(xOverlap.GetXSpanU(), std::min(xOverlap.GetXSpanV(), xOverlap.GetXSpanW())));
120  const float longSpan1(std::max(xOverlap.GetXSpanU(), std::max(xOverlap.GetXSpanV(), xOverlap.GetXSpanW())));
121  const float longSpan2(((xOverlap.GetXSpanU() > shortSpan) && (xOverlap.GetXSpanU() < longSpan1)) ? xOverlap.GetXSpanU() :
122  ((xOverlap.GetXSpanV() > shortSpan) && (xOverlap.GetXSpanV() < longSpan1)) ? xOverlap.GetXSpanV() : xOverlap.GetXSpanW());
123 
124  if ((xOverlap.GetXOverlapSpan() < std::numeric_limits<float>::epsilon()) || (longSpan1 < std::numeric_limits<float>::epsilon()))
125  continue;
126 
127  if (((shortSpan / xOverlap.GetXOverlapSpan()) < m_minInitialXOverlapFraction) || ((longSpan2 / longSpan1) < m_minInitialXOverlapFraction))
128  continue;
129 
130  iteratorList.push_back(eIter);
131  }
132 }
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) ...
Int_t max
Definition: plot.C:27
intermediate_table::const_iterator const_iterator
Int_t min
Definition: plot.C:26

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: