SlidingConePfoMopUpAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArPfoMopUp/SlidingConePfoMopUpAlgorithm.h
3  *
4  * @brief Header file for the sliding cone pfo mop up algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_SLIDING_CONE_PFO_MOP_UP_ALGORITHM_H
9 #define LAR_SLIDING_CONE_PFO_MOP_UP_ALGORITHM_H 1
10 
12 
13 #include <unordered_map>
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief SlidingConePfoMopUpAlgorithm class
20  */
22 {
23 public:
24  /**
25  * @brief Default constructor
26  */
28 
29 private:
30  /**
31  * @brief ClusterMerge class
32  */
34  {
35  public:
36  /**
37  * @brief Constructor
38  *
39  * @param pParentCluster the address of the candidate parent (shower) cluster
40  * @param boundedFraction1 the bounded fraction for algorithm-specified cone angle 1
41  * @param boundedFraction2 the bounded fraction for algorithm-specified cone angle 2
42  */
43  ClusterMerge(const pandora::Cluster *const pParentCluster, const float boundedFraction1, const float boundedFraction2);
44 
45  /**
46  * @brief Get the address of the candidate parent (shower) cluster
47  *
48  * @return the address of the candidate parent (shower) cluster
49  */
50  const pandora::Cluster *GetParentCluster() const;
51 
52  /**
53  * @brief Get the bounded fraction for algorithm-specified cone angle 1
54  *
55  * @return the bounded fraction for algorithm-specified cone angle 1
56  */
57  float GetBoundedFraction1() const;
58 
59  /**
60  * @brief Get the bounded fraction for algorithm-specified cone angle 2
61  *
62  * @return the bounded fraction for algorithm-specified cone angle 2
63  */
64  float GetBoundedFraction2() const;
65 
66  /**
67  * @brief operator <
68  *
69  * @param rhs object for comparison
70  *
71  * @return boolean
72  */
73  bool operator<(const ClusterMerge &rhs) const;
74 
75  private:
76  const pandora::Cluster *m_pParentCluster; ///< The address of the candidate parent (shower) cluster
77  float m_boundedFraction1; ///< The bounded fraction for algorithm-specified cone angle 1
78  float m_boundedFraction2; ///< The bounded fraction for algorithm-specified cone angle 2
79  };
80 
81  typedef std::vector<ClusterMerge> ClusterMergeList;
82 
83  pandora::StatusCode Run();
84 
85  /**
86  * @brief Get the neutrino interaction vertex if it is available and if the algorithm is configured to do so
87  *
88  * @param pVertex to receive the neutrino interaction vertex
89  */
90  void GetInteractionVertex(const pandora::Vertex *&pVertex) const;
91 
92  typedef std::unordered_map<const pandora::Cluster *, const pandora::ParticleFlowObject *> ClusterToPfoMap;
93 
94  /**
95  * @brief Get all 3d clusters contained in the input pfo lists and a mapping from clusters to pfos
96  *
97  * @param clusters3D to receive the sorted list of 3d clusters
98  * @param clusterToPfoMap to receive the mapping from 3d cluster to pfo
99  */
100  void GetThreeDClusters(pandora::ClusterVector &clusters3D, ClusterToPfoMap &clusterToPfoMap) const;
101 
102  typedef std::unordered_map<const pandora::Cluster *, ClusterMergeList> ClusterMergeMap;
103 
104  /**
105  * @brief Get the cluster merge map describing all potential 3d cluster merges
106  *
107  * @param pVertex the neutrino interaction vertex, if available
108  * @param clusters3D the sorted list of 3d clusters
109  * @param clusterToPfoMap the mapping from 3d cluster to pfo
110  * @param clusterMergeMap to receive the populated cluster merge map
111  */
112  void GetClusterMergeMap(const pandora::Vertex *const pVertex, const pandora::ClusterVector &clusters3D,
113  const ClusterToPfoMap &clusterToPfoMap, ClusterMergeMap &clusterMergeMap) const;
114 
115  typedef std::unordered_map<const pandora::Cluster *, bool> VertexAssociationMap;
116 
117  /**
118  * @brief Whether a 3D cluster is nodally associated with a provided vertex
119  *
120  * @param pCluster the address of the cluster
121  * @param pVertex the address of the vertex
122  * @param vertexAssociationMap the vertex association map, which caches the results for efficiency
123  * @param pSlidingFitResult the address of a 3D sliding linear fit, if available, which aids pointing cluster construction efficiency
124  *
125  * @return boolean
126  */
127  bool IsVertexAssociated(const pandora::Cluster *const pCluster, const pandora::Vertex *const pVertex,
128  VertexAssociationMap &vertexAssociationMap, const ThreeDSlidingFitResult *const pSlidingFitResult = nullptr) const;
129 
130  /**
131  * @brief Whether a 3D cluster is nodally associated with a provided vertex
132  *
133  * @param pCluster the address of the cluster
134  * @param vertexPosition the vertex position
135  * @param pSlidingFitResult the address of a 3D sliding linear fit, if available, which aids pointing cluster construction efficiency
136  *
137  * @return boolean
138  */
139  bool IsVertexAssociated(const pandora::Cluster *const pCluster, const pandora::CartesianVector &vertexPosition,
140  const ThreeDSlidingFitResult *const pSlidingFitResult = nullptr) const;
141 
142  /**
143  * @brief Make pfo merges based on the provided cluster merge map
144  *
145  * @param clusterToPfoMap the mapping from 3d cluster to pfo
146  * @param clusterMergeMap the populated cluster merge map
147  *
148  * @return whether a pfo merge has been made
149  */
150  bool MakePfoMerges(const ClusterToPfoMap &clusterToPfoMap, const ClusterMergeMap &clusterMergeMap) const;
151 
152  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
153 
154  typedef std::unordered_map<const pandora::Cluster *, const pandora::Cluster *> ClusterReplacementMap;
155 
156  pandora::StringVector m_inputPfoListNames; ///< The input pfo list names
157  bool m_useVertex; ///< Whether to use the interaction vertex to select useful cone directions
158  unsigned int m_maxIterations; ///< The maximum allowed number of algorithm iterations
159  unsigned int m_maxHitsToConsider3DTrack; ///< The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm
160  unsigned int m_minHitsToConsider3DShower; ///< The minimum number of hits in a 3d shower cluster to attempt cone fits
161  unsigned int m_halfWindowLayers; ///< The number of layers to use for half-window of sliding fit
162  unsigned int m_nConeFitLayers; ///< The number of layers over which to sum fitted direction to obtain cone fit
163  unsigned int m_nConeFits; ///< The number of cone fits to perform, spread roughly uniformly along the shower length
164  float m_coneLengthMultiplier; ///< The cone length multiplier to use when calculating bounded cluster fractions
165  float m_maxConeLength; ///< The maximum allowed cone length to use when calculating bounded cluster fractions
166  float m_coneTanHalfAngle1; ///< The cone tan half angle to use when calculating bounded cluster fractions 1
167  float m_coneBoundedFraction1; ///< The minimum cluster bounded fraction for association 1
168  float m_coneTanHalfAngle2; ///< The cone tan half angle to use when calculating bounded cluster fractions 2
169  float m_coneBoundedFraction2; ///< The minimum cluster bounded fraction for association 2
170  float m_minVertexLongitudinalDistance; ///< Vertex association check: min longitudinal distance cut
171  float m_maxVertexTransverseDistance; ///< Vertex association check: max transverse distance cut
172 };
173 
174 //------------------------------------------------------------------------------------------------------------------------------------------
175 
177  const pandora::Cluster *const pParentCluster, const float boundedFraction1, const float boundedFraction2) :
178  m_pParentCluster(pParentCluster),
179  m_boundedFraction1(boundedFraction1),
180  m_boundedFraction2(boundedFraction2)
181 {
182 }
183 
184 //------------------------------------------------------------------------------------------------------------------------------------------
185 
187 {
188  return m_pParentCluster;
189 }
190 
191 //------------------------------------------------------------------------------------------------------------------------------------------
192 
194 {
195  return m_boundedFraction1;
196 }
197 
198 //------------------------------------------------------------------------------------------------------------------------------------------
199 
201 {
202  return m_boundedFraction2;
203 }
204 
205 } // namespace lar_content
206 
207 #endif // #ifndef LAR_SLIDING_CONE_PFO_MOP_UP_ALGORITHM_H
std::unordered_map< const pandora::Cluster *, const pandora::Cluster * > ClusterReplacementMap
float GetBoundedFraction2() const
Get the bounded fraction for algorithm-specified cone angle 2.
void GetClusterMergeMap(const pandora::Vertex *const pVertex, const pandora::ClusterVector &clusters3D, const ClusterToPfoMap &clusterToPfoMap, ClusterMergeMap &clusterMergeMap) const
Get the cluster merge map describing all potential 3d cluster merges.
float m_coneBoundedFraction2
The minimum cluster bounded fraction for association 2.
void GetInteractionVertex(const pandora::Vertex *&pVertex) const
Get the neutrino interaction vertex if it is available and if the algorithm is configured to do so...
float m_boundedFraction1
The bounded fraction for algorithm-specified cone angle 1.
float m_maxConeLength
The maximum allowed cone length to use when calculating bounded cluster fractions.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
std::unordered_map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
ClusterMerge(const pandora::Cluster *const pParentCluster, const float boundedFraction1, const float boundedFraction2)
Constructor.
float m_boundedFraction2
The bounded fraction for algorithm-specified cone angle 2.
float m_coneLengthMultiplier
The cone length multiplier to use when calculating bounded cluster fractions.
bool MakePfoMerges(const ClusterToPfoMap &clusterToPfoMap, const ClusterMergeMap &clusterMergeMap) const
Make pfo merges based on the provided cluster merge map.
void GetThreeDClusters(pandora::ClusterVector &clusters3D, ClusterToPfoMap &clusterToPfoMap) const
Get all 3d clusters contained in the input pfo lists and a mapping from clusters to pfos...
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
float GetBoundedFraction1() const
Get the bounded fraction for algorithm-specified cone angle 1.
bool IsVertexAssociated(const pandora::Cluster *const pCluster, const pandora::Vertex *const pVertex, VertexAssociationMap &vertexAssociationMap, const ThreeDSlidingFitResult *const pSlidingFitResult=nullptr) const
Whether a 3D cluster is nodally associated with a provided vertex.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
unsigned int m_nConeFitLayers
The number of layers over which to sum fitted direction to obtain cone fit.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const pandora::Cluster * m_pParentCluster
The address of the candidate parent (shower) cluster.
unsigned int m_maxHitsToConsider3DTrack
The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.
PfoMopUpBaseAlgorithm class.
float m_coneTanHalfAngle1
The cone tan half angle to use when calculating bounded cluster fractions 1.
pandora::StringVector m_inputPfoListNames
The input pfo list names.
float m_coneBoundedFraction1
The minimum cluster bounded fraction for association 1.
std::unordered_map< const pandora::Cluster *, bool > VertexAssociationMap
std::vector< string > StringVector
Definition: fcldump.cxx:29
Header file for the pfo mop up algorithm base class.
unsigned int m_maxIterations
The maximum allowed number of algorithm iterations.
unsigned int m_minHitsToConsider3DShower
The minimum number of hits in a 3d shower cluster to attempt cone fits.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool operator<(const ClusterMerge &rhs) const
operator <
unsigned int m_nConeFits
The number of cone fits to perform, spread roughly uniformly along the shower length.
std::unordered_map< const pandora::Cluster *, ClusterMergeList > ClusterMergeMap
const pandora::Cluster * GetParentCluster() const
Get the address of the candidate parent (shower) cluster.
float m_coneTanHalfAngle2
The cone tan half angle to use when calculating bounded cluster fractions 2.
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.