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

DeltaRayGrowingAlgorithm class. More...

#include "DeltaRayGrowingAlgorithm.h"

Inheritance diagram for lar_content::DeltaRayGrowingAlgorithm:
lar_content::ClusterGrowingAlgorithm

Public Member Functions

 DeltaRayGrowingAlgorithm ()
 Default constructor. More...
 

Protected Types

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

Protected Member Functions

virtual pandora::StatusCode Run ()
 

Private Member Functions

void GetListOfCleanClusters (const pandora::ClusterList *const pClusterList, pandora::ClusterVector &cleanClusters) const
 Populate cluster vector with the subset of clusters judged to be clean. More...
 
void GetListOfSeedClusters (const pandora::ClusterVector &inputClusters, pandora::ClusterVector &seedClusters) const
 Select seed clusters for growing. More...
 
void GetPfos (const std::string inputPfoListName, pandora::PfoVector &pfoVector) const
 Get a vector of Pfos from an input Pfo list name. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_parentPfoListName
 The parent Pfo list name. More...
 
std::string m_daughterPfoListName
 The daughter Pfo list name. More...
 
unsigned int m_minCaloHitsPerCluster
 The minimum number of calo hits per candidate cluster. More...
 
unsigned int m_minSeedClusterCaloHits
 The minimum number of calo hits for seed clusters. More...
 
float m_maxSeedClusterLength
 The maximum length of a parent clusters. More...
 
float m_maxSeedClusterDisplacement
 The maximum distance between parent and daughter clusters. More...
 

Detailed Description

DeltaRayGrowingAlgorithm class.

Definition at line 21 of file DeltaRayGrowingAlgorithm.h.

Member Typedef Documentation

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

Definition at line 33 of file ClusterGrowingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::DeltaRayGrowingAlgorithm::DeltaRayGrowingAlgorithm ( )

Default constructor.

Definition at line 21 of file DeltaRayGrowingAlgorithm.cc.

21  :
26 {
27 }
float m_maxSeedClusterLength
The maximum length of a parent clusters.
TFile f
Definition: plotHisto.C:6
unsigned int m_minCaloHitsPerCluster
The minimum number of calo hits per candidate cluster.
unsigned int m_minSeedClusterCaloHits
The minimum number of calo hits for seed clusters.
float m_maxSeedClusterDisplacement
The maximum distance between parent and daughter clusters.

Member Function Documentation

void lar_content::DeltaRayGrowingAlgorithm::GetListOfCleanClusters ( const pandora::ClusterList *const  pClusterList,
pandora::ClusterVector &  cleanClusters 
) const
privatevirtual

Populate cluster vector with the subset of clusters judged to be clean.

Parameters
pClusterListaddress of the cluster list
cleanClustersthe output vector of clean clusters

Implements lar_content::ClusterGrowingAlgorithm.

Definition at line 31 of file DeltaRayGrowingAlgorithm.cc.

References m_minCaloHitsPerCluster, and lar_content::LArClusterHelper::SortByNHits().

32 {
33  for (const Cluster *const pCluster : *pClusterList)
34  {
35  if (!pCluster->IsAvailable() || (pCluster->GetNCaloHits() < m_minCaloHitsPerCluster))
36  continue;
37 
38  clusterVector.push_back(pCluster);
39  }
40 
41  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByNHits);
42 }
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.
unsigned int m_minCaloHitsPerCluster
The minimum number of calo hits per candidate cluster.
void lar_content::DeltaRayGrowingAlgorithm::GetListOfSeedClusters ( const pandora::ClusterVector &  cleanClusters,
pandora::ClusterVector &  seedClusters 
) const
privatevirtual

Select seed clusters for growing.

Parameters
cleanClustersthe input vector of clean clusters
seedClustersthe output vector of seed clusters

Implements lar_content::ClusterGrowingAlgorithm.

Definition at line 46 of file DeltaRayGrowingAlgorithm.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArPfoHelper::GetClusters(), lar_content::LArClusterHelper::GetLengthSquared(), GetPfos(), m_daughterPfoListName, m_maxSeedClusterDisplacement, m_maxSeedClusterLength, m_minSeedClusterCaloHits, m_parentPfoListName, and lar_content::LArClusterHelper::SortByNHits().

47 {
48  if (inputClusters.empty())
49  return;
50 
51  const HitType clusterHitType(LArClusterHelper::GetClusterHitType(inputClusters.front()));
52 
53  // Get parent and daughter Pfos
54  PfoVector parentPfos, daughterPfos;
55  this->GetPfos(m_parentPfoListName, parentPfos);
56  this->GetPfos(m_daughterPfoListName, daughterPfos);
57 
58  ClusterList parentClusters, daughterClusters;
59 
60  for (const Pfo *const pParentPfo : parentPfos)
61  LArPfoHelper::GetClusters(pParentPfo, clusterHitType, parentClusters);
62 
63  for (const Pfo *const pDaughterPfo : daughterPfos)
64  LArPfoHelper::GetClusters(pDaughterPfo, clusterHitType, daughterClusters);
65 
66  // Select short parent clusters
67  for (const Cluster *const pCluster : parentClusters)
68  {
70  seedClusters.push_back(pCluster);
71  }
72 
73  // Select all secondary clusters
74  for (const Cluster *const pCluster : daughterClusters)
75  {
76  seedClusters.push_back(pCluster);
77  }
78 
79  // Select other possible delta rays
80  for (const Cluster *const pCluster : inputClusters)
81  {
82  if (pCluster->GetNCaloHits() < m_minSeedClusterCaloHits)
83  continue;
84 
85  const float parentDistance(
86  parentClusters.empty() ? std::numeric_limits<float>::max() : LArClusterHelper::GetClosestDistance(pCluster, parentClusters));
87 
88  if (parentDistance > m_maxSeedClusterDisplacement)
89  continue;
90 
91  const float daughterDistance(
92  daughterClusters.empty() ? std::numeric_limits<float>::max() : LArClusterHelper::GetClosestDistance(pCluster, daughterClusters));
93 
94  if (daughterDistance < m_maxSeedClusterDisplacement)
95  continue;
96 
97  seedClusters.push_back(pCluster);
98  }
99 
100  std::sort(seedClusters.begin(), seedClusters.end(), LArClusterHelper::SortByNHits);
101 }
float m_maxSeedClusterLength
The maximum length of a parent clusters.
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
std::string m_daughterPfoListName
The daughter Pfo list name.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
unsigned int m_minSeedClusterCaloHits
The minimum number of calo hits for seed clusters.
HitType
Definition: HitType.h:12
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
std::string m_parentPfoListName
The parent Pfo list name.
void GetPfos(const std::string inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of Pfos from an input Pfo list name.
float m_maxSeedClusterDisplacement
The maximum distance between parent and daughter clusters.
void lar_content::DeltaRayGrowingAlgorithm::GetPfos ( const std::string  inputPfoListName,
pandora::PfoVector &  pfoVector 
) const
private

Get a vector of Pfos from an input Pfo list name.

Parameters
inputPfoListNamethe input Pfo list name
pfoVectorthe output vector of Pfos

Definition at line 105 of file DeltaRayGrowingAlgorithm.cc.

References lar_content::LArPfoHelper::SortByNHits().

Referenced by GetListOfSeedClusters().

106 {
107  const PfoList *pPfoList(nullptr);
108  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, inputPfoListName, pPfoList));
109 
110  if (!pPfoList)
111  return;
112 
113  for (const Pfo *const pPfo : *pPfoList)
114  pfoVector.push_back(pPfo);
115 
116  std::sort(pfoVector.begin(), pfoVector.end(), LArPfoHelper::SortByNHits);
117 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
StatusCode lar_content::DeltaRayGrowingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterGrowingAlgorithm.

Definition at line 121 of file DeltaRayGrowingAlgorithm.cc.

References m_daughterPfoListName, m_maxSeedClusterDisplacement, m_maxSeedClusterLength, m_minCaloHitsPerCluster, m_minSeedClusterCaloHits, m_parentPfoListName, and lar_content::ClusterGrowingAlgorithm::ReadSettings().

122 {
123  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ParentPfoListName", m_parentPfoListName));
124  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "DaughterPfoListName", m_daughterPfoListName));
125 
126  PANDORA_RETURN_RESULT_IF_AND_IF(
127  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCaloHitsPerCluster", m_minCaloHitsPerCluster));
128 
129  PANDORA_RETURN_RESULT_IF_AND_IF(
130  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinSeedClusterCaloHits", m_minSeedClusterCaloHits));
131 
132  PANDORA_RETURN_RESULT_IF_AND_IF(
133  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxSeedClusterLength", m_maxSeedClusterLength));
134 
135  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
136  XmlHelper::ReadValue(xmlHandle, "MaxSeedClusterDisplacement", m_maxSeedClusterDisplacement));
137 
138  return ClusterGrowingAlgorithm::ReadSettings(xmlHandle);
139 }
float m_maxSeedClusterLength
The maximum length of a parent clusters.
std::string m_daughterPfoListName
The daughter Pfo list name.
unsigned int m_minCaloHitsPerCluster
The minimum number of calo hits per candidate cluster.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_minSeedClusterCaloHits
The minimum number of calo hits for seed clusters.
std::string m_parentPfoListName
The parent Pfo list name.
float m_maxSeedClusterDisplacement
The maximum distance between parent and daughter clusters.
StatusCode lar_content::ClusterGrowingAlgorithm::Run ( )
protectedvirtualinherited

Definition at line 27 of file ClusterGrowingAlgorithm.cc.

References lar_content::ClusterGrowingAlgorithm::GetListOfCleanClusters(), lar_content::ClusterGrowingAlgorithm::GetListOfNonSeedClusters(), lar_content::ClusterGrowingAlgorithm::GetListOfSeedClusters(), lar_content::ClusterGrowingAlgorithm::m_inputClusterListName, lar_content::ClusterGrowingAlgorithm::MergeClusters(), and lar_content::ClusterGrowingAlgorithm::PopulateClusterMergeMap().

28 {
29  const ClusterList *pClusterList = NULL;
30 
31  if (m_inputClusterListName.empty())
32  {
33  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
34  }
35  else
36  {
37  PANDORA_RETURN_RESULT_IF_AND_IF(
38  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_inputClusterListName, pClusterList));
39  }
40 
41  if (!pClusterList || pClusterList->empty())
42  {
43  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
44  std::cout << "ClusterGrowingAlgorithm: unable to find cluster list " << m_inputClusterListName << std::endl;
45 
46  return STATUS_CODE_SUCCESS;
47  }
48 
49  ClusterVector inputClusters, seedClusters;
50  this->GetListOfCleanClusters(pClusterList, inputClusters);
51  this->GetListOfSeedClusters(inputClusters, seedClusters);
52 
53  while (true)
54  {
55  ClusterVector currentClusters, nonSeedClusters;
56  this->GetListOfCleanClusters(pClusterList, currentClusters);
57  this->GetListOfNonSeedClusters(currentClusters, seedClusters, nonSeedClusters);
58 
59  ClusterMergeMap clusterMergeMap;
60  this->PopulateClusterMergeMap(seedClusters, nonSeedClusters, clusterMergeMap);
61 
62  if (clusterMergeMap.empty())
63  break;
64 
65  this->MergeClusters(clusterMergeMap);
66  }
67 
68  return STATUS_CODE_SUCCESS;
69 }
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
void GetListOfNonSeedClusters(const pandora::ClusterVector &inputClusters, const pandora::ClusterVector &seedClusters, pandora::ClusterVector &nonSeedClusters) const
Get List of non-seed clusters.
void MergeClusters(const ClusterMergeMap &clusterMergeMap) const
Merge clusters.
virtual void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &cleanClusters) const =0
Populate cluster vector with the subset of clusters judged to be clean.
std::string m_inputClusterListName
The name of the input cluster list. If not specified, will access current list.
virtual void GetListOfSeedClusters(const pandora::ClusterVector &cleanClusters, pandora::ClusterVector &seedClusters) const =0
Select seed clusters for growing.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void PopulateClusterMergeMap(const pandora::ClusterVector &seedClusters, const pandora::ClusterVector &nonSeedClusters, ClusterMergeMap &clusterMergeMap) const
Identify a set of cluster merges.

Member Data Documentation

std::string lar_content::DeltaRayGrowingAlgorithm::m_daughterPfoListName
private

The daughter Pfo list name.

Definition at line 44 of file DeltaRayGrowingAlgorithm.h.

Referenced by GetListOfSeedClusters(), and ReadSettings().

float lar_content::DeltaRayGrowingAlgorithm::m_maxSeedClusterDisplacement
private

The maximum distance between parent and daughter clusters.

Definition at line 49 of file DeltaRayGrowingAlgorithm.h.

Referenced by GetListOfSeedClusters(), and ReadSettings().

float lar_content::DeltaRayGrowingAlgorithm::m_maxSeedClusterLength
private

The maximum length of a parent clusters.

Definition at line 48 of file DeltaRayGrowingAlgorithm.h.

Referenced by GetListOfSeedClusters(), and ReadSettings().

unsigned int lar_content::DeltaRayGrowingAlgorithm::m_minCaloHitsPerCluster
private

The minimum number of calo hits per candidate cluster.

Definition at line 46 of file DeltaRayGrowingAlgorithm.h.

Referenced by GetListOfCleanClusters(), and ReadSettings().

unsigned int lar_content::DeltaRayGrowingAlgorithm::m_minSeedClusterCaloHits
private

The minimum number of calo hits for seed clusters.

Definition at line 47 of file DeltaRayGrowingAlgorithm.h.

Referenced by GetListOfSeedClusters(), and ReadSettings().

std::string lar_content::DeltaRayGrowingAlgorithm::m_parentPfoListName
private

The parent Pfo list name.

Definition at line 43 of file DeltaRayGrowingAlgorithm.h.

Referenced by GetListOfSeedClusters(), and ReadSettings().


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