LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TransverseAssociationAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_TRANSVERSE_ASSOCIATION_ALGORITHM_H
9 #define LAR_TRANSVERSE_ASSOCIATION_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 
27 {
28 public:
33 
34 private:
39  {
40  public:
47  LArTransverseCluster(const pandora::Cluster *const pSeedCluster, const pandora::ClusterVector &associatedClusters);
48 
54  const pandora::Cluster *GetSeedCluster() const;
55 
62 
68  const pandora::CartesianVector &GetInnerVertex() const;
69 
75  const pandora::CartesianVector &GetOuterVertex() const;
76 
82  const pandora::CartesianVector &GetDirection() const;
83 
84  private:
85  const pandora::Cluster *m_pSeedCluster;
87  pandora::CartesianVector m_innerVertex;
88  pandora::CartesianVector m_outerVertex;
89  pandora::CartesianVector m_direction;
90  };
91 
92  typedef std::vector<LArTransverseCluster*> TransverseClusterList;
93 
96  typedef std::vector<HitKDNode2D> HitKDNode2DList;
97 
98  typedef std::unordered_map<const pandora::Cluster*, pandora::ClusterSet> ClusterToClustersMap;
99  typedef std::unordered_map<const pandora::CaloHit*, const pandora::Cluster*> HitToClusterMap;
100 
101  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
102  void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const;
103  void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const;
104  bool IsExtremalCluster(const bool isForward, const pandora::Cluster *const pCurrentCluster, const pandora::Cluster *const pTestCluster) const;
105 
112  void GetNearbyClusterMap(const pandora::ClusterVector &allClusters, ClusterToClustersMap &nearbyClusters) const;
113 
123  void SortInputClusters(const pandora::ClusterVector &inputClusters, pandora::ClusterVector &shortClusters,
124  pandora::ClusterVector &transverseMediumClusters, pandora::ClusterVector &longitudinalMediumClusters,
125  pandora::ClusterVector &longClusters) const;
126 
135  void FillReducedAssociationMap(const ClusterToClustersMap &nearbyClusters, const pandora::ClusterVector &firstVector,
136  const pandora::ClusterVector &secondVector, ClusterAssociationMap &clusterAssociationMap) const;
137 
147  void FillAssociationMap(const ClusterToClustersMap &nearbyClusters, const pandora::ClusterVector &firstVector,
148  const pandora::ClusterVector &secondVector, ClusterAssociationMap &firstAssociationMap,
149  ClusterAssociationMap &secondAssociationMap) const;
150 
159  void FillTransverseClusterList(const ClusterToClustersMap &nearbyClusters, const pandora::ClusterVector &inputClusters,
160  const ClusterAssociationMap &inputAssociationMap, TransverseClusterList &transverseClusterList) const;
161 
170  void FillTransverseAssociationMap(const ClusterToClustersMap &nearbyClusters, const TransverseClusterList &transverseClusterList,
171  const ClusterAssociationMap &transverseAssociationMap, ClusterAssociationMap &clusterAssociationMap) const;
172 
181  void GetAssociatedClusters(const ClusterToClustersMap &nearbyClusters, const pandora::Cluster *const pCluster,
182  const ClusterAssociationMap &inputAssociationMap, pandora::ClusterVector &associatedClusters) const;
183 
194  bool IsAssociated(const bool isForward, const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2,
195  const ClusterToClustersMap &nearbyClusters) const;
196 
206  bool IsTransverseAssociated(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2,
207  const ClusterToClustersMap &nearbyClusters) const;
208 
218  bool IsTransverseAssociated(const LArTransverseCluster *const pTransverseCluster1, const LArTransverseCluster *const pTransverseCluster2,
219  const ClusterToClustersMap &nearbyClusters) const;
220 
229  bool IsTransverseAssociated(const LArTransverseCluster *const pTransverseCluster, const pandora::CartesianVector &testPosition) const;
230 
239  bool IsOverlapping(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const;
240 
246  float GetTransverseSpan(const pandora::Cluster *const pCluster) const;
247 
253  float GetLongitudinalSpan(const pandora::Cluster *const pCluster) const;
254 
261  float GetTransverseSpan(const pandora::Cluster *const pCluster, const pandora::ClusterVector &associatedClusters) const;
262 
270  void GetExtremalCoordinatesX(const pandora::Cluster *const pCluster, float &minX, float &maxX) const;
271 
279  void GetExtremalCoordinatesZ(const pandora::Cluster *const pCluster, float &minZ, float &maxZ) const;
280 
289  void GetExtremalCoordinatesXZ(const pandora::Cluster *const pCluster, const bool useX, float &minXZ, float &maxXZ) const;
290 
298  void GetExtremalCoordinatesX(const pandora::Cluster *const pCluster, pandora::CartesianVector &innerCoordinate,
299  pandora::CartesianVector &outerCoordinate) const;
300 
307  void FillReducedAssociationMap(const ClusterAssociationMap &inputAssociationMap, ClusterAssociationMap &outputAssociationMap) const;
308 
317  void FillReducedAssociationMap(const ClusterAssociationMap &firstAssociationMap, const ClusterAssociationMap &secondAssociationMap,
318  const ClusterAssociationMap &secondAssociationMapSwapped, ClusterAssociationMap &clusterAssociationMap) const;
319 
326  void FillSymmetricAssociationMap(const ClusterAssociationMap &inputAssociationMap, ClusterAssociationMap &outputAssociationMap) const;
327 
334  void FinalizeClusterAssociationMap(const ClusterAssociationMap &inputAssociationMap, ClusterAssociationMap &outputAssociationMap) const;
335 
338 
343 
347 
351 
354 };
355 
356 //------------------------------------------------------------------------------------------------------------------------------------------
357 
359 {
360  return m_pSeedCluster;
361 }
362 
363 //------------------------------------------------------------------------------------------------------------------------------------------
364 
366 {
367  return m_associatedClusters;
368 }
369 
370 //------------------------------------------------------------------------------------------------------------------------------------------
371 
372 inline const pandora::CartesianVector &TransverseAssociationAlgorithm::LArTransverseCluster::GetInnerVertex() const
373 {
374  return m_innerVertex;
375 }
376 
377 //------------------------------------------------------------------------------------------------------------------------------------------
378 
379 inline const pandora::CartesianVector &TransverseAssociationAlgorithm::LArTransverseCluster::GetOuterVertex() const
380 {
381  return m_outerVertex;
382 }
383 
384 //------------------------------------------------------------------------------------------------------------------------------------------
385 
386 inline const pandora::CartesianVector &TransverseAssociationAlgorithm::LArTransverseCluster::GetDirection() const
387 {
388  return m_direction;
389 }
390 
391 } // namespace lar_content
392 
393 #endif // #ifndef LAR_TRANSVERSE_ASSOCIATION_ALGORITHM_H
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const
Populate the cluster association map.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
const pandora::CartesianVector & GetInnerVertex() const
Get the inner vertex position.
float GetTransverseSpan(const pandora::Cluster *const pCluster) const
Calculate the overall span in X for a clusters.
Class that implements the KDTree partition of 2D space and a closest point search algorithm...
void FillTransverseAssociationMap(const ClusterToClustersMap &nearbyClusters, const TransverseClusterList &transverseClusterList, const ClusterAssociationMap &transverseAssociationMap, ClusterAssociationMap &clusterAssociationMap) const
Form associations between transverse cluster objects.
void GetExtremalCoordinatesXZ(const pandora::Cluster *const pCluster, const bool useX, float &minXZ, float &maxXZ) const
Get minimum and maximum X or Z coordinates for a given cluster.
bool IsExtremalCluster(const bool isForward, const pandora::Cluster *const pCurrentCluster, const pandora::Cluster *const pTestCluster) const
Determine which of two clusters is extremal.
void FillSymmetricAssociationMap(const ClusterAssociationMap &inputAssociationMap, ClusterAssociationMap &outputAssociationMap) const
Symmetrise an association map.
std::vector< LArTransverseCluster * > TransverseClusterList
bool IsTransverseAssociated(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const ClusterToClustersMap &nearbyClusters) const
Determine whether two clusters are within the same cluster window.
void FillAssociationMap(const ClusterToClustersMap &nearbyClusters, const pandora::ClusterVector &firstVector, const pandora::ClusterVector &secondVector, ClusterAssociationMap &firstAssociationMap, ClusterAssociationMap &secondAssociationMap) const
Form associations between two input lists of cluster.
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
bool IsOverlapping(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const
Determine whether two clusters are overlapping.
void GetExtremalCoordinatesX(const pandora::Cluster *const pCluster, float &minX, float &maxX) const
Get minimum and maximum X coordinates for a given cluster.
float m_searchRegionX
Search region, applied to x dimension, for look-up from kd-trees.
void SortInputClusters(const pandora::ClusterVector &inputClusters, pandora::ClusterVector &shortClusters, pandora::ClusterVector &transverseMediumClusters, pandora::ClusterVector &longitudinalMediumClusters, pandora::ClusterVector &longClusters) const
Separate input clusters by length.
Header file for the cluster association algorithm class.
void FillTransverseClusterList(const ClusterToClustersMap &nearbyClusters, const pandora::ClusterVector &inputClusters, const ClusterAssociationMap &inputAssociationMap, TransverseClusterList &transverseClusterList) const
Create transverse cluster objects, these are protoclusters with a direction and inner/outer vertices...
const pandora::CartesianVector & GetOuterVertex() const
Get the outer vertex position.
std::unordered_map< const pandora::Cluster *, pandora::ClusterSet > ClusterToClustersMap
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void FinalizeClusterAssociationMap(const ClusterAssociationMap &inputAssociationMap, ClusterAssociationMap &outputAssociationMap) const
Symmetrise and then remove double-counting from an association map.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const
Populate cluster vector with subset of cluster list, containing clusters judged to be clean...
void GetNearbyClusterMap(const pandora::ClusterVector &allClusters, ClusterToClustersMap &nearbyClusters) const
Use a kd-tree to obtain details of all nearby cluster combinations.
const pandora::CartesianVector & GetDirection() const
Get the direction.
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
bool IsAssociated(const bool isForward, const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const ClusterToClustersMap &nearbyClusters) const
Determine whether clusters are association.
void FillReducedAssociationMap(const ClusterToClustersMap &nearbyClusters, const pandora::ClusterVector &firstVector, const pandora::ClusterVector &secondVector, ClusterAssociationMap &clusterAssociationMap) const
Form a reduced set of associations between two input lists of clusters.
float GetLongitudinalSpan(const pandora::Cluster *const pCluster) const
Calculate the overall span in Z for a clusters.
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
float m_searchRegionZ
Search region, applied to u/v/w dimension, for look-up from kd-trees.
const pandora::ClusterVector & GetAssociatedClusters() const
Get the associated cluster vector.
void GetExtremalCoordinatesZ(const pandora::Cluster *const pCluster, float &minZ, float &maxZ) const
Get minimum and maximum Z coordinates for a given cluster.
LArTransverseCluster(const pandora::Cluster *const pSeedCluster, const pandora::ClusterVector &associatedClusters)
Constructor.