Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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...
 

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
 

Additional Inherited Members

- Protected Types inherited from lar_content::ClusterExtensionAlgorithm
typedef std::unordered_map< const pandora::Cluster *, ClusterAssociationClusterAssociationMap
 
typedef std::unordered_map< const pandora::Cluster *, ClusterAssociationMapClusterAssociationMatrix
 
- Protected Types inherited from lar_content::ClusterMergingAlgorithm
typedef std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
 
- Protected Member Functions inherited from lar_content::ClusterExtensionAlgorithm
void PopulateClusterMergeMap (const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMatrix) const
 Form associations between pointing clusters. More...
 
- Protected Member Functions inherited from lar_content::ClusterMergingAlgorithm
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 inherited from lar_content::ClusterMergingAlgorithm
std::string m_inputClusterListName
 The name of the input cluster list. If not specified, will access current list. More...
 

Detailed Description

DeltaRayExtensionAlgorithm class.

Definition at line 21 of file DeltaRayExtensionAlgorithm.h.

Member Typedef Documentation

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

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.

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
static int max(int a, int b)
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.

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.

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.
StatusCode lar_content::DeltaRayExtensionAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterMergingAlgorithm.

Definition at line 392 of file DeltaRayExtensionAlgorithm.cc.

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)

Member Data Documentation

float lar_content::DeltaRayExtensionAlgorithm::m_maxClusterLength
private

Definition at line 63 of file DeltaRayExtensionAlgorithm.h.

float lar_content::DeltaRayExtensionAlgorithm::m_maxLongitudinalDisplacement
private

Definition at line 65 of file DeltaRayExtensionAlgorithm.h.

float lar_content::DeltaRayExtensionAlgorithm::m_maxTransverseDisplacement
private

Definition at line 66 of file DeltaRayExtensionAlgorithm.h.

float lar_content::DeltaRayExtensionAlgorithm::m_minClusterLength
private

Definition at line 62 of file DeltaRayExtensionAlgorithm.h.


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