LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
DeltaRayMatchingAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_DELTA_RAY_MATCHING_ALGORITHM_H
9 #define LAR_DELTA_RAY_MATCHING_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
14 
15 namespace lar_content
16 {
17 
18 template<typename, unsigned int> class KDTreeLinkerAlgo;
19 template<typename, unsigned int> class KDTreeNodeInfoT;
20 
21 //------------------------------------------------------------------------------------------------------------------------------------------
22 
26 class DeltaRayMatchingAlgorithm : public pandora::Algorithm
27 {
28 public:
33 
34 private:
35  pandora::StatusCode Run();
36 
40  class Particle
41  {
42  public:
51  Particle(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3,
52  const pandora::ParticleFlowObject *const pPfo);
53 
57  const pandora::Cluster *GetClusterU() const;
58 
62  const pandora::Cluster *GetClusterV() const;
63 
67  const pandora::Cluster *GetClusterW() const;
68 
72  const pandora::ParticleFlowObject *GetParentPfo() const;
73 
77  unsigned int GetNViews() const;
78 
82  unsigned int GetNCaloHits() const;
83 
84  private:
85  const pandora::Cluster *m_pClusterU;
86  const pandora::Cluster *m_pClusterV;
87  const pandora::Cluster *m_pClusterW;
88  const pandora::ParticleFlowObject *m_pParentPfo;
89  };
90 
91  typedef std::vector<Particle> ParticleList;
92 
95  typedef std::vector<HitKDNode2D> HitKDNode2DList;
96 
97  typedef std::unordered_map<const pandora::Cluster*, pandora::ClusterList> ClusterToClustersMap;
98  typedef std::unordered_map<const pandora::CaloHit*, const pandora::Cluster*> HitToClusterMap;
99 
104 
111  void InitializeNearbyClusterMap(const std::string &clusterListName, ClusterToClustersMap &nearbyClusters);
112 
116  void ClearNearbyClusterMaps();
117 
124  void GetAllPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const;
125 
132  void GetTrackPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const;
133 
141  void GetClusters(const std::string &clusterListName, pandora::ClusterVector &clusterVector) const;
142 
143  typedef std::unordered_map<const pandora::Cluster*, float> ClusterLengthMap;
144  typedef std::unordered_map<const pandora::ParticleFlowObject*, float> PfoLengthMap;
145 
151  void ThreeViewMatching(ClusterLengthMap &clusterLengthMap) const;
152 
158  void TwoViewMatching(ClusterLengthMap &clusterLengthMap) const;
159 
165  void OneViewMatching(ClusterLengthMap &clusterLengthMap) const;
166 
177  void ThreeViewMatching(const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, const pandora::ClusterVector &clusters3,
178  ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, ParticleList &particleList) const;
179 
189  void TwoViewMatching(const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, ClusterLengthMap &clusterLengthMap,
190  PfoLengthMap &pfoLengthMap, ParticleList &particleList) const;
191 
200  void OneViewMatching(const pandora::ClusterVector &clusters, ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, ParticleList &particleList) const;
201 
209  void SelectParticles(const ParticleList &inputParticles, ClusterLengthMap &clusterLengthMap, ParticleList &outputParticles) const;
210 
216  void CreateParticles(const ParticleList &particleList) const;
217 
228  void FindBestParentPfo(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW,
229  ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, const pandora::ParticleFlowObject *&pBestPfo) const;
230 
239  float GetLengthFromCache(const pandora::Cluster *const pCluster, ClusterLengthMap &clusterLengthMap) const;
240 
249  float GetLengthFromCache(const pandora::ParticleFlowObject *const pPfo, PfoLengthMap &pfoLengthMap) const;
250 
259  float GetLength(const Particle &particle, ClusterLengthMap &clusterLengthMap) const;
260 
268  bool AreClustersMatched(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2,
269  const pandora::Cluster *const pCluster3) const;
270 
277  float GetDistanceSquaredToPfo(const pandora::Cluster *const pCluster, const pandora::ParticleFlowObject *const pPfo) const;
278 
285  void CreateDaughterPfo(const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const;
286 
293  void AddToDaughterPfo(const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const;
294 
295  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
296 
297  std::string m_parentPfoListName;
298  std::string m_daughterPfoListName;
299 
303 
304  unsigned int m_minCaloHitsPerCluster;
308 
310  ClusterToClustersMap m_nearbyClustersU;
311  ClusterToClustersMap m_nearbyClustersV;
312  ClusterToClustersMap m_nearbyClustersW;
313 };
314 
315 //------------------------------------------------------------------------------------------------------------------------------------------
316 //------------------------------------------------------------------------------------------------------------------------------------------
317 
318 inline const pandora::Cluster *DeltaRayMatchingAlgorithm::Particle::GetClusterU() const
319 {
320  return m_pClusterU;
321 }
322 
323 //------------------------------------------------------------------------------------------------------------------------------------------
324 inline const pandora::Cluster *DeltaRayMatchingAlgorithm::Particle::GetClusterV() const
325 {
326  return m_pClusterV;
327 }
328 
329 //------------------------------------------------------------------------------------------------------------------------------------------
330 inline const pandora::Cluster *DeltaRayMatchingAlgorithm::Particle::GetClusterW() const
331 {
332  return m_pClusterW;
333 }
334 
335 //------------------------------------------------------------------------------------------------------------------------------------------
336 inline const pandora::ParticleFlowObject *DeltaRayMatchingAlgorithm::Particle::GetParentPfo() const
337 {
338  return m_pParentPfo;
339 }
340 
341 } // namespace lar_content
342 
343 #endif // #ifndef LAR_DELTA_RAY_MATCHING_ALGORITHM_H
void InitializeNearbyClusterMap(const std::string &clusterListName, ClusterToClustersMap &nearbyClusters)
Initialize a nearby cluster map with details relating to a specific cluster list. ...
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_xOverlapWindow
The maximum allowed displacement in x position.
float m_pseudoChi2Cut
Pseudo chi2 cut for three view matching.
const pandora::Cluster * GetClusterV() const
Get cluster in V view.
Particle(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3, const pandora::ParticleFlowObject *const pPfo)
Constructor.
void GetTrackPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of track-like Pfos in the provided input Pfo lists.
ClusterToClustersMap m_nearbyClustersU
The nearby clusters map for the u view.
void TwoViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using pairs of views.
std::unordered_map< const pandora::Cluster *, float > ClusterLengthMap
ClusterToClustersMap m_nearbyClustersV
The nearby clusters map for the v view.
void CreateParticles(const ParticleList &particleList) const
Build new particle flow objects.
ClusterToClustersMap m_nearbyClustersW
The nearby clusters map for the w view.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterToClustersMap
unsigned int GetNCaloHits() const
Get number of calo hits.
Class that implements the KDTree partition of 2D space and a closest point search algorithm...
std::unordered_map< const pandora::ParticleFlowObject *, float > PfoLengthMap
unsigned int m_minCaloHitsPerCluster
The min number of calo hits per candidate cluster.
std::string m_inputClusterListNameV
The input cluster list name for the v view.
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
const pandora::Cluster * m_pClusterU
Address of cluster in U view.
void GetAllPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of all Pfos in the provided input Pfo lists.
std::string m_parentPfoListName
The parent pfo list name.
std::string m_inputClusterListNameW
The input cluster list name for the w view.
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-trees.
void OneViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using single views.
void ThreeViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using all three views.
Header file for the lar two dimensional sliding fit result class.
void InitializeNearbyClusterMaps()
Initialize nearby cluster maps.
float GetDistanceSquaredToPfo(const pandora::Cluster *const pCluster, const pandora::ParticleFlowObject *const pPfo) const
Get displacementr between cluster and particle flow object.
bool AreClustersMatched(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3) const
Look at consistency of a combination of clusters.
const pandora::ParticleFlowObject * GetParentPfo() const
Get parent Pfo.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void FindBestParentPfo(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, const pandora::ParticleFlowObject *&pBestPfo) const
Find best Pfo to associate a UVW triplet.
void AddToDaughterPfo(const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const
Merge an input cluster list with an existing daughter Pfo.
std::string m_inputClusterListNameU
The input cluster list name for the u view.
float m_distanceForMatching
The maximum allowed distance between tracks and delta rays.
const pandora::Cluster * GetClusterW() const
Get cluster in W view.
void CreateDaughterPfo(const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const
Create a new Pfo from an input cluster list and set up a parent/daughter relationship.
float GetLength(const Particle &particle, ClusterLengthMap &clusterLengthMap) const
Get the length (squared) of a candidate particle.
const pandora::ParticleFlowObject * m_pParentPfo
Address of parent Pfo.
void ClearNearbyClusterMaps()
Clear nearby cluster maps.
void SelectParticles(const ParticleList &inputParticles, ClusterLengthMap &clusterLengthMap, ParticleList &outputParticles) const
Resolve any ambiguities between candidate particles.
const pandora::Cluster * m_pClusterV
Address of cluster in V view.
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
void GetClusters(const std::string &clusterListName, pandora::ClusterVector &clusterVector) const
Get a vector containing all available input clusters in the provided cluster list, storing sliding linear fits in the algorithm cache.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
float GetLengthFromCache(const pandora::Cluster *const pCluster, ClusterLengthMap &clusterLengthMap) const
Reduce number of length (squared) calculations by caching results when they are first obtained...
const pandora::Cluster * m_pClusterW
Address of cluster in W view.
const pandora::Cluster * GetClusterU() const
Get cluster in U view.
unsigned int GetNViews() const
Get number of views.
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
std::string m_daughterPfoListName
The daughter pfo list name for new daughter particles.