Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ShowerHierarchyMopUpAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
21{
22 const PfoList *pLeadingPfoList(nullptr);
24 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_leadingPfoListName, pLeadingPfoList));
25
26 if (!pLeadingPfoList || pLeadingPfoList->empty())
27 {
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}
40
41//------------------------------------------------------------------------------------------------------------------------------------------
42
43void ShowerHierarchyMopUpAlgorithm::FindParentShowerPfos(const PfoList *const pLeadingPfoList, PfoList &parentShowerPfos) const
44{
45 for (const Pfo *const pLeadingPfo : *pLeadingPfoList)
46 {
47 this->FindParentShowerPfos(pLeadingPfo, parentShowerPfos);
48 }
49}
50
51//------------------------------------------------------------------------------------------------------------------------------------------
52
53void ShowerHierarchyMopUpAlgorithm::FindParentShowerPfos(const Pfo *const pPfo, PfoList &parentShowerPfos) const
54{
55 if (LArPfoHelper::IsShower(pPfo))
56 {
57 if (pPfo->GetDaughterPfoList().empty())
58 return;
59
60 if (parentShowerPfos.end() != std::find(parentShowerPfos.begin(), parentShowerPfos.end(), pPfo))
61 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
62
63 parentShowerPfos.push_back(pPfo);
64 }
65 else
66 {
67 for (const Pfo *const pDaughterPfo : pPfo->GetDaughterPfoList())
68 this->FindParentShowerPfos(pDaughterPfo, parentShowerPfos);
69 }
70}
71
72//------------------------------------------------------------------------------------------------------------------------------------------
73
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}
88
89//------------------------------------------------------------------------------------------------------------------------------------------
90
92{
93 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "LeadingPfoListName", m_leadingPfoListName));
94
96}
97
98} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the pfo helper class.
Header file for the shower hierarchy mop up algorithm class.
#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.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
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...
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
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,...
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.
void PerformPfoMerges(const pandora::PfoList &parentShowerPfos) const
For each parent shower pfo, merge all downstream pfos back into the parent shower.
std::string m_leadingPfoListName
The input leading pfo list name (e.g. list of neutrino or testbeam pfos)
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList