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

DeltaRayExtensionAlgorithm class. More...

#include "DeltaRayExtensionAlgorithm.h"

Inheritance diagram for lar_content::DeltaRayExtensionAlgorithm:
lar_content::ClusterExtensionAlgorithm lar_content::ClusterMergingAlgorithm

Public Member Functions

 DeltaRayExtensionAlgorithm ()
 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 Types

typedef std::unordered_map< const pandora::Cluster *, pandora::CartesianVector > ClusterToCoordinateMap
 

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 GetExtremalCoordinatesFromCache (const pandora::Cluster *const pCluster, ClusterToCoordinateMap &innerCoordinateMap, ClusterToCoordinateMap &outerCoordinateMap, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate) const
 Reduce number of extremal coordinates calculations by caching results when they are first obtained. More...
 
void FillClusterAssociationMatrix (const pandora::Cluster *const pParentCluster, const pandora::Cluster *const pDaughterCluster, ClusterToCoordinateMap &innerCoordinateMap, ClusterToCoordinateMap &outerCoordinateMap, ClusterAssociationMatrix &clusterAssociationMatrix) const
 Form association between two clusters. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_minClusterLength
 
float m_maxClusterLength
 
float m_maxLongitudinalDisplacement
 
float m_maxTransverseDisplacement
 

Detailed Description

DeltaRayExtensionAlgorithm class.

Definition at line 21 of file DeltaRayExtensionAlgorithm.h.

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.

typedef std::unordered_map<const pandora::Cluster *, pandora::CartesianVector> lar_content::DeltaRayExtensionAlgorithm::ClusterToCoordinateMap
private

Definition at line 34 of file DeltaRayExtensionAlgorithm.h.

Constructor & Destructor Documentation

lar_content::DeltaRayExtensionAlgorithm::DeltaRayExtensionAlgorithm ( )

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::DeltaRayExtensionAlgorithm::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 GetExtremalCoordinatesFromCache(), and GetListOfCleanClusters().

void lar_content::DeltaRayExtensionAlgorithm::FillClusterAssociationMatrix ( const pandora::Cluster *const  pParentCluster,
const pandora::Cluster *const  pDaughterCluster,
ClusterToCoordinateMap innerCoordinateMap,
ClusterToCoordinateMap outerCoordinateMap,
ClusterAssociationMatrix clusterAssociationMatrix 
) const
private

Form association between two clusters.

Parameters
pParentClusterthe parent cluster
pDaughterClusterthe daughter cluster
innerCoordinateMapthe map from cluster to inner extremal coordinate
outerCoordinateMapthe map from cluster to outer extremal coordinate
clusterAssociationMatrixthe matrix of cluster associations
void lar_content::DeltaRayExtensionAlgorithm::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 177 of file DeltaRayExtensionAlgorithm.cc.

References lar_content::ClusterExtensionAlgorithm::ClusterAssociation::GetFigureOfMerit(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::INNER, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::OUTER, lar_content::LArClusterHelper::SortByNHits(), and lar_content::ClusterExtensionAlgorithm::ClusterAssociation::STRONG.

178 {
179  // Merge parent and daughter clusters if they are strongly associated
180  // and the associations have the best figures of merit
181  // (i.e. the P --> D association is the best P --> X association,
182  // and the P <-- D association is the best X <-- D association).
183  ClusterAssociationMatrix daughterToParentMatrix;
184 
185  ClusterVector sortedParentClusters;
186  for (const auto &mapEntry : parentToDaughterMatrix)
187  sortedParentClusters.push_back(mapEntry.first);
188  std::sort(sortedParentClusters.begin(), sortedParentClusters.end(), LArClusterHelper::SortByNHits);
189 
190  for (const Cluster *const pParentCluster : sortedParentClusters)
191  {
192  const ClusterAssociationMap &daughterToAssociationMap(parentToDaughterMatrix.at(pParentCluster));
193 
194  ClusterVector sortedLocalDaughterClusters;
195  for (const auto &mapEntry : daughterToAssociationMap)
196  sortedLocalDaughterClusters.push_back(mapEntry.first);
197  std::sort(sortedLocalDaughterClusters.begin(), sortedLocalDaughterClusters.end(), LArClusterHelper::SortByNHits);
198 
199  for (const Cluster *const pDaughterCluster : sortedLocalDaughterClusters)
200  {
201  const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
202  (void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
203  }
204  }
205 
206  ClusterAssociationMatrix reducedParentToDaughterMatrix;
207 
208  ClusterVector sortedDaughterClusters;
209  for (const auto &mapEntry : daughterToParentMatrix)
210  sortedDaughterClusters.push_back(mapEntry.first);
211  std::sort(sortedDaughterClusters.begin(), sortedDaughterClusters.end(), LArClusterHelper::SortByNHits);
212 
213  // Loop over parent clusters and select nearby daughter clusters that are closer than another parent cluster
214  for (const Cluster *const pDaughterCluster : sortedDaughterClusters)
215  {
216  const ClusterAssociationMap &parentToAssociationMap(daughterToParentMatrix.at(pDaughterCluster));
217 
218  const Cluster *pBestInner(NULL);
219  const Cluster *pBestOuter(NULL);
220 
221  float bestFomInner(std::numeric_limits<float>::max());
222  float bestFomOuter(std::numeric_limits<float>::max());
223 
224  ClusterVector sortedLocalParentClusters;
225  for (const auto &mapEntry : parentToAssociationMap)
226  sortedLocalParentClusters.push_back(mapEntry.first);
227  std::sort(sortedLocalParentClusters.begin(), sortedLocalParentClusters.end(), LArClusterHelper::SortByNHits);
228 
229  for (const Cluster *const pParentCluster : sortedLocalParentClusters)
230  {
231  const ClusterAssociation &clusterAssociation(parentToAssociationMap.at(pParentCluster));
232 
233  if (clusterAssociation.GetParent() == ClusterAssociation::INNER)
234  {
235  if (clusterAssociation.GetFigureOfMerit() < bestFomInner)
236  {
237  bestFomInner = clusterAssociation.GetFigureOfMerit();
238 
239  if (clusterAssociation.GetAssociation() == ClusterAssociation::STRONG)
240  {
241  pBestInner = pParentCluster;
242  }
243  else
244  {
245  pBestInner = NULL;
246  }
247  }
248  }
249 
250  if (clusterAssociation.GetParent() == ClusterAssociation::OUTER)
251  {
252  if (clusterAssociation.GetFigureOfMerit() < bestFomOuter)
253  {
254  bestFomOuter = clusterAssociation.GetFigureOfMerit();
255 
256  if (clusterAssociation.GetAssociation() == ClusterAssociation::STRONG)
257  {
258  pBestOuter = pParentCluster;
259  }
260  else
261  {
262  pBestOuter = NULL;
263  }
264  }
265  }
266  }
267 
268  if (pBestInner)
269  {
270  ClusterAssociationMatrix::const_iterator iter3A = parentToDaughterMatrix.find(pBestInner);
271 
272  if (parentToDaughterMatrix.end() == iter3A)
273  throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
274 
275  const ClusterAssociationMap &parentToDaughterMap(iter3A->second);
276  ClusterAssociationMap::const_iterator iter3B = parentToDaughterMap.find(pDaughterCluster);
277 
278  if (parentToDaughterMap.end() == iter3B)
279  throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
280 
281  const ClusterAssociation &bestAssociationInner(iter3B->second);
282  (void)reducedParentToDaughterMatrix[pBestInner].insert(ClusterAssociationMap::value_type(pDaughterCluster, bestAssociationInner));
283  }
284 
285  if (pBestOuter)
286  {
287  ClusterAssociationMatrix::const_iterator iter3A = parentToDaughterMatrix.find(pBestOuter);
288 
289  if (parentToDaughterMatrix.end() == iter3A)
290  throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
291 
292  const ClusterAssociationMap &parentToDaughterMap(iter3A->second);
293  ClusterAssociationMap::const_iterator iter3B = parentToDaughterMap.find(pDaughterCluster);
294 
295  if (parentToDaughterMap.end() == iter3B)
296  throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
297 
298  const ClusterAssociation &bestAssociationOuter(iter3B->second);
299  (void)reducedParentToDaughterMatrix[pBestOuter].insert(ClusterAssociationMap::value_type(pDaughterCluster, bestAssociationOuter));
300  }
301  }
302 
303  ClusterVector sortedReducedParentClusters;
304  for (const auto &mapEntry : reducedParentToDaughterMatrix)
305  sortedReducedParentClusters.push_back(mapEntry.first);
306  std::sort(sortedReducedParentClusters.begin(), sortedReducedParentClusters.end(), LArClusterHelper::SortByNHits);
307 
308  for (const Cluster *const pParentCluster : sortedReducedParentClusters)
309  {
310  const ClusterAssociationMap &daughterToAssociationMap(reducedParentToDaughterMatrix.at(pParentCluster));
311 
312  const Cluster *pBestInner(NULL);
313  const Cluster *pBestOuter(NULL);
314 
315  float bestFomInner(std::numeric_limits<float>::max());
316  float bestFomOuter(std::numeric_limits<float>::max());
317 
318  ClusterVector sortedLocalDaughterClusters;
319  for (const auto &mapEntry : daughterToAssociationMap)
320  sortedLocalDaughterClusters.push_back(mapEntry.first);
321  std::sort(sortedLocalDaughterClusters.begin(), sortedLocalDaughterClusters.end(), LArClusterHelper::SortByNHits);
322 
323  for (const Cluster *const pDaughterCluster : sortedLocalDaughterClusters)
324  {
325  const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
326 
327  if (clusterAssociation.GetParent() == ClusterAssociation::INNER)
328  {
329  if (clusterAssociation.GetFigureOfMerit() < bestFomInner)
330  {
331  bestFomInner = clusterAssociation.GetFigureOfMerit();
332 
333  if (clusterAssociation.GetAssociation() == ClusterAssociation::STRONG)
334  {
335  pBestInner = pDaughterCluster;
336  }
337  else
338  {
339  pBestInner = NULL;
340  }
341  }
342  }
343 
344  if (clusterAssociation.GetParent() == ClusterAssociation::OUTER)
345  {
346  if (clusterAssociation.GetFigureOfMerit() < bestFomOuter)
347  {
348  bestFomOuter = clusterAssociation.GetFigureOfMerit();
349 
350  if (clusterAssociation.GetAssociation() == ClusterAssociation::STRONG)
351  {
352  pBestOuter = pDaughterCluster;
353  }
354  else
355  {
356  pBestOuter = NULL;
357  }
358  }
359  }
360  }
361 
362  if (pBestInner)
363  {
364  ClusterList &parentList(clusterMergeMap[pParentCluster]);
365 
366  if (parentList.end() == std::find(parentList.begin(), parentList.end(), pBestInner))
367  parentList.push_back(pBestInner);
368 
369  ClusterList &bestInnerList(clusterMergeMap[pBestInner]);
370 
371  if (bestInnerList.end() == std::find(bestInnerList.begin(), bestInnerList.end(), pParentCluster))
372  bestInnerList.push_back(pParentCluster);
373  }
374 
375  if (pBestOuter)
376  {
377  ClusterList &parentList(clusterMergeMap[pParentCluster]);
378 
379  if (parentList.end() == std::find(parentList.begin(), parentList.end(), pBestOuter))
380  parentList.push_back(pBestOuter);
381 
382  ClusterList &bestOuterList(clusterMergeMap[pBestOuter]);
383 
384  if (bestOuterList.end() == std::find(bestOuterList.begin(), bestOuterList.end(), pParentCluster))
385  bestOuterList.push_back(pParentCluster);
386  }
387  }
388 }
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::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void lar_content::DeltaRayExtensionAlgorithm::GetExtremalCoordinatesFromCache ( const pandora::Cluster *const  pCluster,
ClusterToCoordinateMap innerCoordinateMap,
ClusterToCoordinateMap outerCoordinateMap,
pandora::CartesianVector &  innerCoordinate,
pandora::CartesianVector &  outerCoordinate 
) const
private

Reduce number of extremal coordinates calculations by caching results when they are first obtained.

Parameters
pParentClusterthe cluster
innerCoordinateMapthe map from cluster to inner extremal coordinate
outerCoordinateMapthe map from cluster to outer extremal coordinate
innerCoordinateto receive the inner coordinate
outerCoordinateto receive the outer coordinate

Definition at line 65 of file DeltaRayExtensionAlgorithm.cc.

References f, FillClusterAssociationMatrix(), lar_content::LArClusterHelper::GetClosestPosition(), lar_content::LArClusterHelper::GetExtremalCoordinates(), lar_content::ClusterExtensionAlgorithm::ClusterAssociation::INNER, m_maxClusterLength, m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::OUTER, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::STRONG, lar_content::ClusterExtensionAlgorithm::ClusterAssociation::UNDEFINED, and lar_content::ClusterExtensionAlgorithm::ClusterAssociation::WEAK.

67 {
68  ClusterToCoordinateMap::const_iterator innerIter = innerCoordinateMap.find(pCluster);
69  ClusterToCoordinateMap::const_iterator outerIter = outerCoordinateMap.find(pCluster);
70 
71  if ((innerCoordinateMap.end() == innerIter) || (outerCoordinateMap.end() == outerIter))
72  {
73  LArClusterHelper::GetExtremalCoordinates(pCluster, innerCoordinate, outerCoordinate);
74  (void)innerCoordinateMap.insert(ClusterToCoordinateMap::value_type(pCluster, innerCoordinate));
75  (void)outerCoordinateMap.insert(ClusterToCoordinateMap::value_type(pCluster, outerCoordinate));
76  }
77  else
78  {
79  innerCoordinate = innerIter->second;
80  outerCoordinate = outerIter->second;
81  }
82 }
intermediate_table::const_iterator const_iterator
static void GetExtremalCoordinates(const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
Get positions of the two most distant calo hits in a list of cluster (ordered by Z) ...
void lar_content::DeltaRayExtensionAlgorithm::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 30 of file DeltaRayExtensionAlgorithm.cc.

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

31 {
32  for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
33  {
34  const Cluster *const pCluster = *iter;
35 
37  continue;
38 
39  clusterVector.push_back(pCluster);
40  }
41 
42  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByNHits);
43 }
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 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 135 of file ClusterMergingAlgorithm.cc.

136 {
137  ClusterVector pfoClusters, availableClusters;
138 
139  for (ClusterVector::const_iterator iter = inputClusters.begin(), iterEnd = inputClusters.end(); iter != iterEnd; ++iter)
140  {
141  const Cluster *const pCluster = *iter;
142 
143  if (!pCluster->IsAvailable())
144  {
145  pfoClusters.push_back(pCluster);
146  }
147  else
148  {
149  availableClusters.push_back(pCluster);
150  }
151  }
152 
153  std::sort(pfoClusters.begin(), pfoClusters.end(), LArClusterHelper::SortByNHits);
154  std::sort(availableClusters.begin(), availableClusters.end(), LArClusterHelper::SortByNHits);
155 
156  outputClusters.insert(outputClusters.end(), pfoClusters.begin(), pfoClusters.end());
157  outputClusters.insert(outputClusters.end(), availableClusters.begin(), availableClusters.end());
158 }
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 62 of file ClusterMergingAlgorithm.cc.

63 {
64  ClusterSet clusterVetoList;
65 
66  for (const Cluster *const pSeedCluster : clusterVector)
67  {
68  ClusterList mergeList;
69  this->CollectAssociatedClusters(pSeedCluster, pSeedCluster, clusterMergeMap, clusterVetoList, mergeList);
70  mergeList.sort(LArClusterHelper::SortByNHits);
71 
72  for (const Cluster *const pAssociatedCluster : mergeList)
73  {
74  if (clusterVetoList.count(pAssociatedCluster))
75  throw StatusCodeException(STATUS_CODE_FAILURE);
76 
77  if (!pAssociatedCluster->IsAvailable())
78  throw StatusCodeException(STATUS_CODE_FAILURE);
79 
80  (void)clusterVetoList.insert(pAssociatedCluster);
81 
82  if (m_inputClusterListName.empty())
83  {
84  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pSeedCluster, pAssociatedCluster));
85  }
86  else
87  {
88  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
89  PandoraContentApi::MergeAndDeleteClusters(*this, pSeedCluster, pAssociatedCluster, m_inputClusterListName, m_inputClusterListName));
90  }
91  }
92  }
93 }
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 }
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.
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
StatusCode lar_content::DeltaRayExtensionAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterMergingAlgorithm.

Definition at line 392 of file DeltaRayExtensionAlgorithm.cc.

References m_maxClusterLength, m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, m_minClusterLength, and lar_content::ClusterMergingAlgorithm::ReadSettings().

393 {
394  PANDORA_RETURN_RESULT_IF_AND_IF(
395  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterLength", m_minClusterLength));
396 
397  PANDORA_RETURN_RESULT_IF_AND_IF(
398  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxClusterLength", m_maxClusterLength));
399 
400  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
401  XmlHelper::ReadValue(xmlHandle, "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
402 
403  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
404  XmlHelper::ReadValue(xmlHandle, "MaxTransverseDisplacement", m_maxTransverseDisplacement));
405 
406  return ClusterExtensionAlgorithm::ReadSettings(xmlHandle);
407 }
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(
31  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_inputClusterListName, pClusterList));
32  }
33 
34  if (!pClusterList || pClusterList->empty())
35  {
36  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
37  std::cout << "ClusterMergingAlgorithm: unable to find cluster list " << m_inputClusterListName << std::endl;
38 
39  return STATUS_CODE_SUCCESS;
40  }
41 
42  while (true)
43  {
44  ClusterVector unsortedVector, clusterVector;
45  this->GetListOfCleanClusters(pClusterList, unsortedVector);
46  this->GetSortedListOfCleanClusters(unsortedVector, clusterVector);
47 
48  ClusterMergeMap clusterMergeMap;
49  this->PopulateClusterMergeMap(clusterVector, clusterMergeMap);
50 
51  if (clusterMergeMap.empty())
52  break;
53 
54  this->MergeClusters(clusterVector, clusterMergeMap);
55  }
56 
57  return STATUS_CODE_SUCCESS;
58 }
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.
void MergeClusters(pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Merge associated clusters.
void GetSortedListOfCleanClusters(const pandora::ClusterVector &inputClusters, pandora::ClusterVector &outputClusters) const
Sort the selected clusters, so that they have a well-defined ordering.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
std::vector< art::Ptr< recob::Cluster > > ClusterVector

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 83 of file ClusterMergingAlgorithm.h.

float lar_content::DeltaRayExtensionAlgorithm::m_maxClusterLength
private

Definition at line 63 of file DeltaRayExtensionAlgorithm.h.

Referenced by GetExtremalCoordinatesFromCache(), and ReadSettings().

float lar_content::DeltaRayExtensionAlgorithm::m_maxLongitudinalDisplacement
private

Definition at line 65 of file DeltaRayExtensionAlgorithm.h.

Referenced by GetExtremalCoordinatesFromCache(), and ReadSettings().

float lar_content::DeltaRayExtensionAlgorithm::m_maxTransverseDisplacement
private

Definition at line 66 of file DeltaRayExtensionAlgorithm.h.

Referenced by GetExtremalCoordinatesFromCache(), and ReadSettings().

float lar_content::DeltaRayExtensionAlgorithm::m_minClusterLength
private

Definition at line 62 of file DeltaRayExtensionAlgorithm.h.

Referenced by GetListOfCleanClusters(), and ReadSettings().


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