All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TwoViewDeltaRayMatchingAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArCosmicRay/TwoViewDeltaRayMatching.h
3  *
4  * @brief Header file for the two view delta ray matching class
5  *
6  * $Log: $
7  */
8 #ifndef LAR_TWO_VIEW_DELTA_RAY_MATCHING_ALGORITHM_H
9 #define LAR_TWO_VIEW_DELTA_RAY_MATCHING_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 #include "Pandora/AlgorithmTool.h"
13 
15 
18 
20 
21 namespace lar_content
22 {
23 
24 class DeltaRayMatrixTool;
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
28 /**
29  * @brief TwoViewDeltaRayMatchingAlgorithm class
30  */
31 class TwoViewDeltaRayMatchingAlgorithm : public NViewDeltaRayMatchingAlgorithm<TwoViewMatchingControl<TwoViewDeltaRayOverlapResult>>
32 {
33 public:
36 
37  /**
38  * @brief Default constructor
39  */
41 
42  /**
43  * @brief Get the name of the third view clusters
44  *
45  * @return the third view cluster list name
46  */
47  const std::string &GetThirdViewClusterListName() const;
48 
49  /**
50  * @brief Get the name of the clustering algorithm to be used to recluster created delta ray remnants
51  *
52  * @return the clustering algorithm name
53  */
54  const std::string &GetClusteringAlgName() const;
55 
56  /**
57  * @brief Obtain the HitTypeVector of input views
58  *
59  * @return the HitTypeVector of input views
60  */
62 
63  /**
64  * @brief Get the address of the given hit type cluster
65  *
66  * @param hitType hit type of the required cluster
67  *
68  * @return address of the required cluster
69  */
70  const pandora::Cluster *GetCluster(const MatrixType::Element &element, const pandora::HitType hitType);
71 
72  /**
73  * @brief Create delta ray pfos out of a given element, merging the third view clusters together and adding in any stray clusters
74  *
75  * @param element the matrix element
76  *
77  * @return whether any pfos were created
78  */
79  bool CreatePfo(const MatrixType::Element &element);
80 
81  /**
82  * @brief Update the matrix after a third view cluster modification - remove delta ray clusters and reassess the matching of cosmic ray clusters
83  *
84  * @param pModifiedCluster the address of the modified cluster
85  * @param isMuon whether the modified cluster belongs to a cosmic ray pfo
86  */
87  void UpdateForThirdViewClusterModification(const pandora::Cluster *const pModifiedCluster, const bool isMuon);
88 
89 private:
90  void CalculateOverlapResult(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3);
91 
92  /**
93  * @brief To check whether a given cluster meets the requirements to be added into the matching container (tensor/matrix)
94  *
95  * @param pCluster the address of the input cluster
96  *
97  * @return whether the checks were met
98  */
99  virtual bool DoesClusterPassTensorThreshold(const pandora::Cluster *const pCluster) const;
100 
101  /**
102  * @brief Calculate the overlap result for given pair of clusters
103  *
104  * @param pCluster1 the cluster from the first input view
105  * @param pCluster2 the cluster from the second input view
106  * @param overlapResult to receive the overlap result
107  *
108  * @return statusCode, faster than throwing in regular use-cases
109  */
110  pandora::StatusCode CalculateOverlapResult(
111  const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, TwoViewDeltaRayOverlapResult &overlapResult) const;
112 
113  /**
114  * @brief Find the cosmic ray pfos that, in each view, lie close to the clusters of the matrix element
115  *
116  * @param pCluster1 the cluster from the first input view
117  * @param pCluster2 the cluster from the second input view
118  * @param commonMuonPfoList the output list of common cosmic ray pfos
119  */
120  void FindCommonMuonParents(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::PfoList &commonMuonPfoList) const;
121 
122  /**
123  * @brief Collect the available and unavailable third view clusters that lie close to the projected delta ray hits
124  *
125  * @param pCluster1 the cluster from the first input view
126  * @param pCluster2 the cluster from the second input view
127  * @param projectedPositions the projected positions of the matched cluster pair
128  * @param matchedClusters the output list of collected clusters
129  */
130  void CollectThirdViewClusters(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2,
131  const pandora::CartesianPointVector &projectedPositions, pandora::ClusterList &matchedClusters) const;
132 
133  /**
134  * @brief Determine the best matched third view cluster and calculate the reduced chi-squared value of the three cluster match
135  *
136  * @param pCluster1 the cluster from the first input view
137  * @param pCluster2 the cluster from the second input view
138  * @param commonMuonPfoList the list of common cosmic ray pfos
139  * @param matchedClusters the list of third view matched clusters
140  * @param reducedChiSquared to receive the calculated reduced chi-squared value
141  *
142  * @return the address of the best matched third view cluster
143  */
144  const pandora::Cluster *GetBestMatchedCluster(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2,
145  const pandora::PfoList &commonMuonPfoList, const pandora::ClusterList &matchedClusters, float &reducedChiSquared) const;
146 
147  /**
148  * @brief Form the third view cluster by removing hits from cosmic ray clusters and merging the matched clusters where appropriate
149  *
150  * @param element the matrix element
151  * @param protoParticle the output proto particle
152  */
153  void FormThirdViewCluster(const MatrixType::Element &element, ProtoParticle &protoParticle);
154 
155  /**
156  * @brief Starting with an input seed cluster, sequentially merge in matched clusters that retain a good reduced chi-squared
157  *
158  * @param element the matrix element
159  * @param pSeedCluster the address of the input seed cluster
160  */
161  void MergeThirdView(const MatrixType::Element &element, const pandora::Cluster *const pSeedCluster);
162 
164  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
165 
166  typedef std::vector<DeltaRayMatrixTool *> MatrixToolVector;
167 
168  std::string m_inputClusterListName; ///< The name of the cluster list in the view in which to project into
169  std::string m_reclusteringAlgorithmName; ///< The name of the clustering algorithm to be used to recluster created delta ray remnants
170  MatrixToolVector m_algorithmToolVector; ///< The algorithm tool vector
171  unsigned int m_nMaxMatrixToolRepeats; ///< The maximum number of repeat loops over matrix tools
172  unsigned int m_minClusterCaloHits; ///< The threshold number of hits for a cluster to be considered
173  float m_maxDistanceFromPrediction; ///< The maximum distance of a matched cluster from the third view projection points
174  float m_maxGoodMatchReducedChiSquared; ///< The maximum reduced chi squared value of a good 1:1:1 match
175  float m_minDistanceFromMuon; ///< The minimum distance of a hit from the cosmic ray track required for removal
176  float m_maxDistanceToCollected; ///< The maximim distance of a hit from the projected delta ray hits required for removal
177 };
178 
179 //------------------------------------------------------------------------------------------------------------------------------------------
180 
182 {
183  return m_inputClusterListName;
184 }
185 
186 //------------------------------------------------------------------------------------------------------------------------------------------
187 
189 {
191 }
192 
193 //------------------------------------------------------------------------------------------------------------------------------------------
194 //------------------------------------------------------------------------------------------------------------------------------------------
195 
196 /**
197  * @brief DeltaRayTensorTool class
198  */
199 class DeltaRayMatrixTool : public pandora::AlgorithmTool
200 {
201 public:
203  typedef std::vector<MatrixType::ElementList::const_iterator> IteratorList;
204 
205  /**
206  * @brief Run the algorithm tool
207  *
208  * @param pAlgorithm address of the calling algorithm
209  * @param overlapTensor the overlap tensor
210  *
211  * @return whether changes have been made by the tool
212  */
213  virtual bool Run(TwoViewDeltaRayMatchingAlgorithm *const pAlgorithm, MatrixType &matrixTensor) = 0;
214 
215  TwoViewDeltaRayMatchingAlgorithm *m_pParentAlgorithm; ///< Address of the parent matching algorithm
216 };
217 
218 } // namespace lar_content
219 
220 #endif // #ifndef LAR_TWO_VIEW_DELTA_RAY_MATCHING_ALGORITHM_H
Header file for the kd tree linker algo template class.
unsigned int m_minClusterCaloHits
The threshold number of hits for a cluster to be considered.
std::string m_inputClusterListName
The name of the cluster list in the view in which to project into.
void FormThirdViewCluster(const MatrixType::Element &element, ProtoParticle &protoParticle)
Form the third view cluster by removing hits from cosmic ray clusters and merging the matched cluster...
unsigned int m_nMaxMatrixToolRepeats
The maximum number of repeat loops over matrix tools.
const std::string & GetThirdViewClusterListName() const
Get the name of the third view clusters.
float m_maxGoodMatchReducedChiSquared
The maximum reduced chi squared value of a good 1:1:1 match.
MatrixToolVector m_algorithmToolVector
The algorithm tool vector.
void ExamineOverlapContainer()
Examine contents of overlap container, collect together best-matching 2D particles and modify cluster...
float m_maxDistanceFromPrediction
The maximum distance of a matched cluster from the third view projection points.
void CalculateOverlapResult(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3)
Calculate cluster overlap result and store in container.
float m_maxDistanceToCollected
The maximim distance of a hit from the projected delta ray hits required for removal.
virtual bool DoesClusterPassTensorThreshold(const pandora::Cluster *const pCluster) const
To check whether a given cluster meets the requirements to be added into the matching container (tens...
virtual bool Run(TwoViewDeltaRayMatchingAlgorithm *const pAlgorithm, MatrixType &matrixTensor)=0
Run the algorithm tool.
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
const pandora::Cluster * GetBestMatchedCluster(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::PfoList &commonMuonPfoList, const pandora::ClusterList &matchedClusters, float &reducedChiSquared) const
Determine the best matched third view cluster and calculate the reduced chi-squared value of the thre...
void FindCommonMuonParents(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::PfoList &commonMuonPfoList) const
Find the cosmic ray pfos that, in each view, lie close to the clusters of the matrix element...
HitTypeVector GetHitTypeVector()
Obtain the HitTypeVector of input views.
std::vector< MatrixType::ElementList::const_iterator > IteratorList
void CollectThirdViewClusters(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::CartesianPointVector &projectedPositions, pandora::ClusterList &matchedClusters) const
Collect the available and unavailable third view clusters that lie close to the projected delta ray h...
float m_minDistanceFromMuon
The minimum distance of a hit from the cosmic ray track required for removal.
std::string m_reclusteringAlgorithmName
The name of the clustering algorithm to be used to recluster created delta ray remnants.
void MergeThirdView(const MatrixType::Element &element, const pandora::Cluster *const pSeedCluster)
Starting with an input seed cluster, sequentially merge in matched clusters that retain a good reduce...
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
bool CreatePfo(const MatrixType::Element &element)
Create delta ray pfos out of a given element, merging the third view clusters together and adding in ...
TwoViewDeltaRayMatchingAlgorithm::MatchingType::MatrixType MatrixType
void UpdateForThirdViewClusterModification(const pandora::Cluster *const pModifiedCluster, const bool isMuon)
Update the matrix after a third view cluster modification - remove delta ray clusters and reassess th...
TwoViewDeltaRayMatchingAlgorithm::MatchingType::MatrixType MatrixType
Header file for the two view matching control class.
Header file for the lar track two view overlap result class.
const std::string & GetClusteringAlgName() const
Get the name of the clustering algorithm to be used to recluster created delta ray remnants...
NViewDeltaRayMatchingAlgorithm< TwoViewMatchingControl< TwoViewDeltaRayOverlapResult > > BaseAlgorithm