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

TrackMergeRefinementAlgorithm class. More...

#include "TrackMergeRefinementAlgorithm.h"

Inheritance diagram for lar_content::TrackMergeRefinementAlgorithm:
lar_content::TrackRefinementBaseAlgorithm

Public Member Functions

 TrackMergeRefinementAlgorithm ()
 Default constructor. More...
 
template<typename T >
void InitialiseContainers (const ClusterList *pClusterList, const T sortFunction, ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
 
template<typename T >
void UpdateContainers (const ClusterList &clustersToAdd, const ClusterList &clustersToDelete, const T sortFunction, ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
 

Protected Types

typedef std::pair< TwoDSlidingFitResultMap *, TwoDSlidingFitResultMap * > SlidingFitResultMapPair
 
typedef std::unordered_map< const pandora::Cluster *, pandora::CaloHitList > ClusterToCaloHitListMap
 

Protected Member Functions

template<typename T >
void InitialiseContainers (const pandora::ClusterList *pClusterList, const T sortFunction, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
 Fill the cluster vector and sliding fit maps with clusters that are determined to be track-like. More...
 
bool GetClusterMergingCoordinates (const TwoDSlidingFitResult &clusterMicroFitResult, const TwoDSlidingFitResult &clusterMacroFitResult, const TwoDSlidingFitResult &associatedMacroFitResult, const bool isEndUpstream, pandora::CartesianVector &clusterMergePosition, pandora::CartesianVector &clusterMergeDirection) const
 Get the merging coordinate and direction for an input cluster with respect to an associated cluster. More...
 
void GetHitsInBoundingBox (const pandora::CartesianVector &firstCorner, const pandora::CartesianVector &secondCorner, const pandora::ClusterList *const pClusterList, ClusterToCaloHitListMap &clusterToCaloHitListMap, const pandora::ClusterList &unavailableProtectedClusters=pandora::ClusterList(), const float distanceToLine=-1.f) const
 Find the unprotected hits that are contained within a defined box with the option to apply a cut on the distance to the connecting line. More...
 
bool IsInBoundingBox (const float minX, const float maxX, const float minZ, const float maxZ, const pandora::CartesianVector &hitPosition) const
 check whether a hit is contained within a defined square region More...
 
bool IsCloseToLine (const pandora::CartesianVector &hitPosition, const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineDirection, const float distanceToLine) const
 Check whether a hit is close to a line. More...
 
bool AreExtrapolatedHitsGood (const ClusterToCaloHitListMap &clusterToCaloHitListMap, ClusterAssociation &clusterAssociation) const
 Perform topological checks on the collected hits to ensure no gaps are present. More...
 
bool IsNearBoundary (const pandora::CaloHit *const pCaloHit, const pandora::CartesianVector &boundaryPosition2D, const float boundaryTolerance) const
 Check whether a hit is close to a boundary point. More...
 
bool IsTrackContinuous (const ClusterAssociation &clusterAssociation, const pandora::CaloHitVector &extrapolatedCaloHitVector) const
 Check whether the extrapolatedCaloHitVector contains a continuous line of hits between the cluster merge points. More...
 
void GetTrackSegmentBoundaries (const ClusterAssociation &clusterAssociation, pandora::CartesianPointVector &trackSegmentBoundaries) const
 Obtain the segment boundaries of the connecting line to test whether extrapolated hits are continuous. More...
 
void RepositionIfInGap (const pandora::CartesianVector &mergeDirection, pandora::CartesianVector &trackPoint) const
 Move an input position to the higher line gap edge if it lies within a gap. More...
 
float DistanceInGap (const pandora::CartesianVector &upstreamPoint, const pandora::CartesianVector &downstreamPoint, const pandora::CartesianVector &connectingLine, pandora::DetectorGapList &consideredGaps) const
 Calculate the track length between two points that lies in gaps. More...
 
bool IsInLineSegment (const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary, const pandora::CartesianVector &point) const
 Whether a position falls within a specified segment of the cluster connecting line. More...
 
const pandora::Cluster * RemoveOffAxisHitsFromTrack (const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition, const bool isEndUpstream, const ClusterToCaloHitListMap &clusterToCaloHitListMap, pandora::ClusterList &remnantClusterList, TwoDSlidingFitResultMap &microSlidingFitResultMap, TwoDSlidingFitResultMap &macroSlidingFitResultMap) const
 Remove any hits in the upstream/downstream cluster that lie off of the main track axis (i.e. clustering errors) More...
 
void AddHitsToMainTrack (const pandora::Cluster *const pMainTrackCluster, const pandora::Cluster *const pShowerTrackCluster, const pandora::CaloHitList &caloHitsToMerge, const ClusterAssociation &clusterAssociation, pandora::ClusterList &remnantClusterList) const
 Remove the hits from a shower cluster that belong to the main track and add them into the main track cluster. More...
 
void ProcessRemnantClusters (const pandora::ClusterList &remnantClusterList, const pandora::Cluster *const pMainTrackCluster, const pandora::ClusterList *const pClusterList, pandora::ClusterList &createdClusters) const
 Process the remnant clusters separating those that stradle the main track. More...
 
bool AddToNearestCluster (const pandora::Cluster *const pClusterToMerge, const pandora::Cluster *const pMainTrackCluster, const pandora::ClusterList *const pClusterList) const
 Add a cluster to the nearest cluster satisfying separation distance thresholds. More...
 
bool IsClusterRemnantDisconnected (const pandora::Cluster *const pRemnantCluster) const
 Whether a remnant cluster is considered to be disconnected and therefore should undergo further fragmentation. More...
 
void FragmentRemnantCluster (const pandora::Cluster *const pRemnantCluster, pandora::ClusterList &fragmentedClusterList) const
 Fragment a cluster using simple hit separation logic. More...
 
template<typename T >
void UpdateContainers (const pandora::ClusterList &clustersToAdd, const pandora::ClusterList &clustersToDelete, const T sortFunction, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
 Remove deleted clusters from the cluster vector and sliding fit maps and add in created clusters that are determined to be track-like. More...
 
void RemoveClusterFromContainers (const pandora::Cluster *const pClustertoRemove, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
 Remove a cluster from the cluster vector and sliding fit maps. More...
 

Protected Attributes

float m_minClusterLength
 The minimum length of a considered cluster. More...
 
unsigned int m_microSlidingFitWindow
 The sliding fit window used in the fits contained within the microSlidingFitResultMap. More...
 
unsigned int m_macroSlidingFitWindow
 The sliding fit window used in the fits contained within the macroSlidingFitResultMap. More...
 
float m_stableRegionClusterFraction
 The threshold fraction of fit contributing layers which defines the stable region. More...
 
float m_mergePointMinCosAngleDeviation
 The threshold cos opening angle between the cluster local gradient and the associated cluster global gradient used to determine merge points. More...
 
float m_minHitFractionForHitRemoval
 The threshold fraction of hits to be removed from the cluster for hit removal to proceed. More...
 
float m_maxDistanceFromMainTrack
 The threshold distance for a hit to be added to the main track. More...
 
float m_maxHitDistanceFromCluster
 The threshold separation between a hit and cluster for the hit to be merged into the cluster. More...
 
float m_maxHitSeparationForConnectedCluster
 The maximum separation between two adjacent (in z) hits in a connected cluster. More...
 
unsigned int m_maxTrackGaps
 The maximum number of graps allowed in the extrapolated hit vector. More...
 
float m_lineSegmentLength
 The length of a track gap. More...
 
bool m_hitWidthMode
 Whether to consider the width of hits. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
bool FindBestClusterAssociation (const pandora::ClusterVector &clusterVector, const SlidingFitResultMapPair &slidingFitResultMapPair, ClusterPairAssociation &clusterAssociation) const
 Find the best cluster association. More...
 
bool AreClustersAssociated (const pandora::CartesianVector &upstreamPoint, const pandora::CartesianVector &upstreamDirection, const pandora::CartesianVector &downstreamPoint, const pandora::CartesianVector &downstreamDirection) const
 Whether two clusters are assoicated to one another. More...
 
void GetUnavailableProtectedClusters (const ClusterPairAssociation &clusterAssociation, const pandora::ClusterList &createdMainTrackClusters, pandora::ClusterList &unavailableProtectedClusters) const
 Obtain a list of clusters whos hits are protected and cannot be reassigned. More...
 
bool AreExtrapolatedHitsNearBoundaries (const pandora::CaloHitVector &extrapolatedHitVector, ClusterAssociation &clusterAssociation) const
 Check the separation of the extremal extrapolated hits with the cluster merge points or, in the case of no hits, the cluster merge point separation. More...
 
void ConsiderClusterAssociation (const ClusterPairAssociation &clusterAssociation, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
 Remove the cluster association from the cluster vector so that the same cluster pair is not considered again. More...
 
const pandora::Cluster * CreateMainTrack (const ClusterPairAssociation &clusterAssociation, const ClusterToCaloHitListMap &clusterToCaloHitListMap, const pandora::ClusterList *pClusterList, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
 Refine the cluster endpoints and merge together the associated clusters alongside any extrapolated hits. More...
 

Private Attributes

unsigned int m_maxLoopIterations
 The maximum number of main loop iterations. More...
 
float m_minClusterLengthSum
 The threshold cluster and associated cluster length sum. More...
 
float m_minSeparationDistance
 The threshold separation distance between associated clusters. More...
 
float m_minDirectionDeviationCosAngle
 The threshold cos opening angle of the associated cluster directions. More...
 
float m_maxPredictedMergePointOffset
 The threshold separation distance between the predicted and true cluster merge points. More...
 
float m_distanceToLine
 The threshold hit distance of an extrapolated hit from the segment connecting line. More...
 
float m_boundaryTolerance
 The maximum allowed distance of an extremal extrapolate hit to a cluster merge point. More...
 

Detailed Description

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster *, pandora::CaloHitList> lar_content::TrackRefinementBaseAlgorithm::ClusterToCaloHitListMap
protectedinherited

Definition at line 31 of file TrackRefinementBaseAlgorithm.h.

Constructor & Destructor Documentation

lar_content::TrackMergeRefinementAlgorithm::TrackMergeRefinementAlgorithm ( )

Default constructor.

Definition at line 21 of file TrackMergeRefinementAlgorithm.cc.

21  :
27  m_distanceToLine(0.35f),
29 {
30 }
float m_maxPredictedMergePointOffset
The threshold separation distance between the predicted and true cluster merge points.
TFile f
Definition: plotHisto.C:6
float m_minClusterLengthSum
The threshold cluster and associated cluster length sum.
float m_minSeparationDistance
The threshold separation distance between associated clusters.
unsigned int m_maxLoopIterations
The maximum number of main loop iterations.
float m_boundaryTolerance
The maximum allowed distance of an extremal extrapolate hit to a cluster merge point.
float m_distanceToLine
The threshold hit distance of an extrapolated hit from the segment connecting line.
float m_minDirectionDeviationCosAngle
The threshold cos opening angle of the associated cluster directions.

Member Function Documentation

void lar_content::TrackRefinementBaseAlgorithm::AddHitsToMainTrack ( const pandora::Cluster *const  pMainTrackCluster,
const pandora::Cluster *const  pShowerTrackCluster,
const pandora::CaloHitList &  caloHitsToMerge,
const ClusterAssociation clusterAssociation,
pandora::ClusterList &  remnantClusterList 
) const
protectedinherited

Remove the hits from a shower cluster that belong to the main track and add them into the main track cluster.

Parameters
pMainTrackClusterthe main track cluster
pShowerClusterthe input shower cluster
caloHitsToMergethe list of calo hits to remove from the shower cluster
clusterAssociationthe clusterAssociation
remnantClusterListthe input list to store the remnant clusters

Definition at line 572 of file TrackRefinementBaseAlgorithm.cc.

References f, lar_content::ClusterAssociation::GetConnectingLineDirection(), lar_content::LArClusterHelper::GetLengthSquared(), lar_content::ClusterAssociation::GetUpstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::m_minClusterLength, and lar_content::TrackRefinementBaseAlgorithm::m_minHitFractionForHitRemoval.

Referenced by CreateMainTrack().

574 {
575  // To ignore crossing CR muon or test beam tracks
576  if (((static_cast<float>(caloHitsToMerge.size()) / static_cast<float>(pShowerCluster->GetNCaloHits())) < m_minHitFractionForHitRemoval) &&
578  return;
579 
580  if (pShowerCluster->GetNCaloHits() == caloHitsToMerge.size())
581  {
582  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pMainTrackCluster, pShowerCluster));
583  return;
584  }
585 
586  // Fragmentation initialisation
587  std::string originalListName, fragmentListName;
588  const ClusterList originalClusterList(1, pShowerCluster);
589  PANDORA_THROW_RESULT_IF(
590  STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeFragmentation(*this, originalClusterList, originalListName, fragmentListName));
591 
592  const Cluster *pAboveCluster(nullptr), *pBelowCluster(nullptr);
593 
594  const bool isVertical(std::fabs(clusterAssociation.GetConnectingLineDirection().GetX()) < std::numeric_limits<float>::epsilon());
595  const float connectingLineGradient(
596  isVertical ? 0.f : clusterAssociation.GetConnectingLineDirection().GetZ() / clusterAssociation.GetConnectingLineDirection().GetX());
597  const float connectingLineIntercept(isVertical
598  ? clusterAssociation.GetUpstreamMergePoint().GetX()
599  : clusterAssociation.GetUpstreamMergePoint().GetZ() - (connectingLineGradient * clusterAssociation.GetUpstreamMergePoint().GetX()));
600 
601  const OrderedCaloHitList orderedCaloHitList(pShowerCluster->GetOrderedCaloHitList());
602  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
603  {
604  for (const CaloHit *const pCaloHit : *mapEntry.second)
605  {
606  const bool isAnExtrapolatedHit(std::find(caloHitsToMerge.begin(), caloHitsToMerge.end(), pCaloHit) != caloHitsToMerge.end());
607  if (isAnExtrapolatedHit)
608  {
609  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromCluster(*this, pShowerCluster, pCaloHit));
610  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, pMainTrackCluster, pCaloHit));
611  }
612  else
613  {
614  const CartesianVector &hitPosition(pCaloHit->GetPositionVector());
615  const bool isAbove(((connectingLineGradient * hitPosition.GetX()) + connectingLineIntercept) <
616  (isVertical ? hitPosition.GetX() : hitPosition.GetZ()));
617  const Cluster *&pClusterToModify(isAbove ? pAboveCluster : pBelowCluster);
618 
619  if (pClusterToModify)
620  {
621  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, pClusterToModify, pCaloHit));
622  }
623  else
624  {
625  PandoraContentApi::Cluster::Parameters parameters;
626  parameters.m_caloHitList.push_back(pCaloHit);
627  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pClusterToModify));
628 
629  remnantClusterList.push_back(pClusterToModify);
630  }
631  }
632  }
633  }
634 
635  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*this, fragmentListName, originalListName));
636 }
float m_minClusterLength
The minimum length of a considered cluster.
float m_minHitFractionForHitRemoval
The threshold fraction of hits to be removed from the cluster for hit removal to proceed.
TFile f
Definition: plotHisto.C:6
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
bool lar_content::TrackRefinementBaseAlgorithm::AddToNearestCluster ( const pandora::Cluster *const  pClusterToMerge,
const pandora::Cluster *const  pMainTrackCluster,
const pandora::ClusterList *const  pClusterList 
) const
protectedinherited

Add a cluster to the nearest cluster satisfying separation distance thresholds.

Parameters
pClusterToMergethe cluster to merge
pMainTrackClusterthe main track cluster
pClusterListthe list of all clusters
Returns
whether cluster was added to a nearby cluster

Definition at line 667 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), lar_content::TrackRefinementBaseAlgorithm::m_maxDistanceFromMainTrack, and lar_content::TrackRefinementBaseAlgorithm::m_maxHitDistanceFromCluster.

Referenced by lar_content::TrackRefinementBaseAlgorithm::ProcessRemnantClusters().

669 {
670  const Cluster *pClosestCluster(nullptr);
671  float closestDistance(std::numeric_limits<float>::max());
672 
673  for (const Cluster *const pCluster : *pClusterList)
674  {
675  if (pCluster == pClusterToMerge)
676  continue;
677 
678  const float separationDistance(LArClusterHelper::GetClosestDistance(pClusterToMerge, pCluster));
679 
680  if (separationDistance < closestDistance)
681  {
682  if ((pCluster == pMainTrackCluster) && (separationDistance > m_maxDistanceFromMainTrack))
683  continue;
684 
685  pClosestCluster = pCluster;
686  closestDistance = separationDistance;
687  }
688  }
689 
690  if (closestDistance < m_maxHitDistanceFromCluster)
691  {
692  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pClosestCluster, pClusterToMerge));
693  return true;
694  }
695 
696  return false;
697 }
float m_maxHitDistanceFromCluster
The threshold separation between a hit and cluster for the hit to be merged into the cluster...
float m_maxDistanceFromMainTrack
The threshold distance for a hit to be added to the main track.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
bool lar_content::TrackMergeRefinementAlgorithm::AreClustersAssociated ( const pandora::CartesianVector &  upstreamPoint,
const pandora::CartesianVector &  upstreamDirection,
const pandora::CartesianVector &  downstreamPoint,
const pandora::CartesianVector &  downstreamDirection 
) const
private

Whether two clusters are assoicated to one another.

Parameters
upstreamPointthe merge point of the upstream cluster
upstreamDirectionthe local direction of the upstream cluster at the merge point
downstreamPointthe merge point of the downstream cluster
downstreamDirectionthe local direction of the downstrean cluster at the merge point
Returns
whether the clusters are associated

Definition at line 175 of file TrackMergeRefinementAlgorithm.cc.

References m_maxPredictedMergePointOffset, m_minDirectionDeviationCosAngle, and m_minSeparationDistance.

Referenced by FindBestClusterAssociation().

177 {
178  if (downstreamPoint.GetZ() < upstreamPoint.GetZ())
179  return false;
180 
181  const float separationDistance(std::sqrt(upstreamPoint.GetDistanceSquared(downstreamPoint)));
182  if (separationDistance < m_minSeparationDistance)
183  return false;
184 
185  if (upstreamDirection.GetCosOpeningAngle(downstreamDirection) < m_minDirectionDeviationCosAngle)
186  return false;
187 
188  const CartesianVector predictedDownstreamPoint(upstreamPoint + (upstreamDirection * separationDistance));
189  const float predictedDownstreamOffset((predictedDownstreamPoint - downstreamPoint).GetMagnitude());
190 
191  if (predictedDownstreamOffset > m_maxPredictedMergePointOffset)
192  return false;
193 
194  const CartesianVector predictedUpstreamPoint(downstreamPoint - (downstreamDirection * separationDistance));
195  const float predictedUpstreamOffset((predictedUpstreamPoint - upstreamPoint).GetMagnitude());
196 
197  if (predictedUpstreamOffset > m_maxPredictedMergePointOffset)
198  return false;
199 
200  return true;
201 }
float m_maxPredictedMergePointOffset
The threshold separation distance between the predicted and true cluster merge points.
float m_minSeparationDistance
The threshold separation distance between associated clusters.
float m_minDirectionDeviationCosAngle
The threshold cos opening angle of the associated cluster directions.
bool lar_content::TrackRefinementBaseAlgorithm::AreExtrapolatedHitsGood ( const ClusterToCaloHitListMap clusterToCaloHitListMap,
ClusterAssociation clusterAssociation 
) const
protectedinherited

Perform topological checks on the collected hits to ensure no gaps are present.

Parameters
clusterToCaloHitListMapthe input map [parent cluster -> list of hits which belong to the main track]
clusterAssociationthe clusterAssociation
Returns
whether the checks pass

Definition at line 187 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::TrackRefinementBaseAlgorithm::AreExtrapolatedHitsNearBoundaries(), lar_content::ClusterAssociation::GetConnectingLineDirection(), lar_content::ClusterAssociation::GetUpstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::IsTrackContinuous(), and lar_content::TrackRefinementBaseAlgorithm::m_hitWidthMode.

Referenced by Run().

188 {
189  CaloHitVector extrapolatedHitVector;
190  for (const auto &entry : clusterToCaloHitListMap)
191  extrapolatedHitVector.insert(extrapolatedHitVector.begin(), entry.second.begin(), entry.second.end());
192 
193  // ATTN: Extrapolated hit checks require extrapolatedHitVector to be ordered from upstream -> downstream merge point
194  std::sort(extrapolatedHitVector.begin(), extrapolatedHitVector.end(),
195  SortByDistanceAlongLine(clusterAssociation.GetUpstreamMergePoint(), clusterAssociation.GetConnectingLineDirection(), m_hitWidthMode));
196 
197  if (!this->AreExtrapolatedHitsNearBoundaries(extrapolatedHitVector, clusterAssociation))
198  return false;
199 
200  if (clusterToCaloHitListMap.empty())
201  return true;
202 
203  if (!this->IsTrackContinuous(clusterAssociation, extrapolatedHitVector))
204  return false;
205 
206  return true;
207 }
bool m_hitWidthMode
Whether to consider the width of hits.
bool IsTrackContinuous(const ClusterAssociation &clusterAssociation, const pandora::CaloHitVector &extrapolatedCaloHitVector) const
Check whether the extrapolatedCaloHitVector contains a continuous line of hits between the cluster me...
virtual bool AreExtrapolatedHitsNearBoundaries(const pandora::CaloHitVector &extrapolatedHitVector, ClusterAssociation &clusterAssociation) const =0
Check the separation of the extremal extrapolated hits with the expected endpoints or...
bool lar_content::TrackMergeRefinementAlgorithm::AreExtrapolatedHitsNearBoundaries ( const pandora::CaloHitVector &  extrapolatedHitVector,
ClusterAssociation clusterAssociation 
) const
privatevirtual

Check the separation of the extremal extrapolated hits with the cluster merge points or, in the case of no hits, the cluster merge point separation.

Parameters
extrapolatedHitVectorthe extrapolated hit vector (ordered closest hit to the upstream merge point -> furthest hit)
clusterAssociationthe cluster association
Returns
whether the checks pass

Implements lar_content::TrackRefinementBaseAlgorithm.

Definition at line 217 of file TrackMergeRefinementAlgorithm.cc.

References lar_content::ClusterAssociation::GetDownstreamMergePoint(), lar_content::ClusterAssociation::GetUpstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::IsNearBoundary(), and m_boundaryTolerance.

218 {
219  if (extrapolatedHitVector.empty())
220  {
221  const float separationDistance((clusterAssociation.GetUpstreamMergePoint() - clusterAssociation.GetDownstreamMergePoint()).GetMagnitude());
222  return (separationDistance < m_boundaryTolerance);
223  }
224 
225  if (!this->IsNearBoundary(extrapolatedHitVector.front(), clusterAssociation.GetUpstreamMergePoint(), m_boundaryTolerance))
226  return false;
227 
228  if (!this->IsNearBoundary(extrapolatedHitVector.back(), clusterAssociation.GetDownstreamMergePoint(), m_boundaryTolerance))
229  return false;
230 
231  return true;
232 }
float m_boundaryTolerance
The maximum allowed distance of an extremal extrapolate hit to a cluster merge point.
bool IsNearBoundary(const pandora::CaloHit *const pCaloHit, const pandora::CartesianVector &boundaryPosition2D, const float boundaryTolerance) const
Check whether a hit is close to a boundary point.
void lar_content::TrackMergeRefinementAlgorithm::ConsiderClusterAssociation ( const ClusterPairAssociation clusterAssociation,
pandora::ClusterVector &  clusterVector,
SlidingFitResultMapPair slidingFitResultMapPair 
) const
private

Remove the cluster association from the cluster vector so that the same cluster pair is not considered again.

Parameters
clusterAssociationthe cluster pair association
clusterVectorthe vector of clusters considered in future iterations of the algorithm
slidingFitResultMapPairthe {micro, macro} pair of [cluster -> TwoDSlidingFitResult] maps

Definition at line 236 of file TrackMergeRefinementAlgorithm.cc.

References lar_content::ClusterPairAssociation::GetDownstreamCluster(), lar_content::ClusterPairAssociation::GetUpstreamCluster(), and lar_content::TrackRefinementBaseAlgorithm::RemoveClusterFromContainers().

Referenced by Run().

238 {
239  const Cluster *const upstreamCluster(clusterAssociation.GetUpstreamCluster()), *const downstreamCluster(clusterAssociation.GetDownstreamCluster());
240  const Cluster *const pConsideredCluster(upstreamCluster->GetNCaloHits() > downstreamCluster->GetNCaloHits() ? downstreamCluster : upstreamCluster);
241  RemoveClusterFromContainers(pConsideredCluster, clusterVector, slidingFitResultMapPair);
242 }
void RemoveClusterFromContainers(const pandora::Cluster *const pClustertoRemove, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
Remove a cluster from the cluster vector and sliding fit maps.
const Cluster * lar_content::TrackMergeRefinementAlgorithm::CreateMainTrack ( const ClusterPairAssociation clusterAssociation,
const ClusterToCaloHitListMap clusterToCaloHitListMap,
const pandora::ClusterList *  pClusterList,
pandora::ClusterVector &  clusterVector,
SlidingFitResultMapPair slidingFitResultMapPair 
) const
private

Refine the cluster endpoints and merge together the associated clusters alongside any extrapolated hits.

Parameters
clusterAssociationthe cluster pair association
clusterToCaloHitListMapthe map [parent cluster -> list of hits which belong to the main track]
pClusterListthe list of all clusters
clusterVectorthe vector of clusters considered in future iterations of the algorithm
slidingFitResultMapPairthe {micro, macro} pair of [cluster -> TwoDSlidingFitResult] maps
Returns
the address of the created main track cluster

Definition at line 246 of file TrackMergeRefinementAlgorithm.cc.

References lar_content::TrackRefinementBaseAlgorithm::AddHitsToMainTrack(), lar_content::ClusterPairAssociation::GetDownstreamCluster(), lar_content::ClusterAssociation::GetDownstreamMergePoint(), lar_content::ClusterPairAssociation::GetUpstreamCluster(), lar_content::ClusterAssociation::GetUpstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::ProcessRemnantClusters(), lar_content::TrackRefinementBaseAlgorithm::RemoveOffAxisHitsFromTrack(), lar_content::LArClusterHelper::SortByNHits(), and lar_content::TrackRefinementBaseAlgorithm::UpdateContainers().

Referenced by Run().

249 {
250  // Determine the shower clusters which contain hits that belong to the main track
251  ClusterVector showerClustersToFragment;
252  for (const auto &entry : clusterToCaloHitListMap)
253  {
254  if ((entry.first != clusterAssociation.GetUpstreamCluster()) && (entry.first != clusterAssociation.GetDownstreamCluster()))
255  showerClustersToFragment.push_back(entry.first);
256  }
257 
258  std::sort(showerClustersToFragment.begin(), showerClustersToFragment.end(), LArClusterHelper::SortByNHits);
259 
260  ClusterList remnantClusterList;
261  const Cluster *const pMainTrackCluster(
262  this->RemoveOffAxisHitsFromTrack(clusterAssociation.GetUpstreamCluster(), clusterAssociation.GetUpstreamMergePoint(), false,
263  clusterToCaloHitListMap, remnantClusterList, *slidingFitResultMapPair.first, *slidingFitResultMapPair.second));
264  const Cluster *const pClusterToDelete(
265  this->RemoveOffAxisHitsFromTrack(clusterAssociation.GetDownstreamCluster(), clusterAssociation.GetDownstreamMergePoint(), true,
266  clusterToCaloHitListMap, remnantClusterList, *slidingFitResultMapPair.first, *slidingFitResultMapPair.second));
267 
268  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pMainTrackCluster, pClusterToDelete));
269 
270  for (const Cluster *const pShowerCluster : showerClustersToFragment)
271  {
272  const CaloHitList &caloHitsToMerge(clusterToCaloHitListMap.at(pShowerCluster));
273  this->AddHitsToMainTrack(pMainTrackCluster, pShowerCluster, caloHitsToMerge, clusterAssociation, remnantClusterList);
274  }
275 
276  ClusterList createdClusters;
277  this->ProcessRemnantClusters(remnantClusterList, pMainTrackCluster, pClusterList, createdClusters);
278 
279  // ATTN: Cleanup containers - choose to add created clusters back into containers
280  ClusterList modifiedClusters(showerClustersToFragment.begin(), showerClustersToFragment.end());
281  modifiedClusters.push_back(clusterAssociation.GetUpstreamCluster());
282  modifiedClusters.push_back(clusterAssociation.GetDownstreamCluster());
283  createdClusters.push_back(pMainTrackCluster);
284  this->UpdateContainers(createdClusters, modifiedClusters, LArClusterHelper::SortByNHits, clusterVector, slidingFitResultMapPair);
285 
286  return pMainTrackCluster;
287 }
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.
void AddHitsToMainTrack(const pandora::Cluster *const pMainTrackCluster, const pandora::Cluster *const pShowerTrackCluster, const pandora::CaloHitList &caloHitsToMerge, const ClusterAssociation &clusterAssociation, pandora::ClusterList &remnantClusterList) const
Remove the hits from a shower cluster that belong to the main track and add them into the main track ...
void UpdateContainers(const pandora::ClusterList &clustersToAdd, const pandora::ClusterList &clustersToDelete, const T sortFunction, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
Remove deleted clusters from the cluster vector and sliding fit maps and add in created clusters that...
void ProcessRemnantClusters(const pandora::ClusterList &remnantClusterList, const pandora::Cluster *const pMainTrackCluster, const pandora::ClusterList *const pClusterList, pandora::ClusterList &createdClusters) const
Process the remnant clusters separating those that stradle the main track.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
const pandora::Cluster * RemoveOffAxisHitsFromTrack(const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition, const bool isEndUpstream, const ClusterToCaloHitListMap &clusterToCaloHitListMap, pandora::ClusterList &remnantClusterList, TwoDSlidingFitResultMap &microSlidingFitResultMap, TwoDSlidingFitResultMap &macroSlidingFitResultMap) const
Remove any hits in the upstream/downstream cluster that lie off of the main track axis (i...
float lar_content::TrackRefinementBaseAlgorithm::DistanceInGap ( const pandora::CartesianVector &  upstreamPoint,
const pandora::CartesianVector &  downstreamPoint,
const pandora::CartesianVector &  connectingLine,
pandora::DetectorGapList &  consideredGaps 
) const
protectedinherited

Calculate the track length between two points that lies in gaps.

Parameters
upstreamPointthe upstream point
downstreamPointthe downstream point
connectingLinethe track direction
consideredGapsthe list of gaps to ignore

Definition at line 384 of file TrackRefinementBaseAlgorithm.cc.

References f.

Referenced by lar_content::TrackRefinementBaseAlgorithm::GetTrackSegmentBoundaries().

386 {
387  const CartesianVector &lowerXPoint(upstreamPoint.GetX() < downstreamPoint.GetX() ? upstreamPoint : downstreamPoint);
388  const CartesianVector &higherXPoint(upstreamPoint.GetX() < downstreamPoint.GetX() ? downstreamPoint : upstreamPoint);
389 
390  const float cosAngleToX(std::fabs(connectingLine.GetDotProduct(CartesianVector(1.f, 0.f, 0.f))));
391  const float cosAngleToZ(std::fabs(connectingLine.GetDotProduct(CartesianVector(0.f, 0.f, 1.f))));
392 
393  float distanceInGaps(0.f);
394  const DetectorGapList detectorGapList(this->GetPandora().GetGeometry()->GetDetectorGapList());
395  for (const DetectorGap *const pDetectorGap : detectorGapList)
396  {
397  if (std::find(consideredGaps.begin(), consideredGaps.end(), pDetectorGap) != consideredGaps.end())
398  continue;
399 
400  const LineGap *const pLineGap(dynamic_cast<const LineGap *>(pDetectorGap));
401 
402  if (pLineGap)
403  {
404  const LineGapType lineGapType(pLineGap->GetLineGapType());
405 
406  if (lineGapType == TPC_DRIFT_GAP)
407  {
408  float xDistanceInGap(0.f);
409 
410  if ((pLineGap->GetLineStartX() > lowerXPoint.GetX()) && (pLineGap->GetLineEndX() < higherXPoint.GetX()))
411  {
412  xDistanceInGap = (pLineGap->GetLineEndX() - pLineGap->GetLineStartX());
413  }
414  else if ((pLineGap->GetLineStartX() < lowerXPoint.GetX()) && (pLineGap->GetLineEndX() > lowerXPoint.GetX()))
415  {
416  xDistanceInGap = (pLineGap->GetLineEndX() - lowerXPoint.GetX());
417  }
418  else if ((pLineGap->GetLineStartX() < higherXPoint.GetX()) && (pLineGap->GetLineEndX() > higherXPoint.GetX()))
419  {
420  xDistanceInGap = (higherXPoint.GetX() - pLineGap->GetLineStartX());
421  }
422  else
423  {
424  continue;
425  }
426 
427  if (std::fabs(cosAngleToX) < std::numeric_limits<float>::epsilon())
428  throw StatusCodeException(STATUS_CODE_FAILURE);
429 
430  distanceInGaps += (xDistanceInGap / cosAngleToX);
431 
432  consideredGaps.push_back(pDetectorGap);
433  }
434 
435  if ((lineGapType == TPC_WIRE_GAP_VIEW_U) || (lineGapType == TPC_WIRE_GAP_VIEW_V) || (lineGapType == TPC_WIRE_GAP_VIEW_W))
436  {
437  float zDistanceInGap(0.f);
438 
439  if ((pLineGap->GetLineStartZ() > upstreamPoint.GetZ()) && (pLineGap->GetLineEndZ() < downstreamPoint.GetZ()))
440  {
441  zDistanceInGap = pLineGap->GetLineEndZ() - pLineGap->GetLineStartZ();
442  }
443  else if ((pLineGap->GetLineStartZ() < upstreamPoint.GetZ()) && (pLineGap->GetLineEndZ() > upstreamPoint.GetZ()))
444  {
445  zDistanceInGap = pLineGap->GetLineEndZ() - upstreamPoint.GetZ();
446  }
447  else if ((pLineGap->GetLineStartZ() < downstreamPoint.GetZ()) && (pLineGap->GetLineEndZ() > downstreamPoint.GetZ()))
448  {
449  zDistanceInGap = downstreamPoint.GetZ() - pLineGap->GetLineStartZ();
450  }
451  else
452  {
453  continue;
454  }
455 
456  if (std::fabs(cosAngleToZ) < std::numeric_limits<float>::epsilon())
457  throw StatusCodeException(STATUS_CODE_FAILURE);
458 
459  distanceInGaps += (zDistanceInGap / cosAngleToZ);
460 
461  consideredGaps.push_back(pDetectorGap);
462  }
463  }
464  }
465 
466  return distanceInGaps;
467 }
TFile f
Definition: plotHisto.C:6
bool lar_content::TrackMergeRefinementAlgorithm::FindBestClusterAssociation ( const pandora::ClusterVector &  clusterVector,
const SlidingFitResultMapPair slidingFitResultMapPair,
ClusterPairAssociation clusterAssociation 
) const
private

Find the best cluster association.

Parameters
clusterVectorthe vector of clusters to consider
slidingFitResultMapPairthe {micro, macro} pair of [cluster -> TwoDSlidingFitResult] maps
clusterAssociationthe cluster pair association
Returns
whether a cluster pair association was found

Definition at line 91 of file TrackMergeRefinementAlgorithm.cc.

References AreClustersAssociated(), f, lar_content::TrackRefinementBaseAlgorithm::GetClusterMergingCoordinates(), lar_content::LArClusterHelper::GetLength(), m_minClusterLengthSum, and lar_content::LArClusterHelper::SortByPosition().

Referenced by Run().

93 {
94  bool foundAssociation(false);
95  float maxLength(0.f);
96 
97  // ATTN: Find the associated cluster pair with the longest length sum
98  for (ClusterVector::const_iterator currentIter = clusterVector.begin(); currentIter != clusterVector.end(); ++currentIter)
99  {
100  const Cluster *const pCurrentCluster(*currentIter);
101 
102  const TwoDSlidingFitResultMap::const_iterator currentMicroFitIter(slidingFitResultMapPair.first->find(pCurrentCluster));
103  if (currentMicroFitIter == slidingFitResultMapPair.first->end())
104  return false;
105 
106  const TwoDSlidingFitResultMap::const_iterator currentMacroFitIter(slidingFitResultMapPair.second->find(pCurrentCluster));
107  if (currentMacroFitIter == slidingFitResultMapPair.second->end())
108  return false;
109 
110  for (ClusterVector::const_iterator testIter = std::next(currentIter); testIter != clusterVector.end(); ++testIter)
111  {
112  const Cluster *const pTestCluster(*testIter);
113 
114  const float lengthSum(LArClusterHelper::GetLength(pCurrentCluster) + LArClusterHelper::GetLength(pTestCluster));
115  if ((lengthSum < maxLength) || (lengthSum < m_minClusterLengthSum))
116  continue;
117 
118  const TwoDSlidingFitResultMap::const_iterator testMicroFitIter(slidingFitResultMapPair.first->find(pTestCluster));
119  if (testMicroFitIter == slidingFitResultMapPair.first->end())
120  continue;
121 
122  const TwoDSlidingFitResultMap::const_iterator testMacroFitIter(slidingFitResultMapPair.second->find(pTestCluster));
123  if (testMacroFitIter == slidingFitResultMapPair.second->end())
124  continue;
125 
126  const bool isCurrentUpstream(LArClusterHelper::SortByPosition(pCurrentCluster, pTestCluster));
127 
128  // ATTN: Ensure that clusters are not contained within one another
129  const float currentMinLayerZ(currentMacroFitIter->second.GetGlobalMinLayerPosition().GetZ()),
130  currentMaxLayerZ(currentMacroFitIter->second.GetGlobalMaxLayerPosition().GetZ());
131  const float testMinLayerZ(testMacroFitIter->second.GetGlobalMinLayerPosition().GetZ()),
132  testMaxLayerZ(testMacroFitIter->second.GetGlobalMaxLayerPosition().GetZ());
133 
134  if (((currentMinLayerZ > testMinLayerZ) && (currentMaxLayerZ < testMaxLayerZ)) ||
135  ((testMinLayerZ > currentMinLayerZ) && (testMaxLayerZ < currentMaxLayerZ)))
136  continue;
137 
138  CartesianVector currentMergePoint(0.f, 0.f, 0.f), testMergePoint(0.f, 0.f, 0.f), currentMergeDirection(0.f, 0.f, 0.f),
139  testMergeDirection(0.f, 0.f, 0.f);
140  if (!this->GetClusterMergingCoordinates(currentMicroFitIter->second, currentMacroFitIter->second, testMacroFitIter->second,
141  !isCurrentUpstream, currentMergePoint, currentMergeDirection) ||
142  !this->GetClusterMergingCoordinates(testMicroFitIter->second, testMacroFitIter->second, currentMacroFitIter->second,
143  isCurrentUpstream, testMergePoint, testMergeDirection))
144  {
145  continue;
146  }
147 
148  if ((isCurrentUpstream && !this->AreClustersAssociated(currentMergePoint, currentMergeDirection, testMergePoint, testMergeDirection)) ||
149  (!isCurrentUpstream && !this->AreClustersAssociated(testMergePoint, testMergeDirection, currentMergePoint, currentMergeDirection)))
150  {
151  continue;
152  }
153 
154  if (isCurrentUpstream)
155  {
156  clusterAssociation = ClusterPairAssociation(
157  currentMergePoint, currentMergeDirection, testMergePoint, testMergeDirection * (-1.f), pCurrentCluster, pTestCluster);
158  }
159  else
160  {
161  clusterAssociation = ClusterPairAssociation(
162  testMergePoint, testMergeDirection, currentMergePoint, currentMergeDirection * (-1.f), pTestCluster, pCurrentCluster);
163  }
164 
165  foundAssociation = true;
166  maxLength = lengthSum;
167  }
168  }
169 
170  return foundAssociation;
171 }
intermediate_table::const_iterator const_iterator
bool GetClusterMergingCoordinates(const TwoDSlidingFitResult &clusterMicroFitResult, const TwoDSlidingFitResult &clusterMacroFitResult, const TwoDSlidingFitResult &associatedMacroFitResult, const bool isEndUpstream, pandora::CartesianVector &clusterMergePosition, pandora::CartesianVector &clusterMergeDirection) const
Get the merging coordinate and direction for an input cluster with respect to an associated cluster...
TFile f
Definition: plotHisto.C:6
static bool SortByPosition(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by position, then pulse-height.
float m_minClusterLengthSum
The threshold cluster and associated cluster length sum.
bool AreClustersAssociated(const pandora::CartesianVector &upstreamPoint, const pandora::CartesianVector &upstreamDirection, const pandora::CartesianVector &downstreamPoint, const pandora::CartesianVector &downstreamDirection) const
Whether two clusters are assoicated to one another.
static float GetLength(const pandora::Cluster *const pCluster)
Get length of cluster.
void lar_content::TrackRefinementBaseAlgorithm::FragmentRemnantCluster ( const pandora::Cluster *const  pRemnantCluster,
pandora::ClusterList &  fragmentedClusterList 
) const
protectedinherited

Fragment a cluster using simple hit separation logic.

Parameters
pRemnantClusterthe input remnant cluster to fragment
fragmentedClusterListthe input list to store the final remnant clusters

Definition at line 730 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), and lar_content::TrackRefinementBaseAlgorithm::m_maxHitDistanceFromCluster.

Referenced by lar_content::TrackRefinementBaseAlgorithm::ProcessRemnantClusters().

731 {
732  // Fragmentation initialisation
733  std::string originalListName, fragmentListName;
734  const ClusterList originalClusterList(1, pRemnantCluster);
735  PANDORA_THROW_RESULT_IF(
736  STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeFragmentation(*this, originalClusterList, originalListName, fragmentListName));
737 
738  ClusterList createdClusters;
739 
740  const OrderedCaloHitList &orderedCaloHitList(pRemnantCluster->GetOrderedCaloHitList());
741  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
742  {
743  for (const CaloHit *const pCaloHit : *mapEntry.second)
744  {
745  const Cluster *pClosestCluster(nullptr);
746 
747  if (!createdClusters.empty())
748  {
749  float closestDistance(std::numeric_limits<float>::max());
750 
751  for (const Cluster *const pCreatedCluster : createdClusters)
752  {
753  const float separationDistance(LArClusterHelper::GetClosestDistance(pCaloHit->GetPositionVector(), pCreatedCluster));
754  if ((separationDistance < closestDistance) && (separationDistance < m_maxHitDistanceFromCluster))
755  {
756  closestDistance = separationDistance;
757  pClosestCluster = pCreatedCluster;
758  }
759  }
760  }
761 
762  if (pClosestCluster)
763  {
764  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, pClosestCluster, pCaloHit));
765  }
766  else
767  {
768  PandoraContentApi::Cluster::Parameters parameters;
769  parameters.m_caloHitList.push_back(pCaloHit);
770  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pClosestCluster));
771  createdClusters.push_back(pClosestCluster);
772  }
773  }
774  }
775 
776  // End fragmentation
777  if (createdClusters.empty())
778  {
779  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*this, originalListName, fragmentListName));
780  fragmentedClusterList.push_back(pRemnantCluster);
781  }
782  else
783  {
784  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*this, fragmentListName, originalListName));
785  fragmentedClusterList.insert(fragmentedClusterList.begin(), createdClusters.begin(), createdClusters.end());
786  }
787 }
float m_maxHitDistanceFromCluster
The threshold separation between a hit and cluster for the hit to be merged into the cluster...
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
bool lar_content::TrackRefinementBaseAlgorithm::GetClusterMergingCoordinates ( const TwoDSlidingFitResult clusterMicroFitResult,
const TwoDSlidingFitResult clusterMacroFitResult,
const TwoDSlidingFitResult associatedMacroFitResult,
const bool  isEndUpstream,
pandora::CartesianVector &  clusterMergePosition,
pandora::CartesianVector &  clusterMergeDirection 
) const
protectedinherited

Get the merging coordinate and direction for an input cluster with respect to an associated cluster.

Parameters
clusterMicroFitResultthe local TwoDSlidingFitResult of the cluster
clusterMacroFitResultthe global TwoDSlidingFitResult of the cluster
associatedMacroFitReultthe global TwoDSlidingFitResult of the associated cluster
isEndUpstreamwhether the sought cluster merge point is the upstream
clusterMergePositionthe merge position of the cluster
clusterMergeDirectionthe merge direction of the cluster
Returns
whether it was possible to find a suitable merge position

Definition at line 68 of file TrackRefinementBaseAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetGlobalDirection(), lar_content::TwoDSlidingFitResult::GetGlobalFitPosition(), lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), lar_content::TwoDSlidingFitResult::GetMaxLayer(), lar_content::TwoDSlidingFitResult::GetMinLayer(), lar_content::TrackRefinementBaseAlgorithm::m_mergePointMinCosAngleDeviation, and lar_content::TrackRefinementBaseAlgorithm::m_stableRegionClusterFraction.

Referenced by FindBestClusterAssociation().

71 {
72  CartesianVector clusterAverageDirection(0.f, 0.f, 0.f), associatedAverageDirection(0.f, 0.f, 0.f);
73  clusterMacroFitResult.GetGlobalDirection(clusterMacroFitResult.GetLayerFitResultMap().begin()->second.GetGradient(), clusterAverageDirection);
74  associatedMacroFitResult.GetGlobalDirection(associatedMacroFitResult.GetLayerFitResultMap().begin()->second.GetGradient(), associatedAverageDirection);
75 
76  const LayerFitResultMap &clusterMicroLayerFitResultMap(clusterMicroFitResult.GetLayerFitResultMap());
77  const int startLayer(isEndUpstream ? clusterMicroFitResult.GetMinLayer() : clusterMicroFitResult.GetMaxLayer());
78  const int endLayer(isEndUpstream ? clusterMicroFitResult.GetMaxLayer() : clusterMicroFitResult.GetMinLayer());
79  const int loopTerminationLayer(endLayer + (isEndUpstream ? 1 : -1));
80  const int step(isEndUpstream ? 1 : -1);
81 
82  // ATTN: Search for stable region for which the local layer gradient agrees well with associated cluster global gradient
83  unsigned int gradientStabilityWindow(std::ceil(clusterMicroLayerFitResultMap.size() * m_stableRegionClusterFraction));
84  unsigned int goodLayerCount(0);
85 
86  clusterMicroLayerFitResultMap.at(endLayer);
87 
88  for (int i = startLayer; i != loopTerminationLayer; i += step)
89  {
90  const auto microIter(clusterMicroLayerFitResultMap.find(i));
91 
92  if (microIter == clusterMicroLayerFitResultMap.end())
93  continue;
94 
95  CartesianVector microDirection(0.f, 0.f, 0.f);
96  clusterMicroFitResult.GetGlobalDirection(microIter->second.GetGradient(), microDirection);
97 
98  const float cosDirectionOpeningAngle(microDirection.GetCosOpeningAngle(associatedAverageDirection));
99  if (cosDirectionOpeningAngle > m_mergePointMinCosAngleDeviation)
100  {
101  // ATTN: Set merge point and direction as that at the first layer in the stable region
102  if (goodLayerCount == 0)
103  {
104  clusterMergeDirection = clusterAverageDirection;
105  PANDORA_THROW_RESULT_IF(
106  STATUS_CODE_SUCCESS, !=, clusterMicroFitResult.GetGlobalFitPosition(microIter->second.GetL(), clusterMergePosition));
107  }
108 
109  ++goodLayerCount;
110  }
111  else
112  {
113  goodLayerCount = 0;
114  }
115 
116  if (goodLayerCount > gradientStabilityWindow)
117  break;
118 
119  // ATTN: Abort merging process have not found a stable region
120  if (i == endLayer)
121  return false;
122  }
123 
124  return true;
125 }
TFile f
Definition: plotHisto.C:6
float m_stableRegionClusterFraction
The threshold fraction of fit contributing layers which defines the stable region.
std::map< int, LayerFitResult > LayerFitResultMap
float m_mergePointMinCosAngleDeviation
The threshold cos opening angle between the cluster local gradient and the associated cluster global ...
void lar_content::TrackRefinementBaseAlgorithm::GetHitsInBoundingBox ( const pandora::CartesianVector &  firstCorner,
const pandora::CartesianVector &  secondCorner,
const pandora::ClusterList *const  pClusterList,
ClusterToCaloHitListMap clusterToCaloHitListMap,
const pandora::ClusterList &  unavailableProtectedClusters = pandora::ClusterList(),
const float  distanceToLine = -1.f 
) const
protectedinherited

Find the unprotected hits that are contained within a defined box with the option to apply a cut on the distance to the connecting line.

Parameters
firstCornerthe position of one corner
secondCornerthe position of the opposite corner
pClusterListthe list of all clusters
clusterToCaloHitListMapthe output map [parent cluster -> list of hits which belong to the main track]
unavailableProtectedClustersthe list of clusters whose hits are protected
distanceToLinethe maximum perpendicular distance of a collected hit from the connecting line

Definition at line 129 of file TrackRefinementBaseAlgorithm.cc.

References f, lar_content::LArHitWidthHelper::GetClosestPointToLine2D(), lar_content::TrackRefinementBaseAlgorithm::IsCloseToLine(), lar_content::TrackRefinementBaseAlgorithm::IsInBoundingBox(), and lar_content::TrackRefinementBaseAlgorithm::m_hitWidthMode.

Referenced by Run().

132 {
133  const float minX(std::min(firstCorner.GetX(), secondCorner.GetX())), maxX(std::max(firstCorner.GetX(), secondCorner.GetX()));
134  const float minZ(std::min(firstCorner.GetZ(), secondCorner.GetZ())), maxZ(std::max(firstCorner.GetZ(), secondCorner.GetZ()));
135 
136  CartesianVector connectingLineDirection(firstCorner - secondCorner);
137  connectingLineDirection = connectingLineDirection.GetUnitVector();
138 
139  for (const Cluster *const pCluster : *pClusterList)
140  {
141  if (std::find(unavailableProtectedClusters.begin(), unavailableProtectedClusters.end(), pCluster) != unavailableProtectedClusters.end())
142  continue;
143 
144  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
145  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
146  {
147  for (const CaloHit *const pCaloHit : *mapEntry.second)
148  {
149  CartesianVector hitPosition(m_hitWidthMode ? LArHitWidthHelper::GetClosestPointToLine2D(firstCorner, connectingLineDirection, pCaloHit)
150  : pCaloHit->GetPositionVector());
151 
152  if (!this->IsInBoundingBox(minX, maxX, minZ, maxZ, hitPosition))
153  continue;
154 
155  if (distanceToLine > 0.f)
156  {
157  if (!this->IsCloseToLine(hitPosition, firstCorner, connectingLineDirection, distanceToLine))
158  continue;
159  }
160 
161  clusterToCaloHitListMap[pCluster].push_back(pCaloHit);
162  }
163  }
164  }
165 }
bool m_hitWidthMode
Whether to consider the width of hits.
bool IsCloseToLine(const pandora::CartesianVector &hitPosition, const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineDirection, const float distanceToLine) const
Check whether a hit is close to a line.
static pandora::CartesianVector GetClosestPointToLine2D(const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineDirection, const pandora::CaloHit *const pCaloHit)
Consider the hit width to find the closest position of a calo hit to a specified line.
TFile f
Definition: plotHisto.C:6
bool IsInBoundingBox(const float minX, const float maxX, const float minZ, const float maxZ, const pandora::CartesianVector &hitPosition) const
check whether a hit is contained within a defined square region
void lar_content::TrackRefinementBaseAlgorithm::GetTrackSegmentBoundaries ( const ClusterAssociation clusterAssociation,
pandora::CartesianPointVector &  trackSegmentBoundaries 
) const
protectedinherited

Obtain the segment boundaries of the connecting line to test whether extrapolated hits are continuous.

Parameters
clusterAssociationthe clusterAssociation
trackSegmentBoundariesthe output vector of segment boundaries

Definition at line 274 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::TrackRefinementBaseAlgorithm::DistanceInGap(), f, lar_content::ClusterAssociation::GetConnectingLineDirection(), lar_content::ClusterAssociation::GetDownstreamMergePoint(), lar_content::ClusterAssociation::GetUpstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::m_lineSegmentLength, and lar_content::TrackRefinementBaseAlgorithm::RepositionIfInGap().

Referenced by lar_content::TrackRefinementBaseAlgorithm::IsTrackContinuous().

275 {
276  if (m_lineSegmentLength < std::numeric_limits<float>::epsilon())
277  {
278  std::cout << "TrackInEMShowerAlgorithm: Line segment length must be positive and nonzero" << std::endl;
279  throw STATUS_CODE_INVALID_PARAMETER;
280  }
281 
282  const CartesianVector &trackDirection(clusterAssociation.GetConnectingLineDirection());
283  float trackLength((clusterAssociation.GetUpstreamMergePoint() - clusterAssociation.GetDownstreamMergePoint()).GetMagnitude());
284 
285  // ATTN: Consider the existence of gaps where no hits will be found
286  DetectorGapList consideredGaps;
287  trackLength -= this->DistanceInGap(
288  clusterAssociation.GetUpstreamMergePoint(), clusterAssociation.GetDownstreamMergePoint(), trackDirection, consideredGaps);
289  consideredGaps.clear();
290 
291  const int fullSegments(std::floor(trackLength / m_lineSegmentLength));
292 
293  if (fullSegments == 0)
294  {
295  trackSegmentBoundaries = {clusterAssociation.GetUpstreamMergePoint(), clusterAssociation.GetDownstreamMergePoint()};
296  return;
297  }
298 
299  // ATTN: To handle final segment merge track remainder with preceding segment and if track remainder was more than half of the segment length split into two
300  const float lengthOfTrackRemainder(trackLength - (fullSegments * m_lineSegmentLength));
301  const bool splitFinalSegment(lengthOfTrackRemainder > m_lineSegmentLength * 0.5f);
302  const int numberOfBoundaries(fullSegments + (splitFinalSegment ? 2 : 1));
303 
304  CartesianVector segmentUpstreamBoundary(clusterAssociation.GetUpstreamMergePoint()), segmentDownstreamBoundary(segmentUpstreamBoundary);
305  this->RepositionIfInGap(trackDirection, segmentUpstreamBoundary);
306  trackSegmentBoundaries.push_back(segmentUpstreamBoundary);
307 
308  for (int i = 1; i < numberOfBoundaries; ++i)
309  {
310  if (i < fullSegments)
311  {
312  segmentDownstreamBoundary += trackDirection * m_lineSegmentLength;
313  }
314  else
315  {
316  if (splitFinalSegment)
317  {
318  segmentDownstreamBoundary += trackDirection * (m_lineSegmentLength + lengthOfTrackRemainder) * 0.5f;
319  }
320  else
321  {
322  segmentDownstreamBoundary += trackDirection * (m_lineSegmentLength + lengthOfTrackRemainder);
323  }
324  }
325 
326  float distanceInGap(this->DistanceInGap(segmentUpstreamBoundary, segmentDownstreamBoundary, trackDirection, consideredGaps));
327  while (distanceInGap > std::numeric_limits<float>::epsilon())
328  {
329  this->RepositionIfInGap(trackDirection, segmentDownstreamBoundary);
330  segmentDownstreamBoundary += trackDirection * distanceInGap;
331  distanceInGap = this->DistanceInGap(segmentUpstreamBoundary, segmentDownstreamBoundary, trackDirection, consideredGaps);
332  }
333 
334  trackSegmentBoundaries.push_back(segmentDownstreamBoundary);
335  }
336 }
float DistanceInGap(const pandora::CartesianVector &upstreamPoint, const pandora::CartesianVector &downstreamPoint, const pandora::CartesianVector &connectingLine, pandora::DetectorGapList &consideredGaps) const
Calculate the track length between two points that lies in gaps.
TFile f
Definition: plotHisto.C:6
void RepositionIfInGap(const pandora::CartesianVector &mergeDirection, pandora::CartesianVector &trackPoint) const
Move an input position to the higher line gap edge if it lies within a gap.
float m_lineSegmentLength
The length of a track gap.
void lar_content::TrackMergeRefinementAlgorithm::GetUnavailableProtectedClusters ( const ClusterPairAssociation clusterAssociation,
const pandora::ClusterList &  createdMainTrackClusters,
pandora::ClusterList &  unavailableProtectedClusters 
) const
private

Obtain a list of clusters whos hits are protected and cannot be reassigned.

Parameters
clusterAssociationthe clusterPairAssociation
createdMainTrackClustersthe list of main track clusters that have hitherto collected
unavailableProtectedClustersthe output list of protected clusters

Definition at line 205 of file TrackMergeRefinementAlgorithm.cc.

References lar_content::ClusterPairAssociation::GetDownstreamCluster(), and lar_content::ClusterPairAssociation::GetUpstreamCluster().

Referenced by Run().

207 {
208  for (const Cluster *const pMainTrackCluster : createdMainTrackClusters)
209  {
210  if ((pMainTrackCluster != clusterAssociation.GetUpstreamCluster()) && (pMainTrackCluster != clusterAssociation.GetDownstreamCluster()))
211  protectedClusters.push_back(pMainTrackCluster);
212  }
213 }
template<typename T >
void lar_content::TrackRefinementBaseAlgorithm::InitialiseContainers ( const ClusterList *  pClusterList,
const T  sortFunction,
ClusterVector &  clusterVector,
SlidingFitResultMapPair slidingFitResultMapPair 
) const
inherited

Definition at line 40 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArClusterHelper::GetLengthSquared(), lar_content::LArGeometryHelper::GetWirePitch(), lar_content::TrackRefinementBaseAlgorithm::m_macroSlidingFitWindow, lar_content::TrackRefinementBaseAlgorithm::m_microSlidingFitWindow, and lar_content::TrackRefinementBaseAlgorithm::m_minClusterLength.

42 {
43  for (const Cluster *const pCluster : *pClusterList)
44  {
46  continue;
47 
48  try
49  {
50  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), LArClusterHelper::GetClusterHitType(pCluster)));
51  const TwoDSlidingFitResult microSlidingFitResult(pCluster, m_microSlidingFitWindow, slidingFitPitch);
52  const TwoDSlidingFitResult macroSlidingFitResult(pCluster, m_macroSlidingFitWindow, slidingFitPitch);
53 
54  slidingFitResultMapPair.first->insert(TwoDSlidingFitResultMap::value_type(pCluster, microSlidingFitResult));
55  slidingFitResultMapPair.second->insert(TwoDSlidingFitResultMap::value_type(pCluster, macroSlidingFitResult));
56  clusterVector.push_back(pCluster);
57  }
58  catch (const StatusCodeException &)
59  {
60  }
61  }
62 
63  std::sort(clusterVector.begin(), clusterVector.end(), sortFunction);
64 }
unsigned int m_macroSlidingFitWindow
The sliding fit window used in the fits contained within the macroSlidingFitResultMap.
float m_minClusterLength
The minimum length of a considered cluster.
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.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
unsigned int m_microSlidingFitWindow
The sliding fit window used in the fits contained within the microSlidingFitResultMap.
template<typename T >
void lar_content::TrackRefinementBaseAlgorithm::InitialiseContainers ( const pandora::ClusterList *  pClusterList,
const T  sortFunction,
pandora::ClusterVector &  clusterVector,
SlidingFitResultMapPair slidingFitResultMapPair 
) const
protectedinherited

Fill the cluster vector and sliding fit maps with clusters that are determined to be track-like.

Parameters
pClusterListthe list of input clusters
sortFunctionthe sort class or function used to sort the clusterVector
clusterVectorthe input vector to store clusters considered within the algorithm
slidingFitResultMapPairthe {micro, macro} pair of [cluster -> TwoDSlidingFitResult] maps

Referenced by Run(), and lar_content::TrackRefinementBaseAlgorithm::UpdateContainers().

bool lar_content::TrackRefinementBaseAlgorithm::IsCloseToLine ( const pandora::CartesianVector &  hitPosition,
const pandora::CartesianVector &  lineStart,
const pandora::CartesianVector &  lineDirection,
const float  distanceToLine 
) const
protectedinherited

Check whether a hit is close to a line.

Parameters
hitPositionthe position of the hit
lineStartthe start point of the line (can actually be any point on the line)
lineDirectionthe unit vector of the line direction
distanceToLinethe definition of 'close'
Returns
whether the hit is close to the line

Definition at line 177 of file TrackRefinementBaseAlgorithm.cc.

Referenced by lar_content::TrackRefinementBaseAlgorithm::GetHitsInBoundingBox().

179 {
180  const float transverseDistanceFromLine(lineDirection.GetCrossProduct(hitPosition - lineStart).GetMagnitude());
181 
182  return (transverseDistanceFromLine < distanceToLine);
183 }
bool lar_content::TrackRefinementBaseAlgorithm::IsClusterRemnantDisconnected ( const pandora::Cluster *const  pRemnantCluster) const
protectedinherited

Whether a remnant cluster is considered to be disconnected and therefore should undergo further fragmentation.

Parameters
pRemnantClusterthe input remnant cluster
Returns
whether the remnant cluster is disconnected

Definition at line 701 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::TrackRefinementBaseAlgorithm::m_maxHitSeparationForConnectedCluster.

Referenced by lar_content::TrackRefinementBaseAlgorithm::ProcessRemnantClusters().

702 {
703  if (pRemnantCluster->GetNCaloHits() == 1)
704  return false;
705 
706  const OrderedCaloHitList &orderedCaloHitList(pRemnantCluster->GetOrderedCaloHitList());
707  const CaloHit *pPreviousCaloHit(orderedCaloHitList.begin()->second->front());
708 
709  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
710  {
711  for (const CaloHit *const pCaloHit : *mapEntry.second)
712  {
713  if (pCaloHit == pPreviousCaloHit)
714  continue;
715 
716  const float separationDistanceSquared(pCaloHit->GetPositionVector().GetDistanceSquared(pPreviousCaloHit->GetPositionVector()));
717 
719  return true;
720 
721  pPreviousCaloHit = pCaloHit;
722  }
723  }
724 
725  return false;
726 }
float m_maxHitSeparationForConnectedCluster
The maximum separation between two adjacent (in z) hits in a connected cluster.
bool lar_content::TrackRefinementBaseAlgorithm::IsInBoundingBox ( const float  minX,
const float  maxX,
const float  minZ,
const float  maxZ,
const pandora::CartesianVector &  hitPosition 
) const
protectedinherited

check whether a hit is contained within a defined square region

Parameters
minXthe minimum x coordinate of the square region
maxXthe maximum x coordinate of the square region
minZthe minimum z coordinate of the square region
maxZthe maximum z coordinate of the square region
hitPositionthe position of the hit
Returns
whether the hit is contained within the square region

Definition at line 169 of file TrackRefinementBaseAlgorithm.cc.

Referenced by lar_content::TrackRefinementBaseAlgorithm::GetHitsInBoundingBox().

171 {
172  return !((hitPosition.GetX() < minX) || (hitPosition.GetX() > maxX) || (hitPosition.GetZ() < minZ) || (hitPosition.GetZ() > maxZ));
173 }
bool lar_content::TrackRefinementBaseAlgorithm::IsInLineSegment ( const pandora::CartesianVector &  lowerBoundary,
const pandora::CartesianVector &  upperBoundary,
const pandora::CartesianVector &  point 
) const
protectedinherited

Whether a position falls within a specified segment of the cluster connecting line.

Parameters
lowerBoundarythe lower boundary of the segment
upperBoundarythe upper boundary of the segment
pointthe position
Returns
whether the position falls within segment

Definition at line 471 of file TrackRefinementBaseAlgorithm.cc.

Referenced by lar_content::TrackRefinementBaseAlgorithm::IsTrackContinuous().

473 {
474  const float segmentBoundaryGradient = (-1.f) * (upperBoundary.GetX() - lowerBoundary.GetX()) / (upperBoundary.GetZ() - lowerBoundary.GetZ());
475  const float xPointOnUpperLine((point.GetZ() - upperBoundary.GetZ()) / segmentBoundaryGradient + upperBoundary.GetX());
476  const float xPointOnLowerLine((point.GetZ() - lowerBoundary.GetZ()) / segmentBoundaryGradient + lowerBoundary.GetX());
477 
478  if (std::fabs(xPointOnUpperLine - point.GetX()) < std::numeric_limits<float>::epsilon())
479  return true;
480 
481  if (std::fabs(xPointOnLowerLine - point.GetX()) < std::numeric_limits<float>::epsilon())
482  return true;
483 
484  if ((point.GetX() > xPointOnUpperLine) && (point.GetX() > xPointOnLowerLine))
485  return false;
486 
487  if ((point.GetX() < xPointOnUpperLine) && (point.GetX() < xPointOnLowerLine))
488  return false;
489 
490  return true;
491 }
bool lar_content::TrackRefinementBaseAlgorithm::IsNearBoundary ( const pandora::CaloHit *const  pCaloHit,
const pandora::CartesianVector &  boundaryPosition2D,
const float  boundaryTolerance 
) const
protectedinherited

Check whether a hit is close to a boundary point.

Parameters
pCaloHitthe input calo hit
boundaryPosition2Dthe position of the 2D boundary point
boundaryTolerancethe definition of close
Returns
whether the check passes

Definition at line 211 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::LArHitWidthHelper::GetClosestDistanceToPoint2D().

Referenced by AreExtrapolatedHitsNearBoundaries().

212 {
213  const float distanceToBoundary(LArHitWidthHelper::GetClosestDistanceToPoint2D(pCaloHit, boundaryPosition2D));
214 
215  return (distanceToBoundary < boundaryTolerance);
216 }
static float GetClosestDistanceToPoint2D(const pandora::CaloHit *const pCaloHit, const pandora::CartesianVector &point2D)
Consider the hit width to find the smallest distance between a calo hit and a given point...
bool lar_content::TrackRefinementBaseAlgorithm::IsTrackContinuous ( const ClusterAssociation clusterAssociation,
const pandora::CaloHitVector &  extrapolatedCaloHitVector 
) const
protectedinherited

Check whether the extrapolatedCaloHitVector contains a continuous line of hits between the cluster merge points.

Parameters
clusterAssociationthe clusterAssociation
extrapolatedCaloHitVectorthe vector of extrapolated calo hits
Returns
whether the calo hits are continuous

Definition at line 220 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::LArHitWidthHelper::GetClosestPointToLine2D(), lar_content::ClusterAssociation::GetConnectingLineDirection(), lar_content::TrackRefinementBaseAlgorithm::GetTrackSegmentBoundaries(), lar_content::ClusterAssociation::GetUpstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::IsInLineSegment(), lar_content::TrackRefinementBaseAlgorithm::m_hitWidthMode, and lar_content::TrackRefinementBaseAlgorithm::m_maxTrackGaps.

Referenced by lar_content::TrackRefinementBaseAlgorithm::AreExtrapolatedHitsGood().

221 {
222  CartesianPointVector trackSegmentBoundaries;
223  this->GetTrackSegmentBoundaries(clusterAssociation, trackSegmentBoundaries);
224 
225  if (trackSegmentBoundaries.size() < 2)
226  {
227  std::cout << "TrackInEMShowerAlgorithm: Less than two track segment boundaries" << std::endl;
228  throw STATUS_CODE_NOT_ALLOWED;
229  }
230 
231  unsigned int segmentsWithoutHits(0);
232  CaloHitVector::const_iterator caloHitIter(extrapolatedCaloHitVector.begin());
233  CartesianVector hitPosition(m_hitWidthMode ? LArHitWidthHelper::GetClosestPointToLine2D(clusterAssociation.GetUpstreamMergePoint(),
234  clusterAssociation.GetConnectingLineDirection(), *caloHitIter)
235  : (*caloHitIter)->GetPositionVector());
236 
237  for (unsigned int i = 0; i < (trackSegmentBoundaries.size() - 1); ++i)
238  {
239  if (caloHitIter == extrapolatedCaloHitVector.end())
240  {
241  ++segmentsWithoutHits;
242 
243  if (segmentsWithoutHits > m_maxTrackGaps)
244  return false;
245 
246  continue;
247  }
248 
249  unsigned int hitsInSegment(0);
250  while (this->IsInLineSegment(trackSegmentBoundaries.at(i), trackSegmentBoundaries.at(i + 1), hitPosition))
251  {
252  ++hitsInSegment;
253  ++caloHitIter;
254 
255  if (caloHitIter == extrapolatedCaloHitVector.end())
256  break;
257 
258  hitPosition = m_hitWidthMode ? LArHitWidthHelper::GetClosestPointToLine2D(clusterAssociation.GetUpstreamMergePoint(),
259  clusterAssociation.GetConnectingLineDirection(), *caloHitIter)
260  : (*caloHitIter)->GetPositionVector();
261  }
262 
263  segmentsWithoutHits = hitsInSegment ? 0 : segmentsWithoutHits + 1;
264 
265  if (segmentsWithoutHits > m_maxTrackGaps)
266  return false;
267  }
268 
269  return true;
270 }
bool m_hitWidthMode
Whether to consider the width of hits.
bool IsInLineSegment(const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary, const pandora::CartesianVector &point) const
Whether a position falls within a specified segment of the cluster connecting line.
unsigned int m_maxTrackGaps
The maximum number of graps allowed in the extrapolated hit vector.
intermediate_table::const_iterator const_iterator
static pandora::CartesianVector GetClosestPointToLine2D(const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineDirection, const pandora::CaloHit *const pCaloHit)
Consider the hit width to find the closest position of a calo hit to a specified line.
void GetTrackSegmentBoundaries(const ClusterAssociation &clusterAssociation, pandora::CartesianPointVector &trackSegmentBoundaries) const
Obtain the segment boundaries of the connecting line to test whether extrapolated hits are continuous...
void lar_content::TrackRefinementBaseAlgorithm::ProcessRemnantClusters ( const pandora::ClusterList &  remnantClusterList,
const pandora::Cluster *const  pMainTrackCluster,
const pandora::ClusterList *const  pClusterList,
pandora::ClusterList &  createdClusters 
) const
protectedinherited

Process the remnant clusters separating those that stradle the main track.

Parameters
remnantClusterListthe list of remnant clusters to process
pMainTrackClusterthe main track cluster
pClusterListthe list of all clusters
createdClustersthe input list to store the final remnant clusters

Definition at line 640 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::TrackRefinementBaseAlgorithm::AddToNearestCluster(), lar_content::TrackRefinementBaseAlgorithm::FragmentRemnantCluster(), and lar_content::TrackRefinementBaseAlgorithm::IsClusterRemnantDisconnected().

Referenced by CreateMainTrack().

642 {
643  ClusterList fragmentedClusters;
644  for (const Cluster *const pRemnantCluster : remnantClusterList)
645  {
646  if (this->IsClusterRemnantDisconnected(pRemnantCluster))
647  {
648  this->FragmentRemnantCluster(pRemnantCluster, fragmentedClusters);
649  }
650  else
651  {
652  fragmentedClusters.push_back(pRemnantCluster);
653  }
654  }
655 
656  for (const Cluster *const pFragmentedCluster : fragmentedClusters)
657  {
658  if ((pFragmentedCluster->GetNCaloHits() == 1) && (this->AddToNearestCluster(pFragmentedCluster, pMainTrackCluster, pClusterList)))
659  continue;
660 
661  createdClusters.push_back(pFragmentedCluster);
662  }
663 }
bool AddToNearestCluster(const pandora::Cluster *const pClusterToMerge, const pandora::Cluster *const pMainTrackCluster, const pandora::ClusterList *const pClusterList) const
Add a cluster to the nearest cluster satisfying separation distance thresholds.
bool IsClusterRemnantDisconnected(const pandora::Cluster *const pRemnantCluster) const
Whether a remnant cluster is considered to be disconnected and therefore should undergo further fragm...
void FragmentRemnantCluster(const pandora::Cluster *const pRemnantCluster, pandora::ClusterList &fragmentedClusterList) const
Fragment a cluster using simple hit separation logic.
StatusCode lar_content::TrackMergeRefinementAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Implements lar_content::TrackRefinementBaseAlgorithm.

Definition at line 291 of file TrackMergeRefinementAlgorithm.cc.

References m_boundaryTolerance, m_distanceToLine, m_maxLoopIterations, m_maxPredictedMergePointOffset, m_minClusterLengthSum, m_minDirectionDeviationCosAngle, m_minSeparationDistance, and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

292 {
293  PANDORA_RETURN_RESULT_IF_AND_IF(
294  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxLoopIterations", m_maxLoopIterations));
295 
296  PANDORA_RETURN_RESULT_IF_AND_IF(
297  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterLengthSum", m_minClusterLengthSum));
298 
299  PANDORA_RETURN_RESULT_IF_AND_IF(
300  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinSeparationDistance", m_minSeparationDistance));
301 
302  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
303  XmlHelper::ReadValue(xmlHandle, "MinDirectionDeviationCosAngle", m_minDirectionDeviationCosAngle));
304 
305  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
306  XmlHelper::ReadValue(xmlHandle, "MaxPredictedMergePointOffset", m_maxPredictedMergePointOffset));
307 
308  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DistanceToLine", m_distanceToLine));
309 
310  PANDORA_RETURN_RESULT_IF_AND_IF(
311  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "BoundaryTolerance", m_boundaryTolerance));
312 
314 }
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)=0
float m_maxPredictedMergePointOffset
The threshold separation distance between the predicted and true cluster merge points.
float m_minClusterLengthSum
The threshold cluster and associated cluster length sum.
float m_minSeparationDistance
The threshold separation distance between associated clusters.
unsigned int m_maxLoopIterations
The maximum number of main loop iterations.
float m_boundaryTolerance
The maximum allowed distance of an extremal extrapolate hit to a cluster merge point.
float m_distanceToLine
The threshold hit distance of an extrapolated hit from the segment connecting line.
float m_minDirectionDeviationCosAngle
The threshold cos opening angle of the associated cluster directions.
void lar_content::TrackRefinementBaseAlgorithm::RemoveClusterFromContainers ( const pandora::Cluster *const  pClustertoRemove,
pandora::ClusterVector &  clusterVector,
SlidingFitResultMapPair slidingFitResultMapPair 
) const
protectedinherited

Remove a cluster from the cluster vector and sliding fit maps.

Parameters
pClustertoRemovethe clusters to remove from the containers
clusterVectorthe vector to store clusters considered within the algorithm
slidingFitResultMapPairthe {micro, macro} pair of [cluster -> TwoDSlidingFitResult] maps

Definition at line 804 of file TrackRefinementBaseAlgorithm.cc.

Referenced by ConsiderClusterAssociation(), and lar_content::TrackRefinementBaseAlgorithm::UpdateContainers().

806 {
807  const TwoDSlidingFitResultMap::const_iterator microFitToDelete(slidingFitResultMapPair.first->find(pClusterToRemove));
808  if (microFitToDelete != slidingFitResultMapPair.first->end())
809  slidingFitResultMapPair.first->erase(microFitToDelete);
810 
811  const TwoDSlidingFitResultMap::const_iterator macroFitToDelete(slidingFitResultMapPair.second->find(pClusterToRemove));
812  if (macroFitToDelete != slidingFitResultMapPair.second->end())
813  slidingFitResultMapPair.second->erase(macroFitToDelete);
814 
815  const ClusterVector::const_iterator clusterToDelete(std::find(clusterVector.begin(), clusterVector.end(), pClusterToRemove));
816  if (clusterToDelete != clusterVector.end())
817  clusterVector.erase(clusterToDelete);
818 }
intermediate_table::const_iterator const_iterator
const Cluster * lar_content::TrackRefinementBaseAlgorithm::RemoveOffAxisHitsFromTrack ( const pandora::Cluster *const  pCluster,
const pandora::CartesianVector &  splitPosition,
const bool  isEndUpstream,
const ClusterToCaloHitListMap clusterToCaloHitListMap,
pandora::ClusterList &  remnantClusterList,
TwoDSlidingFitResultMap microSlidingFitResultMap,
TwoDSlidingFitResultMap macroSlidingFitResultMap 
) const
protectedinherited

Remove any hits in the upstream/downstream cluster that lie off of the main track axis (i.e. clustering errors)

Parameters
pClusterthe input cluster
splitPositionthe position after which hits are considered for removal
isEndUpstreamwhether the upstream end is to be refined
clusterToCaloHitListMapthe map [parent cluster -> list of hits which belong to the main track]
remnantClusterListthe input list to store the remnant clusters
microSlidingFitResultMapthe mapping [cluster -> TwoDSlidingFitResult] where fits correspond to local gradients
macroSlidingFitResultMapthe mapping [cluster -> TwoDSlidingFitResult] where fits correspond to global cluster gradients
Returns
the address of the (possibly) modified cluster

Definition at line 495 of file TrackRefinementBaseAlgorithm.cc.

References f, and lar_content::TwoDSlidingFitResult::GetLocalPosition().

Referenced by CreateMainTrack().

498 {
499  float rL(0.f), rT(0.f);
500  const TwoDSlidingFitResult &microFitResult(microSlidingFitResultMap.at(pCluster));
501  microFitResult.GetLocalPosition(splitPosition, rL, rT);
502 
503  const TwoDSlidingFitResult &macroFitResult(macroSlidingFitResultMap.at(pCluster));
504  CartesianVector averageDirection(0.f, 0.f, 0.f);
505  macroFitResult.GetGlobalDirection(macroFitResult.GetLayerFitResultMap().begin()->second.GetGradient(), averageDirection);
506 
507  const bool isVertical(std::fabs(averageDirection.GetX()) < std::numeric_limits<float>::epsilon());
508  const float clusterGradient(isVertical ? 0.f : averageDirection.GetZ() / averageDirection.GetX());
509  const float clusterIntercept(isVertical ? splitPosition.GetX() : splitPosition.GetZ() - (clusterGradient * splitPosition.GetX()));
510 
511  // Fragmentation initialisation
512  std::string originalListName, fragmentListName;
513  const ClusterList originalClusterList(1, pCluster);
514  PANDORA_THROW_RESULT_IF(
515  STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeFragmentation(*this, originalClusterList, originalListName, fragmentListName));
516 
517  const Cluster *pMainTrackCluster(nullptr), *pAboveCluster(nullptr), *pBelowCluster(nullptr);
518 
519  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
520  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
521  {
522  for (const CaloHit *const pCaloHit : *mapEntry.second)
523  {
524  const CartesianVector &hitPosition(pCaloHit->GetPositionVector());
525  float thisL(0.f), thisT(0.f);
526 
527  microFitResult.GetLocalPosition(pCaloHit->GetPositionVector(), thisL, thisT);
528 
529  bool isAnExtrapolatedHit(false);
530  const auto extrapolatedCaloHitIter(clusterToCaloHitListMap.find(pCluster));
531 
532  if (extrapolatedCaloHitIter != clusterToCaloHitListMap.end())
533  isAnExtrapolatedHit = std::find(extrapolatedCaloHitIter->second.begin(), extrapolatedCaloHitIter->second.end(), pCaloHit) !=
534  extrapolatedCaloHitIter->second.end();
535 
536  const bool isAbove(((clusterGradient * hitPosition.GetX()) + clusterIntercept) < (isVertical ? hitPosition.GetX() : hitPosition.GetZ()));
537  const bool isToRemove(!isAnExtrapolatedHit && (((thisL < rL) && isEndUpstream) || ((thisL > rL) && !isEndUpstream)));
538 
539  const Cluster *&pClusterToModify(isToRemove ? (isAbove ? pAboveCluster : pBelowCluster) : pMainTrackCluster);
540 
541  if (pClusterToModify)
542  {
543  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, pClusterToModify, pCaloHit));
544  }
545  else
546  {
547  PandoraContentApi::Cluster::Parameters parameters;
548  parameters.m_caloHitList.push_back(pCaloHit);
549  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pClusterToModify));
550 
551  if (pClusterToModify != pMainTrackCluster)
552  remnantClusterList.push_back(pClusterToModify);
553  }
554  }
555  }
556 
557  // End fragmentation
558  if (pAboveCluster || pBelowCluster)
559  {
560  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*this, fragmentListName, originalListName));
561  return pMainTrackCluster;
562  }
563  else
564  {
565  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*this, originalListName, fragmentListName));
566  return pCluster;
567  }
568 }
TFile f
Definition: plotHisto.C:6
void lar_content::TrackRefinementBaseAlgorithm::RepositionIfInGap ( const pandora::CartesianVector &  mergeDirection,
pandora::CartesianVector &  trackPoint 
) const
protectedinherited

Move an input position to the higher line gap edge if it lies within a gap.

Parameters
mergeDirectionthe direction of the track
trackPointthe input position

Definition at line 340 of file TrackRefinementBaseAlgorithm.cc.

Referenced by lar_content::TrackRefinementBaseAlgorithm::GetTrackSegmentBoundaries().

341 {
342  const DetectorGapList detectorGapList(this->GetPandora().GetGeometry()->GetDetectorGapList());
343  for (const DetectorGap *const pDetectorGap : detectorGapList)
344  {
345  const LineGap *const pLineGap(dynamic_cast<const LineGap *>(pDetectorGap));
346 
347  if (pLineGap)
348  {
349  const LineGapType lineGapType(pLineGap->GetLineGapType());
350 
351  if (lineGapType == TPC_DRIFT_GAP)
352  {
353  if ((pLineGap->GetLineStartX() < trackPoint.GetX()) && (pLineGap->GetLineEndX() > trackPoint.GetX()))
354  {
355  if (std::fabs(mergeDirection.GetX()) < std::numeric_limits<float>::epsilon())
356  throw StatusCodeException(STATUS_CODE_FAILURE);
357 
358  const float gradient(mergeDirection.GetZ() / mergeDirection.GetX());
359 
360  trackPoint = CartesianVector(
361  pLineGap->GetLineEndX(), 0.f, trackPoint.GetZ() + (gradient * (pLineGap->GetLineEndX() - trackPoint.GetX())));
362  }
363  }
364 
365  if ((lineGapType == TPC_WIRE_GAP_VIEW_U) || (lineGapType == TPC_WIRE_GAP_VIEW_V) || (lineGapType == TPC_WIRE_GAP_VIEW_W))
366  {
367  if ((pLineGap->GetLineStartZ() < trackPoint.GetZ()) && (pLineGap->GetLineEndZ() > trackPoint.GetZ()))
368  {
369  if (std::fabs(mergeDirection.GetZ()) < std::numeric_limits<float>::epsilon())
370  throw StatusCodeException(STATUS_CODE_FAILURE);
371 
372  const float gradient(mergeDirection.GetX() / mergeDirection.GetZ());
373 
374  trackPoint = CartesianVector(
375  trackPoint.GetX() + (gradient * (pLineGap->GetLineEndZ() - trackPoint.GetZ())), 0.f, pLineGap->GetLineEndZ());
376  }
377  }
378  }
379  }
380 }
StatusCode lar_content::TrackMergeRefinementAlgorithm::Run ( )
privatevirtual

Implements lar_content::TrackRefinementBaseAlgorithm.

Definition at line 34 of file TrackMergeRefinementAlgorithm.cc.

References lar_content::TrackRefinementBaseAlgorithm::AreExtrapolatedHitsGood(), ConsiderClusterAssociation(), CreateMainTrack(), FindBestClusterAssociation(), lar_content::ClusterPairAssociation::GetDownstreamCluster(), lar_content::ClusterAssociation::GetDownstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::GetHitsInBoundingBox(), GetUnavailableProtectedClusters(), lar_content::ClusterPairAssociation::GetUpstreamCluster(), lar_content::ClusterAssociation::GetUpstreamMergePoint(), lar_content::TrackRefinementBaseAlgorithm::InitialiseContainers(), m_distanceToLine, m_maxLoopIterations, and lar_content::LArClusterHelper::SortByNHits().

35 {
36  const ClusterList *pClusterList(nullptr);
37  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
38 
39  const CaloHitList *pCaloHitList(nullptr);
40  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pCaloHitList));
41 
42  ClusterVector clusterVector;
43  TwoDSlidingFitResultMap microSlidingFitResultMap, macroSlidingFitResultMap;
44  SlidingFitResultMapPair slidingFitResultMapPair({&microSlidingFitResultMap, &macroSlidingFitResultMap});
45 
46  this->InitialiseContainers(pClusterList, LArClusterHelper::SortByNHits, clusterVector, slidingFitResultMapPair);
47 
48  // ATTN: Keep track of created main track clusters so their hits can be protected in future iterations
49  unsigned int loopIterations(0);
50  ClusterList createdMainTrackClusters;
51  while (loopIterations < m_maxLoopIterations)
52  {
53  ++loopIterations;
54 
55  ClusterPairAssociation clusterAssociation;
56  if (!this->FindBestClusterAssociation(clusterVector, slidingFitResultMapPair, clusterAssociation))
57  break;
58 
59  ClusterList unavailableProtectedClusters;
60  this->GetUnavailableProtectedClusters(clusterAssociation, createdMainTrackClusters, unavailableProtectedClusters);
61 
62  ClusterToCaloHitListMap clusterToCaloHitListMap;
63  this->GetHitsInBoundingBox(clusterAssociation.GetUpstreamMergePoint(), clusterAssociation.GetDownstreamMergePoint(), pClusterList,
64  clusterToCaloHitListMap, unavailableProtectedClusters, m_distanceToLine);
65 
66  if (!this->AreExtrapolatedHitsGood(clusterToCaloHitListMap, clusterAssociation))
67  {
68  this->ConsiderClusterAssociation(clusterAssociation, clusterVector, slidingFitResultMapPair);
69  continue;
70  }
71 
72  const ClusterList::const_iterator upstreamIter(
73  std::find(createdMainTrackClusters.begin(), createdMainTrackClusters.end(), clusterAssociation.GetUpstreamCluster()));
74  if (upstreamIter != createdMainTrackClusters.end())
75  createdMainTrackClusters.erase(upstreamIter);
76 
77  const ClusterList::const_iterator downstreamIter(
78  std::find(createdMainTrackClusters.begin(), createdMainTrackClusters.end(), clusterAssociation.GetDownstreamCluster()));
79  if (downstreamIter != createdMainTrackClusters.end())
80  createdMainTrackClusters.erase(downstreamIter);
81 
82  createdMainTrackClusters.push_back(
83  this->CreateMainTrack(clusterAssociation, clusterToCaloHitListMap, pClusterList, clusterVector, slidingFitResultMapPair));
84  }
85 
86  return STATUS_CODE_SUCCESS;
87 }
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.
std::pair< TwoDSlidingFitResultMap *, TwoDSlidingFitResultMap * > SlidingFitResultMapPair
void ConsiderClusterAssociation(const ClusterPairAssociation &clusterAssociation, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
Remove the cluster association from the cluster vector so that the same cluster pair is not considere...
intermediate_table::const_iterator const_iterator
std::unordered_map< const pandora::Cluster *, pandora::CaloHitList > ClusterToCaloHitListMap
bool AreExtrapolatedHitsGood(const ClusterToCaloHitListMap &clusterToCaloHitListMap, ClusterAssociation &clusterAssociation) const
Perform topological checks on the collected hits to ensure no gaps are present.
bool FindBestClusterAssociation(const pandora::ClusterVector &clusterVector, const SlidingFitResultMapPair &slidingFitResultMapPair, ClusterPairAssociation &clusterAssociation) const
Find the best cluster association.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
void InitialiseContainers(const pandora::ClusterList *pClusterList, const T sortFunction, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
Fill the cluster vector and sliding fit maps with clusters that are determined to be track-like...
const pandora::Cluster * CreateMainTrack(const ClusterPairAssociation &clusterAssociation, const ClusterToCaloHitListMap &clusterToCaloHitListMap, const pandora::ClusterList *pClusterList, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
Refine the cluster endpoints and merge together the associated clusters alongside any extrapolated hi...
unsigned int m_maxLoopIterations
The maximum number of main loop iterations.
void GetHitsInBoundingBox(const pandora::CartesianVector &firstCorner, const pandora::CartesianVector &secondCorner, const pandora::ClusterList *const pClusterList, ClusterToCaloHitListMap &clusterToCaloHitListMap, const pandora::ClusterList &unavailableProtectedClusters=pandora::ClusterList(), const float distanceToLine=-1.f) const
Find the unprotected hits that are contained within a defined box with the option to apply a cut on t...
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void GetUnavailableProtectedClusters(const ClusterPairAssociation &clusterAssociation, const pandora::ClusterList &createdMainTrackClusters, pandora::ClusterList &unavailableProtectedClusters) const
Obtain a list of clusters whos hits are protected and cannot be reassigned.
float m_distanceToLine
The threshold hit distance of an extrapolated hit from the segment connecting line.
template<typename T >
void lar_content::TrackRefinementBaseAlgorithm::UpdateContainers ( const pandora::ClusterList &  clustersToAdd,
const pandora::ClusterList &  clustersToDelete,
const T  sortFunction,
pandora::ClusterVector &  clusterVector,
SlidingFitResultMapPair slidingFitResultMapPair 
) const
protectedinherited

Remove deleted clusters from the cluster vector and sliding fit maps and add in created clusters that are determined to be track-like.

Parameters
clustersToAddthe list of clusters to add to the containers
clustersToDeletethe list of clusters to remove from the containers
sortFunctionthe sort class or function used to sort the clusterVector
clusterVectorthe vector to store clusters considered within the algorithm
slidingFitResultMapPairthe {micro, macro} pair of [cluster -> TwoDSlidingFitResult] maps

Referenced by CreateMainTrack().

template<typename T >
void lar_content::TrackRefinementBaseAlgorithm::UpdateContainers ( const ClusterList &  clustersToAdd,
const ClusterList &  clustersToDelete,
const T  sortFunction,
ClusterVector &  clusterVector,
SlidingFitResultMapPair slidingFitResultMapPair 
) const
inherited

Definition at line 792 of file TrackRefinementBaseAlgorithm.cc.

References lar_content::TrackRefinementBaseAlgorithm::InitialiseContainers(), and lar_content::TrackRefinementBaseAlgorithm::RemoveClusterFromContainers().

794 {
795  //ATTN: Very important to first delete pointers from containers
796  for (const Cluster *const pClusterToDelete : clustersToDelete)
797  this->RemoveClusterFromContainers(pClusterToDelete, clusterVector, slidingFitResultMapPair);
798 
799  this->InitialiseContainers(&clustersToAdd, sortFunction, clusterVector, slidingFitResultMapPair);
800 }
void InitialiseContainers(const pandora::ClusterList *pClusterList, const T sortFunction, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
Fill the cluster vector and sliding fit maps with clusters that are determined to be track-like...
void RemoveClusterFromContainers(const pandora::Cluster *const pClustertoRemove, pandora::ClusterVector &clusterVector, SlidingFitResultMapPair &slidingFitResultMapPair) const
Remove a cluster from the cluster vector and sliding fit maps.

Member Data Documentation

float lar_content::TrackMergeRefinementAlgorithm::m_boundaryTolerance
private

The maximum allowed distance of an extremal extrapolate hit to a cluster merge point.

Definition at line 105 of file TrackMergeRefinementAlgorithm.h.

Referenced by AreExtrapolatedHitsNearBoundaries(), and ReadSettings().

float lar_content::TrackMergeRefinementAlgorithm::m_distanceToLine
private

The threshold hit distance of an extrapolated hit from the segment connecting line.

Definition at line 104 of file TrackMergeRefinementAlgorithm.h.

Referenced by ReadSettings(), and Run().

float lar_content::TrackRefinementBaseAlgorithm::m_lineSegmentLength
protectedinherited
unsigned int lar_content::TrackRefinementBaseAlgorithm::m_macroSlidingFitWindow
protectedinherited

The sliding fit window used in the fits contained within the macroSlidingFitResultMap.

Definition at line 309 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::InitialiseContainers(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

float lar_content::TrackRefinementBaseAlgorithm::m_maxDistanceFromMainTrack
protectedinherited

The threshold distance for a hit to be added to the main track.

Definition at line 313 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::AddToNearestCluster(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

float lar_content::TrackRefinementBaseAlgorithm::m_maxHitDistanceFromCluster
protectedinherited

The threshold separation between a hit and cluster for the hit to be merged into the cluster.

Definition at line 314 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::AddToNearestCluster(), lar_content::TrackRefinementBaseAlgorithm::FragmentRemnantCluster(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

float lar_content::TrackRefinementBaseAlgorithm::m_maxHitSeparationForConnectedCluster
protectedinherited

The maximum separation between two adjacent (in z) hits in a connected cluster.

Definition at line 315 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::IsClusterRemnantDisconnected(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

unsigned int lar_content::TrackMergeRefinementAlgorithm::m_maxLoopIterations
private

The maximum number of main loop iterations.

Definition at line 99 of file TrackMergeRefinementAlgorithm.h.

Referenced by ReadSettings(), and Run().

float lar_content::TrackMergeRefinementAlgorithm::m_maxPredictedMergePointOffset
private

The threshold separation distance between the predicted and true cluster merge points.

Definition at line 103 of file TrackMergeRefinementAlgorithm.h.

Referenced by AreClustersAssociated(), and ReadSettings().

unsigned int lar_content::TrackRefinementBaseAlgorithm::m_maxTrackGaps
protectedinherited

The maximum number of graps allowed in the extrapolated hit vector.

Definition at line 316 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::IsTrackContinuous(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

float lar_content::TrackRefinementBaseAlgorithm::m_mergePointMinCosAngleDeviation
protectedinherited

The threshold cos opening angle between the cluster local gradient and the associated cluster global gradient used to determine merge points.

Definition at line 311 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::GetClusterMergingCoordinates(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

unsigned int lar_content::TrackRefinementBaseAlgorithm::m_microSlidingFitWindow
protectedinherited

The sliding fit window used in the fits contained within the microSlidingFitResultMap.

Definition at line 308 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::InitialiseContainers(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

float lar_content::TrackRefinementBaseAlgorithm::m_minClusterLength
protectedinherited
float lar_content::TrackMergeRefinementAlgorithm::m_minClusterLengthSum
private

The threshold cluster and associated cluster length sum.

Definition at line 100 of file TrackMergeRefinementAlgorithm.h.

Referenced by FindBestClusterAssociation(), and ReadSettings().

float lar_content::TrackMergeRefinementAlgorithm::m_minDirectionDeviationCosAngle
private

The threshold cos opening angle of the associated cluster directions.

Definition at line 102 of file TrackMergeRefinementAlgorithm.h.

Referenced by AreClustersAssociated(), and ReadSettings().

float lar_content::TrackRefinementBaseAlgorithm::m_minHitFractionForHitRemoval
protectedinherited

The threshold fraction of hits to be removed from the cluster for hit removal to proceed.

Definition at line 312 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::AddHitsToMainTrack(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().

float lar_content::TrackMergeRefinementAlgorithm::m_minSeparationDistance
private

The threshold separation distance between associated clusters.

Definition at line 101 of file TrackMergeRefinementAlgorithm.h.

Referenced by AreClustersAssociated(), and ReadSettings().

float lar_content::TrackRefinementBaseAlgorithm::m_stableRegionClusterFraction
protectedinherited

The threshold fraction of fit contributing layers which defines the stable region.

Definition at line 310 of file TrackRefinementBaseAlgorithm.h.

Referenced by lar_content::TrackRefinementBaseAlgorithm::GetClusterMergingCoordinates(), and lar_content::TrackRefinementBaseAlgorithm::ReadSettings().


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