All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexBasedPfoMopUpAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArPfoMopUp/VertexBasedPfoMopUpAlgorithm.h
3  *
4  * @brief Header file for the vertex based pfo mop up algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_VERTEX_BASED_PFO_MOP_UP_ALGORITHM_H
9 #define LAR_VERTEX_BASED_PFO_MOP_UP_ALGORITHM_H 1
10 
12 
13 #include <unordered_map>
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief VertexBasedPfoMopUpAlgorithm class
20  */
22 {
23 public:
24  /**
25  * @brief Default constructor
26  */
28 
29 protected:
30  /**
31  * @brief ClusterAssociation class
32  */
34  {
35  public:
36  /**
37  * @brief Default constructor
38  */
40 
41  /**
42  * @brief Constructor
43  *
44  * @param pVertexCluster the address of the vertex cluster
45  * @param pDaughterCluster the address of the daughter cluster
46  * @param boundedFraction the fraction of daughter hits bounded by the cone defined by the vertex cluster
47  * @param isConsistentDirection whether clusters have consistent directions
48  */
49  ClusterAssociation(const pandora::Cluster *const pVertexCluster, const pandora::Cluster *const pDaughterCluster,
50  const float boundedFraction, const bool isConsistentDirection);
51 
52  /**
53  * @brief Get the address of the vertex cluster
54  *
55  * @return the address of the vertex cluster
56  */
57  const pandora::Cluster *GetVertexCluster() const;
58 
59  /**
60  * @brief Get the address of the daughter cluster
61  *
62  * @return the address of the daughter cluster
63  */
64  const pandora::Cluster *GetDaughterCluster() const;
65 
66  /**
67  * @brief Get the fraction of daughter hits bounded by the cone defined by the vertex cluster
68  *
69  * @return the bounded fraction
70  */
71  float GetBoundedFraction() const;
72 
73  /**
74  * @brief Whether the vertex and daughter clusters have consistent directions
75  *
76  * @return boolean
77  */
78  bool IsConsistentDirection() const;
79 
80  private:
81  const pandora::Cluster *m_pVertexCluster; ///< The address of the vertex cluster
82  const pandora::Cluster *m_pDaughterCluster; ///< The address of the daughter cluster
83  float m_boundedFraction; ///< The fraction of daughter hits bounded by the cone defined by the vertex cluster
84  bool m_isConsistentDirection; ///< Whether the vertex and daughter clusters have consistent directions
85  };
86 
87  /**
88  * @brief PfoAssociation class
89  */
91  {
92  public:
93  /**
94  * @brief Constructor
95  *
96  * @param pVertexPfo the address of the vertex pfo
97  * @param pDaughterPfo the address of the daughter candidate pfo
98  * @param clusterAssociationU the cluster association in the u view
99  * @param clusterAssociationV the cluster association in the v view
100  * @param clusterAssociationW the cluster association in the w view
101  */
102  PfoAssociation(const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo, const ClusterAssociation &clusterAssociationU,
103  const ClusterAssociation &clusterAssociationV, const ClusterAssociation &clusterAssociationW);
104 
105  /**
106  * @brief Get the address of the vertex-associated pfo
107  *
108  * @return the address of the vertex-associated pfo
109  */
110  const pandora::Pfo *GetVertexPfo() const;
111 
112  /**
113  * @brief Get the address of the non-vertex-associated candidate daughter pfo
114  *
115  * @return the address of the non-vertex-associated candidate daughter pfo
116  */
117  const pandora::Pfo *GetDaughterPfo() const;
118 
119  /**
120  * @brief Get the mean bounded fraction, averaging over the u, v and w views
121  *
122  * @return the mean bounded fraction, averaging over the u, v and w views
123  */
124  float GetMeanBoundedFraction() const;
125 
126  /**
127  * @brief Get the maximum bounded fraction from the u, v and w views
128  *
129  * @return the maximum bounded fraction from the u, v and w views
130  */
131  float GetMaxBoundedFraction() const;
132 
133  /**
134  * @brief Get the minimum bounded fraction from the u, v and w views
135  *
136  * @return the minimum bounded fraction from the u, v and w views
137  */
138  float GetMinBoundedFraction() const;
139 
140  /**
141  * @brief Get the number of views for which the vertex and daughter cluster directions are consistent
142  *
143  * @return the number of views for which the cluster directions are consistent
144  */
145  unsigned int GetNConsistentDirections() const;
146 
147  /**
148  * @brief Get the cluster association in the u view
149  *
150  * @return the cluster association in the u view
151  */
153 
154  /**
155  * @brief Get the cluster association in the v view
156  *
157  * @return the cluster association in the v view
158  */
160 
161  /**
162  * @brief Get the cluster association in the w view
163  *
164  * @return the cluster association in the w view
165  */
167 
168  /**
169  * @brief operator<
170  *
171  * @param rhs the pfo association object for comparison
172  *
173  * @return boolean
174  */
175  bool operator<(const PfoAssociation &rhs) const;
176 
177  private:
178  const pandora::Pfo *m_pVertexPfo; ///< The address of the vertex-associated pfo
179  const pandora::Pfo *m_pDaughterPfo; ///< The address of the non-vertex-associated candidate daughter pfo
180 
181  ClusterAssociation m_clusterAssociationU; ///< The cluster association in the u view
182  ClusterAssociation m_clusterAssociationV; ///< The cluster association in the v view
183  ClusterAssociation m_clusterAssociationW; ///< The cluster association in the w view
184  };
185 
186  typedef std::vector<PfoAssociation> PfoAssociationList;
187 
188  /**
189  * @brief ConeParameters class
190  */
192  {
193  public:
194  /**
195  * @brief Constructor
196  *
197  * @param pCluster address of the cluster
198  * @param vertexPosition2D the event 2D vertex position
199  * @param coneAngleCentile the cone angle centile
200  * @param maxConeCosHalfAngle the maximum value for cosine of cone half angle
201  */
202  ConeParameters(const pandora::Cluster *const pCluster, const pandora::CartesianVector &vertexPosition2D,
203  const float coneAngleCentile, const float maxConeCosHalfAngle);
204 
205  /**
206  * @brief Get the fraction of hits in a candidate daughter cluster bounded by the cone
207  *
208  * @param pDaughterCluster the address of the daughter cluster
209  * @param coneLengthMultiplier cnsider hits as bound if inside cone with projected distance less than N times cone length
210  *
211  * @return the bounded fraction
212  */
213  float GetBoundedFraction(const pandora::Cluster *const pDaughterCluster, const float coneLengthMultiplier) const;
214 
215  private:
216  /**
217  * @brief Get the cone direction estimate, with apex fixed at the 2d vertex position
218  *
219  * @return the direction estimate
220  */
221  pandora::CartesianVector GetDirectionEstimate() const;
222 
223  /**
224  * @brief Get the cone length (signed, by projections of hits onto initial direction estimate)
225  *
226  * @return rhe cone length
227  */
228  float GetSignedConeLength() const;
229 
230  /**
231  * @brief Get the cone cos half angle estimate
232  *
233  * @param coneAngleCentile the cone angle centile
234  *
235  * @return the cone cos half angle estimate
236  */
237  float GetCosHalfAngleEstimate(const float coneAngleCentile) const;
238 
239  const pandora::Cluster *m_pCluster; ///< The parent cluster
240  pandora::CartesianVector m_apex; ///< The cone apex
241  pandora::CartesianVector m_direction; ///< The cone direction
242  float m_coneLength; ///< The cone length
243  float m_coneCosHalfAngle; ///< The cone cos half angle
244  };
245 
246  pandora::StatusCode Run();
247 
248  /**
249  * @brief Whether a specified pfo is associated with a specified vertex
250  *
251  * @param vertex2D the 2d vertex position
252  * @param pointingCluster the pointing cluster
253  *
254  * @return boolean
255  */
256  virtual bool IsVertexAssociated(const pandora::CartesianVector &vertex2D, const LArPointingCluster &pointingCluster) const;
257 
258  typedef std::map<pandora::HitType, ClusterAssociation> HitTypeToAssociationMap;
259 
260  /**
261  * @brief Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter candidate pfo
262  *
263  * @param pVertexPfo the address of the vertex-associated pfo
264  * @param pDaughterPfo the address of the non-vertex-associated pfo
265  * @param hitTypeToAssociationMap the hit type to association map
266  *
267  * @return the pfo association details
268  */
269  virtual PfoAssociation GetPfoAssociation(const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo,
270  HitTypeToAssociationMap &hitTypeToAssociationMap) const;
271 
272  /**
273  * @brief Get the list of input pfos and divide them into vertex-associated and non-vertex-associated lists
274  *
275  * @param pVertex the address of the 3d vertex
276  * @param vertexPfos to receive the list of vertex-associated pfos
277  * @param nonVertexPfos to receive the list of nonvertex-associated pfos
278  */
279  void GetInputPfos(const pandora::Vertex *const pVertex, pandora::PfoList &vertexPfos, pandora::PfoList &nonVertexPfos) const;
280 
281  /**
282  * @brief Whether a specified pfo is associated with a specified vertex
283  *
284  * @param pPfo the address of the pfo
285  * @param pVertex the address of the 3d vertex
286  *
287  * @return boolean
288  */
289  bool IsVertexAssociated(const pandora::Pfo *const pPfo, const pandora::Vertex *const pVertex) const;
290 
291  /**
292  * @brief Get the list of associations between vertex-associated pfos and non-vertex-associated pfos
293  *
294  * @param pVertex the address of the 3d vertex
295  * @param vertexPfos the list of vertex-associated pfos
296  * @param nonVertexPfos the list of nonvertex-associated pfos
297  * @param pfoAssociationList to receive the pfo association list
298  */
299  void GetPfoAssociations(const pandora::Vertex *const pVertex, const pandora::PfoList &vertexPfos, const pandora::PfoList &nonVertexPfos,
300  PfoAssociationList &pfoAssociationList) const;
301 
302  /**
303  * @brief Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter candidate pfo
304  *
305  * @param pVertex the address of the 3d vertex
306  * @param pVertexPfo the address of the vertex-associated pfo
307  * @param pDaughterPfo the address of the non-vertex-associated pfo
308  *
309  * @return the pfo association details
310  */
312  const pandora::Vertex *const pVertex, const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo) const;
313 
314  /**
315  * @brief Get cluster association details between a vertex-associated cluster and a non-vertex associated daughter candidate cluster
316  *
317  * @param pVertex the address of the vertex
318  * @param pVertexCluster the address of the vertex-associated cluster
319  * @param pDaughterCluster the address of the non-vertex-associated cluster
320  *
321  * @return the cluster association details
322  */
323  ClusterAssociation GetClusterAssociation(const pandora::Vertex *const pVertex, const pandora::Cluster *const pVertexCluster,
324  const pandora::Cluster *const pDaughterCluster) const;
325 
326  /**
327  * @brief Process the list of pfo associations, merging the best-matching pfo
328  *
329  * @param pfoAssociationList the pfo association list
330  *
331  * @return whether a pfo merge was made
332  */
333  bool ProcessPfoAssociations(const PfoAssociationList &pfoAssociationList) const;
334 
335  /**
336  * @brief Merge the vertex and daughter pfos (deleting daughter pfo, merging clusters, etc.) described in the specified pfoAssociation
337  *
338  * @param pfoAssociation the pfo association details
339  */
340  void MergePfos(const PfoAssociation &pfoAssociation) const;
341 
342  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
343 
344  typedef std::set<pandora::HitType> HitTypeSet;
345  typedef std::map<pandora::HitType, const pandora::Cluster *> HitTypeToClusterMap;
346 
347  std::string m_trackPfoListName; ///< The input track pfo list name
348  std::string m_showerPfoListName; ///< The input shower pfo list name
349 
350  float m_minVertexLongitudinalDistance; ///< Vertex association check: min longitudinal distance cut
351  float m_maxVertexTransverseDistance; ///< Vertex association check: max transverse distance cut
352  unsigned int m_minVertexAssociatedHitTypes; ///< The min number of vertex associated hit types for a vertex associated pfo
353 
354  float m_coneAngleCentile; ///< Cluster cone angle is defined using specified centile of distribution of hit half angles
355  float m_maxConeCosHalfAngle; ///< Maximum value for cosine of cone half angle
356  float m_maxConeLengthMultiplier; ///< Consider hits as bound if inside cone, with projected distance less than N times cone length
357 
358  float m_directionTanAngle; ///< Direction determination, look for vertex inside triangle with apex shifted along the cluster length
359  float m_directionApexShift; ///< Direction determination, look for vertex inside triangle with apex shifted along the cluster length
360 
361  float m_meanBoundedFractionCut; ///< Cut on association info (mean bounded fraction) for determining pfo merges
362  float m_maxBoundedFractionCut; ///< Cut on association info (max bounded fraction) for determining pfo merges
363  float m_minBoundedFractionCut; ///< Cut on association info (min bounded fraction) for determining pfo merges
364 
365  unsigned int m_minConsistentDirections; ///< The minimum number of consistent cluster directions to allow a pfo merge
366  unsigned int m_minConsistentDirectionsTrack; ///< The minimum number of consistent cluster directions to allow a merge involving a track pfo
367 };
368 
369 //------------------------------------------------------------------------------------------------------------------------------------------
370 
372 {
373  return m_pVertexCluster;
374 }
375 
376 //------------------------------------------------------------------------------------------------------------------------------------------
377 
379 {
380  return m_pDaughterCluster;
381 }
382 
383 //------------------------------------------------------------------------------------------------------------------------------------------
384 
386 {
387  return m_boundedFraction;
388 }
389 
390 //------------------------------------------------------------------------------------------------------------------------------------------
391 
393 {
394  return m_isConsistentDirection;
395 }
396 
397 //------------------------------------------------------------------------------------------------------------------------------------------
398 //------------------------------------------------------------------------------------------------------------------------------------------
399 
401 {
402  return m_pVertexPfo;
403 }
404 
405 //------------------------------------------------------------------------------------------------------------------------------------------
406 
408 {
409  return m_pDaughterPfo;
410 }
411 
412 //------------------------------------------------------------------------------------------------------------------------------------------
413 
415 {
416  return m_clusterAssociationU;
417 }
418 
419 //------------------------------------------------------------------------------------------------------------------------------------------
420 
422 {
423  return m_clusterAssociationV;
424 }
425 
426 //------------------------------------------------------------------------------------------------------------------------------------------
427 
429 {
430  return m_clusterAssociationW;
431 }
432 
433 } // namespace lar_content
434 
435 #endif // #ifndef LAR_VERTEX_BASED_PFO_MOP_UP_ALGORITHM_H
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float GetBoundedFraction(const pandora::Cluster *const pDaughterCluster, const float coneLengthMultiplier) const
Get the fraction of hits in a candidate daughter cluster bounded by the cone.
void GetPfoAssociations(const pandora::Vertex *const pVertex, const pandora::PfoList &vertexPfos, const pandora::PfoList &nonVertexPfos, PfoAssociationList &pfoAssociationList) const
Get the list of associations between vertex-associated pfos and non-vertex-associated pfos...
unsigned int m_minVertexAssociatedHitTypes
The min number of vertex associated hit types for a vertex associated pfo.
float m_maxConeLengthMultiplier
Consider hits as bound if inside cone, with projected distance less than N times cone length...
PfoAssociation(const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo, const ClusterAssociation &clusterAssociationU, const ClusterAssociation &clusterAssociationV, const ClusterAssociation &clusterAssociationW)
Constructor.
ClusterAssociation GetClusterAssociation(const pandora::Vertex *const pVertex, const pandora::Cluster *const pVertexCluster, const pandora::Cluster *const pDaughterCluster) const
Get cluster association details between a vertex-associated cluster and a non-vertex associated daugh...
ConeParameters(const pandora::Cluster *const pCluster, const pandora::CartesianVector &vertexPosition2D, const float coneAngleCentile, const float maxConeCosHalfAngle)
Constructor.
bool IsConsistentDirection() const
Whether the vertex and daughter clusters have consistent directions.
const pandora::Cluster * m_pDaughterCluster
The address of the daughter cluster.
unsigned int GetNConsistentDirections() const
Get the number of views for which the vertex and daughter cluster directions are consistent.
float m_coneAngleCentile
Cluster cone angle is defined using specified centile of distribution of hit half angles...
float GetCosHalfAngleEstimate(const float coneAngleCentile) const
Get the cone cos half angle estimate.
unsigned int m_minConsistentDirections
The minimum number of consistent cluster directions to allow a pfo merge.
const pandora::Cluster * GetVertexCluster() const
Get the address of the vertex cluster.
void MergePfos(const PfoAssociation &pfoAssociation) const
Merge the vertex and daughter pfos (deleting daughter pfo, merging clusters, etc.) described in the s...
LArPointingCluster class.
float GetMaxBoundedFraction() const
Get the maximum bounded fraction from the u, v and w views.
bool m_isConsistentDirection
Whether the vertex and daughter clusters have consistent directions.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
float m_maxBoundedFractionCut
Cut on association info (max bounded fraction) for determining pfo merges.
float GetSignedConeLength() const
Get the cone length (signed, by projections of hits onto initial direction estimate) ...
bool ProcessPfoAssociations(const PfoAssociationList &pfoAssociationList) const
Process the list of pfo associations, merging the best-matching pfo.
float GetBoundedFraction() const
Get the fraction of daughter hits bounded by the cone defined by the vertex cluster.
const pandora::Cluster * GetDaughterCluster() const
Get the address of the daughter cluster.
std::map< pandora::HitType, ClusterAssociation > HitTypeToAssociationMap
float m_directionApexShift
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
float m_meanBoundedFractionCut
Cut on association info (mean bounded fraction) for determining pfo merges.
virtual PfoAssociation GetPfoAssociation(const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo, HitTypeToAssociationMap &hitTypeToAssociationMap) const
Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter cand...
PfoMopUpBaseAlgorithm class.
pandora::CartesianVector GetDirectionEstimate() const
Get the cone direction estimate, with apex fixed at the 2d vertex position.
float m_boundedFraction
The fraction of daughter hits bounded by the cone defined by the vertex cluster.
const ClusterAssociation & GetClusterAssociationW() const
Get the cluster association in the w view.
const pandora::Pfo * m_pDaughterPfo
The address of the non-vertex-associated candidate daughter pfo.
float m_directionTanAngle
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
ClusterAssociation m_clusterAssociationV
The cluster association in the v view.
void GetInputPfos(const pandora::Vertex *const pVertex, pandora::PfoList &vertexPfos, pandora::PfoList &nonVertexPfos) const
Get the list of input pfos and divide them into vertex-associated and non-vertex-associated lists...
virtual bool IsVertexAssociated(const pandora::CartesianVector &vertex2D, const LArPointingCluster &pointingCluster) const
Whether a specified pfo is associated with a specified vertex.
unsigned int m_minConsistentDirectionsTrack
The minimum number of consistent cluster directions to allow a merge involving a track pfo...
ClusterAssociation m_clusterAssociationW
The cluster association in the w view.
float m_maxConeCosHalfAngle
Maximum value for cosine of cone half angle.
const pandora::Pfo * GetDaughterPfo() const
Get the address of the non-vertex-associated candidate daughter pfo.
ClusterAssociation m_clusterAssociationU
The cluster association in the u view.
Header file for the pfo mop up algorithm base class.
const ClusterAssociation & GetClusterAssociationU() const
Get the cluster association in the u view.
std::string m_trackPfoListName
The input track pfo list name.
const pandora::Pfo * GetVertexPfo() const
Get the address of the vertex-associated pfo.
float GetMinBoundedFraction() const
Get the minimum bounded fraction from the u, v and w views.
const ClusterAssociation & GetClusterAssociationV() const
Get the cluster association in the v view.
const pandora::Cluster * m_pVertexCluster
The address of the vertex cluster.
const pandora::Pfo * m_pVertexPfo
The address of the vertex-associated pfo.
std::map< pandora::HitType, const pandora::Cluster * > HitTypeToClusterMap
float GetMeanBoundedFraction() const
Get the mean bounded fraction, averaging over the u, v and w views.
bool operator<(const PfoAssociation &rhs) const
operator&lt;
std::string m_showerPfoListName
The input shower pfo list name.
float m_minBoundedFractionCut
Cut on association info (min bounded fraction) for determining pfo merges.