9 #include "Pandora/AlgorithmHeaders.h" 20 StatusCode ShowerHierarchyMopUpAlgorithm::Run()
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));
26 if (!pLeadingPfoList || pLeadingPfoList->empty())
28 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
29 std::cout <<
"ShowerHierarchyMopUpAlgorithm: unable to find pfos in provided list, " << m_leadingPfoListName << std::endl;
31 return STATUS_CODE_SUCCESS;
34 PfoList parentShowerPfos;
35 this->FindParentShowerPfos(pLeadingPfoList, parentShowerPfos);
36 this->PerformPfoMerges(parentShowerPfos);
38 return STATUS_CODE_SUCCESS;
43 void ShowerHierarchyMopUpAlgorithm::FindParentShowerPfos(
const PfoList *
const pLeadingPfoList, PfoList &parentShowerPfos)
const 45 for (
const Pfo *
const pLeadingPfo : *pLeadingPfoList)
47 this->FindParentShowerPfos(pLeadingPfo, parentShowerPfos);
53 void ShowerHierarchyMopUpAlgorithm::FindParentShowerPfos(
const Pfo *
const pPfo, PfoList &parentShowerPfos)
const 55 if (LArPfoHelper::IsShower(pPfo))
57 if (pPfo->GetDaughterPfoList().empty())
60 if (parentShowerPfos.end() != std::find(parentShowerPfos.begin(), parentShowerPfos.end(), pPfo))
61 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
63 parentShowerPfos.push_back(pPfo);
67 for (
const Pfo *
const pDaughterPfo : pPfo->GetDaughterPfoList())
68 this->FindParentShowerPfos(pDaughterPfo, parentShowerPfos);
74 void ShowerHierarchyMopUpAlgorithm::PerformPfoMerges(
const PfoList &parentShowerPfos)
const 76 for (
const Pfo *
const pParentShowerPfo : parentShowerPfos)
78 PfoList downstreamPfos;
79 LArPfoHelper::GetAllDownstreamPfos(pParentShowerPfo, downstreamPfos);
81 for (
const Pfo *
const pDownstreamPfo : downstreamPfos)
83 if (pDownstreamPfo != pParentShowerPfo)
84 this->MergeAndDeletePfos(pParentShowerPfo, pDownstreamPfo);
91 StatusCode ShowerHierarchyMopUpAlgorithm::ReadSettings(
const TiXmlHandle xmlHandle)
93 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"LeadingPfoListName", m_leadingPfoListName));
95 return PfoMopUpBaseAlgorithm::ReadSettings(xmlHandle);
Header file for the pfo helper class.
Header file for the shower hierarchy mop up algorithm class.