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

ShowerHierarchyMopUpAlgorithm class. More...

#include "ShowerHierarchyMopUpAlgorithm.h"

Inheritance diagram for lar_content::ShowerHierarchyMopUpAlgorithm:
lar_content::PfoMopUpBaseAlgorithm lar_content::MopUpBaseAlgorithm

Public Member Functions

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, vertex use, etc. More...
 
template<typename T >
const std::string GetListName (const T *const pT) const
 Find the name of the list hosting a specific object. More...
 

Static Public Member Functions

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

Protected Attributes

pandora::StringVector m_daughterListNames
 The list of potential daughter object list names. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
void FindParentShowerPfos (const pandora::PfoList *const pLeadingPfoList, pandora::PfoList &parentShowerPfos) const
 Starting with provided leading pfos, find all shower pfos that themselves have daughter pfos. More...
 
void FindParentShowerPfos (const pandora::Pfo *const pLeadiPfo, pandora::PfoList &parentShowerPfos) const
 Starting with provided pfo, find all downstream shower pfos that themselves have daughter pfos. More...
 
void PerformPfoMerges (const pandora::PfoList &parentShowerPfos) const
 For each parent shower pfo, merge all downstream pfos back into the parent shower. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_leadingPfoListName
 The input leading pfo list name (e.g. list of neutrino or testbeam pfos) More...
 

Detailed Description

Member Function Documentation

void lar_content::ShowerHierarchyMopUpAlgorithm::FindParentShowerPfos ( const pandora::PfoList *const  pLeadingPfoList,
pandora::PfoList &  parentShowerPfos 
) const
private

Starting with provided leading pfos, find all shower pfos that themselves have daughter pfos.

Parameters
pLeadingPfoListthe list of leading pfos
parentShowerPfosto receive the list of parent shower pfos
void lar_content::ShowerHierarchyMopUpAlgorithm::FindParentShowerPfos ( const pandora::Pfo *const  pLeadiPfo,
pandora::PfoList &  parentShowerPfos 
) const
private

Starting with provided pfo, find all downstream shower pfos that themselves have daughter pfos.

Parameters
pPfothe address of a pfo
parentShowerPfosto receive the list of parent shower pfos
template<typename T >
template const std::string lar_content::MopUpBaseAlgorithm::GetListName ( const T *const  pT) const
inherited

Find the name of the list hosting a specific object.

Parameters
pTthe address of the object
Returns
the name of the list

Definition at line 19 of file MopUpBaseAlgorithm.cc.

Referenced by lar_content::IsolatedClusterMopUpAlgorithm::DissolveClustersToHits(), lar_content::ClusterMopUpBaseAlgorithm::MakeClusterMerges(), and lar_content::SlidingConeClusterMopUpAlgorithm::MakeClusterMerges().

20 {
21  std::string currentListName;
22  const MANAGED_CONTAINER<const T *> *pCurrentList(nullptr);
23  (void)PandoraContentApi::GetCurrentList(*this, pCurrentList, currentListName);
24 
25  if (pCurrentList && (pCurrentList->end() != std::find(pCurrentList->begin(), pCurrentList->end(), pT)))
26  return currentListName;
27 
28  for (const std::string &listName : m_daughterListNames)
29  {
30  const MANAGED_CONTAINER<const T *> *pList(nullptr);
31  (void)PandoraContentApi::GetList(*this, listName, pList);
32 
33  if (pList && (pList->end() != std::find(pList->begin(), pList->end(), pT)))
34  return listName;
35  }
36 
37  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
38 }
pandora::StringVector m_daughterListNames
The list of potential daughter object list names.
const Cluster * lar_content::PfoMopUpBaseAlgorithm::GetParentCluster ( const pandora::ClusterList &  clusterList,
const pandora::HitType  hitType 
)
staticinherited

Select the parent cluster (same hit type and most hits) using a provided cluster list and hit type.

Parameters
clusterListthe cluster list
hitTypethe hit type
Returns
the address of the parent cluster

Definition at line 61 of file PfoMopUpBaseAlgorithm.cc.

Referenced by lar_content::SlidingConeClusterMopUpAlgorithm::MakeClusterMerges(), lar_content::SlidingConeClusterMopUpAlgorithm::ClusterMerge::operator<(), lar_content::SlidingConePfoMopUpAlgorithm::ClusterMerge::operator<(), and lar_content::MasterAlgorithm::StitchPfos().

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 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void lar_content::PfoMopUpBaseAlgorithm::MergeAndDeletePfos ( const pandora::ParticleFlowObject *const  pPfoToEnlarge,
const pandora::ParticleFlowObject *const  pPfoToDelete 
) const
virtualinherited

Merge and delete a pair of pfos, with a specific set of conventions for cluster merging, vertex use, etc.

Parameters
pPfoToEnlargethe address of the pfo to enlarge
pPfoToDeletethe address of the pfo to delete (will become a dangling pointer)

Definition at line 20 of file PfoMopUpBaseAlgorithm.cc.

Referenced by lar_content::SlidingConePfoMopUpAlgorithm::MakePfoMerges(), and lar_content::VertexBasedPfoMopUpAlgorithm::MergePfos().

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, !=,
49  PandoraContentApi::MergeAndDeleteClusters(
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 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const std::string GetListName(const T *const pT) const
Find the name of the list hosting a specific object.
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...
HitType
Definition: HitType.h:12
std::vector< art::Ptr< recob::Vertex > > VertexVector
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void lar_content::ShowerHierarchyMopUpAlgorithm::PerformPfoMerges ( const pandora::PfoList &  parentShowerPfos) const
private

For each parent shower pfo, merge all downstream pfos back into the parent shower.

Parameters
parentShowerPfosthe list of parent shower pfos

Definition at line 74 of file ShowerHierarchyMopUpAlgorithm.cc.

75 {
76  for (const Pfo *const pParentShowerPfo : parentShowerPfos)
77  {
78  PfoList downstreamPfos;
79  LArPfoHelper::GetAllDownstreamPfos(pParentShowerPfo, downstreamPfos);
80 
81  for (const Pfo *const pDownstreamPfo : downstreamPfos)
82  {
83  if (pDownstreamPfo != pParentShowerPfo)
84  this->MergeAndDeletePfos(pParentShowerPfo, pDownstreamPfo);
85  }
86  }
87 }
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
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, vertex use, etc.
StatusCode lar_content::ShowerHierarchyMopUpAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::PfoMopUpBaseAlgorithm.

Definition at line 91 of file ShowerHierarchyMopUpAlgorithm.cc.

92 {
93  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "LeadingPfoListName", m_leadingPfoListName));
94 
95  return PfoMopUpBaseAlgorithm::ReadSettings(xmlHandle);
96 }
std::string m_leadingPfoListName
The input leading pfo list name (e.g. list of neutrino or testbeam pfos)
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
StatusCode lar_content::ShowerHierarchyMopUpAlgorithm::Run ( )
private

Definition at line 20 of file ShowerHierarchyMopUpAlgorithm.cc.

21 {
22  const PfoList *pLeadingPfoList(nullptr);
23  PANDORA_RETURN_RESULT_IF_AND_IF(
24  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_leadingPfoListName, pLeadingPfoList));
25 
26  if (!pLeadingPfoList || pLeadingPfoList->empty())
27  {
28  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
29  std::cout << "ShowerHierarchyMopUpAlgorithm: unable to find pfos in provided list, " << m_leadingPfoListName << std::endl;
30 
31  return STATUS_CODE_SUCCESS;
32  }
33 
34  PfoList parentShowerPfos;
35  this->FindParentShowerPfos(pLeadingPfoList, parentShowerPfos);
36  this->PerformPfoMerges(parentShowerPfos);
37 
38  return STATUS_CODE_SUCCESS;
39 }
std::string m_leadingPfoListName
The input leading pfo list name (e.g. list of neutrino or testbeam pfos)
void PerformPfoMerges(const pandora::PfoList &parentShowerPfos) const
For each parent shower pfo, merge all downstream pfos back into the parent shower.
void FindParentShowerPfos(const pandora::PfoList *const pLeadingPfoList, pandora::PfoList &parentShowerPfos) const
Starting with provided leading pfos, find all shower pfos that themselves have daughter pfos...

Member Data Documentation

pandora::StringVector lar_content::MopUpBaseAlgorithm::m_daughterListNames
protectedinherited
std::string lar_content::ShowerHierarchyMopUpAlgorithm::m_leadingPfoListName
private

The input leading pfo list name (e.g. list of neutrino or testbeam pfos)

Definition at line 49 of file ShowerHierarchyMopUpAlgorithm.h.


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