LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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...
 

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 20 of file LongitudinalAssociationAlgorithm.cc.

20  :
22  m_maxGapLayers(7),
23  m_fitLayers(30),
28  m_hitSizeZ(0.3f),
29  m_hitSizeX(0.5f)
30 {
31 }
float m_maxLongitudinalDisplacement
maximum allowed longitudinal displacement after extrapolation (normalised to cell size) ...
float m_minCosRelativeAngle
maximum allowed relative angle between associated clusters
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 35 of file LongitudinalAssociationAlgorithm.cc.

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

36 {
37  for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
38  {
39  const Cluster *const pCluster = *iter;
40 
41  if (1 + pCluster->GetOuterPseudoLayer() - pCluster->GetInnerPseudoLayer() < m_minClusterLayers)
42  continue;
43 
44  clusterVector.push_back(pCluster);
45  }
46 
47  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByInnerLayer);
48 }
unsigned int m_minClusterLayers
minimum allowed number of layers for a clean cluster
intermediate_table::const_iterator const_iterator
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 77 of file LongitudinalAssociationAlgorithm.cc.

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

78 {
79  const unsigned int currentLayer(isForward ? pCurrentCluster->GetOuterPseudoLayer() : pCurrentCluster->GetInnerPseudoLayer());
80  const unsigned int testLayer(isForward ? pTestCluster->GetOuterPseudoLayer() : pTestCluster->GetInnerPseudoLayer());
81 
82  if (isForward && ((testLayer > currentLayer) || ((testLayer == currentLayer) && LArClusterHelper::SortByNHits(pTestCluster, pCurrentCluster))))
83  return true;
84 
85  if (!isForward && ((testLayer < currentLayer) || ((testLayer == currentLayer) && LArClusterHelper::SortByNHits(pTestCluster, pCurrentCluster))))
86  return true;
87 
88  return false;
89 }
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 52 of file LongitudinalAssociationAlgorithm.cc.

References AreClustersAssociated().

53 {
54  // ATTN This method assumes that clusters have been sorted by layer
55  for (ClusterVector::const_iterator iterI = clusterVector.begin(), iterIEnd = clusterVector.end(); iterI != iterIEnd; ++iterI)
56  {
57  const Cluster *const pInnerCluster = *iterI;
58 
59  for (ClusterVector::const_iterator iterJ = iterI, iterJEnd = clusterVector.end(); iterJ != iterJEnd; ++iterJ)
60  {
61  const Cluster *const pOuterCluster = *iterJ;
62 
63  if (pInnerCluster == pOuterCluster)
64  continue;
65 
66  if (!this->AreClustersAssociated(pInnerCluster, pOuterCluster))
67  continue;
68 
69  clusterAssociationMap[pInnerCluster].m_forwardAssociations.insert(pOuterCluster);
70  clusterAssociationMap[pOuterCluster].m_backwardAssociations.insert(pInnerCluster);
71  }
72  }
73 }
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 179 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().

180 {
181  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
182  "MinClusterLayers", m_minClusterLayers));
183 
184  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
185  "MaxGapLayers", m_maxGapLayers));
186 
187  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
188  "FitLayers", m_fitLayers));
189 
190  float maxGapDistance = std::sqrt(m_maxGapDistanceSquared);
191  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
192  "MaxGapDistance", maxGapDistance));
193  m_maxGapDistanceSquared = maxGapDistance * maxGapDistance;
194 
195  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
196  "MinCosRelativeAngle", m_minCosRelativeAngle));
197 
198  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
199  "MaxTransverseDisplacement", m_maxTransverseDisplacement));
200 
201  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
202  "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
203 
204  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
205  "HitSizeZ", m_hitSizeZ));
206 
207  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
208  "HitSizeX", m_hitSizeX));
209 
211 }
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 mapIter = clusterAssociationMap.find(pCluster);
67 
68  if (clusterAssociationMap.end() == mapIter)
69  continue;
70 
71  if (mapIter->second.m_backwardAssociations.empty() && !mapIter->second.m_forwardAssociations.empty())
72  this->AmbiguousPropagation(pCluster, true, clusterAssociationMap);
73 
74  if (mapIter->second.m_forwardAssociations.empty() && !mapIter->second.m_backwardAssociations.empty())
75  this->AmbiguousPropagation(pCluster, false, clusterAssociationMap);
76  }
77  }
78 
79  return STATUS_CODE_SUCCESS;
80 }
bool m_resolveAmbiguousAssociations
Whether to resolve ambiguous associations.
intermediate_table::const_iterator const_iterator
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.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void UnambiguousPropagation(const pandora::Cluster *const pCluster, const bool isForward, ClusterAssociationMap &clusterAssociationMap) const
Unambiguous propagation.
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
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().


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