LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LongitudinalAssociationAlgorithm Class Reference

LongitudinalAssociationAlgorithm class. More...

#include "LongitudinalAssociationAlgorithm.h"

Inheritance diagram for lar_content::LongitudinalAssociationAlgorithm:
lar_content::ClusterAssociationAlgorithm

Public Member Functions

 LongitudinalAssociationAlgorithm ()
 Default constructor. More...
 

Protected Types

typedef std::unordered_map< const pandora::Cluster *, ClusterAssociationClusterAssociationMap
 

Protected Member Functions

virtual pandora::StatusCode Run ()
 

Private Member Functions

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. More...
 
void PopulateClusterAssociationMap (const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const
 Populate the cluster association map. More...
 
bool IsExtremalCluster (const bool isForward, const pandora::Cluster *const pCurrentCluster, const pandora::Cluster *const pTestCluster) const
 Determine which of two clusters is extremal. More...
 
bool AreClustersAssociated (const pandora::Cluster *const pInnerCluster, const pandora::Cluster *const pOuterCluster) const
 Determine whether two clusters are associated. More...
 
bool AreClustersAssociated (const pandora::CartesianVector &innerClusterEnd, const pandora::CartesianVector &outerClusterStart, const pandora::ClusterFitResult &innerFit, const pandora::ClusterFitResult &outerFit) const
 Determine whether two clusters are associated. More...
 

Private Attributes

unsigned int m_minClusterLayers
 minimum allowed number of layers for a clean cluster More...
 
unsigned int m_maxGapLayers
 maximum allowed number of layers between associated clusters More...
 
unsigned int m_fitLayers
 number of layers to fit at start and end of cluster More...
 
float m_maxGapDistanceSquared
 maximum allowed distance (squared) between associated clusters More...
 
float m_minCosRelativeAngle
 maximum allowed relative angle between associated clusters More...
 
float m_maxTransverseDisplacement
 maximum allowed transverse displacement after extrapolation (normalised to cell size) More...
 
float m_maxLongitudinalDisplacement
 maximum allowed longitudinal displacement after extrapolation (normalised to cell size) More...
 
float m_hitSizeZ
 estimated hit size in z (wire number) dimension, units cm More...
 
float m_hitSizeX
 estimated hit size in x (drift time) dimension, units cm More...
 
pandora::HitType m_view
 The view to which the hits under consideration belong. More...
 

Detailed Description

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster *, ClusterAssociation> lar_content::ClusterAssociationAlgorithm::ClusterAssociationMap
protectedinherited

Definition at line 43 of file ClusterAssociationAlgorithm.h.

Constructor & Destructor Documentation

lar_content::LongitudinalAssociationAlgorithm::LongitudinalAssociationAlgorithm ( )

Default constructor.

Definition at line 21 of file LongitudinalAssociationAlgorithm.cc.

21  :
23  m_maxGapLayers(7),
24  m_fitLayers(30),
29  m_hitSizeZ(0.3f),
30  m_hitSizeX(0.5f),
31  m_view(TPC_3D)
32 {
33 }
float m_maxLongitudinalDisplacement
maximum allowed longitudinal displacement after extrapolation (normalised to cell size) ...
float m_minCosRelativeAngle
maximum allowed relative angle between associated clusters
pandora::HitType m_view
The view to which the hits under consideration belong.
unsigned int m_minClusterLayers
minimum allowed number of layers for a clean cluster
TFile f
Definition: plotHisto.C:6
float m_hitSizeX
estimated hit size in x (drift time) dimension, units cm
float m_maxGapDistanceSquared
maximum allowed distance (squared) between associated clusters
unsigned int m_maxGapLayers
maximum allowed number of layers between associated clusters
float m_hitSizeZ
estimated hit size in z (wire number) dimension, units cm
unsigned int m_fitLayers
number of layers to fit at start and end of cluster
float m_maxTransverseDisplacement
maximum allowed transverse displacement after extrapolation (normalised to cell size) ...

Member Function Documentation

bool lar_content::LongitudinalAssociationAlgorithm::AreClustersAssociated ( const pandora::Cluster *const  pInnerCluster,
const pandora::Cluster *const  pOuterCluster 
) const
private

Determine whether two clusters are associated.

Parameters
pInnerClusteraddress of the inner cluster
pOuterClusteraddress of the outer cluster
Returns
whether the clusters are associated

Referenced by IsExtremalCluster(), and PopulateClusterAssociationMap().

bool lar_content::LongitudinalAssociationAlgorithm::AreClustersAssociated ( const pandora::CartesianVector &  innerClusterEnd,
const pandora::CartesianVector &  outerClusterStart,
const pandora::ClusterFitResult &  innerFit,
const pandora::ClusterFitResult &  outerFit 
) const
private

Determine whether two clusters are associated.

Parameters
innerClusterEndinner cluster end position
outerClusterStartouter cluster start position
innerFitinner cluster fit result
outerFitouter cluster fit result
Returns
whether the clusters are associated
void lar_content::LongitudinalAssociationAlgorithm::GetListOfCleanClusters ( const pandora::ClusterList *const  pClusterList,
pandora::ClusterVector &  clusterVector 
) const
privatevirtual

Populate cluster vector with subset of cluster list, containing clusters judged to be clean.

Parameters
pClusterListaddress of the cluster list
clusterVectorto receive the populated cluster vector

Implements lar_content::ClusterAssociationAlgorithm.

Definition at line 37 of file LongitudinalAssociationAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), m_minClusterLayers, m_view, and lar_content::LArClusterHelper::SortByInnerLayer().

38 {
39  if (!pClusterList->empty())
40  m_view = LArClusterHelper::GetClusterHitType(pClusterList->front());
41 
42  for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
43  {
44  const Cluster *const pCluster = *iter;
45 
46  if (1 + pCluster->GetOuterPseudoLayer() - pCluster->GetInnerPseudoLayer() < m_minClusterLayers)
47  continue;
48 
49  clusterVector.push_back(pCluster);
50  }
51 
52  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByInnerLayer);
53 }
pandora::HitType m_view
The view to which the hits under consideration belong.
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
unsigned int m_minClusterLayers
minimum allowed number of layers for a clean cluster
static bool SortByInnerLayer(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by inner layer, then position, then pulse-height.
bool lar_content::LongitudinalAssociationAlgorithm::IsExtremalCluster ( const bool  isForward,
const pandora::Cluster *const  pCurrentCluster,
const pandora::Cluster *const  pTestCluster 
) const
privatevirtual

Determine which of two clusters is extremal.

Parameters
isForwardwhether propagation direction is forward
pCurrentClustercurrent extremal cluster
pTestClusterpotential extremal cluster
Returns
boolean

Implements lar_content::ClusterAssociationAlgorithm.

Definition at line 82 of file LongitudinalAssociationAlgorithm.cc.

References AreClustersAssociated(), lar_content::LArGeometryHelper::GetWirePitchRatio(), m_fitLayers, m_hitSizeX, m_hitSizeZ, m_maxGapDistanceSquared, m_maxGapLayers, m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, m_minCosRelativeAngle, m_view, and lar_content::LArClusterHelper::SortByNHits().

83 {
84  const unsigned int currentLayer(isForward ? pCurrentCluster->GetOuterPseudoLayer() : pCurrentCluster->GetInnerPseudoLayer());
85  const unsigned int testLayer(isForward ? pTestCluster->GetOuterPseudoLayer() : pTestCluster->GetInnerPseudoLayer());
86 
87  if (isForward && ((testLayer > currentLayer) || ((testLayer == currentLayer) && LArClusterHelper::SortByNHits(pTestCluster, pCurrentCluster))))
88  return true;
89 
90  if (!isForward && ((testLayer < currentLayer) || ((testLayer == currentLayer) && LArClusterHelper::SortByNHits(pTestCluster, pCurrentCluster))))
91  return true;
92 
93  return false;
94 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
void lar_content::LongitudinalAssociationAlgorithm::PopulateClusterAssociationMap ( const pandora::ClusterVector &  clusterVector,
ClusterAssociationMap clusterAssociationMap 
) const
privatevirtual

Populate the cluster association map.

Parameters
clusterVectorthe cluster vector
clusterAssociationMapto receive the populated cluster association map

Implements lar_content::ClusterAssociationAlgorithm.

Definition at line 57 of file LongitudinalAssociationAlgorithm.cc.

References AreClustersAssociated().

58 {
59  // ATTN This method assumes that clusters have been sorted by layer
60  for (ClusterVector::const_iterator iterI = clusterVector.begin(), iterIEnd = clusterVector.end(); iterI != iterIEnd; ++iterI)
61  {
62  const Cluster *const pInnerCluster = *iterI;
63 
64  for (ClusterVector::const_iterator iterJ = iterI, iterJEnd = clusterVector.end(); iterJ != iterJEnd; ++iterJ)
65  {
66  const Cluster *const pOuterCluster = *iterJ;
67 
68  if (pInnerCluster == pOuterCluster)
69  continue;
70 
71  if (!this->AreClustersAssociated(pInnerCluster, pOuterCluster))
72  continue;
73 
74  clusterAssociationMap[pInnerCluster].m_forwardAssociations.insert(pOuterCluster);
75  clusterAssociationMap[pOuterCluster].m_backwardAssociations.insert(pInnerCluster);
76  }
77  }
78 }
intermediate_table::const_iterator const_iterator
bool AreClustersAssociated(const pandora::Cluster *const pInnerCluster, const pandora::Cluster *const pOuterCluster) const
Determine whether two clusters are associated.
StatusCode lar_content::LongitudinalAssociationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterAssociationAlgorithm.

Definition at line 195 of file LongitudinalAssociationAlgorithm.cc.

References m_fitLayers, m_hitSizeX, m_hitSizeZ, m_maxGapDistanceSquared, m_maxGapLayers, m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, m_minClusterLayers, m_minCosRelativeAngle, and lar_content::ClusterAssociationAlgorithm::ReadSettings().

196 {
197  PANDORA_RETURN_RESULT_IF_AND_IF(
198  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterLayers", m_minClusterLayers));
199 
200  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxGapLayers", m_maxGapLayers));
201 
202  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FitLayers", m_fitLayers));
203 
204  float maxGapDistance = std::sqrt(m_maxGapDistanceSquared);
205  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxGapDistance", maxGapDistance));
206  m_maxGapDistanceSquared = maxGapDistance * maxGapDistance;
207 
208  PANDORA_RETURN_RESULT_IF_AND_IF(
209  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCosRelativeAngle", m_minCosRelativeAngle));
210 
211  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
212  XmlHelper::ReadValue(xmlHandle, "MaxTransverseDisplacement", m_maxTransverseDisplacement));
213 
214  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
215  XmlHelper::ReadValue(xmlHandle, "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
216 
217  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "HitSizeZ", m_hitSizeZ));
218 
219  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "HitSizeX", m_hitSizeX));
220 
222 }
float m_maxLongitudinalDisplacement
maximum allowed longitudinal displacement after extrapolation (normalised to cell size) ...
float m_minCosRelativeAngle
maximum allowed relative angle between associated clusters
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_minClusterLayers
minimum allowed number of layers for a clean cluster
float m_hitSizeX
estimated hit size in x (drift time) dimension, units cm
float m_maxGapDistanceSquared
maximum allowed distance (squared) between associated clusters
unsigned int m_maxGapLayers
maximum allowed number of layers between associated clusters
float m_hitSizeZ
estimated hit size in z (wire number) dimension, units cm
unsigned int m_fitLayers
number of layers to fit at start and end of cluster
float m_maxTransverseDisplacement
maximum allowed transverse displacement after extrapolation (normalised to cell size) ...
StatusCode lar_content::ClusterAssociationAlgorithm::Run ( )
protectedvirtualinherited

Definition at line 28 of file ClusterAssociationAlgorithm.cc.

References lar_content::ClusterAssociationAlgorithm::AmbiguousPropagation(), lar_content::ClusterAssociationAlgorithm::GetListOfCleanClusters(), lar_content::ClusterAssociationAlgorithm::m_mergeMade, lar_content::ClusterAssociationAlgorithm::m_resolveAmbiguousAssociations, lar_content::ClusterAssociationAlgorithm::PopulateClusterAssociationMap(), and lar_content::ClusterAssociationAlgorithm::UnambiguousPropagation().

29 {
30  const ClusterList *pClusterList = NULL;
31  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
32 
33  ClusterVector clusterVector;
34  this->GetListOfCleanClusters(pClusterList, clusterVector);
35 
36  ClusterAssociationMap clusterAssociationMap;
37  this->PopulateClusterAssociationMap(clusterVector, clusterAssociationMap);
38 
39  m_mergeMade = true;
40 
41  while (m_mergeMade)
42  {
43  // Unambiguous propagation
44  while (m_mergeMade)
45  {
46  m_mergeMade = false;
47 
48  for (const Cluster *const pCluster : clusterVector)
49  {
50  // ATTN The clusterVector may end up with dangling pointers; only protected by this check against managed cluster list
51  if (pClusterList->end() == std::find(pClusterList->begin(), pClusterList->end(), pCluster))
52  continue;
53 
54  this->UnambiguousPropagation(pCluster, true, clusterAssociationMap);
55  this->UnambiguousPropagation(pCluster, false, clusterAssociationMap);
56  }
57  }
58 
60  continue;
61 
62  // Propagation with ambiguities
63  for (const Cluster *const pCluster : clusterVector)
64  {
65  // ATTN The clusterVector may end up with dangling pointers; only protected by this check against up-to-date association list
66  ClusterAssociationMap::const_iterator mapIterFwd = clusterAssociationMap.find(pCluster);
67 
68  if (clusterAssociationMap.end() == mapIterFwd)
69  continue;
70 
71  if (mapIterFwd->second.m_backwardAssociations.empty() && !mapIterFwd->second.m_forwardAssociations.empty())
72  this->AmbiguousPropagation(pCluster, true, clusterAssociationMap);
73 
74  ClusterAssociationMap::const_iterator mapIterBwd = clusterAssociationMap.find(pCluster);
75 
76  if (clusterAssociationMap.end() == mapIterBwd)
77  continue;
78 
79  if (mapIterBwd->second.m_forwardAssociations.empty() && !mapIterBwd->second.m_backwardAssociations.empty())
80  this->AmbiguousPropagation(pCluster, false, clusterAssociationMap);
81  }
82  }
83 
84  return STATUS_CODE_SUCCESS;
85 }
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
intermediate_table::const_iterator const_iterator
bool m_resolveAmbiguousAssociations
Whether to resolve ambiguous associations.
void AmbiguousPropagation(const pandora::Cluster *const pCluster, const bool isForward, ClusterAssociationMap &clusterAssociationMap) const
Ambiguous propagation.
virtual void PopulateClusterAssociationMap(const pandora::ClusterVector &clusterVector, ClusterAssociationMap &clusterAssociationMap) const =0
Populate the cluster association map.
void UnambiguousPropagation(const pandora::Cluster *const pCluster, const bool isForward, ClusterAssociationMap &clusterAssociationMap) const
Unambiguous propagation.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
virtual void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const =0
Populate cluster vector with subset of cluster list, containing clusters judged to be clean...

Member Data Documentation

unsigned int lar_content::LongitudinalAssociationAlgorithm::m_fitLayers
private

number of layers to fit at start and end of cluster

Definition at line 62 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

float lar_content::LongitudinalAssociationAlgorithm::m_hitSizeX
private

estimated hit size in x (drift time) dimension, units cm

Definition at line 68 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

float lar_content::LongitudinalAssociationAlgorithm::m_hitSizeZ
private

estimated hit size in z (wire number) dimension, units cm

Definition at line 67 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

float lar_content::LongitudinalAssociationAlgorithm::m_maxGapDistanceSquared
private

maximum allowed distance (squared) between associated clusters

Definition at line 63 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

unsigned int lar_content::LongitudinalAssociationAlgorithm::m_maxGapLayers
private

maximum allowed number of layers between associated clusters

Definition at line 61 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

float lar_content::LongitudinalAssociationAlgorithm::m_maxLongitudinalDisplacement
private

maximum allowed longitudinal displacement after extrapolation (normalised to cell size)

Definition at line 66 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

float lar_content::LongitudinalAssociationAlgorithm::m_maxTransverseDisplacement
private

maximum allowed transverse displacement after extrapolation (normalised to cell size)

Definition at line 65 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

unsigned int lar_content::LongitudinalAssociationAlgorithm::m_minClusterLayers
private

minimum allowed number of layers for a clean cluster

Definition at line 60 of file LongitudinalAssociationAlgorithm.h.

Referenced by GetListOfCleanClusters(), and ReadSettings().

float lar_content::LongitudinalAssociationAlgorithm::m_minCosRelativeAngle
private

maximum allowed relative angle between associated clusters

Definition at line 64 of file LongitudinalAssociationAlgorithm.h.

Referenced by IsExtremalCluster(), and ReadSettings().

pandora::HitType lar_content::LongitudinalAssociationAlgorithm::m_view
mutableprivate

The view to which the hits under consideration belong.

Definition at line 69 of file LongitudinalAssociationAlgorithm.h.

Referenced by GetListOfCleanClusters(), and IsExtremalCluster().


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