RecursivePfoMopUpAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTwoDReco/LArClusterMopUp/RecursivePfoMopUpAlgorithm.cc
3  *
4  * @brief Implementation file for the recursive pfo mop up algorithm that runs other algs.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
14 
15 using namespace pandora;
16 
17 namespace lar_content
18 {
19 
20 StatusCode RecursivePfoMopUpAlgorithm::Run()
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 
42 RecursivePfoMopUpAlgorithm::PfoMergeStatsList RecursivePfoMopUpAlgorithm::GetPfoMergeStats() const
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 
73 StatusCode RecursivePfoMopUpAlgorithm::ReadSettings(const pandora::TiXmlHandle xmlHandle)
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
Header file for the pfo helper class.
PfoMergeStats class: Object to compare PFO before/after merging algs have run to see if anything chan...
Cluster finding and building.
def move(depos, offset)
Definition: depos.py:107