LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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,
97  const TwoDSlidingFitResult &replacementSlidingFit, pandora::CartesianVector &replacementStartPosition,
98  pandora::CartesianVector &branchSplitPosition, pandora::CartesianVector &branchSplitDirection) const = 0;
99 
100 private:
101 
108  void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const;
109 
117  void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers,
118  TwoDSlidingFitResultMap &slidingFitResultMap) const;
119 
128  void BuildClusterExtensionList(const pandora::ClusterVector &clusterVector, const TwoDSlidingFitResultMap &branchResultMap,
129  const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &clusterExtensionList) const;
130 
139  void PruneClusterExtensionList(const ClusterExtensionList &inputList, const TwoDSlidingFitResultMap &branchResultMap,
140  const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &outputList) const;
141 
149  float CalculateBranchChi2(const pandora::Cluster* const pCluster, const pandora::CartesianVector &splitPosition,
150  const pandora::CartesianVector &splitDirection) const;
151 
161  void SplitBranchCluster(const pandora::Cluster* const pCluster, const pandora::CartesianVector &splitPosition,
162  const pandora::CartesianVector &splitDirection, pandora::CaloHitList &principalCaloHitList,
163  pandora::CaloHitList &branchCaloHitList) const;
164 
172  pandora::StatusCode RunSplitAndExtension(const ClusterExtensionList &splitList, TwoDSlidingFitResultMap &branchResultMap,
173  TwoDSlidingFitResultMap &replacementResultMap) const;
174 
183  pandora::StatusCode ReplaceBranch(const pandora::Cluster *const pBranchCluster, const pandora::Cluster *const pReplacementCluster,
184  const pandora::CartesianVector &branchSplitPosition, const pandora::CartesianVector &branchSplitDirection) const;
185 
186  unsigned int m_shortHalfWindowLayers;
187  unsigned int m_longHalfWindowLayers;
191 };
192 
193 //------------------------------------------------------------------------------------------------------------------------------------------
194 //------------------------------------------------------------------------------------------------------------------------------------------
195 
197  const pandora::Cluster *const pReplacementCluster, const pandora::CartesianVector &replacementVertex,
198  const pandora::CartesianVector &branchVertex, const pandora::CartesianVector &branchDirection) :
199  m_pBranchCluster(pBranchCluster),
200  m_pReplacementCluster(pReplacementCluster),
201  m_replacementVertex(replacementVertex),
202  m_branchVertex(branchVertex),
203  m_branchDirection(branchDirection)
204 {
205 
206 }
207 
208 //------------------------------------------------------------------------------------------------------------------------------------------
209 
211 {
212  return m_pBranchCluster;
213 }
214 
215 //------------------------------------------------------------------------------------------------------------------------------------------
216 
218 {
219  return m_pReplacementCluster;
220 }
221 
222 //------------------------------------------------------------------------------------------------------------------------------------------
223 
225 {
226  return m_replacementVertex;
227 }
228 
229 //------------------------------------------------------------------------------------------------------------------------------------------
230 
232 {
233  return m_branchVertex;
234 }
235 
236 //------------------------------------------------------------------------------------------------------------------------------------------
237 
239 {
240  return m_branchDirection;
241 }
242 
243 } // namespace lar_content
244 
245 #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
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
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::vector< art::Ptr< recob::Cluster > > ClusterVector
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.
void PruneClusterExtensionList(const ClusterExtensionList &inputList, const TwoDSlidingFitResultMap &branchResultMap, const TwoDSlidingFitResultMap &replacementResultMap, ClusterExtensionList &outputList) const
Finalize the list of candidate splits.