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

LongitudinalExtensionAlgorithm class. More...

#include "LongitudinalExtensionAlgorithm.h"

Inheritance diagram for lar_content::LongitudinalExtensionAlgorithm:
lar_content::ClusterExtensionAlgorithm lar_content::ClusterMergingAlgorithm

Public Member Functions

 LongitudinalExtensionAlgorithm ()
 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 FillClusterAssociationMatrix (const LArPointingCluster &clusterI, const LArPointingCluster &clusterJ, ClusterAssociationMatrix &clusterAssociationMatrix) const
 Form association between two pointing clusters. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_clusterMinLength
 
float m_clusterMinLayerOccupancy
 
float m_nodeMaxDisplacement
 
float m_nodeMaxCosRelativeAngle
 
float m_emissionMaxLongitudinalDisplacement
 
float m_emissionMaxTransverseDisplacement
 
float m_emissionMaxCosRelativeAngle
 

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::LongitudinalExtensionAlgorithm::LongitudinalExtensionAlgorithm ( )

Member Function Documentation

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::LongitudinalExtensionAlgorithm::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.

Referenced by GetListOfCleanClusters().

void lar_content::LongitudinalExtensionAlgorithm::FillClusterAssociationMatrix ( const LArPointingCluster clusterI,
const LArPointingCluster clusterJ,
ClusterAssociationMatrix clusterAssociationMatrix 
) const
private

Form association between two pointing clusters.

Parameters
clusterIthe first pointing cluster
clusterJthe second pointing cluster
clusterAssociationMatrixthe matrix of cluster associations

Definition at line 89 of file LongitudinalExtensionAlgorithm.cc.

References f, lar_content::LArPointingClusterHelper::GetClosestVertices(), lar_content::LArPointingCluster::GetCluster(), lar_content::LArPointingCluster::Vertex::GetDirection(), lar_content::LArPointingClusterHelper::GetImpactParameters(), lar_content::LArClusterHelper::GetLayerOccupancy(), lar_content::LArPointingClusterHelper::GetLength(), lar_content::LArPointingCluster::Vertex::GetPosition(), lar_content::LArPointingCluster::Vertex::GetRms(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::INNER, lar_content::LArPointingCluster::Vertex::IsInitialized(), lar_content::LArPointingCluster::Vertex::IsInnerVertex(), m_clusterMinLayerOccupancy, m_emissionMaxCosRelativeAngle, m_emissionMaxLongitudinalDisplacement, m_emissionMaxTransverseDisplacement, m_nodeMaxCosRelativeAngle, m_nodeMaxDisplacement, min, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::NONE, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::OUTER, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::STRONG, and lar_content::ClusterExtensionAlgorithm::ClusterAssociation::WEAK.

91 {
92  const Cluster *const pClusterI(clusterI.GetCluster());
93  const Cluster *const pClusterJ(clusterJ.GetCluster());
94 
95  if (pClusterI == pClusterJ)
96  return;
97 
98  // Check that new layer occupancy would be reasonable
100  return;
101 
102  // Identify closest pair of vertices
103  LArPointingCluster::Vertex targetVertexI, targetVertexJ;
104 
105  try
106  {
107  LArPointingClusterHelper::GetClosestVertices(clusterI, clusterJ, targetVertexI, targetVertexJ);
108  }
109  catch (StatusCodeException &)
110  {
111  return;
112  }
113 
114  // (Just in case...)
115  if (!(targetVertexI.IsInitialized() && targetVertexJ.IsInitialized()))
116  throw StatusCodeException(STATUS_CODE_FAILURE);
117 
118  const CartesianVector &vertexPositionI(targetVertexI.GetPosition());
119  const CartesianVector &vertexPositionJ(targetVertexJ.GetPosition());
120  const CartesianVector &vertexDirectionI(targetVertexI.GetDirection());
121  const CartesianVector &vertexDirectionJ(targetVertexJ.GetDirection());
122 
123  // Check for reasonable proximity between vertices
124  const float distanceSquared((vertexPositionI - vertexPositionJ).GetMagnitudeSquared());
125 
127  return;
128 
129  // Check that vertices have a reasonable linear fit
130  if (targetVertexI.GetRms() > 1.f || targetVertexJ.GetRms() > 1.f)
131  return;
132 
133  // Association type
135 
136  // Requirements for Nodes
137  if (distanceSquared < 2.f * m_nodeMaxDisplacement * m_nodeMaxDisplacement)
138  {
139  associationType = ClusterAssociation::WEAK;
140 
141  if (distanceSquared < m_nodeMaxDisplacement * m_nodeMaxDisplacement)
142  {
143  const float cosTheta(-vertexDirectionI.GetDotProduct(vertexDirectionJ));
144 
145  if (cosTheta > m_nodeMaxCosRelativeAngle)
146  {
147  associationType = ClusterAssociation::STRONG;
148  }
149  }
150  }
151 
152  // Requirements for Emissions
153  const float clusterLengthI(LArPointingClusterHelper::GetLength(clusterI));
154  const float clusterLengthJ(LArPointingClusterHelper::GetLength(clusterJ));
155 
156  if (associationType < ClusterAssociation::STRONG)
157  {
158  const float cosTheta(-vertexDirectionI.GetDotProduct(vertexDirectionJ));
159  const float cosThetaI((vertexPositionI - vertexPositionJ).GetUnitVector().GetDotProduct(vertexDirectionI));
160  const float cosThetaJ((vertexPositionJ - vertexPositionI).GetUnitVector().GetDotProduct(vertexDirectionJ));
161 
162  float rT1(0.f), rL1(0.f), rT2(0.f), rL2(0.f);
163  LArPointingClusterHelper::GetImpactParameters(vertexPositionI, vertexDirectionI, vertexPositionJ, rL1, rT1);
164  LArPointingClusterHelper::GetImpactParameters(vertexPositionJ, vertexDirectionJ, vertexPositionI, rL2, rT2);
165 
166  if ((rL1 > -2.5f && rL1 < std::min(0.66f * clusterLengthJ, m_emissionMaxLongitudinalDisplacement)) &&
167  (rL2 > -2.5f && rL2 < std::min(0.66f * clusterLengthI, m_emissionMaxLongitudinalDisplacement)) &&
169  (targetVertexI.GetRms() < 0.5f && targetVertexJ.GetRms() < 0.5f) &&
170  (cosTheta > m_emissionMaxCosRelativeAngle) && (std::fabs(cosThetaI) > 0.25f) && (std::fabs(cosThetaJ) > 0.25f))
171  {
172  associationType = ClusterAssociation::STRONG;
173  }
174  }
175 
176  // Record the association
177  if (ClusterAssociation::NONE != associationType)
178  {
179  const ClusterAssociation::VertexType vertexTypeI(targetVertexI.IsInnerVertex() ? ClusterAssociation::INNER : ClusterAssociation::OUTER);
180  const ClusterAssociation::VertexType vertexTypeJ(targetVertexJ.IsInnerVertex() ? ClusterAssociation::INNER : ClusterAssociation::OUTER);
181  (void) clusterAssociationMatrix[pClusterI].insert(ClusterAssociationMap::value_type(pClusterJ, ClusterAssociation(vertexTypeI, vertexTypeJ, associationType, clusterLengthJ)));
182  (void) clusterAssociationMatrix[pClusterJ].insert(ClusterAssociationMap::value_type(pClusterI, ClusterAssociation(vertexTypeJ, vertexTypeI, associationType, clusterLengthI)));
183  return;
184  }
185 }
static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices.
static float GetLength(const LArPointingCluster &pointingCluster)
Calculate distance squared between inner and outer vertices of pointing cluster.
static void GetClosestVertices(const bool useX, const bool useY, const bool useZ, const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ, LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ)
Given a pair of pointing clusters, receive the closest or farthest pair of vertices.
TFile f
Definition: plotHisto.C:6
static float GetLayerOccupancy(const pandora::Cluster *const pCluster)
Fraction of occupied layers in cluster.
Int_t min
Definition: plot.C:26
void lar_content::LongitudinalExtensionAlgorithm::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 189 of file LongitudinalExtensionAlgorithm.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(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::STRONG, and lar_content::ClusterExtensionAlgorithm::ClusterAssociation::UNDEFINED.

190 {
191  // Decide which associations will become merges
192  // To make the merge A <-> B, both A -> B and B -> A must be strong associations
193  // with the largest figures of merit of all the A -> X and B -> Y associations
194 
195  // First step: remove double-counting from the map of associations
196  // i.e. if the map has A <-> B, B <-> C, A <-> C, then remove A <-> C
197  ClusterAssociationMatrix clusterAssociationMatrix;
198 
199  ClusterVector sortedInputClusters;
200  for (const auto &mapEntry : inputAssociationMatrix) sortedInputClusters.push_back(mapEntry.first);
201  std::sort(sortedInputClusters.begin(), sortedInputClusters.end(), LArClusterHelper::SortByNHits);
202 
203  for (const Cluster *const pCluster1 : sortedInputClusters)
204  {
205  const ClusterAssociationMap &associationMap1(inputAssociationMatrix.at(pCluster1));
206 
207  for (const Cluster *const pCluster2 : sortedInputClusters)
208  {
209  if (pCluster1 == pCluster2)
210  continue;
211 
212  const ClusterAssociationMap &associationMap2(inputAssociationMatrix.at(pCluster2));
213 
214  ClusterAssociationMap::const_iterator iter12 = associationMap1.find(pCluster2);
215  if (associationMap1.end() == iter12)
216  continue;
217 
218  ClusterAssociationMap::const_iterator iter21 = associationMap2.find(pCluster1);
219  if (associationMap2.end() == iter21)
220  continue;
221 
222  const ClusterAssociation &association12(iter12->second);
223  const ClusterAssociation &association21(iter21->second);
224 
225  bool isAssociated(true);
226 
227  ClusterVector sortedAssociationClusters;
228  for (const auto &mapEntry : associationMap1) sortedAssociationClusters.push_back(mapEntry.first);
229  std::sort(sortedAssociationClusters.begin(), sortedAssociationClusters.end(), LArClusterHelper::SortByNHits);
230 
231  for (const Cluster *const pCluster3 : sortedAssociationClusters)
232  {
233  const ClusterAssociation &association13(associationMap1.at(pCluster3));
234 
235  ClusterAssociationMap::const_iterator iter23 = associationMap2.find(pCluster3);
236  if (associationMap2.end() == iter23)
237  continue;
238 
239  const ClusterAssociation &association23(iter23->second);
240 
241  if (association12.GetParent() == association13.GetParent() &&
242  association23.GetParent() == association21.GetParent() &&
243  association13.GetDaughter() != association23.GetDaughter())
244  {
245  isAssociated = false;
246  break;
247  }
248  }
249 
250  if (isAssociated)
251  {
252  (void) clusterAssociationMatrix[pCluster1].insert(ClusterAssociationMap::value_type(pCluster2, association12));
253  (void) clusterAssociationMatrix[pCluster2].insert(ClusterAssociationMap::value_type(pCluster1, association21));
254  }
255  }
256  }
257 
258 
259  // Second step: find the best associations A -> X and B -> Y
260  ClusterAssociationMatrix intermediateAssociationMatrix;
261 
262  ClusterVector sortedClusters;
263  for (const auto &mapEntry : clusterAssociationMatrix) sortedClusters.push_back(mapEntry.first);
264  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
265 
266  for (const Cluster *const pParentCluster : sortedClusters)
267  {
268  const ClusterAssociationMap &clusterAssociationMap(clusterAssociationMatrix.at(pParentCluster));
269 
270  const Cluster *pBestClusterInner(nullptr);
271  ClusterAssociation bestAssociationInner(ClusterAssociation::UNDEFINED, ClusterAssociation::UNDEFINED, ClusterAssociation::NONE, 0.f);
272 
273  const Cluster *pBestClusterOuter(nullptr);
274  ClusterAssociation bestAssociationOuter(ClusterAssociation::UNDEFINED, ClusterAssociation::UNDEFINED, ClusterAssociation::NONE, 0.f);
275 
276  ClusterVector sortedAssociationClusters;
277  for (const auto &mapEntry : clusterAssociationMap) sortedAssociationClusters.push_back(mapEntry.first);
278  std::sort(sortedAssociationClusters.begin(), sortedAssociationClusters.end(), LArClusterHelper::SortByNHits);
279 
280  for (const Cluster *const pDaughterCluster : sortedAssociationClusters)
281  {
282  const ClusterAssociation &clusterAssociation(clusterAssociationMap.at(pDaughterCluster));
283 
284  // Inner associations
285  if (clusterAssociation.GetParent() == ClusterAssociation::INNER)
286  {
287  if (clusterAssociation.GetFigureOfMerit() > bestAssociationInner.GetFigureOfMerit())
288  {
289  bestAssociationInner = clusterAssociation;
290 
291  if (clusterAssociation.GetAssociation() == ClusterAssociation::STRONG)
292  pBestClusterInner = pDaughterCluster;
293  else
294  pBestClusterInner = nullptr;
295  }
296  }
297 
298  // Outer associations
299  if (clusterAssociation.GetParent() == ClusterAssociation::OUTER)
300  {
301  if (clusterAssociation.GetFigureOfMerit() > bestAssociationOuter.GetFigureOfMerit())
302  {
303  bestAssociationOuter = clusterAssociation;
304 
305  if (clusterAssociation.GetAssociation() == ClusterAssociation::STRONG)
306  pBestClusterOuter = pDaughterCluster;
307  else
308  pBestClusterOuter = nullptr;
309  }
310  }
311  }
312 
313  if (pBestClusterInner)
314  (void) intermediateAssociationMatrix[pParentCluster].insert(ClusterAssociationMap::value_type(pBestClusterInner, bestAssociationInner));
315 
316  if (pBestClusterOuter)
317  (void) intermediateAssociationMatrix[pParentCluster].insert(ClusterAssociationMap::value_type(pBestClusterOuter, bestAssociationOuter));
318  }
319 
320 
321  // Third step: make the merge if A -> X and B -> Y is in fact A -> B and B -> A
322  ClusterVector intermediateSortedClusters;
323  for (const auto &mapEntry : intermediateAssociationMatrix) intermediateSortedClusters.push_back(mapEntry.first);
324  std::sort(intermediateSortedClusters.begin(), intermediateSortedClusters.end(), LArClusterHelper::SortByNHits);
325 
326  for (const Cluster *const pParentCluster : intermediateSortedClusters)
327  {
328  const ClusterAssociationMap &parentAssociationMap(intermediateAssociationMatrix.at(pParentCluster));
329 
330  ClusterVector sortedAssociationClusters;
331  for (const auto &mapEntry : parentAssociationMap) sortedAssociationClusters.push_back(mapEntry.first);
332  std::sort(sortedAssociationClusters.begin(), sortedAssociationClusters.end(), LArClusterHelper::SortByNHits);
333 
334  for (const Cluster *const pDaughterCluster : sortedAssociationClusters)
335  {
336  const ClusterAssociation &parentToDaughterAssociation(parentAssociationMap.at(pDaughterCluster));
337 
338  ClusterAssociationMatrix::const_iterator iter5 = intermediateAssociationMatrix.find(pDaughterCluster);
339 
340  if (intermediateAssociationMatrix.end() == iter5)
341  continue;
342 
343  const ClusterAssociationMap &daughterAssociationMap(iter5->second);
344 
345  ClusterAssociationMap::const_iterator iter6 = daughterAssociationMap.find(pParentCluster);
346 
347  if (daughterAssociationMap.end() == iter6)
348  continue;
349 
350  const ClusterAssociation &daughterToParentAssociation(iter6->second);
351 
352  if (parentToDaughterAssociation.GetParent() == daughterToParentAssociation.GetDaughter() &&
353  parentToDaughterAssociation.GetDaughter() == daughterToParentAssociation.GetParent())
354  {
355  ClusterList &parentList(clusterMergeMap[pParentCluster]);
356 
357  if (parentList.end() == std::find(parentList.begin(), parentList.end(), pDaughterCluster))
358  parentList.push_back(pDaughterCluster);
359  }
360  }
361  }
362 }
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::LongitudinalExtensionAlgorithm::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 34 of file LongitudinalExtensionAlgorithm.cc.

References FillClusterAssociationMatrix(), lar_content::LArPointingCluster::GetCluster(), lar_content::LArClusterHelper::GetLayerOccupancy(), lar_content::LArClusterHelper::GetLengthSquared(), m_clusterMinLayerOccupancy, m_clusterMinLength, and lar_content::LArClusterHelper::SortByNHits().

35 {
36  for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
37  {
38  const Cluster *const pCluster = *iter;
39 
41  continue;
42 
44  continue;
45 
46  clusterVector.push_back(pCluster);
47  }
48 
49  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByNHits);
50 }
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
static float GetLayerOccupancy(const pandora::Cluster *const pCluster)
Fraction of occupied layers in cluster.
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
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::LongitudinalExtensionAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterMergingAlgorithm.

Definition at line 366 of file LongitudinalExtensionAlgorithm.cc.

References m_clusterMinLayerOccupancy, m_clusterMinLength, m_emissionMaxCosRelativeAngle, m_emissionMaxLongitudinalDisplacement, m_emissionMaxTransverseDisplacement, m_nodeMaxCosRelativeAngle, m_nodeMaxDisplacement, and lar_content::ClusterMergingAlgorithm::ReadSettings().

367 {
368  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
369  "ClusterMinLength", m_clusterMinLength));
370 
371  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
372  "ClusterMinLayerOccupancy", m_clusterMinLayerOccupancy));
373 
374  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
375  "NodeMaxDisplacement", m_nodeMaxDisplacement));
376 
377  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
378  "NodeMaxCosRelativeAngle", m_nodeMaxCosRelativeAngle));
379 
380  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
381  "EmissionMaxLongitudinalDisplacement", m_emissionMaxLongitudinalDisplacement));
382 
383  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
384  "EmissionMaxTransverseDisplacement", m_emissionMaxTransverseDisplacement));
385 
386  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
387  "EmissionMaxCosRelativeAngle", m_emissionMaxCosRelativeAngle));
388 
389  return ClusterExtensionAlgorithm::ReadSettings(xmlHandle);
390 }
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

float lar_content::LongitudinalExtensionAlgorithm::m_clusterMinLayerOccupancy
private
float lar_content::LongitudinalExtensionAlgorithm::m_clusterMinLength
private

Definition at line 45 of file LongitudinalExtensionAlgorithm.h.

Referenced by GetListOfCleanClusters(), and ReadSettings().

float lar_content::LongitudinalExtensionAlgorithm::m_emissionMaxCosRelativeAngle
private

Definition at line 51 of file LongitudinalExtensionAlgorithm.h.

Referenced by FillClusterAssociationMatrix(), and ReadSettings().

float lar_content::LongitudinalExtensionAlgorithm::m_emissionMaxLongitudinalDisplacement
private

Definition at line 49 of file LongitudinalExtensionAlgorithm.h.

Referenced by FillClusterAssociationMatrix(), and ReadSettings().

float lar_content::LongitudinalExtensionAlgorithm::m_emissionMaxTransverseDisplacement
private

Definition at line 50 of file LongitudinalExtensionAlgorithm.h.

Referenced by FillClusterAssociationMatrix(), and ReadSettings().

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::LongitudinalExtensionAlgorithm::m_nodeMaxCosRelativeAngle
private

Definition at line 48 of file LongitudinalExtensionAlgorithm.h.

Referenced by FillClusterAssociationMatrix(), and ReadSettings().

float lar_content::LongitudinalExtensionAlgorithm::m_nodeMaxDisplacement
private

Definition at line 47 of file LongitudinalExtensionAlgorithm.h.

Referenced by FillClusterAssociationMatrix(), and ReadSettings().


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