LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TwoDSlidingFitSplittingAndSplicingAlgorithm.h
Go to the documentation of this file.
1 
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 
21 class TwoDSlidingFitSplittingAndSplicingAlgorithm : public pandora::Algorithm
22 {
23 public:
28 
29 protected:
30  virtual pandora::StatusCode Run();
31  virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
32 
37  {
38  public:
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 
55  const pandora::Cluster *GetBranchCluster() const;
56 
60  const pandora::Cluster *GetReplacementCluster() const;
61 
65  const pandora::CartesianVector &GetReplacementVertex() const;
66 
70  const pandora::CartesianVector &GetBranchVertex() const;
71 
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 
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:
107  void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const;
108 
116  void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers,
117  TwoDSlidingFitResultMap &slidingFitResultMap) const;
118 
127  void BuildClusterExtensionList(const pandora::ClusterVector &clusterVector, const TwoDSlidingFitResultMap &branchResultMap,
128  const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &clusterExtensionList) const;
129 
138  void PruneClusterExtensionList(const ClusterExtensionList &inputList, const TwoDSlidingFitResultMap &branchResultMap,
139  const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &outputList) const;
140 
148  float CalculateBranchChi2(const pandora::Cluster *const pCluster, const pandora::CartesianVector &splitPosition,
149  const pandora::CartesianVector &splitDirection) const;
150 
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 
170  pandora::StatusCode RunSplitAndExtension(const ClusterExtensionList &splitList, TwoDSlidingFitResultMap &branchResultMap,
171  TwoDSlidingFitResultMap &replacementResultMap) const;
172 
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;
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.