All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HitWidthClusterMergingAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTwoDReco/LArClusterAssociation/HitWidthClusterMergingAlgorithm.h
3  *
4  * @brief Header file for the hit width cluster merging algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_HIT_WIDTH_CLUSTER_MERGING_ALGORITHM_H
9 #define LAR_HIT_WIDTH_CLUSTER_MERGING_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
14 
16 
17 namespace lar_content
18 {
19 
20 /**
21  * @brief HitWidthClusterMergingAlgorithm class
22  */
24 {
25 public:
26  /**
27  * @brief Default constructor
28  */
30 
31 private:
32  void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const;
33  void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const;
34  bool IsExtremalCluster(const bool isForward, const pandora::Cluster *const pCurrentCluster, const pandora::Cluster *const pTestCluster) const;
35 
36  /**
37  * @brief Determine whether two clusters are associated
38  *
39  * @param currentClusterParameters parameters defining the current cluster
40  * @param testClusterParameters parameters defining the test cluster
41  *
42  * @return boolean whether the clusters are associated
43  */
44  bool AreClustersAssociated(const LArHitWidthHelper::ClusterParameters &currentClusterParameters,
45  const LArHitWidthHelper::ClusterParameters &testClusterParameters) const;
46 
47  /**
48  * @brief Determine the position of the constituent hit that lies closest to a specified position
49  *
50  * @param position the point to which the consituent hits will be compared
51  * @param constituentHitVector the input vector of constituent hits
52  * @param closestPoint the position of the closest constituent hit
53  *
54  */
55  void FindClosestPointToPosition(const pandora::CartesianVector &position,
56  const LArHitWidthHelper::ConstituentHitVector &constituentHitVector, pandora::CartesianVector &closestPoint) const;
57 
58  /**
59  * @brief Determine the cluster direction at a reference point by performing a weighted least squared fit to the input consitutent hit positions
60  * The fit is performed in a rotated cartesian coordinate system defined by a fitting axis determined by eigen
61  * The function is composed of two main loops that calculate the:
62  * 1. rL & rT weighted means
63  * 2. gradient of the fit
64  * The fit is performed using a subset of points that are closest to the fitReferencePoint
65  *
66  * @param constituentHitVector the input vector of constituent hits
67  * @param direction the fitted cluster direction
68  * @param fitReferencePoint the hits closest to this point are included in the fit
69  * @param fittingWeight the weight that is considered in the fit
70  *
71  */
72  void GetClusterDirection(const LArHitWidthHelper::ConstituentHitVector &constituentHitVector, pandora::CartesianVector &direction,
73  const pandora::CartesianVector &fitReferencePoint, const float fittingWeight) const;
74 
75  /**
76  * @brief Obtain a vector of the minimum number of hits closest to a reference point that exceed a given weight
77  *
78  * @param constituentHitVector the input vector of constituent hits
79  * @param fitReferencePoint the reference point
80  * @param fittingWeight the specified cumulative hit weight
81  * @param constituentHitSubsetVector the subset of constituent hits
82  *
83  */
84  void GetConstituentHitSubsetVector(const LArHitWidthHelper::ConstituentHitVector &constituentHitVector, const pandora::CartesianVector &fitReferencePoint,
85  const float fittingWeight, LArHitWidthHelper::ConstituentHitVector &constituentHitSubsetVector) const;
86 
87  /**
88  * @brief Obtain the axes of the fitting frame
89  *
90  * @param constituentHitSubsetVector the input vector of constituent hits
91  * @param axisDirection the fitting 'x-axis'
92  * @param orthoDirection the fitting 'z-axis'
93  *
94  */
95  void GetFittingAxes(const LArHitWidthHelper::ConstituentHitVector &constituentHitSubsetVector, pandora::CartesianVector &axisDirection,
96  pandora::CartesianVector &orthoDirection) const;
97 
98  /**
99  * @brief Translate from (x, y, z) coordinates to (rL, rT) coordinates
100  *
101  * @param axisDirection the fitting 'x-axis'
102  * @param constituentHitPosition the (x, y, z) position of a constituent hit
103  * @param rL the fitting 'x' coordinate
104  * @param rT the fitting 'z' coordinate
105  *
106  */
108  const pandora::CartesianVector &axisDirection, const pandora::CartesianVector &constituentHitPosition, float &rL, float &rT) const;
109 
110  /**
111  * @brief Translate a gradient in the fitting coordinate frame to a direction vector in the detector frame
112  *
113  * @param axisDirection the fitting 'x-axis'
114  * @param gradient the gradient dT/dL
115  * @param globalDirection the direction vector in the detector frame
116  *
117  */
118  void GetGlobalDirection(const pandora::CartesianVector &axisDirection, const float gradient, pandora::CartesianVector &globalDirection) const;
119 
120  /**
121  * @brief Remove 'shortcut' associations from the cluster association map
122  *
123  * @param clusterVector the vector of clusters considered in the merging process
124  * @param clusterAssociationMap the mapping of clusters to forward/backward associations
125  *
126  */
127  void RemoveShortcutAssociations(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const;
128 
129  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
130 
131  float m_maxConstituentHitWidth; ///< The maximum hit width of a constituent hit of broken up hit, units cm
132  float m_hitWidthScalingFactor; ///< The scaling factor of the hit widths
133  float m_fittingWeight; ///< The maximum hit weight considered in the least squared fit
134  float m_minClusterWeight; ///< The threshold hit weight of the original, unscaled cluster to be considered in the merging process
135  float m_maxXMergeDistance; ///< The maximum x distance between merging points of associated clusters, units cm
136  float m_maxZMergeDistance; ///< The maximum z distance between merging points of associated clusters, units cm
137  float m_minMergeCosOpeningAngle; ///< The minimum cosine opening angle of the directions of associated clusters
138  float m_minDirectionDeviationCosAngle; ///< The minimum cosine opening angle of the direction of and associated cluster before and after merge
139  float m_minClusterSparseness; ///< The threshold sparseness of a cluster to be considered in the merging process
140 
141  // ATTN Dangling pointers emerge during cluster merging, here explicitly not dereferenced
142  mutable LArHitWidthHelper::ClusterToParametersMap m_clusterToParametersMap; ///< The map [cluster -> cluster parameters]
143 };
144 
145 } //namespace lar_content
146 
147 #endif //LAR_HIT_WIDTH_CLUSTER_MERGING_ALGORITHM_H
float m_minClusterWeight
The threshold hit weight of the original, unscaled cluster to be considered in the merging process...
Header file for the lar hit width helper class.
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_maxXMergeDistance
The maximum x distance between merging points of associated clusters, units cm.
void GetFittingAxes(const LArHitWidthHelper::ConstituentHitVector &constituentHitSubsetVector, pandora::CartesianVector &axisDirection, pandora::CartesianVector &orthoDirection) const
Obtain the axes of the fitting frame.
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const
Populate the cluster association map.
void GetGlobalDirection(const pandora::CartesianVector &axisDirection, const float gradient, pandora::CartesianVector &globalDirection) const
Translate a gradient in the fitting coordinate frame to a direction vector in the detector frame...
float m_minDirectionDeviationCosAngle
The minimum cosine opening angle of the direction of and associated cluster before and after merge...
float m_minClusterSparseness
The threshold sparseness of a cluster to be considered in the merging process.
void FindClosestPointToPosition(const pandora::CartesianVector &position, const LArHitWidthHelper::ConstituentHitVector &constituentHitVector, pandora::CartesianVector &closestPoint) const
Determine the position of the constituent hit that lies closest to a specified position.
float m_minMergeCosOpeningAngle
The minimum cosine opening angle of the directions of associated clusters.
std::vector< ConstituentHit > ConstituentHitVector
bool AreClustersAssociated(const LArHitWidthHelper::ClusterParameters &currentClusterParameters, const LArHitWidthHelper::ClusterParameters &testClusterParameters) const
Determine whether two clusters are associated.
Header file for the cluster association algorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void RemoveShortcutAssociations(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const
Remove &#39;shortcut&#39; associations from the cluster association map.
float m_maxConstituentHitWidth
The maximum hit width of a constituent hit of broken up hit, units cm.
float m_hitWidthScalingFactor
The scaling factor of the hit widths.
std::unordered_map< const pandora::Cluster *, const ClusterParameters > ClusterToParametersMap
void GetFittingCoordinates(const pandora::CartesianVector &axisDirection, const pandora::CartesianVector &constituentHitPosition, float &rL, float &rT) const
Translate from (x, y, z) coordinates to (rL, rT) coordinates.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void GetClusterDirection(const LArHitWidthHelper::ConstituentHitVector &constituentHitVector, pandora::CartesianVector &direction, const pandora::CartesianVector &fitReferencePoint, const float fittingWeight) const
Determine the cluster direction at a reference point by performing a weighted least squared fit to th...
float m_fittingWeight
The maximum hit weight considered in the least squared fit.
LArHitWidthHelper::ClusterToParametersMap m_clusterToParametersMap
The map [cluster -&gt; cluster parameters].
float m_maxZMergeDistance
The maximum z distance between merging points of associated clusters, units cm.
void GetConstituentHitSubsetVector(const LArHitWidthHelper::ConstituentHitVector &constituentHitVector, const pandora::CartesianVector &fitReferencePoint, const float fittingWeight, LArHitWidthHelper::ConstituentHitVector &constituentHitSubsetVector) const
Obtain a vector of the minimum number of hits closest to a reference point that exceed a given weight...
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...