All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lar_content::IsolatedClusterMopUpAlgorithm Class Reference

IsolatedClusterMopUpAlgorithm class. More...

#include <IsolatedClusterMopUpAlgorithm.h>

Inheritance diagram for lar_content::IsolatedClusterMopUpAlgorithm:
lar_content::ClusterMopUpBaseAlgorithm lar_content::MopUpBaseAlgorithm

Public Member Functions

 IsolatedClusterMopUpAlgorithm ()
 Default constructor. More...
 
- Public Member Functions inherited from lar_content::ClusterMopUpBaseAlgorithm
 ClusterMopUpBaseAlgorithm ()
 Default constructor. More...
 
- Public Member Functions inherited from lar_content::MopUpBaseAlgorithm
template<typename T >
const std::string GetListName (const T *const pT) const
 Find the name of the list hosting a specific object. More...
 

Private Types

typedef std::unordered_map
< const pandora::CaloHit
*, const pandora::Cluster * > 
CaloHitToClusterMap
 
typedef KDTreeLinkerAlgo
< const pandora::CaloHit *, 2 > 
HitKDTree2D
 
typedef KDTreeNodeInfoT< const
pandora::CaloHit *, 2 > 
HitKDNode2D
 
typedef std::vector< HitKDNode2DHitKDNode2DList
 

Private Member Functions

void ClusterMopUp (const pandora::ClusterList &pfoClusters, const pandora::ClusterList &remnantClusters) const
 Cluster mop up for a single view. This function is responsible for instructing pandora to make cluster alterations. More...
 
void DissolveClustersToHits (const pandora::ClusterList &clusterList, pandora::CaloHitList &caloHitList) const
 Examine a list of clusters, identify and delete remnants; receive the list of newly available hits. More...
 
void GetCaloHitToClusterMap (const pandora::CaloHitList &caloHitList, const pandora::ClusterList &clusterList, CaloHitToClusterMap &caloHitToClusterMap) const
 Look for isolated hit additions, considering a list of candidate hits and a list of host clusters. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

unsigned int m_maxCaloHitsInCluster
 The maximum number of hits in a cluster to be dissolved. More...
 
float m_maxHitClusterDistance
 The maximum hit to cluster distance for isolated hit merging. More...
 
bool m_addHitsAsIsolated
 Whether to add hits to clusters as "isolated" (don't contribute to spatial properties) More...
 

Additional Inherited Members

- Protected Types inherited from lar_content::ClusterMopUpBaseAlgorithm
typedef std::unordered_map
< const pandora::Cluster
*, float > 
AssociationDetails
 
typedef std::unordered_map
< const pandora::Cluster
*, AssociationDetails
ClusterAssociationMap
 
- Protected Member Functions inherited from lar_content::ClusterMopUpBaseAlgorithm
virtual pandora::StatusCode Run ()
 
virtual void GetPfoClusterLists (pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
 Get the two dimensional clusters contained in the input pfo list, divided into three different views. More...
 
virtual void GetDaughterClusterLists (pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
 Get the two dimensional clusters contained in the input remant/daughter cluster lists, divided into three different views. More...
 
virtual void GetClusterLists (const pandora::ClusterList &inputClusterList, const bool availabilityFlag, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
 Get the two dimensional clusters contained in an input cluster list, divided into three different views. More...
 
virtual void MakeClusterMerges (const ClusterAssociationMap &clusterAssociationMap) const
 Make the cluster merges specified in the cluster association map, using list name information in the cluster list name map. More...
 
- Protected Attributes inherited from lar_content::ClusterMopUpBaseAlgorithm
pandora::StringVector m_pfoListNames
 The list of pfo list names. More...
 
bool m_excludePfosContainingTracks
 Whether to exclude any pfos containing clusters flagged as fixed tracks. More...
 
- Protected Attributes inherited from lar_content::MopUpBaseAlgorithm
pandora::StringVector m_daughterListNames
 The list of potential daughter object list names. More...
 

Detailed Description

IsolatedClusterMopUpAlgorithm class.

Definition at line 30 of file IsolatedClusterMopUpAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::CaloHit *, const pandora::Cluster *> lar_content::IsolatedClusterMopUpAlgorithm::CaloHitToClusterMap
private

Definition at line 49 of file IsolatedClusterMopUpAlgorithm.h.

typedef KDTreeNodeInfoT<const pandora::CaloHit *, 2> lar_content::IsolatedClusterMopUpAlgorithm::HitKDNode2D
private

Definition at line 64 of file IsolatedClusterMopUpAlgorithm.h.

Definition at line 65 of file IsolatedClusterMopUpAlgorithm.h.

typedef KDTreeLinkerAlgo<const pandora::CaloHit *, 2> lar_content::IsolatedClusterMopUpAlgorithm::HitKDTree2D
private

Definition at line 63 of file IsolatedClusterMopUpAlgorithm.h.

Constructor & Destructor Documentation

lar_content::IsolatedClusterMopUpAlgorithm::IsolatedClusterMopUpAlgorithm ( )

Default constructor.

Definition at line 22 of file IsolatedClusterMopUpAlgorithm.cc.

22  :
26 {
27  // ATTN Default value differs from base class
29 }
bool m_excludePfosContainingTracks
Whether to exclude any pfos containing clusters flagged as fixed tracks.
unsigned int m_maxCaloHitsInCluster
The maximum number of hits in a cluster to be dissolved.
bool m_addHitsAsIsolated
Whether to add hits to clusters as &quot;isolated&quot; (don&#39;t contribute to spatial properties) ...
float m_maxHitClusterDistance
The maximum hit to cluster distance for isolated hit merging.

Member Function Documentation

void lar_content::IsolatedClusterMopUpAlgorithm::ClusterMopUp ( const pandora::ClusterList &  pfoClusters,
const pandora::ClusterList &  remnantClusters 
) const
privatevirtual

Cluster mop up for a single view. This function is responsible for instructing pandora to make cluster alterations.

Parameters
pfoClustersthe list of pfo clusters
remnantClustersthe list of remnant clusters

Implements lar_content::ClusterMopUpBaseAlgorithm.

Definition at line 33 of file IsolatedClusterMopUpAlgorithm.cc.

34 {
35  CaloHitList caloHitList;
36  this->DissolveClustersToHits(remnantClusters, caloHitList);
37 
38  // ATTN remnantClusters now contains dangling pointers
39  CaloHitToClusterMap caloHitToClusterMap;
40  this->GetCaloHitToClusterMap(caloHitList, pfoClusters, caloHitToClusterMap);
41 
42  CaloHitList sortedCaloHitList;
43  for (const auto &mapEntry : caloHitToClusterMap)
44  sortedCaloHitList.push_back(mapEntry.first);
45  sortedCaloHitList.sort(LArClusterHelper::SortHitsByPosition);
46 
47  for (const CaloHit *pCaloHit : sortedCaloHitList)
48  {
50  {
51  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddIsolatedToCluster(*this, caloHitToClusterMap.at(pCaloHit), pCaloHit));
52  }
53  else
54  {
55  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, caloHitToClusterMap.at(pCaloHit), pCaloHit));
56  }
57  }
58 }
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > CaloHitToClusterMap
void DissolveClustersToHits(const pandora::ClusterList &clusterList, pandora::CaloHitList &caloHitList) const
Examine a list of clusters, identify and delete remnants; receive the list of newly available hits...
bool m_addHitsAsIsolated
Whether to add hits to clusters as &quot;isolated&quot; (don&#39;t contribute to spatial properties) ...
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
void GetCaloHitToClusterMap(const pandora::CaloHitList &caloHitList, const pandora::ClusterList &clusterList, CaloHitToClusterMap &caloHitToClusterMap) const
Look for isolated hit additions, considering a list of candidate hits and a list of host clusters...
void lar_content::IsolatedClusterMopUpAlgorithm::DissolveClustersToHits ( const pandora::ClusterList &  clusterList,
pandora::CaloHitList &  caloHitList 
) const
private

Examine a list of clusters, identify and delete remnants; receive the list of newly available hits.

Parameters
clusterListthe list of clusters to consider
caloHitListto receive the list of newly available hits

Definition at line 62 of file IsolatedClusterMopUpAlgorithm.cc.

63 {
64  for (const Cluster *const pRemnantCluster : clusterList)
65  {
66  if (pRemnantCluster->GetNCaloHits() < m_maxCaloHitsInCluster)
67  {
68  const std::string listNameR(this->GetListName(pRemnantCluster));
69  pRemnantCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
70  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pRemnantCluster, listNameR));
71  }
72  }
73 }
unsigned int m_maxCaloHitsInCluster
The maximum number of hits in a cluster to be dissolved.
const std::string GetListName(const T *const pT) const
Find the name of the list hosting a specific object.
void lar_content::IsolatedClusterMopUpAlgorithm::GetCaloHitToClusterMap ( const pandora::CaloHitList &  caloHitList,
const pandora::ClusterList &  clusterList,
CaloHitToClusterMap caloHitToClusterMap 
) const
private

Look for isolated hit additions, considering a list of candidate hits and a list of host clusters.

Parameters
caloHitListthe list of hits to consider
clusterListthe list of clusters to consider
caloHitToClusterMapto receive the calo hit to cluster map

Definition at line 77 of file IsolatedClusterMopUpAlgorithm.cc.

79 {
80  CaloHitList allCaloHits;
81  CaloHitToClusterMap hitToParentClusterMap;
82 
83  for (const Cluster *const pCluster : clusterList)
84  {
85  CaloHitList daughterHits;
86  pCluster->GetOrderedCaloHitList().FillCaloHitList(daughterHits);
87  allCaloHits.insert(allCaloHits.end(), daughterHits.begin(), daughterHits.end());
88 
89  for (const CaloHit *const pCaloHit : daughterHits)
90  (void)hitToParentClusterMap.insert(CaloHitToClusterMap::value_type(pCaloHit, pCluster));
91  }
92 
93  HitKDTree2D kdTree;
94  HitKDNode2DList hitKDNode2DList;
95 
96  KDTreeBox hitsBoundingRegion2D(fill_and_bound_2d_kd_tree(allCaloHits, hitKDNode2DList));
97  kdTree.build(hitKDNode2DList, hitsBoundingRegion2D);
98 
99  for (const CaloHit *const pCaloHit : caloHitList)
100  {
101  if (!PandoraContentApi::IsAvailable(*this, pCaloHit))
102  throw StatusCodeException(STATUS_CODE_FAILURE);
103 
104  const HitKDNode2D *pResultHit(nullptr);
105  float resultDistance(std::numeric_limits<float>::max());
106  const HitKDNode2D targetHit(pCaloHit, pCaloHit->GetPositionVector().GetX(), pCaloHit->GetPositionVector().GetZ());
107  kdTree.findNearestNeighbour(targetHit, pResultHit, resultDistance);
108 
109  if (pResultHit && (resultDistance < m_maxHitClusterDistance))
110  (void)caloHitToClusterMap.insert(CaloHitToClusterMap::value_type(pCaloHit, hitToParentClusterMap.at(pResultHit->data)));
111  }
112 }
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > CaloHitToClusterMap
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
j template void())
Definition: json.hpp:3108
float m_maxHitClusterDistance
The maximum hit to cluster distance for isolated hit merging.
KDTreeBox fill_and_bound_2d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 2 >> &nodes)
fill_and_bound_2d_kd_tree
KDTreeBoxT< 2 > KDTreeBox
StatusCode lar_content::IsolatedClusterMopUpAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterMopUpBaseAlgorithm.

Definition at line 116 of file IsolatedClusterMopUpAlgorithm.cc.

117 {
118  PANDORA_RETURN_RESULT_IF_AND_IF(
119  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxCaloHitsInCluster", m_maxCaloHitsInCluster));
120 
121  PANDORA_RETURN_RESULT_IF_AND_IF(
122  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxHitClusterDistance", m_maxHitClusterDistance));
123 
124  PANDORA_RETURN_RESULT_IF_AND_IF(
125  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "AddHitsAsIsolated", m_addHitsAsIsolated));
126 
127  return ClusterMopUpBaseAlgorithm::ReadSettings(xmlHandle);
128 }
unsigned int m_maxCaloHitsInCluster
The maximum number of hits in a cluster to be dissolved.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
bool m_addHitsAsIsolated
Whether to add hits to clusters as &quot;isolated&quot; (don&#39;t contribute to spatial properties) ...
float m_maxHitClusterDistance
The maximum hit to cluster distance for isolated hit merging.

Member Data Documentation

bool lar_content::IsolatedClusterMopUpAlgorithm::m_addHitsAsIsolated
private

Whether to add hits to clusters as "isolated" (don't contribute to spatial properties)

Definition at line 69 of file IsolatedClusterMopUpAlgorithm.h.

unsigned int lar_content::IsolatedClusterMopUpAlgorithm::m_maxCaloHitsInCluster
private

The maximum number of hits in a cluster to be dissolved.

Definition at line 67 of file IsolatedClusterMopUpAlgorithm.h.

float lar_content::IsolatedClusterMopUpAlgorithm::m_maxHitClusterDistance
private

The maximum hit to cluster distance for isolated hit merging.

Definition at line 68 of file IsolatedClusterMopUpAlgorithm.h.


The documentation for this class was generated from the following files: