CosmicRayBaseMatchingAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArCosmicRay/CosmicRayBaseMatchingAlgorithm.h
3  *
4  * @brief Header file for the cosmic ray base matching algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_COSMIC_RAY_BASE_MATCHING_ALGORITHM_H
9 #define LAR_COSMIC_RAY_BASE_MATCHING_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 #include "Pandora/AlgorithmHeaders.h"
13 
14 #include <unordered_map>
15 
16 namespace lar_content
17 {
18 
19 /**
20  * @brief CosmicRayBaseMatchingAlgorithm class
21  */
22 class CosmicRayBaseMatchingAlgorithm : public pandora::Algorithm
23 {
24 protected:
25  pandora::StatusCode Run();
26  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
27 
28  /**
29  * @brief Particle class
30  */
31  class Particle
32  {
33  public:
34  /**
35  * @brief Constructor
36  *
37  * @param pClusterU the cluster in the U view
38  * @param pClusterV the cluster in the V view
39  * @param pClusterW the cluster in the W view
40  */
41  Particle(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW);
42 
43  const pandora::Cluster *m_pClusterU; ///< Address of cluster in U view
44  const pandora::Cluster *m_pClusterV; ///< Address of cluster in V view
45  const pandora::Cluster *m_pClusterW; ///< Address of cluster in W view
46  };
47 
48  typedef std::vector<Particle> ParticleList;
49  typedef std::unordered_map<const pandora::Cluster *, pandora::ClusterList> ClusterAssociationMap;
50  typedef std::set<unsigned int> UIntSet;
51 
52  /**
53  * @brief Select a set of clusters judged to be clean
54  *
55  * @param inputVector the input vector of all available clusters
56  * @param outputVector the output vector of clean clusters
57  */
58  virtual void SelectCleanClusters(const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const = 0;
59 
60  /**
61  * @brief Match a pair of clusters from two views
62  *
63  * @param pCluster1 the first cluster
64  * @param pCluster2 the second cluster
65  *
66  * @return boolean
67  */
68  virtual bool MatchClusters(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const = 0;
69 
70  /**
71  * @brief Check that three clusters have a consistent 3D position
72  *
73  * @param pCluster1 the cluster from the first view
74  * @param pCluster2 the cluster from the second view
75  * @param pCluster3 the cluster from the third view
76  *
77  * @return boolean
78  */
79  virtual bool CheckMatchedClusters3D(
80  const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3) const = 0;
81 
82  /**
83  * @brief Calculate Pfo properties from proto particle
84  *
85  * @param protoParticle the input proto particle
86  * @param pfoParameters the output pfo parameters
87  */
88  virtual void SetPfoParameters(const CosmicRayBaseMatchingAlgorithm::Particle &protoParticle,
89  PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const = 0;
90 
91 private:
92  /**
93  * @brief Get a vector of available clusters
94  *
95  * @param inputClusterListName the input name of the cluster list
96  * @param clusterVector the output vector of available clusters
97  */
98  pandora::StatusCode GetAvailableClusters(const std::string inputClusterListName, pandora::ClusterVector &clusterVector) const;
99  /**
100  * @brief Match sets of clusters from two views
101  *
102  * @param clusterVector1 the vector of clusters from the first view
103  * @param clusterVector2 the vector of clusters from the second view
104  * @param matchedClusters12 the map of cluster matches
105  */
106  void MatchClusters(const pandora::ClusterVector &clusterVector1, const pandora::ClusterVector &clusterVector2,
108 
109  /**
110  * @brief Match clusters from three views and form into particles
111  *
112  * @param matchedClusters12 the map of matches between the view 1 and view 2
113  * @param matchedClusters23 the map of matches between the view 2 and view 3
114  * @param matchedClusters31 the map of matches between the view 3 and view 1
115  * @param particleList the output list of particles
116  */
119  const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters31, ParticleList &particleList) const;
120 
121  /**
122  * @brief Match clusters from two views and form into particles
123  *
124  * @param matchedClusters12 the map of matches between the view 1 and view 2
125  * @param matchedClusters23 the map of matches between the view 2 and view 3
126  * @param matchedClusters31 the map of matches between the view 3 and view 1
127  * @param particleList the output list of particles
128  */
131  const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters31, ParticleList &particleList) const;
132 
133  /**
134  * @brief Match clusters from two views and form into particles
135  *
136  * @param matchedClusters12 the map of matches between the first and second views
137  * @param particleList the output list of particles
138  */
139  void MatchTwoViews(const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters12, ParticleList &particleList) const;
140 
141  /**
142  * @brief Remove ambiguities between candidate particles
143  *
144  * @param inputList the input list of particles
145  * @param outputList the output list of particles
146  */
147  void ResolveAmbiguities(const ParticleList &inputList, ParticleList &outputList) const;
148 
149  /**
150  * @brief Build PFO objects from candidate particles
151  *
152  * @param particleList the input list of particles
153  */
154  void BuildParticles(const ParticleList &particleList);
155 
156  std::string m_inputClusterListNameU; ///< The name of the view U cluster list
157  std::string m_inputClusterListNameV; ///< The name of the view V cluster list
158  std::string m_inputClusterListNameW; ///< The name of the view W cluster list
159  std::string m_outputPfoListName; ///< The name of the output PFO list
160 };
161 
162 } // namespace lar_content
163 
164 #endif // #ifndef LAR_COSMIC_RAY_BASE_MATCHING_ALGORITHM_H
std::string m_inputClusterListNameV
The name of the view V cluster list.
void BuildParticles(const ParticleList &particleList)
Build PFO objects from candidate particles.
void MatchThreeViews(const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters12, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters23, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters31, ParticleList &particleList) const
Match clusters from three views and form into particles.
std::string string
Definition: nybbler.cc:12
virtual void SetPfoParameters(const CosmicRayBaseMatchingAlgorithm::Particle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const =0
Calculate Pfo properties from proto particle.
const pandora::Cluster * m_pClusterV
Address of cluster in V view.
virtual bool MatchClusters(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const =0
Match a pair of clusters from two views.
const pandora::Cluster * m_pClusterW
Address of cluster in W view.
std::string m_outputPfoListName
The name of the output PFO list.
const pandora::Cluster * m_pClusterU
Address of cluster in U view.
void MatchTwoViews(const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters12, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters23, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters31, ParticleList &particleList) const
Match clusters from two views and form into particles.
virtual bool CheckMatchedClusters3D(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3) const =0
Check that three clusters have a consistent 3D position.
pandora::StatusCode GetAvailableClusters(const std::string inputClusterListName, pandora::ClusterVector &clusterVector) const
Get a vector of available clusters.
Particle(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Constructor.
std::string m_inputClusterListNameU
The name of the view U cluster list.
std::string m_inputClusterListNameW
The name of the view W cluster list.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void ResolveAmbiguities(const ParticleList &inputList, ParticleList &outputList) const
Remove ambiguities between candidate particles.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterAssociationMap
virtual void SelectCleanClusters(const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const =0
Select a set of clusters judged to be clean.