LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ClusterMopUpBaseAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 ClusterMopUpBaseAlgorithm::ClusterMopUpBaseAlgorithm() :
22  m_excludePfosContainingTracks(true)
23 {
24 }
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
29 {
30  ClusterList pfoClusterListU, pfoClusterListV, pfoClusterListW;
31  this->GetPfoClusterLists(pfoClusterListU, pfoClusterListV, pfoClusterListW);
32 
33  ClusterList daughterClusterListU, daughterClusterListV, daughterClusterListW;
34  this->GetDaughterClusterLists(daughterClusterListU, daughterClusterListV, daughterClusterListW);
35 
36  this->ClusterMopUp(pfoClusterListU, daughterClusterListU);
37  this->ClusterMopUp(pfoClusterListV, daughterClusterListV);
38  this->ClusterMopUp(pfoClusterListW, daughterClusterListW);
39 
40  return STATUS_CODE_SUCCESS;
41 }
42 
43 //------------------------------------------------------------------------------------------------------------------------------------------
44 
45 void ClusterMopUpBaseAlgorithm::GetPfoClusterLists(ClusterList &clusterListU, ClusterList &clusterListV, ClusterList &clusterListW) const
46 {
47  for (StringVector::const_iterator sIter = m_pfoListNames.begin(), sIterEnd = m_pfoListNames.end(); sIter != sIterEnd; ++sIter)
48  {
49  const PfoList *pPfoList = NULL;
50  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, *sIter, pPfoList))
51  continue;
52 
53  for (PfoList::const_iterator pIter = pPfoList->begin(), pIterEnd = pPfoList->end(); pIter != pIterEnd; ++pIter)
54  {
55  const ParticleFlowObject *const pPfo = *pIter;
56 
58  continue;
59 
60  this->GetClusterLists(pPfo->GetClusterList(), false, clusterListU, clusterListV, clusterListW);
61  }
62  }
63 }
64 
65 //------------------------------------------------------------------------------------------------------------------------------------------
66 
67 void ClusterMopUpBaseAlgorithm::GetDaughterClusterLists(ClusterList &clusterListU, ClusterList &clusterListV, ClusterList &clusterListW) const
68 {
69  for (const std::string &daughterListName : m_daughterListNames)
70  {
71  const ClusterList *pClusterList(nullptr);
72 
73  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, daughterListName, pClusterList))
74  continue;
75 
76  this->GetClusterLists(*pClusterList, true, clusterListU, clusterListV, clusterListW);
77  }
78 }
79 
80 //------------------------------------------------------------------------------------------------------------------------------------------
81 
82 void ClusterMopUpBaseAlgorithm::GetClusterLists(const ClusterList &inputClusterList, const bool availabilityFlag, ClusterList &clusterListU,
83  ClusterList &clusterListV, ClusterList &clusterListW) const
84 {
85  for (ClusterList::const_iterator cIter = inputClusterList.begin(), cIterEnd = inputClusterList.end(); cIter != cIterEnd; ++cIter)
86  {
87  const Cluster *const pCluster(*cIter);
88 
89  if (availabilityFlag != pCluster->IsAvailable())
90  continue;
91 
92  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
93 
94  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
95  continue;
96 
97  ClusterList &target((TPC_VIEW_U == hitType) ? clusterListU : (TPC_VIEW_V == hitType) ? clusterListV : clusterListW);
98  target.push_back(pCluster);
99  }
100 }
101 
102 //------------------------------------------------------------------------------------------------------------------------------------------
103 
105 {
106  ClusterVector sortedRemnantClusters;
107  for (const auto &remnantMapEntry : clusterAssociationMap)
108  sortedRemnantClusters.push_back(remnantMapEntry.first);
109  std::sort(sortedRemnantClusters.begin(), sortedRemnantClusters.end(), LArClusterHelper::SortByNHits);
110 
111  for (const Cluster *const pRemnantCluster : sortedRemnantClusters)
112  {
113  const AssociationDetails &associationDetails(clusterAssociationMap.at(pRemnantCluster));
114  const Cluster *pBestPfoCluster(nullptr);
115  float bestFigureOfMerit(-std::numeric_limits<float>::max());
116 
117  ClusterVector sortedPfoClusters;
118  for (const auto &pfoMapEntry : associationDetails)
119  sortedPfoClusters.push_back(pfoMapEntry.first);
120  std::sort(sortedPfoClusters.begin(), sortedPfoClusters.end(), LArClusterHelper::SortByNHits);
121 
122  for (const Cluster *const pPfoCluster : sortedPfoClusters)
123  {
124  const float figureOfMerit(associationDetails.at(pPfoCluster));
125 
126  if (figureOfMerit > bestFigureOfMerit)
127  {
128  pBestPfoCluster = pPfoCluster;
129  bestFigureOfMerit = figureOfMerit;
130  }
131  }
132 
133  if (!pBestPfoCluster)
134  continue;
135 
136  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
137  PandoraContentApi::MergeAndDeleteClusters(
138  *this, pBestPfoCluster, pRemnantCluster, this->GetListName(pBestPfoCluster), this->GetListName(pRemnantCluster)));
139  }
140 }
141 
142 //------------------------------------------------------------------------------------------------------------------------------------------
143 
144 StatusCode ClusterMopUpBaseAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
145 {
146  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
147 
148  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
149  XmlHelper::ReadValue(xmlHandle, "ExcludePfosContainingTracks", m_excludePfosContainingTracks));
150 
151  return MopUpBaseAlgorithm::ReadSettings(xmlHandle);
152 }
153 
154 } // namespace lar_content
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
virtual void MakeClusterMerges(const ClusterAssociationMap &clusterAssociationMap) const
Make the cluster merges specified in the cluster association map, using list name information in the ...
virtual void GetClusterLists(const pandora::ClusterList &inputClusterList, const bool availabilityFlag, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get the two dimensional clusters contained in an input cluster list, divided into three different vie...
Header file for the pfo helper class.
pandora::StringVector m_daughterListNames
The list of potential daughter object list names.
bool m_excludePfosContainingTracks
Whether to exclude any pfos containing clusters flagged as fixed tracks.
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
std::unordered_map< const pandora::Cluster *, AssociationDetails > ClusterAssociationMap
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const std::string GetListName(const T *const pT) const
Find the name of the list hosting a specific object.
Header file for the cluster helper class.
Header file for the cluster mop up algorithm base class.
std::unordered_map< const pandora::Cluster *, float > AssociationDetails
virtual void GetPfoClusterLists(pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get the two dimensional clusters contained in the input pfo list, divided into three different views...
virtual void ClusterMopUp(const pandora::ClusterList &pfoClusters, const pandora::ClusterList &remnantClusters) const =0
Cluster mop up for a single view. This function is responsible for instructing pandora to make cluste...
HitType
Definition: HitType.h:12
cout<< "-> Edep in the target
Definition: analysis.C:53
std::vector< art::Ptr< recob::Cluster > > ClusterVector
pandora::StringVector m_pfoListNames
The list of pfo list names.
virtual void GetDaughterClusterLists(pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get the two dimensional clusters contained in the input remant/daughter cluster lists, divided into three different views.