TwoDSlidingFitSplittingAndSplicingAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTwoDReco/LArClusterSplitting/TwoDSlidingFitSplittingAndSplicingAlgorithm.h
3  *
4  * @brief Header file for the two dimensional sliding fit splitting and splicing algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_TWO_D_SLIDING_FIT_SPLITTING_AND_SPLICING_ALGORITHM_H
9 #define LAR_TWO_D_SLIDING_FIT_SPLITTING_AND_SPLICING_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief TwoDSlidingFitSplittingAndSplicingAlgorithm class
20  */
21 class TwoDSlidingFitSplittingAndSplicingAlgorithm : public pandora::Algorithm
22 {
23 public:
24  /**
25  * @brief Default constructor
26  */
28 
29 protected:
30  virtual pandora::StatusCode Run();
31  virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
32 
33  /**
34  * @brief ClusterExtension class
35  */
37  {
38  public:
39  /**
40  * @brief Constructor
41  *
42  * @param pBranchCluster the address of the branch cluster
43  * @param pReplacementCluster the address of the replacement cluster
44  * @param replacementVertex the start position of the replacement cluster
45  * @param branchVertex the split position of the branch cluster
46  * @param branchDirection the split direction of the branch cluster
47  */
48  ClusterExtension(const pandora::Cluster *const pBranchCluster, const pandora::Cluster *const pReplacementCluster,
49  const pandora::CartesianVector &replacementVertex, const pandora::CartesianVector &branchVertex,
50  const pandora::CartesianVector &branchDirection);
51 
52  /**
53  * @brief return the address of the branch Cluster
54  */
55  const pandora::Cluster *GetBranchCluster() const;
56 
57  /**
58  * @brief return the address of the replacement Cluster
59  */
60  const pandora::Cluster *GetReplacementCluster() const;
61 
62  /**
63  * @brief return the start position of the replacement cluster
64  */
65  const pandora::CartesianVector &GetReplacementVertex() const;
66 
67  /**
68  * @brief return the split position of the branch cluster
69  */
70  const pandora::CartesianVector &GetBranchVertex() const;
71 
72  /**
73  * @brief return the split direction of the branch cluster
74  */
75  const pandora::CartesianVector &GetBranchDirection() const;
76 
77  private:
78  const pandora::Cluster *m_pBranchCluster; ///<
79  const pandora::Cluster *m_pReplacementCluster; ///<
80  pandora::CartesianVector m_replacementVertex; ///<
81  pandora::CartesianVector m_branchVertex; ///<
82  pandora::CartesianVector m_branchDirection; ///<
83  };
84 
85  typedef std::vector<ClusterExtension> ClusterExtensionList;
86 
87  /**
88  * @brief Output the best split positions in branch and replacement clusters
89  *
90  * @param branchSlidingFit the inputted sliding fit result for possible branch cluster
91  * @param pReplacementCluster the inputted sliding fit result for possible replacement cluster
92  * @param replacementStartPosition the outputted start position of the replacement
93  * @param branchSplitPosition the outputted start position of the branch
94  * @param branchSplitDirection the outputted start direction of the branch
95  */
96  virtual void FindBestSplitPosition(const TwoDSlidingFitResult &branchSlidingFit, const TwoDSlidingFitResult &replacementSlidingFit,
97  pandora::CartesianVector &replacementStartPosition, pandora::CartesianVector &branchSplitPosition,
98  pandora::CartesianVector &branchSplitDirection) const = 0;
99 
100 private:
101  /**
102  * @brief Populate cluster vector with subset of cluster list, containing clusters judged to be clean
103  *
104  * @param pClusterList address of the cluster list
105  * @param clusterVector to receive the populated cluster vector
106  */
107  void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const;
108 
109  /**
110  * @brief Build the map of sliding fit results
111  *
112  * @param clusterVector the input cluster vector
113  * @param halfWindowLayers the half-window to use for the sliding fits
114  * @param slidingFitResultMap the output sliding fit result map
115  */
116  void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers,
117  TwoDSlidingFitResultMap &slidingFitResultMap) const;
118 
119  /**
120  * @brief Build a list of candidate splits
121  *
122  * @param clusterVector the input cluster vector
123  * @param branchResultMap the sliding fit result map for branch clusters
124  * @param replacementResultMap the sliding fit result map for replacement clusters
125  * @param clusterExtensionList the output list of candidate splits
126  */
127  void BuildClusterExtensionList(const pandora::ClusterVector &clusterVector, const TwoDSlidingFitResultMap &branchResultMap,
128  const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &clusterExtensionList) const;
129 
130  /**
131  * @brief Finalize the list of candidate splits
132  *
133  * @param inputList the input list of possible splits
134  * @param branchResultMap the sliding fit result map for branch clusters
135  * @param replacementResultMap the sliding fit result map for replacement clusters
136  * @param outputList the output list of definite splits
137  */
138  void PruneClusterExtensionList(const ClusterExtensionList &inputList, const TwoDSlidingFitResultMap &branchResultMap,
139  const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &outputList) const;
140 
141  /**
142  * @brief Calculate RMS deviation of branch hits relative to the split direction
143  *
144  * @param pCluster the input branch cluster
145  * @param splitPosition the start position of the branch
146  * @param splitDirection the start direction of the branch
147  */
148  float CalculateBranchChi2(const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition,
149  const pandora::CartesianVector &splitDirection) const;
150 
151  /**
152  * @brief Separate cluster into the branch hits to be split from the primary cluster
153  *
154  * @param pCluster the input branch cluster
155  * @param splitPosition the start position of the branch
156  * @param splitDirection the start direction of the branch
157  * @param principalCaloHitList the hits to be added to the principal cluster
158  * @param branchCaloHitList the hits to be split off into the output branch cluster
159  */
160  void SplitBranchCluster(const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition,
161  const pandora::CartesianVector &splitDirection, pandora::CaloHitList &principalCaloHitList, pandora::CaloHitList &branchCaloHitList) const;
162 
163  /**
164  * @brief Run the machinary that performs the cluster splitting and extending
165  *
166  * @param splitList the input list of candidate splits
167  * @param branchResultMap the sliding fit result map for branch clusters
168  * @param replacementResultMap the sliding fit result map for replacement clusters
169  */
170  pandora::StatusCode RunSplitAndExtension(const ClusterExtensionList &splitList, TwoDSlidingFitResultMap &branchResultMap,
171  TwoDSlidingFitResultMap &replacementResultMap) const;
172 
173  /**
174  * @brief Remove a branch from a cluster and replace it with a second cluster
175  *
176  * @param pBranchCluster the cluster containing a branch to be removed
177  * @param pReplacementCluster the replacement cluster
178  * @param branchSplitPosition the position at the start of the branch
179  * @param branchSplitDirection the direction at the start of the branch
180  */
181  pandora::StatusCode ReplaceBranch(const pandora::Cluster *const pBranchCluster, const pandora::Cluster *const pReplacementCluster,
182  const pandora::CartesianVector &branchSplitPosition, const pandora::CartesianVector &branchSplitDirection) const;
183 
184  unsigned int m_shortHalfWindowLayers; ///<
185  unsigned int m_longHalfWindowLayers; ///<
186  float m_minClusterLength; ///<
187  float m_vetoDisplacement; ///<
188  bool m_runCosmicMode; ///<
189 };
190 
191 //------------------------------------------------------------------------------------------------------------------------------------------
192 //------------------------------------------------------------------------------------------------------------------------------------------
193 
195  const pandora::Cluster *const pReplacementCluster, const pandora::CartesianVector &replacementVertex,
196  const pandora::CartesianVector &branchVertex, const pandora::CartesianVector &branchDirection) :
197  m_pBranchCluster(pBranchCluster),
198  m_pReplacementCluster(pReplacementCluster),
199  m_replacementVertex(replacementVertex),
200  m_branchVertex(branchVertex),
201  m_branchDirection(branchDirection)
202 {
203 }
204 
205 //------------------------------------------------------------------------------------------------------------------------------------------
206 
208 {
209  return m_pBranchCluster;
210 }
211 
212 //------------------------------------------------------------------------------------------------------------------------------------------
213 
215 {
216  return m_pReplacementCluster;
217 }
218 
219 //------------------------------------------------------------------------------------------------------------------------------------------
220 
222 {
223  return m_replacementVertex;
224 }
225 
226 //------------------------------------------------------------------------------------------------------------------------------------------
227 
229 {
230  return m_branchVertex;
231 }
232 
233 //------------------------------------------------------------------------------------------------------------------------------------------
234 
236 {
237  return m_branchDirection;
238 }
239 
240 } // namespace lar_content
241 
242 #endif // #ifndef LAR_TWO_D_SLIDING_FIT_SPLITTING_AND_SPLICING_ALGORITHM_H
const pandora::CartesianVector & GetReplacementVertex() const
return the start position of the replacement cluster
const pandora::Cluster * GetReplacementCluster() const
return the address of the replacement Cluster
virtual void FindBestSplitPosition(const TwoDSlidingFitResult &branchSlidingFit, const TwoDSlidingFitResult &replacementSlidingFit, pandora::CartesianVector &replacementStartPosition, pandora::CartesianVector &branchSplitPosition, pandora::CartesianVector &branchSplitDirection) const =0
Output the best split positions in branch and replacement clusters.
void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers, TwoDSlidingFitResultMap &slidingFitResultMap) const
Build the map of sliding fit results.
void BuildClusterExtensionList(const pandora::ClusterVector &clusterVector, const TwoDSlidingFitResultMap &branchResultMap, const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &clusterExtensionList) const
Build a list of candidate splits.
const pandora::Cluster * GetBranchCluster() const
return the address of the branch Cluster
ClusterExtension(const pandora::Cluster *const pBranchCluster, const pandora::Cluster *const pReplacementCluster, const pandora::CartesianVector &replacementVertex, const pandora::CartesianVector &branchVertex, const pandora::CartesianVector &branchDirection)
Constructor.
const pandora::CartesianVector & GetBranchVertex() const
return the split position of the branch cluster
const pandora::CartesianVector & GetBranchDirection() const
return the split direction of the branch cluster
void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const
Populate cluster vector with subset of cluster list, containing clusters judged to be clean...
Header file for the cluster helper class.
pandora::StatusCode RunSplitAndExtension(const ClusterExtensionList &splitList, TwoDSlidingFitResultMap &branchResultMap, TwoDSlidingFitResultMap &replacementResultMap) const
Run the machinary that performs the cluster splitting and extending.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StatusCode ReplaceBranch(const pandora::Cluster *const pBranchCluster, const pandora::Cluster *const pReplacementCluster, const pandora::CartesianVector &branchSplitPosition, const pandora::CartesianVector &branchSplitDirection) const
Remove a branch from a cluster and replace it with a second cluster.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
void SplitBranchCluster(const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition, const pandora::CartesianVector &splitDirection, pandora::CaloHitList &principalCaloHitList, pandora::CaloHitList &branchCaloHitList) const
Separate cluster into the branch hits to be split from the primary cluster.
float CalculateBranchChi2(const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition, const pandora::CartesianVector &splitDirection) const
Calculate RMS deviation of branch hits relative to the split direction.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void PruneClusterExtensionList(const ClusterExtensionList &inputList, const TwoDSlidingFitResultMap &branchResultMap, const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &outputList) const
Finalize the list of candidate splits.