Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
DeltaRayGrowingAlgorithm.cc
Go to the documentation of this file.
1
10
13
15
16using namespace pandora;
17
18namespace lar_content
19{
20
22 m_minCaloHitsPerCluster(2),
23 m_minSeedClusterCaloHits(5),
24 m_maxSeedClusterLength(10.f),
25 m_maxSeedClusterDisplacement(1.5f)
26{
27}
28
29//------------------------------------------------------------------------------------------------------------------------------------------
30
31void 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
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}
102
103//------------------------------------------------------------------------------------------------------------------------------------------
104
105void DeltaRayGrowingAlgorithm::GetPfos(const std::string inputPfoListName, PfoVector &pfoVector) const
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}
118
119//------------------------------------------------------------------------------------------------------------------------------------------
120
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
127 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCaloHitsPerCluster", m_minCaloHitsPerCluster));
128
130 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinSeedClusterCaloHits", m_minSeedClusterCaloHits));
131
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
139}
140
141} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cluster helper class.
Header file for the pfo helper class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:55
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_daughterPfoListName
The daughter Pfo list name.
unsigned int m_minSeedClusterCaloHits
The minimum number of calo hits for seed clusters.
float m_maxSeedClusterLength
The maximum length of a parent clusters.
std::string m_parentPfoListName
The parent Pfo list name.
void GetListOfSeedClusters(const pandora::ClusterVector &inputClusters, pandora::ClusterVector &seedClusters) const
Select seed clusters for growing.
unsigned int m_minCaloHitsPerCluster
The minimum number of calo hits per candidate cluster.
void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &cleanClusters) const
Populate cluster vector with the subset of clusters judged to be clean.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
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.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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,...
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
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.
Cluster class.
Definition Cluster.h:31
ParticleFlowObject class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
HitType
Calorimeter hit type enum.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< const ParticleFlowObject * > PfoVector
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList