All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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 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
*, SegmentOverlap
SegmentOverlapMap
 
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...
 

Additional Inherited Members

- Public Types inherited from lar_content::TransverseTensorTool
typedef
ThreeViewTransverseTracksAlgorithm::MatchingType::TensorType 
TensorType
 
typedef std::vector
< TensorType::ElementList::const_iterator
IteratorList
 

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) ...
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.

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...
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 175 of file MissingTrackSegmentTool.cc.

177 {
178  const ClusterList &clusterList(pAlgorithm->GetInputClusterList(particle.m_shortHitType));
179 
180  for (ClusterList::const_iterator iter = clusterList.begin(), iterEnd = clusterList.end(); iter != iterEnd; ++iter)
181  {
182  const Cluster *const pCluster(*iter);
183 
184  if (pCluster == particle.m_pShortCluster)
185  continue;
186 
187  if (pCluster->GetNCaloHits() < m_minCaloHitsInCandidateCluster)
188  continue;
189 
190  candidateClusters.push_back(pCluster);
191  }
192 }
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 229 of file MissingTrackSegmentTool.cc.

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

198 {
199  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
200 
201  for (ClusterList::const_iterator iter = candidateClusterList.begin(), iterEnd = candidateClusterList.end(); iter != iterEnd; ++iter)
202  {
203  const Cluster *const pCluster(*iter);
204 
205  try
206  {
207  const TwoDSlidingFitResult &slidingFitResult(pAlgorithm->GetCachedSlidingFitResult(pCluster));
208  (void)slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult));
209  continue;
210  }
211  catch (StatusCodeException &)
212  {
213  }
214 
215  try
216  {
217  const TwoDSlidingFitResult slidingFitResult(pCluster, pAlgorithm->GetSlidingFitWindow(), slidingFitPitch);
218  (void)slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult));
219  continue;
220  }
221  catch (StatusCodeException &)
222  {
223  }
224  }
225 }
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
j template void())
Definition: json.hpp:3108
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 358 of file MissingTrackSegmentTool.cc.

360 {
361  if ((segmentOverlap.m_pseudoChi2Sum / static_cast<float>(segmentOverlap.m_nSamplingPoints)) > m_mergeMaxChi2PerSamplingPoint)
362  return false;
363 
364  TwoDSlidingFitResultMap::const_iterator fitIter = slidingFitResultMap.find(pCluster);
365 
366  if (slidingFitResultMap.end() == fitIter)
367  throw StatusCodeException(STATUS_CODE_FAILURE);
368 
369  float mergeMinX(std::numeric_limits<float>::max()), mergeMaxX(-std::numeric_limits<float>::max());
370  fitIter->second.GetMinAndMaxX(mergeMinX, mergeMaxX);
371 
372  // cluster should not be wider than the longest span
373  if ((mergeMinX < particle.m_longMinX - m_mergeXContainmentTolerance) || (mergeMaxX > particle.m_longMaxX + m_mergeXContainmentTolerance))
374  return false;
375 
376  // cluster should not overlap with the shortest span
377  if ((mergeMinX < particle.m_shortMaxX - m_mergeXContainmentTolerance) && (mergeMaxX > particle.m_shortMinX + m_mergeXContainmentTolerance))
378  return false;
379 
380  return true;
381 }
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 293 of file MissingTrackSegmentTool.cc.

295 {
296  ClusterVector possibleMerges;
297  float shortMinX(particle.m_shortMinX), shortMaxX(particle.m_shortMaxX);
298  bool matchesACluster(false);
299 
300  ClusterVector sortedClusters;
301  for (const auto &mapEntry : segmentOverlapMap)
302  sortedClusters.push_back(mapEntry.first);
303  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
304 
305  for (const Cluster *const pCluster : sortedClusters)
306  {
307  const SegmentOverlap &segmentOverlap(segmentOverlapMap.at(pCluster));
308 
309  if (!this->PassesSamplingCuts(segmentOverlap))
310  continue;
311 
312  shortMinX = std::min(segmentOverlap.m_matchedSamplingMinX, shortMinX);
313  shortMaxX = std::max(segmentOverlap.m_matchedSamplingMaxX, shortMaxX);
314  matchesACluster = true;
315 
316  // Allow pfo construction if find hits in an unavailable cluster, but can't merge unavailable cluster into this pfo
317  if (!usedClusters.insert(pCluster).second || !pCluster->IsAvailable())
318  continue;
319 
320  if (!this->IsPossibleMerge(pCluster, particle, segmentOverlap, slidingFitResultMap))
321  continue;
322 
323  possibleMerges.push_back(pCluster);
324  }
325 
326  if (std::fabs(particle.m_longMaxX - particle.m_longMinX) < std::numeric_limits<float>::epsilon())
327  throw StatusCodeException(STATUS_CODE_FAILURE);
328 
329  if (!matchesACluster || possibleMerges.empty())
330  return false;
331 
332  if (((shortMaxX - shortMinX) / (particle.m_longMaxX - particle.m_longMinX)) < m_minFinalXOverlapFraction)
333  return false;
334 
335  ClusterList &clusterList(clusterMergeMap[particle.m_pShortCluster]);
336  clusterList.insert(clusterList.end(), possibleMerges.begin(), possibleMerges.end());
337  return true;
338 }
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:21
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 140 of file MissingTrackSegmentTool.cc.

142 {
143  try
144  {
145  const Particle particle(element);
146 
147  ClusterList candidateClusters;
148  this->GetCandidateClusters(pAlgorithm, particle, candidateClusters);
149 
150  if (candidateClusters.empty())
151  return false;
152 
153  TwoDSlidingFitResultMap slidingFitResultMap;
154  this->GetSlidingFitResultMap(pAlgorithm, candidateClusters, slidingFitResultMap);
155 
156  if (slidingFitResultMap.empty())
157  return false;
158 
159  SegmentOverlapMap segmentOverlapMap;
160  this->GetSegmentOverlapMap(pAlgorithm, particle, slidingFitResultMap, segmentOverlapMap);
161 
162  if (segmentOverlapMap.empty())
163  return false;
164 
165  return this->MakeDecisions(particle, slidingFitResultMap, segmentOverlapMap, usedClusters, clusterMergeMap);
166  }
167  catch (StatusCodeException &)
168  {
169  return false;
170  }
171 }
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 342 of file MissingTrackSegmentTool.cc.

343 {
344  if (0 == segmentOverlap.m_nSamplingPoints)
345  return false;
346 
347  if ((segmentOverlap.m_nSamplingPoints < m_makePfoMinSamplingPoints) || (segmentOverlap.m_nMatchedSamplingPoints < m_makePfoMinMatchedSamplingPoints))
348  return false;
349 
350  if ((static_cast<float>(segmentOverlap.m_nMatchedSamplingPoints) / static_cast<float>(segmentOverlap.m_nSamplingPoints)) < m_makePfoMinMatchedFraction)
351  return false;
352 
353  return true;
354 }
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 419 of file MissingTrackSegmentTool.cc.

420 {
421  PANDORA_RETURN_RESULT_IF_AND_IF(
422  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchedFraction", m_minMatchedFraction));
423 
424  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
425  XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
426 
427  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
428  XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPointRatio", m_minMatchedSamplingPointRatio));
429 
430  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
431  XmlHelper::ReadValue(xmlHandle, "MinInitialXOverlapFraction", m_minInitialXOverlapFraction));
432 
433  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
434  XmlHelper::ReadValue(xmlHandle, "MinFinalXOverlapFraction", m_minFinalXOverlapFraction));
435 
436  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
437  XmlHelper::ReadValue(xmlHandle, "MinCaloHitsInCandidateCluster", m_minCaloHitsInCandidateCluster));
438 
439  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PseudoChi2Cut", m_pseudoChi2Cut));
440 
441  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
442  XmlHelper::ReadValue(xmlHandle, "MakePfoMinSamplingPoints", m_makePfoMinSamplingPoints));
443 
444  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
445  XmlHelper::ReadValue(xmlHandle, "MakePfoMinMatchedSamplingPoints", m_makePfoMinMatchedSamplingPoints));
446 
447  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
448  XmlHelper::ReadValue(xmlHandle, "MakePfoMinMatchedFraction", m_makePfoMinMatchedFraction));
449 
450  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
451  XmlHelper::ReadValue(xmlHandle, "MakePfoMaxImpactParameter", m_makePfoMaxImpactParameter));
452 
453  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
454  XmlHelper::ReadValue(xmlHandle, "MergeMaxChi2PerSamplingPoint", m_mergeMaxChi2PerSamplingPoint));
455 
456  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
457  XmlHelper::ReadValue(xmlHandle, "MergeXContainmentTolerance", m_mergeXContainmentTolerance));
458 
459  return STATUS_CODE_SUCCESS;
460 }
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.

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...
BEGIN_PROLOG could also be cout
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.

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(
124  ((xOverlap.GetXSpanU() > shortSpan) && (xOverlap.GetXSpanU() < longSpan1))
125  ? xOverlap.GetXSpanU()
126  : ((xOverlap.GetXSpanV() > shortSpan) && (xOverlap.GetXSpanV() < longSpan1)) ? xOverlap.GetXSpanV() : xOverlap.GetXSpanW());
127 
128  if ((xOverlap.GetXOverlapSpan() < std::numeric_limits<float>::epsilon()) || (longSpan1 < std::numeric_limits<float>::epsilon()))
129  continue;
130 
131  if (((shortSpan / xOverlap.GetXOverlapSpan()) < m_minInitialXOverlapFraction) || ((longSpan2 / longSpan1) < m_minInitialXOverlapFraction))
132  continue;
133 
134  iteratorList.push_back(eIter);
135  }
136 }
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) ...

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.

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.

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.

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.

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.

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.

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.

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.

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.

float lar_content::MissingTrackSegmentTool::m_minMatchedFraction
private

The min matched sampling point fraction for particle creation.

Definition at line 177 of file MissingTrackSegmentTool.h.

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.

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.

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.


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