CandidateVertexCreationAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArVertex/CandidateVertexCreationAlgorithm.h
3  *
4  * @brief Header file for the candidate vertex creation algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_CANDIDATE_VERTEX_CREATION_ALGORITHM_H
9 #define LAR_CANDIDATE_VERTEX_CREATION_ALGORITHM_H 1
10 
12 
13 #include "Pandora/Algorithm.h"
14 
15 #include <unordered_map>
16 
17 namespace lar_content
18 {
19 
20 /**
21  * @brief CandidateVertexCreationAlgorithm::Algorithm class
22  */
23 class CandidateVertexCreationAlgorithm : public pandora::Algorithm
24 {
25 public:
26  /**
27  * @brief Default constructor
28  */
30 
31 private:
32  pandora::StatusCode Run();
33 
34  /**
35  * @brief Select a subset of input clusters (contained in the input list names) for processing in this algorithm
36  *
37  * @param clusterVectorU to receive the selected clusters in the u view
38  * @param clusterVectorV to receive the selected clusters in the v view
39  * @param clusterVectorW to receive the selected clusters in the w view
40  */
41  void SelectClusters(pandora::ClusterVector &clusterVectorU, pandora::ClusterVector &clusterVectorV, pandora::ClusterVector &clusterVectorW);
42 
43  /**
44  * @brief Create candidate vertex positions by comparing pairs of cluster end positions
45  *
46  * @param clusterVector1 the clusters in view 1
47  * @param clusterVector1 the clusters in view 2
48  */
49  void CreateEndpointCandidates(const pandora::ClusterVector &clusterVector1, const pandora::ClusterVector &clusterVector2) const;
50 
51  /**
52  * @brief Create a candidate vertex position, using an end-point position from one cluster and sliding fit to a second cluster
53  *
54  * @param position1 an end-point position for the first cluster
55  * @param hitType1 the hit type of the first cluster
56  * @param fitResult2 the two dimensional sliding fit result for the second cluster
57  */
58  void CreateEndpointVertex(const pandora::CartesianVector &position1, const pandora::HitType hitType1, const TwoDSlidingFitResult &fitResult2) const;
59 
60  /**
61  * @brief Extrapolate 2D clusters, find where they cross, and match crossing points between views to create vertex candidates
62  *
63  * @param clusterVectorU the clusters in the u view
64  * @param clusterVectorV the clusters in the v view
65  * @param clusterVectorW the clusters in the w view
66  */
67  void CreateCrossingCandidates(const pandora::ClusterVector &clusterVectorU, const pandora::ClusterVector &clusterVectorV,
68  const pandora::ClusterVector &clusterVectorW) const;
69 
70  /**
71  * @brief Identify where (extrapolated) clusters plausibly cross in 2D
72  *
73  * @param clusterVector the input clusters
74  * @param crossingPoints to receive the 2D crossing points
75  */
76  void FindCrossingPoints(const pandora::ClusterVector &clusterVector, pandora::CartesianPointVector &crossingPoints) const;
77 
78  /**
79  * @brief Get a list of spacepoints representing cluster 2D hit positions and extrapolated positions
80  *
81  * @param pCluster address of the cluster
82  * @param spacePoints to receive the list of spacepoints
83  */
84  void GetSpacepoints(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &spacePoints) const;
85 
86  /**
87  * @brief Identify where (extrapolated) clusters plausibly cross in 2D
88  *
89  * @param spacepoints1 space points for cluster 1
90  * @param spacepoints2 space points for cluster 2
91  * @param crossingPoints to receive the list of plausible 2D crossing points
92  */
93  void FindCrossingPoints(const pandora::CartesianPointVector &spacepoints1, const pandora::CartesianPointVector &spacepoints2,
94  pandora::CartesianPointVector &crossingPoints) const;
95 
96  /**
97  * @brief Attempt to create candidate vertex positions, using 2D crossing points in 2 views
98  *
99  * @param crossingPoints1 the crossing points in view 1
100  * @param crossingPoints2 the crossing points in view 2
101  * @param hitType1 the hit type of crossing points 1
102  * @param hitType2 the hit type of crossing points 2
103  * @param nCrossingCandidates to count the number of crossing candidates created
104  */
105  void CreateCrossingVertices(const pandora::CartesianPointVector &crossingPoints1, const pandora::CartesianPointVector &crossingPoints2,
106  const pandora::HitType hitType1, const pandora::HitType hitType2, unsigned int &nCrossingCandidates) const;
107 
108  /**
109  * @brief Creates a 2D sliding fit of a cluster and stores it for later use
110  *
111  * @param pCluster address of the relevant cluster
112  */
113  void AddToSlidingFitCache(const pandora::Cluster *const pCluster);
114 
115  /**
116  * @brief Get a sliding fit result from the algorithm cache
117  *
118  * @param pCluster address of the relevant cluster
119  */
120  const TwoDSlidingFitResult &GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const;
121 
122  /**
123  * @brief Clear relevant algorithm member variables between events
124  */
125  void TidyUp();
126 
127  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
128 
129  typedef std::unordered_map<const pandora::Cluster *, pandora::CartesianPointVector> ClusterToSpacepointsMap;
130 
131  pandora::StringVector m_inputClusterListNames; ///< The list of cluster list names
132  std::string m_outputVertexListName; ///< The name under which to save the output vertex list
133  bool m_replaceCurrentVertexList; ///< Whether to replace the current vertex list with the output list
134 
135  unsigned int m_slidingFitWindow; ///< The layer window for the sliding linear fits
136  TwoDSlidingFitResultMap m_slidingFitResultMap; ///< The sliding fit result map
137 
138  unsigned int m_minClusterCaloHits; ///< The min number of hits in base cluster selection method
139  float m_minClusterLengthSquared; ///< The min length (squared) in base cluster selection method
140  float m_chiSquaredCut; ///< The chi squared cut (accept only 3D vertex positions with values below cut)
141 
142  bool m_enableEndpointCandidates; ///< Whether to create endpoint-based candidates
143  float m_maxEndpointXDiscrepancy; ///< The max cluster endpoint discrepancy
144 
145  bool m_enableCrossingCandidates; ///< Whether to create crossing vertex candidates
146  unsigned int m_nMaxCrossingCandidates; ///< The max number of crossing candidates to create
147  float m_maxCrossingXDiscrepancy; ///< The max cluster endpoint discrepancy
148  unsigned int m_extrapolationNSteps; ///< Number of extrapolation steps, at each end of cluster, of specified size
149  float m_extrapolationStepSize; ///< The extrapolation step size in cm
150  float m_maxCrossingSeparationSquared; ///< The separation (squared) between spacepoints below which a crossing can be identified
151  float m_minNearbyCrossingDistanceSquared; ///< The minimum allowed distance between identified crossing positions
152 
153  bool m_reducedCandidates; ///< Whether to reduce the number of candidates
154  float m_selectionCutFactorMax; ///< Maximum factor to multiply the base cluster selection cuts
155  float m_nClustersPassingMaxCutsPar; ///< Parameter for number of clusters passing the max base cluster selection cuts
156 };
157 
158 } // namespace lar_content
159 
160 #endif // #ifndef LAR_CANDIDATE_VERTEX_CREATION_ALGORITHM_H
bool m_reducedCandidates
Whether to reduce the number of candidates.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
void CreateEndpointVertex(const pandora::CartesianVector &position1, const pandora::HitType hitType1, const TwoDSlidingFitResult &fitResult2) const
Create a candidate vertex position, using an end-point position from one cluster and sliding fit to a...
void CreateCrossingCandidates(const pandora::ClusterVector &clusterVectorU, const pandora::ClusterVector &clusterVectorV, const pandora::ClusterVector &clusterVectorW) const
Extrapolate 2D clusters, find where they cross, and match crossing points between views to create ver...
void GetSpacepoints(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &spacePoints) const
Get a list of spacepoints representing cluster 2D hit positions and extrapolated positions.
float m_extrapolationStepSize
The extrapolation step size in cm.
float m_maxCrossingSeparationSquared
The separation (squared) between spacepoints below which a crossing can be identified.
enum cvn::HType HitType
std::string string
Definition: nybbler.cc:12
bool m_enableEndpointCandidates
Whether to create endpoint-based candidates.
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Creates a 2D sliding fit of a cluster and stores it for later use.
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
float m_maxEndpointXDiscrepancy
The max cluster endpoint discrepancy.
void FindCrossingPoints(const pandora::ClusterVector &clusterVector, pandora::CartesianPointVector &crossingPoints) const
Identify where (extrapolated) clusters plausibly cross in 2D.
bool m_enableCrossingCandidates
Whether to create crossing vertex candidates.
float m_maxCrossingXDiscrepancy
The max cluster endpoint discrepancy.
TwoDSlidingFitResultMap m_slidingFitResultMap
The sliding fit result map.
void CreateEndpointCandidates(const pandora::ClusterVector &clusterVector1, const pandora::ClusterVector &clusterVector2) const
Create candidate vertex positions by comparing pairs of cluster end positions.
float m_nClustersPassingMaxCutsPar
Parameter for number of clusters passing the max base cluster selection cuts.
Header file for the lar two dimensional sliding fit result class.
float m_minNearbyCrossingDistanceSquared
The minimum allowed distance between identified crossing positions.
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
void TidyUp()
Clear relevant algorithm member variables between events.
unsigned int m_extrapolationNSteps
Number of extrapolation steps, at each end of cluster, of specified size.
std::string m_outputVertexListName
The name under which to save the output vertex list.
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
CandidateVertexCreationAlgorithm::Algorithm class.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
unsigned int m_nMaxCrossingCandidates
The max number of crossing candidates to create.
std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > ClusterToSpacepointsMap
float m_selectionCutFactorMax
Maximum factor to multiply the base cluster selection cuts.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void SelectClusters(pandora::ClusterVector &clusterVectorU, pandora::ClusterVector &clusterVectorV, pandora::ClusterVector &clusterVectorW)
Select a subset of input clusters (contained in the input list names) for processing in this algorith...
float m_chiSquaredCut
The chi squared cut (accept only 3D vertex positions with values below cut)
std::vector< string > StringVector
Definition: fcldump.cxx:29
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void CreateCrossingVertices(const pandora::CartesianPointVector &crossingPoints1, const pandora::CartesianPointVector &crossingPoints2, const pandora::HitType hitType1, const pandora::HitType hitType2, unsigned int &nCrossingCandidates) const
Attempt to create candidate vertex positions, using 2D crossing points in 2 views.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.