23 m_minClusterLayers(6),
24 m_slidingFitWindow(20),
25 m_maxSamplingPoints(1000),
26 m_sampleStepSize(0.5f),
27 m_maxUnmatchedSampleRun(8),
28 m_maxOnClusterDistance(1.5f),
29 m_minMatchedSamplingPoints(10),
30 m_minMatchedSamplingFraction(0.5f),
43 for (
const Cluster *
const pCluster : *pClusterList)
48 if (1 + pCluster->GetOuterPseudoLayer() - pCluster->GetInnerPseudoLayer() <
m_minClusterLayers)
51 clusterVector.push_back(pCluster);
64 for (
const Cluster *
const pCluster : clusterVector)
68 (void)slidingFitResultMap.insert(
77 for (ClusterVector::const_iterator iterI = clusterVector.begin(), iterIEnd = clusterVector.end(); iterI != iterIEnd; ++iterI)
79 const Cluster *
const pInnerCluster = *iterI;
80 TwoDSlidingFitResultMap::const_iterator fitIterI = slidingFitResultMap.find(pInnerCluster);
82 if (slidingFitResultMap.end() == fitIterI)
85 for (ClusterVector::const_iterator iterJ = iterI, iterJEnd = clusterVector.end(); iterJ != iterJEnd; ++iterJ)
87 const Cluster *
const pOuterCluster = *iterJ;
89 if (pInnerCluster == pOuterCluster)
92 TwoDSlidingFitResultMap::const_iterator fitIterJ = slidingFitResultMap.find(pOuterCluster);
94 if (slidingFitResultMap.end() == fitIterJ)
100 clusterAssociationMap[pInnerCluster].m_forwardAssociations.insert(pOuterCluster);
101 clusterAssociationMap[pOuterCluster].m_backwardAssociations.insert(pInnerCluster);
113 if (isForward && ((testLayer > currentLayer) || ((testLayer == currentLayer) &&
LArClusterHelper::SortByNHits(pTestCluster, pCurrentCluster))))
116 if (!isForward && ((testLayer < currentLayer) || ((testLayer == currentLayer) &&
LArClusterHelper::SortByNHits(pTestCluster, pCurrentCluster))))
142 unsigned int nSamplingPoints(0), nGapSamplingPoints(0), nMatchedSamplingPoints(0), nUnmatchedSampleRun(0);
151 ++nGapSamplingPoints;
152 nUnmatchedSampleRun = 0;
158 ++nMatchedSamplingPoints;
159 nUnmatchedSampleRun = 0;
168 const float matchedSamplingFraction(expectation > 0.f ?
static_cast<float>(nMatchedSamplingPoints) / expectation : 0.f);
180 float rL(std::numeric_limits<float>::max()), rT(std::numeric_limits<float>::max());
221 std::cout <<
"CrossGapsAssociationAlgorithm: Invalid value for SampleStepSize " <<
m_sampleStepSize << std::endl;
Header file for the cross gaps association algorithm class.
Header file for the cluster helper class.
Header file for the geometry helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
unsigned int m_minClusterHits
The minimum allowed number of hits in a clean cluster.
unsigned int m_minClusterLayers
The minimum allowed number of layers for a clean cluster.
unsigned int m_maxSamplingPoints
The maximum number of extension sampling points considered per association check.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
float m_sampleStepSize
The sampling step size used in association checks, units cm.
unsigned int m_minMatchedSamplingPoints
Minimum number of matched sampling points to declare association.
float m_maxOnClusterDistance
The maximum distance between a sampling point and sliding fit to target cluster.
bool IsNearCluster(const pandora::CartesianVector &samplingPoint, const TwoDSlidingFitResult &targetFitResult) const
Whether a sampling point lies near a target 2d sliding fit result.
void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const
Populate cluster vector with subset of cluster list, containing clusters judged to be clean.
bool IsAssociated(const pandora::CartesianVector &startPosition, const pandora::CartesianVector &startDirection, const TwoDSlidingFitResult &targetFitResult) const
Sample points along the extrapolation from a starting position to a target fit result to declare clus...
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
unsigned int m_maxUnmatchedSampleRun
The maximum run of unmatched (and non-gap) samples to consider before stopping.
float m_gapTolerance
The tolerance to use when querying whether a sampling point is in a gap, units cm.
CrossGapsAssociationAlgorithm()
Default constructor.
bool IsExtremalCluster(const bool isForward, const pandora::Cluster *const pCurrentCluster, const pandora::Cluster *const pTestCluster) const
Determine which of two clusters is extremal.
float m_minMatchedSamplingFraction
Minimum ratio between matched sampling points and expectation to declare association.
void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const
Populate the cluster association map.
bool AreClustersAssociated(const TwoDSlidingFitResult &innerFitResult, const TwoDSlidingFitResult &outerFitResult) const
Determine whether two clusters are associated.
static bool SortByInnerLayer(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by inner layer, then position, then pulse-height.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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,...
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
static bool IsInGap(const pandora::Pandora &pandora, const pandora::CartesianVector &testPoint2D, const pandora::HitType hitType, const float gapTolerance=0.f)
Whether a 2D test point lies in a registered gap with the associated hit type.
TwoDSlidingFitResult class.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.
pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const
Get global fit position for a given longitudinal coordinate.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
pandora::StatusCode GetGlobalFitPositionAtX(const float x, pandora::CartesianVector &position) const
Get global fit position for a given input x coordinate.
float GetX() const
Get the cartesian x coordinate.
unsigned int GetOuterPseudoLayer() const
Get the outermost pseudo layer in the cluster.
unsigned int GetInnerPseudoLayer() const
Get the innermost pseudo layer in the cluster.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
HitType
Calorimeter hit type enum.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.