Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
PfoMopUpBaseAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
20void PfoMopUpBaseAlgorithm::MergeAndDeletePfos(const ParticleFlowObject *const pPfoToEnlarge, const ParticleFlowObject *const pPfoToDelete) const
21{
22 if (pPfoToEnlarge == pPfoToDelete)
23 throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
24
25 const PfoList daughterPfos(pPfoToDelete->GetDaughterPfoList());
26 const ClusterVector daughterClusters(pPfoToDelete->GetClusterList().begin(), pPfoToDelete->GetClusterList().end());
27 const VertexVector daughterVertices(pPfoToDelete->GetVertexList().begin(), pPfoToDelete->GetVertexList().end());
28
29 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pPfoToDelete, this->GetListName(pPfoToDelete)));
30
31 for (const ParticleFlowObject *const pDaughterPfo : daughterPfos)
32 {
33 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pPfoToEnlarge, pDaughterPfo));
34 }
35
36 for (const Vertex *const pDaughterVertex : daughterVertices)
37 {
38 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pDaughterVertex, this->GetListName(pDaughterVertex)));
39 }
40
41 for (const Cluster *const pDaughterCluster : daughterClusters)
42 {
43 const HitType daughterHitType(LArClusterHelper::GetClusterHitType(pDaughterCluster));
44 const Cluster *pParentCluster(PfoMopUpBaseAlgorithm::GetParentCluster(pPfoToEnlarge->GetClusterList(), daughterHitType));
45
46 if (pParentCluster)
47 {
48 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
50 *this, pParentCluster, pDaughterCluster, this->GetListName(pParentCluster), this->GetListName(pDaughterCluster)));
51 }
52 else
53 {
54 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPfoToEnlarge, pDaughterCluster));
55 }
56 }
57}
58
59//------------------------------------------------------------------------------------------------------------------------------------------
60
61const Cluster *PfoMopUpBaseAlgorithm::GetParentCluster(const ClusterList &clusterList, const HitType hitType)
62{
63 unsigned int mostHits(0);
64 const Cluster *pBestParentCluster(nullptr);
65
66 for (const Cluster *const pParentCluster : clusterList)
67 {
68 if (hitType != LArClusterHelper::GetClusterHitType(pParentCluster))
69 continue;
70
71 const unsigned int nParentHits(pParentCluster->GetNCaloHits());
72
73 if (nParentHits > mostHits)
74 {
75 mostHits = nParentHits;
76 pBestParentCluster = pParentCluster;
77 }
78 }
79
80 return pBestParentCluster;
81}
82
83//------------------------------------------------------------------------------------------------------------------------------------------
84
89
90} // 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 mop up algorithm base class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:43
static pandora::StatusCode AddToPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Add a cluster to a particle flow object.
static pandora::StatusCode MergeAndDeleteClusters(const pandora::Algorithm &algorithm, const pandora::Cluster *const pClusterToEnlarge, const pandora::Cluster *const pClusterToDelete)
Merge two clusters in the current list, enlarging one cluster and deleting the second.
static pandora::StatusCode SetPfoParentDaughterRelationship(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pParentPfo, const pandora::ParticleFlowObject *const pDaughterPfo)
Set parent-daughter particle flow object relationship.
static pandora::StatusCode Delete(const pandora::Algorithm &algorithm, const T *const pT)
Delete an object from the current list.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
const std::string GetListName(const T *const pT) const
Find the name of the list hosting a specific object.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
virtual void MergeAndDeletePfos(const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete) const
Merge and delete a pair of pfos, with a specific set of conventions for cluster merging,...
static const pandora::Cluster * GetParentCluster(const pandora::ClusterList &clusterList, const pandora::HitType hitType)
Select the parent cluster (same hit type and most hits) using a provided cluster list and hit type.
Cluster class.
Definition Cluster.h:31
ParticleFlowObject class.
const PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
const ClusterList & GetClusterList() const
Get the cluster list.
const VertexList & GetVertexList() const
Get the vertex list.
StatusCodeException class.
Vertex class.
Definition Vertex.h:26
HitType
Calorimeter hit type enum.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList
std::vector< const Vertex * > VertexVector