LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::CrossGapsExtensionAlgorithm Class Reference

CrossGapsExtensionAlgorithm class. More...

#include "CrossGapsExtensionAlgorithm.h"

Inheritance diagram for lar_content::CrossGapsExtensionAlgorithm:
lar_content::ClusterExtensionAlgorithm lar_content::ClusterMergingAlgorithm

Public Member Functions

 CrossGapsExtensionAlgorithm ()
 Default constructor. More...
 

Protected Types

typedef std::unordered_map< const pandora::Cluster *, ClusterAssociationClusterAssociationMap
 
typedef std::unordered_map< const pandora::Cluster *, ClusterAssociationMapClusterAssociationMatrix
 
typedef std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
 

Protected Member Functions

void PopulateClusterMergeMap (const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMatrix) const
 Form associations between pointing clusters. More...
 
virtual pandora::StatusCode Run ()
 
void MergeClusters (pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
 Merge associated clusters. More...
 
void CollectAssociatedClusters (const pandora::Cluster *const pSeedCluster, const ClusterMergeMap &clusterMergeMap, pandora::ClusterList &associatedClusterList) const
 Collect up all clusters associations related to a given seed cluster. More...
 
void CollectAssociatedClusters (const pandora::Cluster *const pSeedCluster, const pandora::Cluster *const pCurrentCluster, const ClusterMergeMap &clusterMergeMap, const pandora::ClusterSet &clusterVetoList, pandora::ClusterList &associatedClusterList) const
 Collect up all clusters associations related to a given seed cluster. More...
 
void GetSortedListOfCleanClusters (const pandora::ClusterVector &inputClusters, pandora::ClusterVector &outputClusters) const
 Sort the selected clusters, so that they have a well-defined ordering. More...
 

Protected Attributes

std::string m_inputClusterListName
 The name of the input cluster list. If not specified, will access current list. More...
 

Private Member Functions

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 FillClusterAssociationMatrix (const pandora::ClusterVector &clusterVector, ClusterAssociationMatrix &clusterAssociationMatrix) const
 Fill the cluster association matrix. More...
 
void FillClusterMergeMap (const ClusterAssociationMatrix &clusterAssociationMatrix, ClusterMergeMap &clusterMergeMap) const
 Fill the cluster merge map. More...
 
void BuildPointingClusterList (const pandora::ClusterVector &clusterVector, LArPointingClusterList &innerPointingClusterList, LArPointingClusterList &outerPointingClusterList) const
 Build lists of pointing clusters that are adjacent to a detector gap. More...
 
void BuildPointingClusterList (const bool useInner, const LArPointingClusterList &inputPointingClusterList, LArPointingClusterList &outputPointingClusterList) const
 Build a list of pointing clusters that are adjacent to a detector gap. More...
 
bool IsAssociated (const LArPointingCluster::Vertex &pointingVertex1, const LArPointingCluster::Vertex &pointingVertex2) const
 Use pointing information to determine whether two clusters are associated. More...
 
bool IsAcrossGap (const float minZ, const float maxZ, const pandora::HitType hitType) const
 Determine whether a start and end position sit either side of a gap. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_minClusterLength
 
float m_minGapFraction
 
float m_maxGapTolerance
 
float m_maxTransverseDisplacement
 
float m_maxRelativeAngle
 

Detailed Description

Member Typedef Documentation

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

Definition at line 97 of file ClusterExtensionAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster*, ClusterAssociationMap> lar_content::ClusterExtensionAlgorithm::ClusterAssociationMatrix
protectedinherited

Definition at line 98 of file ClusterExtensionAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster*, pandora::ClusterList> lar_content::ClusterMergingAlgorithm::ClusterMergeMap
protectedinherited

Definition at line 27 of file ClusterMergingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::CrossGapsExtensionAlgorithm::CrossGapsExtensionAlgorithm ( )

Member Function Documentation

void lar_content::CrossGapsExtensionAlgorithm::BuildPointingClusterList ( const pandora::ClusterVector &  clusterVector,
LArPointingClusterList innerPointingClusterList,
LArPointingClusterList outerPointingClusterList 
) const
private

Build lists of pointing clusters that are adjacent to a detector gap.

Parameters
clusterVectorthe input vector of clusters
innerPointingClusterListthe pointing clusters whose inner vertex is close to a detector gap
outerPointingClusterListthe pointing clusters whose outer vertex is close to a detector gap

Referenced by FillClusterAssociationMatrix().

void lar_content::CrossGapsExtensionAlgorithm::BuildPointingClusterList ( const bool  useInner,
const LArPointingClusterList inputPointingClusterList,
LArPointingClusterList outputPointingClusterList 
) const
private

Build a list of pointing clusters that are adjacent to a detector gap.

Parameters
useInnercheck the inner vertex
inputPointingClusterListthe input list of pointing clusters
outputPointingClusterListthe output list of pointing clusters

Definition at line 110 of file CrossGapsExtensionAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArGeometryHelper::IsInGap(), and m_maxGapTolerance.

112 {
113  for (const LArPointingCluster &pointingCluster : inputPointingClusterList)
114  {
115  const LArPointingCluster::Vertex &pointingVertex(useInner ? pointingCluster.GetInnerVertex() : pointingCluster.GetOuterVertex());
116  const HitType hitType(LArClusterHelper::GetClusterHitType(pointingCluster.GetCluster()));
117 
118  if (LArGeometryHelper::IsInGap(this->GetPandora(), pointingVertex.GetPosition(), hitType, m_maxGapTolerance))
119  outputPointingClusterList.push_back(pointingCluster);
120  }
121 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool IsInGap(const pandora::Pandora &pandora, const pandora::CartesianVector &testPoint2D, const pandora::HitType hitType, const float gapTolerance=0.f)
Whether a 2D test point lies in a registered gap with the associated hit type.
void lar_content::ClusterMergingAlgorithm::CollectAssociatedClusters ( const pandora::Cluster *const  pSeedCluster,
const ClusterMergeMap clusterMergeMap,
pandora::ClusterList &  associatedClusterList 
) const
protectedinherited

Collect up all clusters associations related to a given seed cluster.

Parameters
pSeedClusterpointer to the initial cluster
clusterMergeMapthe map of cluster associations
associatedClusterListthe output list of associated clusters
void lar_content::ClusterMergingAlgorithm::CollectAssociatedClusters ( const pandora::Cluster *const  pSeedCluster,
const pandora::Cluster *const  pCurrentCluster,
const ClusterMergeMap clusterMergeMap,
const pandora::ClusterSet &  clusterVetoList,
pandora::ClusterList &  associatedClusterList 
) const
protectedinherited

Collect up all clusters associations related to a given seed cluster.

Parameters
pSeedClusterpointer to the initial cluster
pCurrentClusterpointer to the current cluster
clusterMergeMapthe map of cluster associations
clusterVetoListthe list of clusters that have already been merged
associatedClusterListthe output list of associated clusters
void lar_content::CrossGapsExtensionAlgorithm::FillClusterAssociationMatrix ( const pandora::ClusterVector &  clusterVector,
ClusterAssociationMatrix clusterAssociationMatrix 
) const
privatevirtual

Fill the cluster association matrix.

Parameters
clusterVectorthe input vector of clusters
clusterAssociationMatrixthe matrix of associations

Implements lar_content::ClusterExtensionAlgorithm.

Definition at line 52 of file CrossGapsExtensionAlgorithm.cc.

References BuildPointingClusterList(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArClusterHelper::GetLengthSquared(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::INNER, IsAcrossGap(), IsAssociated(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::OUTER, and lar_content::ClusterExtensionAlgorithm::ClusterAssociation::STRONG.

53 {
54  // Build lists of pointing clusters in proximity to gaps
55  LArPointingClusterList innerPointingClusterList, outerPointingClusterList;
56  this->BuildPointingClusterList(clusterVector, innerPointingClusterList, outerPointingClusterList);
57 
58  // Form associations between pairs of pointing clusters
59  for (const LArPointingCluster &pointingClusterInner : innerPointingClusterList)
60  {
61  const LArPointingCluster::Vertex &pointingVertexInner(pointingClusterInner.GetInnerVertex());
62  const float zInner(pointingVertexInner.GetPosition().GetZ());
63 
64  for (const LArPointingCluster &pointingClusterOuter : outerPointingClusterList)
65  {
66  const LArPointingCluster::Vertex &pointingVertexOuter(pointingClusterOuter.GetOuterVertex());
67  const float zOuter(pointingVertexOuter.GetPosition().GetZ());
68 
69  if (!this->IsAcrossGap(zOuter, zInner, LArClusterHelper::GetClusterHitType(pointingClusterInner.GetCluster())))
70  continue;
71 
72  if (!this->IsAssociated(pointingVertexInner, pointingVertexOuter))
73  continue;
74 
75  const Cluster *const pClusterInner(pointingClusterInner.GetCluster());
76  const Cluster *const pClusterOuter(pointingClusterOuter.GetCluster());
77 
78  const float lengthSquaredInner(LArClusterHelper::GetLengthSquared(pClusterInner));
79  const float lengthSquaredOuter(LArClusterHelper::GetLengthSquared(pClusterOuter));
80 
81  (void) clusterAssociationMatrix[pClusterInner].insert(ClusterAssociationMap::value_type(pClusterOuter,
82  ClusterAssociation(ClusterAssociation::INNER, ClusterAssociation::OUTER, ClusterAssociation::STRONG, lengthSquaredOuter)));
83  (void) clusterAssociationMatrix[pClusterOuter].insert(ClusterAssociationMap::value_type(pClusterInner,
84  ClusterAssociation(ClusterAssociation::OUTER, ClusterAssociation::INNER, ClusterAssociation::STRONG, lengthSquaredInner)));
85  }
86  }
87 }
void BuildPointingClusterList(const pandora::ClusterVector &clusterVector, LArPointingClusterList &innerPointingClusterList, LArPointingClusterList &outerPointingClusterList) const
Build lists of pointing clusters that are adjacent to a detector gap.
std::vector< LArPointingCluster > LArPointingClusterList
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
bool IsAcrossGap(const float minZ, const float maxZ, const pandora::HitType hitType) const
Determine whether a start and end position sit either side of a gap.
bool IsAssociated(const LArPointingCluster::Vertex &pointingVertex1, const LArPointingCluster::Vertex &pointingVertex2) const
Use pointing information to determine whether two clusters are associated.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
void lar_content::CrossGapsExtensionAlgorithm::FillClusterMergeMap ( const ClusterAssociationMatrix clusterAssociationMatrix,
ClusterMergeMap clusterMergeMap 
) const
privatevirtual

Fill the cluster merge map.

Parameters
clusterAssociationMatrixthe matrix of cluster associations
clusterMergeMapthe map of cluster merges

Implements lar_content::ClusterExtensionAlgorithm.

Definition at line 154 of file CrossGapsExtensionAlgorithm.cc.

References f, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::GetDaughter(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::GetFigureOfMerit(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::GetParent(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::INNER, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::NONE, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::OUTER, lar_content::LArClusterHelper::SortByNHits(), and lar_content::ClusterExtensionAlgorithm::ClusterAssociation::UNDEFINED.

155 {
156  // Decide which associations will become merges
157  // To make the merge A <-> B, both A -> B and B -> A must be strong associations
158  // with the largest figures of merit of all the A -> X and B -> Y associations
159 
160  // First step: remove double-counting from the map of associations
161  // i.e. if the map has A <-> B, B <-> C, A <-> C, then remove A <-> C
162  ClusterAssociationMatrix clusterAssociationMatrix;
163 
164  ClusterVector sortedInputClusters;
165  for (const auto &mapEntry : inputAssociationMatrix) sortedInputClusters.push_back(mapEntry.first);
166  std::sort(sortedInputClusters.begin(), sortedInputClusters.end(), LArClusterHelper::SortByNHits);
167 
168  for (const Cluster *const pCluster1 : sortedInputClusters)
169  {
170  const ClusterAssociationMap &associationMap1(inputAssociationMatrix.at(pCluster1));
171 
172  for (const Cluster *const pCluster2 : sortedInputClusters)
173  {
174  if (pCluster1 == pCluster2)
175  continue;
176 
177  const ClusterAssociationMap &associationMap2(inputAssociationMatrix.at(pCluster2));
178 
179  ClusterAssociationMap::const_iterator iter12 = associationMap1.find(pCluster2);
180  if (associationMap1.end() == iter12)
181  continue;
182 
183  ClusterAssociationMap::const_iterator iter21 = associationMap2.find(pCluster1);
184  if (associationMap2.end() == iter21)
185  continue;
186 
187  const ClusterAssociation &association12(iter12->second);
188  const ClusterAssociation &association21(iter21->second);
189 
190  bool isAssociated(true);
191 
192  ClusterVector sortedAssociationClusters;
193  for (const auto &mapEntry : associationMap1) sortedAssociationClusters.push_back(mapEntry.first);
194  std::sort(sortedAssociationClusters.begin(), sortedAssociationClusters.end(), LArClusterHelper::SortByNHits);
195 
196  for (const Cluster *const pCluster3 : sortedAssociationClusters)
197  {
198  const ClusterAssociation &association13(associationMap1.at(pCluster3));
199 
200  ClusterAssociationMap::const_iterator iter23 = associationMap2.find(pCluster3);
201  if (associationMap2.end() == iter23)
202  continue;
203 
204  const ClusterAssociation &association23(iter23->second);
205 
206  if (association12.GetParent() == association13.GetParent() &&
207  association23.GetParent() == association21.GetParent() &&
208  association13.GetDaughter() != association23.GetDaughter())
209  {
210  isAssociated = false;
211  break;
212  }
213  }
214 
215  if (isAssociated)
216  {
217  (void) clusterAssociationMatrix[pCluster1].insert(ClusterAssociationMap::value_type(pCluster2, association12));
218  (void) clusterAssociationMatrix[pCluster2].insert(ClusterAssociationMap::value_type(pCluster1, association21));
219  }
220  }
221  }
222 
223 
224  // Second step: find the best associations A -> X and B -> Y
225  ClusterAssociationMatrix intermediateAssociationMatrix;
226 
227  ClusterVector sortedClusters;
228  for (const auto &mapEntry : clusterAssociationMatrix) sortedClusters.push_back(mapEntry.first);
229  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
230 
231  for (const Cluster *const pParentCluster : sortedClusters)
232  {
233  const ClusterAssociationMap &clusterAssociationMap(clusterAssociationMatrix.at(pParentCluster));
234 
235  const Cluster *pBestClusterInner(nullptr);
236  ClusterAssociation bestAssociationInner(ClusterAssociation::UNDEFINED, ClusterAssociation::UNDEFINED, ClusterAssociation::NONE, 0.f);
237 
238  const Cluster *pBestClusterOuter(nullptr);
239  ClusterAssociation bestAssociationOuter(ClusterAssociation::UNDEFINED, ClusterAssociation::UNDEFINED, ClusterAssociation::NONE, 0.f);
240 
241  ClusterVector sortedAssociationClusters;
242  for (const auto &mapEntry : clusterAssociationMap) sortedAssociationClusters.push_back(mapEntry.first);
243  std::sort(sortedAssociationClusters.begin(), sortedAssociationClusters.end(), LArClusterHelper::SortByNHits);
244 
245  for (const Cluster *const pDaughterCluster : sortedAssociationClusters)
246  {
247  const ClusterAssociation &clusterAssociation(clusterAssociationMap.at(pDaughterCluster));
248 
249  // Inner associations
250  if (clusterAssociation.GetParent() == ClusterAssociation::INNER)
251  {
252  if (clusterAssociation.GetFigureOfMerit() > bestAssociationInner.GetFigureOfMerit())
253  {
254  bestAssociationInner = clusterAssociation;
255  pBestClusterInner = pDaughterCluster;
256  }
257  }
258 
259  // Outer associations
260  if (clusterAssociation.GetParent() == ClusterAssociation::OUTER)
261  {
262  if (clusterAssociation.GetFigureOfMerit() > bestAssociationOuter.GetFigureOfMerit())
263  {
264  bestAssociationOuter = clusterAssociation;
265  pBestClusterOuter = pDaughterCluster;
266  }
267  }
268  }
269 
270  if (pBestClusterInner)
271  (void) intermediateAssociationMatrix[pParentCluster].insert(ClusterAssociationMap::value_type(pBestClusterInner, bestAssociationInner));
272 
273  if (pBestClusterOuter)
274  (void) intermediateAssociationMatrix[pParentCluster].insert(ClusterAssociationMap::value_type(pBestClusterOuter, bestAssociationOuter));
275  }
276 
277 
278  // Third step: make the merge if A -> X and B -> Y is in fact A -> B and B -> A
279  ClusterVector intermediateSortedClusters;
280  for (const auto &mapEntry : intermediateAssociationMatrix) intermediateSortedClusters.push_back(mapEntry.first);
281  std::sort(intermediateSortedClusters.begin(), intermediateSortedClusters.end(), LArClusterHelper::SortByNHits);
282 
283  for (const Cluster *const pParentCluster : intermediateSortedClusters)
284  {
285  const ClusterAssociationMap &parentAssociationMap(intermediateAssociationMatrix.at(pParentCluster));
286 
287  ClusterVector sortedAssociationClusters;
288  for (const auto &mapEntry : parentAssociationMap) sortedAssociationClusters.push_back(mapEntry.first);
289  std::sort(sortedAssociationClusters.begin(), sortedAssociationClusters.end(), LArClusterHelper::SortByNHits);
290 
291  for (const Cluster *const pDaughterCluster : sortedAssociationClusters)
292  {
293  const ClusterAssociation &parentToDaughterAssociation(parentAssociationMap.at(pDaughterCluster));
294 
295  ClusterAssociationMatrix::const_iterator iter5 = intermediateAssociationMatrix.find(pDaughterCluster);
296 
297  if (intermediateAssociationMatrix.end() == iter5)
298  continue;
299 
300  const ClusterAssociationMap &daughterAssociationMap(iter5->second);
301 
302  ClusterAssociationMap::const_iterator iter6 = daughterAssociationMap.find(pParentCluster);
303 
304  if (daughterAssociationMap.end() == iter6)
305  continue;
306 
307  const ClusterAssociation &daughterToParentAssociation(iter6->second);
308 
309  if (parentToDaughterAssociation.GetParent() == daughterToParentAssociation.GetDaughter() &&
310  parentToDaughterAssociation.GetDaughter() == daughterToParentAssociation.GetParent())
311  {
312  ClusterList &parentList(clusterMergeMap[pParentCluster]);
313 
314  if (parentList.end() == std::find(parentList.begin(), parentList.end(), pDaughterCluster))
315  parentList.push_back(pDaughterCluster);
316  }
317  }
318  }
319 }
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.
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
TFile f
Definition: plotHisto.C:6
intermediate_table::const_iterator const_iterator
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
void lar_content::CrossGapsExtensionAlgorithm::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::ClusterMergingAlgorithm.

Definition at line 33 of file CrossGapsExtensionAlgorithm.cc.

References lar_content::LArClusterHelper::GetLengthSquared(), m_minClusterLength, and lar_content::LArClusterHelper::SortByNHits().

34 {
35  // ATTN May want to opt-out completely if no gap information available
36  // if (PandoraContentApi::GetGeometry(*this)->GetDetectorGapList().empty())
37  // return;
38 
39  for (const Cluster *const pCluster : *pClusterList)
40  {
42  continue;
43 
44  clusterVector.push_back(pCluster);
45  }
46 
47  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByNHits);
48 }
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.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
void lar_content::ClusterMergingAlgorithm::GetSortedListOfCleanClusters ( const pandora::ClusterVector &  inputClusters,
pandora::ClusterVector &  outputClusters 
) const
protectedinherited

Sort the selected clusters, so that they have a well-defined ordering.

Parameters
inputClustersthe input vector of clusters
outputClustersthe output vector of clusters

Definition at line 133 of file ClusterMergingAlgorithm.cc.

134 {
135  ClusterVector pfoClusters, availableClusters;
136 
137  for (ClusterVector::const_iterator iter = inputClusters.begin(), iterEnd = inputClusters.end(); iter != iterEnd; ++iter)
138  {
139  const Cluster *const pCluster = *iter;
140 
141  if (!pCluster->IsAvailable())
142  {
143  pfoClusters.push_back(pCluster);
144  }
145  else
146  {
147  availableClusters.push_back(pCluster);
148  }
149  }
150 
151  std::sort(pfoClusters.begin(), pfoClusters.end(), LArClusterHelper::SortByNHits);
152  std::sort(availableClusters.begin(), availableClusters.end(), LArClusterHelper::SortByNHits);
153 
154  outputClusters.insert(outputClusters.end(), pfoClusters.begin(), pfoClusters.end());
155  outputClusters.insert(outputClusters.end(), availableClusters.begin(), availableClusters.end());
156 }
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.
intermediate_table::const_iterator const_iterator
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool lar_content::CrossGapsExtensionAlgorithm::IsAcrossGap ( const float  minZ,
const float  maxZ,
const pandora::HitType  hitType 
) const
private

Determine whether a start and end position sit either side of a gap.

Parameters
minZthe start position
maxZthe end position
hitTypethe hitType

Definition at line 139 of file CrossGapsExtensionAlgorithm.cc.

References lar_content::LArGeometryHelper::CalculateGapDeltaZ(), and m_minGapFraction.

Referenced by FillClusterAssociationMatrix().

140 {
141  if (maxZ - minZ < std::numeric_limits<float>::epsilon())
142  return false;
143 
144  const float gapDeltaZ(LArGeometryHelper::CalculateGapDeltaZ(this->GetPandora(), minZ, maxZ, hitType));
145 
146  if (gapDeltaZ / (maxZ - minZ) < m_minGapFraction)
147  return false;
148 
149  return true;
150 }
static float CalculateGapDeltaZ(const pandora::Pandora &pandora, const float minZ, const float maxZ, const pandora::HitType hitType)
Calculate the total distance within a given 2D region that is composed of detector gaps...
bool lar_content::CrossGapsExtensionAlgorithm::IsAssociated ( const LArPointingCluster::Vertex pointingVertex1,
const LArPointingCluster::Vertex pointingVertex2 
) const
private

Use pointing information to determine whether two clusters are associated.

Parameters
pointingVertex1the first pointing vertex
pointingVertex2the second pointing vertex

Definition at line 125 of file CrossGapsExtensionAlgorithm.cc.

References lar_content::LArPointingCluster::Vertex::GetPosition(), lar_content::LArPointingClusterHelper::IsEmission(), m_maxRelativeAngle, and m_maxTransverseDisplacement.

Referenced by FillClusterAssociationMatrix().

126 {
127  const float maxLongitudinalDisplacement((pointingVertex2.GetPosition() - pointingVertex1.GetPosition()).GetMagnitude());
128 
129  const bool isAssociated1(LArPointingClusterHelper::IsEmission(pointingVertex1.GetPosition(), pointingVertex2, -1.f,
130  maxLongitudinalDisplacement + 1.f, m_maxTransverseDisplacement, m_maxRelativeAngle));
131  const bool isAssociated2(LArPointingClusterHelper::IsEmission(pointingVertex2.GetPosition(), pointingVertex1, -1.f,
132  maxLongitudinalDisplacement + 1.f, m_maxTransverseDisplacement, m_maxRelativeAngle));
133 
134  return (isAssociated1 && isAssociated2);
135 }
static bool IsEmission(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance)
Whether pointing vertex is emitted from a given position.
void lar_content::ClusterMergingAlgorithm::MergeClusters ( pandora::ClusterVector &  clusterVector,
ClusterMergeMap clusterMergeMap 
) const
protectedinherited

Merge associated clusters.

Parameters
clusterVectorthe vector of clean clusters
clusterMergeMapthe matrix of cluster associations

Definition at line 61 of file ClusterMergingAlgorithm.cc.

62 {
63  ClusterSet clusterVetoList;
64 
65  for (const Cluster *const pSeedCluster : clusterVector)
66  {
67  ClusterList mergeList;
68  this->CollectAssociatedClusters(pSeedCluster, pSeedCluster, clusterMergeMap, clusterVetoList, mergeList);
69  mergeList.sort(LArClusterHelper::SortByNHits);
70 
71  for (const Cluster *const pAssociatedCluster : mergeList)
72  {
73  if (clusterVetoList.count(pAssociatedCluster))
74  throw StatusCodeException(STATUS_CODE_FAILURE);
75 
76  if (!pAssociatedCluster->IsAvailable())
77  throw StatusCodeException(STATUS_CODE_FAILURE);
78 
79  (void) clusterVetoList.insert(pAssociatedCluster);
80 
81  if (m_inputClusterListName.empty())
82  {
83  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pSeedCluster, pAssociatedCluster));
84  }
85  else
86  {
87  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pSeedCluster, pAssociatedCluster,
89  }
90  }
91  }
92 }
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.
std::string m_inputClusterListName
The name of the input cluster list. If not specified, will access current list.
void CollectAssociatedClusters(const pandora::Cluster *const pSeedCluster, const ClusterMergeMap &clusterMergeMap, pandora::ClusterList &associatedClusterList) const
Collect up all clusters associations related to a given seed cluster.
void lar_content::ClusterExtensionAlgorithm::PopulateClusterMergeMap ( const pandora::ClusterVector &  clusterVector,
ClusterMergeMap clusterMergeMap 
) const
protectedvirtualinherited

Form associations between pointing clusters.

Parameters
clusterVectorthe vector of clean clusters
clusterMergeMapthe matrix of cluster associations

Implements lar_content::ClusterMergingAlgorithm.

Definition at line 18 of file ClusterExtensionAlgorithm.cc.

19 {
20  ClusterAssociationMatrix clusterAssociationMatrix;
21  this->FillClusterAssociationMatrix(clusterVector, clusterAssociationMatrix);
22  this->FillClusterMergeMap(clusterAssociationMatrix, clusterMergeMap);
23 }
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
virtual void FillClusterMergeMap(const ClusterAssociationMatrix &clusterAssociationMatrix, ClusterMergeMap &clusterMergeMap) const =0
Fill the cluster merge map.
virtual void FillClusterAssociationMatrix(const pandora::ClusterVector &clusterVector, ClusterAssociationMatrix &clusterAssociationMatrix) const =0
Fill the cluster association matrix.
StatusCode lar_content::CrossGapsExtensionAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterMergingAlgorithm.

Definition at line 323 of file CrossGapsExtensionAlgorithm.cc.

References m_maxGapTolerance, m_maxRelativeAngle, m_maxTransverseDisplacement, m_minClusterLength, m_minGapFraction, and lar_content::ClusterMergingAlgorithm::ReadSettings().

324 {
325  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
326  "MinClusterLength", m_minClusterLength));
327 
328  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
329  "MinGapFraction", m_minGapFraction));
330 
331  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
332  "MaxGapTolerance", m_maxGapTolerance));
333 
334  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
335  "MaxTransverseDisplacement", m_maxTransverseDisplacement));
336 
337  float maxCosRelativeAngle(std::cos(m_maxRelativeAngle * M_PI / 180.0));
338  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
339  "MaxCosRelativeAngle", maxCosRelativeAngle));
340  m_maxRelativeAngle = (180.0 / M_PI) * std::acos(maxCosRelativeAngle);
341 
342  return ClusterExtensionAlgorithm::ReadSettings(xmlHandle);
343 }
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
StatusCode lar_content::ClusterMergingAlgorithm::Run ( )
protectedvirtualinherited

Definition at line 20 of file ClusterMergingAlgorithm.cc.

21 {
22  const ClusterList *pClusterList = NULL;
23 
24  if (m_inputClusterListName.empty())
25  {
26  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
27  }
28  else
29  {
30  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_inputClusterListName, pClusterList));
31  }
32 
33  if (!pClusterList || pClusterList->empty())
34  {
35  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
36  std::cout << "ClusterMergingAlgorithm: unable to find cluster list " << m_inputClusterListName << std::endl;
37 
38  return STATUS_CODE_SUCCESS;
39  }
40 
41  while (true)
42  {
43  ClusterVector unsortedVector, clusterVector;
44  this->GetListOfCleanClusters(pClusterList, unsortedVector);
45  this->GetSortedListOfCleanClusters(unsortedVector, clusterVector);
46 
47  ClusterMergeMap clusterMergeMap;
48  this->PopulateClusterMergeMap(clusterVector, clusterMergeMap);
49 
50  if (clusterMergeMap.empty())
51  break;
52 
53  this->MergeClusters(clusterVector, clusterMergeMap);
54  }
55 
56  return STATUS_CODE_SUCCESS;
57 }
std::string m_inputClusterListName
The name of the input cluster list. If not specified, will access current list.
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...
virtual void PopulateClusterMergeMap(const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const =0
Form associations between pointing clusters.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void MergeClusters(pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Merge associated clusters.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
void GetSortedListOfCleanClusters(const pandora::ClusterVector &inputClusters, pandora::ClusterVector &outputClusters) const
Sort the selected clusters, so that they have a well-defined ordering.

Member Data Documentation

std::string lar_content::ClusterMergingAlgorithm::m_inputClusterListName
protectedinherited

The name of the input cluster list. If not specified, will access current list.

Definition at line 82 of file ClusterMergingAlgorithm.h.

float lar_content::CrossGapsExtensionAlgorithm::m_maxGapTolerance
private

Definition at line 75 of file CrossGapsExtensionAlgorithm.h.

Referenced by BuildPointingClusterList(), and ReadSettings().

float lar_content::CrossGapsExtensionAlgorithm::m_maxRelativeAngle
private

Definition at line 77 of file CrossGapsExtensionAlgorithm.h.

Referenced by IsAssociated(), and ReadSettings().

float lar_content::CrossGapsExtensionAlgorithm::m_maxTransverseDisplacement
private

Definition at line 76 of file CrossGapsExtensionAlgorithm.h.

Referenced by IsAssociated(), and ReadSettings().

float lar_content::CrossGapsExtensionAlgorithm::m_minClusterLength
private

Definition at line 73 of file CrossGapsExtensionAlgorithm.h.

Referenced by GetListOfCleanClusters(), and ReadSettings().

float lar_content::CrossGapsExtensionAlgorithm::m_minGapFraction
private

Definition at line 74 of file CrossGapsExtensionAlgorithm.h.

Referenced by IsAcrossGap(), and ReadSettings().


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