LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
PfoMopUpBaseAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
14 
15 using namespace pandora;
16 
17 namespace lar_content
18 {
19 
20 void PfoMopUpBaseAlgorithm::MergeAndDeletePfos(const ParticleFlowObject *const pPfoToEnlarge, const ParticleFlowObject *const pPfoToDelete) const
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, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pParentCluster, pDaughterCluster,
49  this->GetListName(pParentCluster), this->GetListName(pDaughterCluster)));
50  }
51  else
52  {
53  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPfoToEnlarge, pDaughterCluster));
54  }
55  }
56 }
57 
58 //------------------------------------------------------------------------------------------------------------------------------------------
59 
60 const Cluster *PfoMopUpBaseAlgorithm::GetParentCluster(const ClusterList &clusterList, const HitType hitType)
61 {
62  unsigned int mostHits(0);
63  const Cluster *pBestParentCluster(nullptr);
64 
65  for (const Cluster *const pParentCluster : clusterList)
66  {
67  if (hitType != LArClusterHelper::GetClusterHitType(pParentCluster))
68  continue;
69 
70  const unsigned int nParentHits(pParentCluster->GetNCaloHits());
71 
72  if (nParentHits > mostHits)
73  {
74  mostHits = nParentHits;
75  pBestParentCluster = pParentCluster;
76  }
77  }
78 
79  return pBestParentCluster;
80 }
81 
82 //------------------------------------------------------------------------------------------------------------------------------------------
83 
84 StatusCode PfoMopUpBaseAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
85 {
86  return MopUpBaseAlgorithm::ReadSettings(xmlHandle);
87 }
88 
89 } // namespace lar_content
Header file for the cluster helper class.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Header file for the pfo mop up algorithm base class.
std::vector< art::Ptr< recob::Vertex > > VertexVector