Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
RecursivePfoMopUpAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
21{
22 PfoMergeStatsList mergeStatsListBefore(this->GetPfoMergeStats());
23
24 for (unsigned int iter = 0; iter < m_maxIterations; ++iter)
25 {
26 for (auto const &mopUpAlg : m_mopUpAlgorithms)
27 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RunDaughterAlgorithm(*this, mopUpAlg));
28
29 PfoMergeStatsList mergeStatsListAfter(this->GetPfoMergeStats());
30
31 if (std::equal(mergeStatsListBefore.cbegin(), mergeStatsListBefore.cend(), mergeStatsListAfter.cbegin(), mergeStatsListAfter.cend(), PfoMergeStatsComp))
32 break;
33
34 mergeStatsListBefore = std::move(mergeStatsListAfter);
35 }
36
37 return STATUS_CODE_SUCCESS;
38}
39
40//------------------------------------------------------------------------------------------------------------------------------------------
41
43{
44 PfoMergeStatsList pfoMergeStatsList;
45
46 for (auto const &pfoListName : m_pfoListNames)
47 {
48 const PfoList *pPfoList(nullptr);
49 if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, pfoListName, pPfoList))
50 continue;
51
52 for (const ParticleFlowObject *const pPfo : *pPfoList)
53 {
54 ClusterNumHitsList pfoHits;
55 ClusterList clusterList;
56 LArPfoHelper::GetTwoDClusterList(pPfo, clusterList);
57
58 for (auto const &cluster : clusterList)
59 pfoHits.push_back(cluster->GetNCaloHits());
60
61 const PropertiesMap &pfoMeta(pPfo->GetPropertiesMap());
62 const auto &trackScoreIter(pfoMeta.find("TrackScore"));
63 const float trackScore(trackScoreIter != pfoMeta.end() ? trackScoreIter->second : -1.f);
64
65 pfoMergeStatsList.emplace_back(PfoMergeStats{pfoHits, trackScore});
66 }
67 }
68 return pfoMergeStatsList;
69}
70
71//------------------------------------------------------------------------------------------------------------------------------------------
72
74{
75 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmList(*this, xmlHandle, "MopUpAlgorithms", m_mopUpAlgorithms));
76
77 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
78
79 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MaxIterations", m_maxIterations));
80
81 return STATUS_CODE_SUCCESS;
82}
83
84} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the pfo helper class.
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
static pandora::StatusCode RunDaughterAlgorithm(const pandora::Algorithm &algorithm, const std::string &daughterAlgorithmName)
Run an algorithm registered with pandora, from within a parent algorithm.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
unsigned int m_maxIterations
Maximum number of iterations.
PfoMergeStatsList GetPfoMergeStats() const
Get the PfoMergeStats for all of the particles in the event from m_pfoListNames.
pandora::StatusCode Run()
Run the algorithm.
pandora::StringVector m_mopUpAlgorithms
Ordered list of mop up algorithms to run.
pandora::StringVector m_pfoListNames
The list of pfo list names.
static bool PfoMergeStatsComp(const PfoMergeStats &lhs, const PfoMergeStats &rhs)
Equality comparator for two PfoMergeStats.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
ParticleFlowObject class.
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
Definition XmlHelper.h:229
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
static StatusCode ProcessAlgorithmList(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &listName, StringVector &algorithmNames)
Process a list of daughter algorithms in an xml file.
Definition XmlHelper.cc:48
MANAGED_CONTAINER< const Cluster * > ClusterList
std::map< std::string, float > PropertiesMap
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList
PfoMergeStats class: Object to compare PFO before/after merging algs have run to see if anything chan...