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

Reimplemented from lar_content::ClusterMergingAlgorithm.

Definition at line 388 of file DeltaRayExtensionAlgorithm.cc.

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

389 {
390  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
391  "MinClusterLength", m_minClusterLength));
392 
393  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
394  "MaxClusterLength", m_maxClusterLength));
395 
396  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
397  "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
398 
399  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
400  "MaxTransverseDisplacement", m_maxTransverseDisplacement));
401 
402  return ClusterExtensionAlgorithm::ReadSettings(xmlHandle);
403 }
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::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: