ParticleRecoveryAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArPfoRecovery/ParticleRecoveryAlgorithm.h
3  *
4  * @brief Header file for the track recovery algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_PARTICLE_RECOVERY_ALGORITHM_H
9 #define LAR_PARTICLE_RECOVERY_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
13 #include <unordered_map>
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief ParticleRecoveryAlgorithm class
20  */
21 class ParticleRecoveryAlgorithm : public pandora::Algorithm
22 {
23 public:
24  /**
25  * @brief Default constructor
26  */
28 
29 private:
30  /**
31  * @brief SimpleOverlapTensor class
32  */
34  {
35  public:
36  /**
37  * @brief Add an association between two clusters to the simple overlap tensor
38  *
39  * @param pCluster1 address of cluster 1
40  * @param pCluster2 address of cluster 2
41  */
42  void AddAssociation(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2);
43 
44  /**
45  * @brief Get elements connected to a specified cluster
46  *
47  * @param pCluster address of the cluster
48  * @param elementList the element list
49  * @param clusterListU connected u clusters
50  * @param clusterListV connected v clusters
51  * @param clusterListW connected w clusters
52  */
53  void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, pandora::ClusterList &clusterListU,
54  pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const;
55 
56  /**
57  * @brief Get the list of key clusters
58  *
59  * @return the list of key clusters
60  */
61  const pandora::ClusterList &GetKeyClusters() const;
62 
63  private:
64  typedef std::unordered_map<const pandora::Cluster *, pandora::ClusterList> ClusterNavigationMap;
65 
66  pandora::ClusterList m_keyClusters; ///< The list of key clusters
67  ClusterNavigationMap m_clusterNavigationMapUV; ///< The cluster navigation map U->V
68  ClusterNavigationMap m_clusterNavigationMapVW; ///< The cluster navigation map V->W
69  ClusterNavigationMap m_clusterNavigationMapWU; ///< The cluster navigation map W->U
70  };
71 
72  pandora::StatusCode Run();
73 
74  /**
75  * @brief Get the input cluster lists for processing in this algorithm
76  *
77  * @param inputClusterListU to receive the list of clusters in the u view
78  * @param inputClusterListU to receive the list of clusters in the v view
79  * @param inputClusterListU to receive the list of clusters in the w view
80  */
81  void GetInputClusters(pandora::ClusterList &inputClusterListU, pandora::ClusterList &inputClusterListV, pandora::ClusterList &inputClusterListW) const;
82 
83  /**
84  * @brief Select a subset of input clusters for processing in this algorithm
85  *
86  * @param inputClusterList the input cluster list
87  * @param selectedClusterList to receive the selected cluster list
88  */
89  void SelectInputClusters(const pandora::ClusterList &inputClusterList, pandora::ClusterList &selectedClusterList) const;
90 
91  /**
92  * @brief Select a subset of input clusters for processing in this algorithm
93  *
94  * @param inputClusterList the input cluster list
95  * @param selectedClusterList to receive the selected cluster list
96  */
97  void StandardClusterSelection(const pandora::ClusterList &inputClusterList, pandora::ClusterList &selectedClusterList) const;
98 
99  /**
100  * @brief Select a subset of input clusters nodally associated with the vertices of existing particles
101  *
102  * @param inputClusterList the input cluster list
103  * @param selectedClusterList to receive the selected cluster list
104  */
105  void VertexClusterSelection(const pandora::ClusterList &inputClusterList, pandora::ClusterList &selectedClusterList) const;
106 
107  /**
108  * @brief Find cluster overlaps and record these in the overlap tensor
109  *
110  * @param clusterList1 the first cluster list
111  * @param clusterList2 the second cluster list
112  * @param overlapTensor the overlap tensor
113  */
114  void FindOverlaps(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2, SimpleOverlapTensor &overlapTensor) const;
115 
116  /**
117  * @brief Whether two clusters overlap convincingly in x
118  *
119  * @param pCluster1 address of the first cluster
120  * @param pCluster2 address of the second cluster
121  */
122  bool IsOverlap(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const;
123 
124  /**
125  * @brief Calculate effective overlap fractions taking into account gaps
126  *
127  * @param pCluster1 address of the first cluster
128  * @param xMin1 min x value of the first cluster
129  * @param xMax1 max x value of the first cluster
130  * @param pCluster2 address of the second cluster
131  * @param xMin2 min x value of the second cluster
132  * @param xMax2 max x value of the second cluster
133  * @param xOverlapFraction1 to receive the effective overlap fraction for the first cluster
134  * @param xOverlapFraction2 to receive the effective overlap fraction for the second cluster
135  */
136  void CalculateEffectiveOverlapFractions(const pandora::Cluster *const pCluster1, const float xMin1, const float xMax1,
137  const pandora::Cluster *const pCluster2, const float xMin2, const float xMax2, float &xOverlapFraction1, float &xOverlapFraction2) const;
138 
139  /**
140  * @brief Calculate effective span for a given clsuter taking gaps into account
141  *
142  * @param pCluster address of the cluster
143  * @param xMin the min x value above which checks for gaps will be performed
144  * @param xMax the max x value below which checks for gaps will be performed
145  * @param xMinEff to receive the effective min x value for the cluster, including adjacent gaps
146  * @param xMaxEff to receive the effective max x value for the cluster, including adjacent gaps
147  */
148  void CalculateEffectiveSpan(const pandora::Cluster *const pCluster, const float xMin, const float xMax, float &xMinEff, float &xMaxEff) const;
149 
150  /**
151  * @brief Identify unambiguous cluster overlaps and resolve ambiguous overlaps, creating new track particles
152  *
153  * @param overlapTensor the overlap tensor
154  */
155  void ExamineTensor(const SimpleOverlapTensor &overlapTensor) const;
156 
157  /**
158  * @brief Whether a trio of clusters are consistent with representing projections of the same 3d trajectory
159  *
160  * @param pClusterU the address of cluster u
161  * @param pClusterV the address of cluster v
162  * @param pClusterW the address of cluster w
163  *
164  * @return boolean
165  */
166  bool CheckConsistency(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW) const;
167 
168  /**
169  * @brief Create and save a track particle containing the provided clusters
170  *
171  * @param clusterList the cluster list
172  */
173  void CreateTrackParticle(const pandora::ClusterList &clusterList) const;
174 
175  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
176 
177  pandora::StringVector m_inputClusterListNames; ///< The list of cluster list names
178  std::string m_outputPfoListName; ///< The output pfo list name
179 
180  bool m_checkGaps; ///< Whether to check for gaps in the calculation of the overlap
181 
182  unsigned int m_minClusterCaloHits; ///< The min number of hits in base cluster selection method
183  float m_minClusterLengthSquared; ///< The min length (squared) in base cluster selection method
184  float m_minClusterXSpan; ///< The min x span required in order to consider a cluster
185 
186  bool m_vertexClusterMode; ///< Whether to demand clusters are associated with vertices of existing particles
187  float m_minVertexLongitudinalDistance; ///< Vertex association check: min longitudinal distance cut
188  float m_maxVertexTransverseDistance; ///< Vertex association check: max transverse distance cut
189 
190  float m_minXOverlapFraction; ///< The min x overlap fraction required in order to id overlapping clusters
191  float m_minXOverlapFractionGaps; ///< The min x overlap fraction when there are gaps involved
192  float m_sampleStepSize; ///< The sampling step size used in association checks, units cm
193  unsigned int m_slidingFitHalfWindow; ///< The half window for the fit sliding result constructor
194  float m_pseudoChi2Cut; ///< The selection cut on the matched chi2
195 };
196 
197 //------------------------------------------------------------------------------------------------------------------------------------------
198 
199 inline const pandora::ClusterList &ParticleRecoveryAlgorithm::SimpleOverlapTensor::GetKeyClusters() const
200 {
201  return m_keyClusters;
202 }
203 
204 } // namespace lar_content
205 
206 #endif // #ifndef LAR_PARTICLE_RECOVERY_ALGORITHM_H
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
ClusterNavigationMap m_clusterNavigationMapVW
The cluster navigation map V->W.
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
void GetInputClusters(pandora::ClusterList &inputClusterListU, pandora::ClusterList &inputClusterListV, pandora::ClusterList &inputClusterListW) const
Get the input cluster lists for processing in this algorithm.
const pandora::ClusterList & GetKeyClusters() const
Get the list of key clusters.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
std::string string
Definition: nybbler.cc:12
void ExamineTensor(const SimpleOverlapTensor &overlapTensor) const
Identify unambiguous cluster overlaps and resolve ambiguous overlaps, creating new track particles...
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterNavigationMap
bool CheckConsistency(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW) const
Whether a trio of clusters are consistent with representing projections of the same 3d trajectory...
float m_minXOverlapFractionGaps
The min x overlap fraction when there are gaps involved.
void SelectInputClusters(const pandora::ClusterList &inputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
void CalculateEffectiveSpan(const pandora::Cluster *const pCluster, const float xMin, const float xMax, float &xMinEff, float &xMaxEff) const
Calculate effective span for a given clsuter taking gaps into account.
void CreateTrackParticle(const pandora::ClusterList &clusterList) const
Create and save a track particle containing the provided clusters.
ClusterNavigationMap m_clusterNavigationMapWU
The cluster navigation map W->U.
bool IsOverlap(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const
Whether two clusters overlap convincingly in x.
void AddAssociation(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2)
Add an association between two clusters to the simple overlap tensor.
void FindOverlaps(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2, SimpleOverlapTensor &overlapTensor) const
Find cluster overlaps and record these in the overlap tensor.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
pandora::ClusterList m_keyClusters
The list of key clusters.
ClusterNavigationMap m_clusterNavigationMapUV
The cluster navigation map U->V.
float m_minClusterXSpan
The min x span required in order to consider a cluster.
float m_pseudoChi2Cut
The selection cut on the matched chi2.
void CalculateEffectiveOverlapFractions(const pandora::Cluster *const pCluster1, const float xMin1, const float xMax1, const pandora::Cluster *const pCluster2, const float xMin2, const float xMax2, float &xOverlapFraction1, float &xOverlapFraction2) const
Calculate effective overlap fractions taking into account gaps.
unsigned int m_slidingFitHalfWindow
The half window for the fit sliding result constructor.
float m_minXOverlapFraction
The min x overlap fraction required in order to id overlapping clusters.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
bool m_checkGaps
Whether to check for gaps in the calculation of the overlap.
bool m_vertexClusterMode
Whether to demand clusters are associated with vertices of existing particles.
std::vector< string > StringVector
Definition: fcldump.cxx:29
std::string m_outputPfoListName
The output pfo list name.
void StandardClusterSelection(const pandora::ClusterList &inputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
float m_sampleStepSize
The sampling step size used in association checks, units cm.
void VertexClusterSelection(const pandora::ClusterList &inputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters nodally associated with the vertices of existing particles...
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get elements connected to a specified cluster.