LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
DeltaRayGrowingAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 DeltaRayGrowingAlgorithm::DeltaRayGrowingAlgorithm() :
22  m_minCaloHitsPerCluster(2),
23  m_minSeedClusterCaloHits(5),
24  m_maxSeedClusterLength(10.f),
25  m_maxSeedClusterDisplacement(1.5f)
26 {
27 }
28 
29 //------------------------------------------------------------------------------------------------------------------------------------------
30 
31 void DeltaRayGrowingAlgorithm::GetListOfCleanClusters(const ClusterList *const pClusterList, ClusterVector &clusterVector) const
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 }
43 
44 //------------------------------------------------------------------------------------------------------------------------------------------
45 
46 void DeltaRayGrowingAlgorithm::GetListOfSeedClusters(const ClusterVector &inputClusters, ClusterVector &seedClusters) const
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(parentClusters.empty() ? std::numeric_limits<float>::max() : LArClusterHelper::GetClosestDistance(pCluster, parentClusters));
86 
87  if (parentDistance > m_maxSeedClusterDisplacement)
88  continue;
89 
90  const float daughterDistance(daughterClusters.empty() ? std::numeric_limits<float>::max() : LArClusterHelper::GetClosestDistance(pCluster, daughterClusters));
91 
92  if (daughterDistance < m_maxSeedClusterDisplacement)
93  continue;
94 
95  seedClusters.push_back(pCluster);
96  }
97 
98  std::sort(seedClusters.begin(), seedClusters.end(), LArClusterHelper::SortByNHits);
99 }
100 
101 //------------------------------------------------------------------------------------------------------------------------------------------
102 
103 void DeltaRayGrowingAlgorithm::GetPfos(const std::string inputPfoListName, PfoVector &pfoVector) const
104 {
105  const PfoList *pPfoList(nullptr);
106  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, inputPfoListName, pPfoList));
107 
108  if (!pPfoList)
109  return;
110 
111  for (const Pfo *const pPfo : *pPfoList)
112  pfoVector.push_back(pPfo);
113 
114  std::sort(pfoVector.begin(), pfoVector.end(), LArPfoHelper::SortByNHits);
115 }
116 
117 //------------------------------------------------------------------------------------------------------------------------------------------
118 
119 StatusCode DeltaRayGrowingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
120 {
121  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ParentPfoListName", m_parentPfoListName));
122  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "DaughterPfoListName", m_daughterPfoListName));
123 
124  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
125  "MinCaloHitsPerCluster", m_minCaloHitsPerCluster));
126 
127  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
128  "MinSeedClusterCaloHits", m_minSeedClusterCaloHits));
129 
130  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
131  "MaxSeedClusterLength", m_maxSeedClusterLength));
132 
133  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
134  "MaxSeedClusterDisplacement", m_maxSeedClusterDisplacement));
135 
136  return ClusterGrowingAlgorithm::ReadSettings(xmlHandle);
137 }
138 
139 } // namespace lar_content
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 bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
Header file for the pfo helper class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
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.
void GetListOfSeedClusters(const pandora::ClusterVector &inputClusters, pandora::ClusterVector &seedClusters) const
Select seed clusters for growing.
std::string m_daughterPfoListName
The daughter Pfo list name.
void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &cleanClusters) const
Populate cluster vector with the subset of clusters judged to be clean.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
Header file for the cluster helper class.
unsigned int m_minCaloHitsPerCluster
The minimum number of calo hits per candidate cluster.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::vector< art::Ptr< recob::Cluster > > ClusterVector
unsigned int m_minSeedClusterCaloHits
The minimum number of calo hits for seed clusters.
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.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
float m_maxSeedClusterDisplacement
The maximum distance between parent and daughter clusters.