MatchingBaseAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArThreeDBase/MatchingBaseAlgorithm.h
3  *
4  * @brief Header file for the three dimension algorithm base class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_MATCHING_BASE_ALGORITHM_H
9 #define LAR_MATCHING_BASE_ALGORITHM_H 1
10 
11 #include "Api/PandoraContentApi.h"
12 
13 #include "Pandora/Algorithm.h"
14 
15 #include <unordered_map>
16 #include <vector>
17 
18 namespace lar_content
19 {
20 
21 /**
22  * @brief ProtoParticle
23  */
25 {
26 public:
27  pandora::ClusterList m_clusterList; ///< List of 2D clusters in a 3D proto particle
28 };
29 
30 typedef std::vector<ProtoParticle> ProtoParticleVector;
31 typedef std::unordered_map<const pandora::Cluster *, pandora::ClusterList> ClusterMergeMap;
32 
33 //------------------------------------------------------------------------------------------------------------------------------------------
34 
35 /**
36  * @brief MatchingBaseAlgorithm class
37  */
38 class MatchingBaseAlgorithm : public pandora::Algorithm
39 {
40 public:
41  /**
42  * @brief Default constructor
43  */
45 
46  /**
47  * @brief Destructor
48  */
49  virtual ~MatchingBaseAlgorithm();
50 
51  /**
52  * @brief Update to reflect addition of a new cluster to the problem space
53  *
54  * @param pNewCluster address of the new cluster
55  */
56  virtual void UpdateForNewCluster(const pandora::Cluster *const pNewCluster) = 0;
57 
58  /**
59  * @brief Update to reflect cluster deletion
60  *
61  * @param pDeletedCluster address of the deleted cluster
62  */
63  virtual void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster) = 0;
64 
65  /**
66  * @brief Get the cluster list name corresponding to a specified hit type
67  *
68  * @param hitType the hit type
69  *
70  * @return the cluster list name
71  */
72  virtual const std::string &GetClusterListName(const pandora::HitType hitType) const = 0;
73 
74  /**
75  * @brief Get the input cluster list corresponding to a specified hit type
76  *
77  * @param hitType the hit type
78  *
79  * @return the input cluster list
80  */
81  virtual const pandora::ClusterList &GetInputClusterList(const pandora::HitType hitType) const = 0;
82 
83  /**
84  * @brief Get the selected cluster list corresponding to a specified hit type
85  *
86  * @param hitType the hit type
87  *
88  * @return the selected cluster list
89  */
90  virtual const pandora::ClusterList &GetSelectedClusterList(const pandora::HitType hitType) const = 0;
91 
92  /**
93  * @brief Calculate cluster overlap result and store in container
94  *
95  * @param pCluster1 address of cluster1
96  * @param pCluster2 address of cluster2
97  * @param pCluster3 address of cluster3
98  */
99  virtual void CalculateOverlapResult(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2,
100  const pandora::Cluster *const pCluster3 = nullptr) = 0;
101 
102  /**
103  * @brief Select a subset of input clusters for processing in this algorithm
104  *
105  * @param pInputClusterList address of an input cluster list
106  * @param selectedClusterList to receive the selected cluster list
107  */
108  virtual void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const;
109 
110  /**
111  * @brief Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results
112  *
113  * @param preparedClusterList to receive the prepared cluster list, non const so as to be able to modify input selected list
114  */
115  virtual void PrepareInputClusters(pandora::ClusterList &preparedClusterList);
116 
117  /**
118  * @brief Merge clusters together
119  *
120  * @param clusterMergeMap the cluster merge map
121  *
122  * @return whether changes to the overlap container have been made
123  */
124  virtual bool MakeClusterMerges(const ClusterMergeMap &clusterMergeMap);
125 
126  /**
127  * @brief Create particles using findings from recent algorithm processing
128  *
129  * @param protoParticleVector the proto particle vector
130  *
131  * @param whether particles were created
132  */
133  virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector);
134 
135  /**
136  * @brief Set Pfo properties
137  *
138  * @param protoParticle the input proto particle
139  * @param pfoParameters the output pfo parameters
140  */
141  virtual void SetPfoParameters(const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const;
142 
143  /**
144  * @brief Set pfo particle id
145  *
146  * @param pfoParameters the output pfo parameters
147  */
148  virtual void SetPfoParticleId(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const;
149 
150 protected:
151  /**
152  * @brief Select a subset of input clusters for processing in this algorithm
153  */
154  virtual void SelectAllInputClusters() = 0;
155 
156  /**
157  * @brief Perform any preparatory steps required, e.g. caching expensive fit results for clusters
158  */
159  virtual void PrepareAllInputClusters() = 0;
160 
161  /**
162  * @brief Main loop over cluster combinations in order to populate the overlap container. Responsible for calling CalculateOverlapResult.
163  */
164  virtual void PerformMainLoop() = 0;
165 
166  /**
167  * @brief Examine contents of overlap container, collect together best-matching 2D particles and modify clusters as required
168  */
169  virtual void ExamineOverlapContainer() = 0;
170 
171  /**
172  * @brief Tidy member variables in derived class
173  */
174  virtual void TidyUp() = 0;
175 
176  virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
177 
178 private:
179  pandora::StatusCode Run();
180 
181  std::string m_outputPfoListName; ///< The output pfo list name
182 };
183 
184 } // namespace lar_content
185 
186 #endif // #ifndef LAR_MATCHING_BASE_ALGORITHM_H
std::vector< ProtoParticle > ProtoParticleVector
enum cvn::HType HitType
std::string string
Definition: nybbler.cc:12
MatchingBaseAlgorithm class.
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
std::string m_outputPfoListName
The output pfo list name.