ClusterAssociationAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTwoDReco/LArClusterAssociation/ClusterAssociationAlgorithm.h
3  *
4  * @brief Header file for the cluster association algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_CLUSTER_ASSOCIATION_ALGORITHM_H
9 #define LAR_CLUSTER_ASSOCIATION_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
13 #include <unordered_map>
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief ClusterAssociationAlgorithm class
20  */
21 class ClusterAssociationAlgorithm : public pandora::Algorithm
22 {
23 public:
24  /**
25  * @brief Default constructor
26  */
28 
29 protected:
30  virtual pandora::StatusCode Run();
31  virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
32 
33  /**
34  * @brief ClusterAssociation class
35  */
37  {
38  public:
39  pandora::ClusterSet m_forwardAssociations; ///< The list of forward associations
40  pandora::ClusterSet m_backwardAssociations; ///< The list of backward associations
41  };
42 
43  typedef std::unordered_map<const pandora::Cluster *, ClusterAssociation> ClusterAssociationMap;
44 
45  /**
46  * @brief Populate cluster vector with subset of cluster list, containing clusters judged to be clean
47  *
48  * @param pClusterList address of the cluster list
49  * @param clusterVector to receive the populated cluster vector
50  */
51  virtual void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const = 0;
52 
53  /**
54  * @brief Populate the cluster association map
55  *
56  * @param clusterVector the cluster vector
57  * @param clusterAssociationMap to receive the populated cluster association map
58  */
59  virtual void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const = 0;
60 
61  /**
62  * @brief Determine which of two clusters is extremal
63  *
64  * @param isForward whether propagation direction is forward
65  * @param pCurrentCluster current extremal cluster
66  * @param pTestCluster potential extremal cluster
67  *
68  * @return boolean
69  */
70  virtual bool IsExtremalCluster(
71  const bool isForward, const pandora::Cluster *const pCurrentCluster, const pandora::Cluster *const pTestCluster) const = 0;
72 
73 private:
74  /**
75  * @brief Unambiguous propagation
76  *
77  * @param pCluster address of the cluster to propagate
78  * @param isForward whether propagation direction is forward
79  * @param clusterAssociationMap the cluster association map
80  */
81  void UnambiguousPropagation(const pandora::Cluster *const pCluster, const bool isForward, ClusterAssociationMap &clusterAssociationMap) const;
82 
83  /**
84  * @brief Ambiguous propagation
85  *
86  * @param pCluster address of the cluster to propagate
87  * @param isForward whether propagation direction is forward
88  * @param clusterAssociationMap the cluster association map
89  */
90  void AmbiguousPropagation(const pandora::Cluster *const pCluster, const bool isForward, ClusterAssociationMap &clusterAssociationMap) const;
91 
92  /**
93  * @brief Update cluster association map to reflect an unambiguous cluster merge
94  *
95  * @param pClusterToEnlarge address of the cluster to be enlarged
96  * @param pClusterToDelete address of the cluster to be deleted
97  * @param isForwardMerge whether merge is forward (pClusterToEnlarge is forward-associated with pClusterToDelete)
98  * @param clusterAssociationMap the cluster association map
99  */
100  void UpdateForUnambiguousMerge(const pandora::Cluster *const pClusterToEnlarge, const pandora::Cluster *const pClusterToDelete,
101  const bool isForwardMerge, ClusterAssociationMap &clusterAssociationMap) const;
102 
103  /**
104  * @brief Update cluster association map to reflect an ambiguous cluster merge
105  *
106  * @param pCluster address of the cluster to be cleared
107  * @param clusterAssociationMap the cluster association map
108  */
109  void UpdateForAmbiguousMerge(const pandora::Cluster *const pCluster, ClusterAssociationMap &clusterAssociationMap) const;
110 
111  /**
112  * @brief Navigate along cluster associations, from specified cluster, in specified direction
113  *
114  * @param clusterAssociationMap the cluster association map
115  * @param pCluster address of cluster with which to begin search
116  * @param isForward whether propagation direction is forward
117  * @param pExtremalCluster to receive the extremal cluster
118  * @param clusterSet to receive set of clusters traversed
119  */
120  void NavigateAlongAssociations(const ClusterAssociationMap &clusterAssociationMap, const pandora::Cluster *const pCluster,
121  const bool isForward, const pandora::Cluster *&pExtremalCluster, pandora::ClusterSet &clusterSet) const;
122 
123  mutable bool m_mergeMade;
124 
125  bool m_resolveAmbiguousAssociations; ///< Whether to resolve ambiguous associations
126 };
127 
128 } // namespace lar_content
129 
130 #endif // #ifndef LAR_CLUSTER_ASSOCIATION_ALGORITHM_H
pandora::ClusterSet m_backwardAssociations
The list of backward associations.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
bool m_resolveAmbiguousAssociations
Whether to resolve ambiguous associations.
void NavigateAlongAssociations(const ClusterAssociationMap &clusterAssociationMap, const pandora::Cluster *const pCluster, const bool isForward, const pandora::Cluster *&pExtremalCluster, pandora::ClusterSet &clusterSet) const
Navigate along cluster associations, from specified cluster, in specified direction.
pandora::ClusterSet m_forwardAssociations
The list of forward associations.
void AmbiguousPropagation(const pandora::Cluster *const pCluster, const bool isForward, ClusterAssociationMap &clusterAssociationMap) const
Ambiguous propagation.
virtual void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const =0
Populate the cluster association map.
void UnambiguousPropagation(const pandora::Cluster *const pCluster, const bool isForward, ClusterAssociationMap &clusterAssociationMap) const
Unambiguous propagation.
void UpdateForUnambiguousMerge(const pandora::Cluster *const pClusterToEnlarge, const pandora::Cluster *const pClusterToDelete, const bool isForwardMerge, ClusterAssociationMap &clusterAssociationMap) const
Update cluster association map to reflect an unambiguous cluster merge.
void UpdateForAmbiguousMerge(const pandora::Cluster *const pCluster, ClusterAssociationMap &clusterAssociationMap) const
Update cluster association map to reflect an ambiguous cluster merge.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
virtual void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const =0
Populate cluster vector with subset of cluster list, containing clusters judged to be clean...
virtual bool IsExtremalCluster(const bool isForward, const pandora::Cluster *const pCurrentCluster, const pandora::Cluster *const pTestCluster) const =0
Determine which of two clusters is extremal.