BranchGrowingAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTrackShowerId/BranchGrowingAlgorithm.h
3  *
4  * @brief Header file for the branch growing algorithm base class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_BRANCH_GROWING_ALGORITHM_H
9 #define LAR_BRANCH_GROWING_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
13 #include <unordered_map>
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief BranchGrowingAlgorithm class
20  */
21 class BranchGrowingAlgorithm : public pandora::Algorithm
22 {
23 protected:
24  /**
25  * @brief AssociationType enum
26  */
28  {
29  NONE = 0,
31  STANDARD = 2,
32  STRONG = 3
33  };
34 
35  /**
36  * @brief Association class
37  */
39  {
40  public:
41  /**
42  * @brief Default constructor
43  */
44  Association();
45 
46  /**
47  * @brief Constructor
48  *
49  * @param order the association order
50  * @param type the association type
51  */
52  Association(const unsigned int order, const AssociationType type);
53 
54  /**
55  * @brief Set association order
56  *
57  * @param order the association order
58  */
59  void SetOrder(const unsigned int order);
60 
61  /**
62  * @brief Set association type
63  *
64  * @param associationType the association type
65  */
66  void SetType(const AssociationType associationType);
67 
68  /**
69  * @brief Get association order
70  *
71  * @return the association order
72  */
73  unsigned int GetOrder() const;
74 
75  /**
76  * @brief Get association type
77  *
78  * @return the association type
79  */
80  AssociationType GetType() const;
81 
82  private:
83  unsigned int m_order;
85  };
86 
87  typedef std::unordered_map<const pandora::Cluster *, Association> ClusterAssociationMap;
88  typedef std::unordered_map<const pandora::Cluster *, ClusterAssociationMap> ClusterUsageMap;
89 
90  /**
91  * @brief Determine whether two clusters are associated
92  *
93  * @param pClusterSeed address of cluster seed (may be daughter of primary seed)
94  * @param pCluster address of cluster
95  *
96  * @return the association type
97  */
98  virtual AssociationType AreClustersAssociated(const pandora::Cluster *const pClusterSeed, const pandora::Cluster *const pCluster) const = 0;
99 
100  /**
101  * @brief Find clusters associated with a particle seed
102  *
103  * @param pParticleSeed address of the particle seed
104  * @param candidateClusters list of clusters which may be associated with seed
105  * @param forwardUsageMap the particle seed usage map
106  * @param backwardUsageMap the cluster usage map
107  */
108  void FindAssociatedClusters(const pandora::Cluster *const pParticleSeed, pandora::ClusterVector &candidateClusters,
109  ClusterUsageMap &forwardUsageMap, ClusterUsageMap &backwardUsageMap) const;
110 
111  typedef std::unordered_map<const pandora::Cluster *, pandora::ClusterVector> SeedAssociationList;
112 
113  /**
114  * @brief Identify cluster merges
115  *
116  * @param particleSeedVector the list of all particle seeds
117  * @param backwardUsageMap the map from cluster to particle seed associations
118  * @param seedAssociationList to receive the populated seed association list
119  */
120  void IdentifyClusterMerges(const pandora::ClusterVector &particleSeedVector, const ClusterUsageMap &backwardUsageMap,
121  SeedAssociationList &seedAssociationList) const;
122 
123  virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
124 };
125 
126 //------------------------------------------------------------------------------------------------------------------------------------------
127 //------------------------------------------------------------------------------------------------------------------------------------------
128 
130 {
131 }
132 
133 //------------------------------------------------------------------------------------------------------------------------------------------
134 
135 inline BranchGrowingAlgorithm::Association::Association(const unsigned int order, const AssociationType type) : m_order(order), m_type(type)
136 {
137 }
138 
139 //------------------------------------------------------------------------------------------------------------------------------------------
140 
141 inline void BranchGrowingAlgorithm::Association::SetOrder(const unsigned int order)
142 {
143  m_order = order;
144 }
145 
146 //------------------------------------------------------------------------------------------------------------------------------------------
147 
149 {
150  m_type = associationType;
151 }
152 
153 //------------------------------------------------------------------------------------------------------------------------------------------
154 
156 {
157  return m_order;
158 }
159 
160 //------------------------------------------------------------------------------------------------------------------------------------------
161 
163 {
164  return m_type;
165 }
166 
167 } // namespace lar_content
168 
169 #endif // #ifndef LAR_BRANCH_GROWING_ALGORITHM_H
BranchGrowingAlgorithm class.
void SetType(const AssociationType associationType)
Set association type.
AssociationType GetType() const
Get association type.
STL namespace.
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterUsageMap
std::unordered_map< const pandora::Cluster *, Association > ClusterAssociationMap
unsigned int GetOrder() const
Get association order.
std::unordered_map< const pandora::Cluster *, pandora::ClusterVector > SeedAssociationList
void FindAssociatedClusters(const pandora::Cluster *const pParticleSeed, pandora::ClusterVector &candidateClusters, ClusterUsageMap &forwardUsageMap, ClusterUsageMap &backwardUsageMap) const
Find clusters associated with a particle seed.
static int max(int a, int b)
void IdentifyClusterMerges(const pandora::ClusterVector &particleSeedVector, const ClusterUsageMap &backwardUsageMap, SeedAssociationList &seedAssociationList) const
Identify cluster merges.
virtual AssociationType AreClustersAssociated(const pandora::Cluster *const pClusterSeed, const pandora::Cluster *const pCluster) const =0
Determine whether two clusters are associated.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void SetOrder(const unsigned int order)
Set association order.