8 #ifndef LAR_TRACK_REFINEMENT_BASE_ALGORITHM_H
9 #define LAR_TRACK_REFINEMENT_BASE_ALGORITHM_H 1
11 #include "Pandora/Algorithm.h"
46 SortByDistanceAlongLine(
const pandora::CartesianVector &startPoint,
const pandora::CartesianVector &lineDirection,
const bool hitWidthMode);
56 bool operator()(
const pandora::CaloHit *
const pLhs,
const pandora::CaloHit *
const pRhs)
const;
64 virtual pandora::StatusCode
Run() = 0;
65 virtual pandora::StatusCode
ReadSettings(
const pandora::TiXmlHandle xmlHandle) = 0;
92 const TwoDSlidingFitResult &associatedMacroFitResult,
const bool isEndUpstream, pandora::CartesianVector &clusterMergePosition,
93 pandora::CartesianVector &clusterMergeDirection)
const;
105 void GetHitsInBoundingBox(
const pandora::CartesianVector &firstCorner,
const pandora::CartesianVector &secondCorner,
107 const pandora::ClusterList &unavailableProtectedClusters = pandora::ClusterList(),
const float distanceToLine = -1.f)
const;
120 bool IsInBoundingBox(
const float minX,
const float maxX,
const float minZ,
const float maxZ,
const pandora::CartesianVector &hitPosition)
const;
132 bool IsCloseToLine(
const pandora::CartesianVector &hitPosition,
const pandora::CartesianVector &lineStart,
133 const pandora::CartesianVector &lineDirection,
const float distanceToLine)
const;
164 bool IsNearBoundary(
const pandora::CaloHit *
const pCaloHit,
const pandora::CartesianVector &boundaryPosition2D,
const float boundaryTolerance)
const;
190 void RepositionIfInGap(
const pandora::CartesianVector &mergeDirection, pandora::CartesianVector &trackPoint)
const;
200 float DistanceInGap(
const pandora::CartesianVector &upstreamPoint,
const pandora::CartesianVector &downstreamPoint,
201 const pandora::CartesianVector &connectingLine, pandora::DetectorGapList &consideredGaps)
const;
212 bool IsInLineSegment(
const pandora::CartesianVector &lowerBoundary,
const pandora::CartesianVector &upperBoundary,
213 const pandora::CartesianVector &point)
const;
228 const pandora::Cluster *
RemoveOffAxisHitsFromTrack(
const pandora::Cluster *
const pCluster,
const pandora::CartesianVector &splitPosition,
229 const bool isEndUpstream,
const ClusterToCaloHitListMap &clusterToCaloHitListMap, pandora::ClusterList &remnantClusterList,
241 void AddHitsToMainTrack(
const pandora::Cluster *
const pMainTrackCluster,
const pandora::Cluster *
const pShowerTrackCluster,
242 const pandora::CaloHitList &caloHitsToMerge,
const ClusterAssociation &clusterAssociation, pandora::ClusterList &remnantClusterList)
const;
252 void ProcessRemnantClusters(
const pandora::ClusterList &remnantClusterList,
const pandora::Cluster *
const pMainTrackCluster,
253 const pandora::ClusterList *
const pClusterList, pandora::ClusterList &createdClusters)
const;
264 bool AddToNearestCluster(
const pandora::Cluster *
const pClusterToMerge,
const pandora::Cluster *
const pMainTrackCluster,
265 const pandora::ClusterList *
const pClusterList)
const;
282 void FragmentRemnantCluster(
const pandora::Cluster *
const pRemnantCluster, pandora::ClusterList &fragmentedClusterList)
const;
293 template <
typename T>
294 void UpdateContainers(
const pandora::ClusterList &clustersToAdd,
const pandora::ClusterList &clustersToDelete,
const T sortFunction,
324 const pandora::CartesianVector &startPoint,
const pandora::CartesianVector &lineDirection,
const bool hitWidthMode) :
325 m_startPoint(startPoint),
326 m_lineDirection(lineDirection.GetUnitVector()),
327 m_hitWidthMode(hitWidthMode)
333 #endif // #ifndef TRACK_REFINEMENT_BASE_ALGORITHM_H
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.
unsigned int m_macroSlidingFitWindow
The sliding fit window used in the fits contained within the macroSlidingFitResultMap.
bool m_hitWidthMode
Whether to consider the width of hits.
SortByDistanceAlongLine class.
ClusterAssociation class.
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.
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.
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 ...
float m_minClusterLength
The minimum length of a considered cluster.
std::pair< TwoDSlidingFitResultMap *, TwoDSlidingFitResultMap * > SlidingFitResultMapPair
unsigned int m_maxTrackGaps
The maximum number of graps allowed in the extrapolated hit vector.
std::unordered_map< const pandora::Cluster *, pandora::CaloHitList > ClusterToCaloHitListMap
bool m_hitWidthMode
Wether to consider hit widths or not.
TrackRefinementBaseAlgorithm class.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)=0
float m_minHitFractionForHitRemoval
The threshold fraction of hits to be removed from the cluster for hit removal to proceed.
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 IsTrackContinuous(const ClusterAssociation &clusterAssociation, const pandora::CaloHitVector &extrapolatedCaloHitVector) const
Check whether the extrapolatedCaloHitVector contains a continuous line of hits between the cluster me...
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...
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.
float m_maxHitDistanceFromCluster
The threshold separation between a hit and cluster for the hit to be merged into the cluster...
bool AreExtrapolatedHitsGood(const ClusterToCaloHitListMap &clusterToCaloHitListMap, ClusterAssociation &clusterAssociation) const
Perform topological checks on the collected hits to ensure no gaps are present.
bool IsClusterRemnantDisconnected(const pandora::Cluster *const pRemnantCluster) const
Whether a remnant cluster is considered to be disconnected and therefore should undergo further fragm...
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...
pandora::CartesianVector m_lineDirection
The line end point.
void FragmentRemnantCluster(const pandora::Cluster *const pRemnantCluster, pandora::ClusterList &fragmentedClusterList) const
Fragment a cluster using simple hit separation logic.
float m_maxHitSeparationForConnectedCluster
The maximum separation between two adjacent (in z) hits in a connected cluster.
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.
Header file for the lar two dimensional sliding fit result class.
Header file for the lar cluster association class.
float m_stableRegionClusterFraction
The threshold fraction of fit contributing layers which defines the stable region.
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.
TrackRefinementBaseAlgorithm()
Default constructor.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
virtual pandora::StatusCode Run()=0
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.
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
float m_maxDistanceFromMainTrack
The threshold distance for a hit to be added to the main track.
bool operator()(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs) const
Sort hits by their projected distance along a line from a start point.
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
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.
pandora::CartesianVector m_startPoint
The line start point.
const pandora::Cluster * RemoveOffAxisHitsFromTrack(const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition, const bool isEndUpstream, const ClusterToCaloHitListMap &clusterToCaloHitListMap, pandora::ClusterList &remnantClusterList, TwoDSlidingFitResultMap µSlidingFitResultMap, TwoDSlidingFitResultMap ¯oSlidingFitResultMap) const
Remove any hits in the upstream/downstream cluster that lie off of the main track axis (i...
void GetTrackSegmentBoundaries(const ClusterAssociation &clusterAssociation, pandora::CartesianPointVector &trackSegmentBoundaries) const
Obtain the segment boundaries of the connecting line to test whether extrapolated hits are continuous...
SortByDistanceAlongLine(const pandora::CartesianVector &startPoint, const pandora::CartesianVector &lineDirection, const bool hitWidthMode)
Constructor.
unsigned int m_microSlidingFitWindow
The sliding fit window used in the fits contained within the microSlidingFitResultMap.
TwoDSlidingFitResult class.
float m_mergePointMinCosAngleDeviation
The threshold cos opening angle between the cluster local gradient and the associated cluster global ...