All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThreeViewTrackFragmentsAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArTrackFragments/ThreeViewTrackFragmentsAlgorithm.h
3  *
4  * @brief Header file for the three view fragments algorithm base class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_THREE_VIEW_TRACK_FRAGMENTS_ALGORITHM_H
9 #define LAR_THREE_VIEW_TRACK_FRAGMENTS_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 #include "Pandora/AlgorithmTool.h"
13 
15 
18 
19 #include <unordered_map>
20 
21 namespace lar_content
22 {
23 
24 class FragmentTensorTool;
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
28 /**
29  * @brief ThreeViewTrackFragmentsAlgorithm class
30  */
31 class ThreeViewTrackFragmentsAlgorithm : public NViewTrackMatchingAlgorithm<ThreeViewMatchingControl<FragmentOverlapResult>>
32 {
33 public:
35 
36  /**
37  * @brief Default constructor
38  */
40 
41  void UpdateForNewCluster(const pandora::Cluster *const pNewCluster);
42 
43  /**
44  * @brief Rebuild clusters after fragmentation
45  *
46  * @param rebuildList the list of clusters containing hits to be rebuilt
47  * @param newClusters the output list of clusters
48  */
49  void RebuildClusters(const pandora::ClusterList &rebuildList, pandora::ClusterList &newClusters) const;
50 
51 protected:
52  void PerformMainLoop();
53  void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW);
54 
55  /**
56  * @brief Calculate overlap result for track fragment candidate consisting of two sliding fit results and a list of available clusters
57  *
58  * @param fitResult1 the first sliding fit result
59  * @param fitResult2 the second sliding fit result
60  * @param inputClusterList the input cluster list
61  * @param pBestMatchedCluster to receive the address of the best matched cluster
62  * @param fragmentOverlapResult to receive the populated fragment overlap result
63  *
64  * @return statusCode, faster than throwing in regular use-cases
65  */
66  pandora::StatusCode CalculateOverlapResult(const TwoDSlidingFitResult &fitResult1, const TwoDSlidingFitResult &fitResult2,
67  const pandora::ClusterList &inputClusterList, const pandora::Cluster *&pBestMatchedCluster, FragmentOverlapResult &fragmentOverlapResult) const;
68 
69  typedef std::unordered_map<const pandora::CaloHit *, const pandora::Cluster *> HitToClusterMap;
70 
71  /**
72  * @brief Get the list of projected positions, in the third view, corresponding to a pair of sliding fit results
73  *
74  * @param fitResult1 the first sliding fit result
75  * @param fitResult2 the second sliding fit result
76  * @param projectedPositions to receive the list of projected positions
77  *
78  * @return statusCode, faster than throwing in regular use-cases
79  */
80  pandora::StatusCode GetProjectedPositions(const TwoDSlidingFitResult &fitResult1, const TwoDSlidingFitResult &fitResult2,
81  pandora::CartesianPointVector &projectedPositions) const;
82 
83  /**
84  * @brief Get the list of hits associated with the projected positions and a useful hit to cluster map
85  *
86  * @param inputClusterList the input cluster list
87  * @param projectedPositions the list of projected positions
88  * @param hitToClusterMap to receive the hit to cluster map
89  * @param matchedCaloHits to receive the list of associated calo hits
90  *
91  * @return statusCode, faster than throwing in regular use-cases
92  */
93  pandora::StatusCode GetMatchedHits(const pandora::ClusterList &inputClusterList, const pandora::CartesianPointVector &projectedPositions,
94  HitToClusterMap &hitToClusterMap, pandora::CaloHitList &matchedCaloHits) const;
95 
96  /**
97  * @brief Get the list of the relevant clusters and the address of the single best matched cluster
98  *
99  * @param matchedHits the list of matched calo hits
100  * @param hitToClusterMap the hit to cluster map
101  * @param matchedClusters to receive the list of matched clusters
102  * @param pBestMatchedCluster to receive the address of the single best matched cluster
103  *
104  * @return statusCode, faster than throwing in regular use-cases
105  */
106  pandora::StatusCode GetMatchedClusters(const pandora::CaloHitList &matchedHits, const HitToClusterMap &hitToClusterMap,
107  pandora::ClusterList &matchedClusters, const pandora::Cluster *&pBestMatchedCluster) const;
108 
109  /**
110  * @brief Get the populated fragment overlap result
111  *
112  * @param projectedPositions the list of projected positions
113  * @param matchedHits the list of matched hits
114  * @param matchedClusters the list of matched clusters
115  * @param fragmentOverlapResult to receive the populated fragment overlap result
116  */
117  void GetFragmentOverlapResult(const pandora::CartesianPointVector &projectedPositions, const pandora::CaloHitList &matchedHits,
118  const pandora::ClusterList &matchedClusters, FragmentOverlapResult &fragmentOverlapResult) const;
119 
120  /**
121  * @brief Whether the matched clusters are consistent with the projected positions
122  *
123  * @param projectedPositions the list of projected positions
124  * @param matchedClusters the list of matched clusters
125  *
126  * @return boolean
127  */
128  bool CheckMatchedClusters(const pandora::CartesianPointVector &projectedPositions, const pandora::ClusterList &matchedClusters) const;
129 
130  /**
131  * @brief Whether the matched clusters and hits pass the algorithm quality cuts
132  *
133  * @param fragmentOverlapResult the fragment overlap result
134  *
135  * @return boolean
136  */
137  bool CheckOverlapResult(const FragmentOverlapResult &overlapResult) const;
138 
140  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
141 
142  typedef std::unordered_map<const pandora::Cluster *, unsigned int> ClusterToMatchedHitsMap;
143 
144  std::string m_reclusteringAlgorithmName; ///< Name of daughter algorithm to use for cluster re-building
145 
146  typedef std::vector<FragmentTensorTool *> TensorToolVector;
147  TensorToolVector m_algorithmToolVector; ///< The algorithm tool list
148 
149  unsigned int m_nMaxTensorToolRepeats; ///< The maximum number of repeat loops over tensor tools
150 
151  float m_minXOverlap; ///< requirement on minimum X overlap for associated clusters
152  float m_minXOverlapFraction; ///< requirement on minimum X overlap fraction for associated clusters
153  float m_maxPointDisplacementSquared; ///< maximum allowed distance (squared) between projected points and associated hits
154  float m_minMatchedSamplingPointFraction; ///< minimum fraction of matched sampling points
155  unsigned int m_minMatchedHits; ///< minimum number of matched calo hits
156 };
157 
158 //------------------------------------------------------------------------------------------------------------------------------------------
159 
160 /**
161  * @brief FragmentTensorTool class
162  */
163 class FragmentTensorTool : public pandora::AlgorithmTool
164 {
165 public:
167  typedef std::vector<TensorType::ElementList::const_iterator> IteratorList;
168 
169  /**
170  * @brief Run the algorithm tool
171  *
172  * @param pAlgorithm address of the calling algorithm
173  * @param overlapTensor the overlap tensor
174  *
175  * @return whether changes have been made by the tool
176  */
177  virtual bool Run(ThreeViewTrackFragmentsAlgorithm *const pAlgorithm, TensorType &overlapTensor) = 0;
178 };
179 
180 } // namespace lar_content
181 
182 #endif // #ifndef LAR_THREE_VIEW_TRACK_FRAGMENTS_ALGORITHM_H
FragmentOverlapResult class.
void RebuildClusters(const pandora::ClusterList &rebuildList, pandora::ClusterList &newClusters) const
Rebuild clusters after fragmentation.
Header file for the n view track matching algorithm class.
void GetFragmentOverlapResult(const pandora::CartesianPointVector &projectedPositions, const pandora::CaloHitList &matchedHits, const pandora::ClusterList &matchedClusters, FragmentOverlapResult &fragmentOverlapResult) const
Get the populated fragment overlap result.
void PerformMainLoop()
Main loop over cluster combinations in order to populate the overlap container. Responsible for calli...
pandora::StatusCode GetMatchedClusters(const pandora::CaloHitList &matchedHits, const HitToClusterMap &hitToClusterMap, pandora::ClusterList &matchedClusters, const pandora::Cluster *&pBestMatchedCluster) const
Get the list of the relevant clusters and the address of the single best matched cluster.
virtual bool Run(ThreeViewTrackFragmentsAlgorithm *const pAlgorithm, TensorType &overlapTensor)=0
Run the algorithm tool.
pandora::StatusCode GetProjectedPositions(const TwoDSlidingFitResult &fitResult1, const TwoDSlidingFitResult &fitResult2, pandora::CartesianPointVector &projectedPositions) const
Get the list of projected positions, in the third view, corresponding to a pair of sliding fit result...
std::unordered_map< const pandora::Cluster *, unsigned int > ClusterToMatchedHitsMap
unsigned int m_minMatchedHits
minimum number of matched calo hits
NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > > BaseAlgorithm
void ExamineOverlapContainer()
Examine contents of overlap container, collect together best-matching 2D particles and modify cluster...
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
bool CheckOverlapResult(const FragmentOverlapResult &overlapResult) const
Whether the matched clusters and hits pass the algorithm quality cuts.
std::string m_reclusteringAlgorithmName
Name of daughter algorithm to use for cluster re-building.
std::vector< TensorType::ElementList::const_iterator > IteratorList
ThreeViewTrackFragmentsAlgorithm::MatchingType::TensorType TensorType
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in container.
bool CheckMatchedClusters(const pandora::CartesianPointVector &projectedPositions, const pandora::ClusterList &matchedClusters) const
Whether the matched clusters are consistent with the projected positions.
Header file for the lar track overlap result class.
TensorToolVector m_algorithmToolVector
The algorithm tool list.
Header file for the three view matching control class.
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
float m_maxPointDisplacementSquared
maximum allowed distance (squared) between projected points and associated hits
float m_minXOverlap
requirement on minimum X overlap for associated clusters
float m_minMatchedSamplingPointFraction
minimum fraction of matched sampling points
pandora::StatusCode GetMatchedHits(const pandora::ClusterList &inputClusterList, const pandora::CartesianPointVector &projectedPositions, HitToClusterMap &hitToClusterMap, pandora::CaloHitList &matchedCaloHits) const
Get the list of hits associated with the projected positions and a useful hit to cluster map...