LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::SlidingConeClusterMopUpAlgorithm Class Reference

SlidingConeClusterMopUpAlgorithm class. More...

#include "SlidingConeClusterMopUpAlgorithm.h"

Inheritance diagram for lar_content::SlidingConeClusterMopUpAlgorithm:
lar_content::PfoMopUpBaseAlgorithm lar_content::MopUpBaseAlgorithm

Classes

class  ClusterMerge
 ClusterMerge class. More...
 

Public Member Functions

 SlidingConeClusterMopUpAlgorithm ()
 Default constructor. More...
 
virtual void MergeAndDeletePfos (const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete) const
 Merge and delete a pair of pfos, with a specific set of conventions for cluster merging, vertex use, etc. More...
 
template<typename T >
const std::string GetListName (const T *const pT) const
 Find the name of the list hosting a specific object. More...
 

Static Public Member Functions

static const pandora::Cluster * GetParentCluster (const pandora::ClusterList &clusterList, const pandora::HitType hitType)
 Select the parent cluster (same hit type and most hits) using a provided cluster list and hit type. More...
 

Protected Attributes

pandora::StringVector m_daughterListNames
 The list of potential daughter object list names. More...
 

Private Types

typedef std::vector< ClusterMergeClusterMergeList
 
typedef std::unordered_map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
 
typedef std::unordered_map< const pandora::Cluster *, ClusterMergeListClusterMergeMap
 

Private Member Functions

pandora::StatusCode Run ()
 
void GetInteractionVertex (const pandora::Vertex *&pVertex) const
 Get the neutrino interaction vertex if it is available and if the algorithm is configured to do so. More...
 
void GetThreeDClusters (pandora::ClusterVector &clusters3D, ClusterToPfoMap &clusterToPfoMap) const
 Get all 3d clusters contained in the input pfo lists and a mapping from clusters to pfos. More...
 
void GetAvailableTwoDClusters (pandora::ClusterVector &availableClusters2D) const
 Get all available 2d clusters contained in the input cluster lists. More...
 
void GetClusterMergeMap (const pandora::Vertex *const pVertex, const pandora::ClusterVector &clusters3D, const pandora::ClusterVector &availableClusters2D, ClusterMergeMap &clusterMergeMap) const
 Get the cluster merge map describing all potential 3d cluster merges. More...
 
void MakeClusterMerges (const ClusterToPfoMap &clusterToPfoMap, const ClusterMergeMap &clusterMergeMap) const
 Make cluster merges based on the provided cluster merge map. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

pandora::StringVector m_inputPfoListNames
 The input pfo list names. More...
 
bool m_useVertex
 Whether to use the interaction vertex to select useful cone directions. More...
 
unsigned int m_maxIterations
 The maximum allowed number of algorithm iterations. More...
 
unsigned int m_maxHitsToConsider3DTrack
 The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm. More...
 
unsigned int m_minHitsToConsider3DShower
 The minimum number of hits in a 3d shower cluster to attempt cone fits. More...
 
unsigned int m_maxHitsToConsider2DCluster
 The maximum number of hits in a 2d cluster to allow pick-up via sliding cone fits. More...
 
unsigned int m_halfWindowLayers
 The number of layers to use for half-window of sliding fit. More...
 
unsigned int m_nConeFitLayers
 The number of layers over which to sum fitted direction to obtain cone fit. More...
 
unsigned int m_nConeFits
 The number of cone fits to perform, spread roughly uniformly along the shower length. More...
 
float m_coneLengthMultiplier
 The cone length multiplier to use when calculating bounded cluster fractions. More...
 
float m_maxConeLength
 The maximum allowed cone length to use when calculating bounded cluster fractions. More...
 
float m_coneTanHalfAngle
 The cone tan half angle to use when calculating bounded cluster fractions. More...
 
float m_coneBoundedFraction
 The minimum cluster bounded fraction for association. More...
 

Detailed Description

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster*, ClusterMergeList> lar_content::SlidingConeClusterMopUpAlgorithm::ClusterMergeMap
private

Definition at line 109 of file SlidingConeClusterMopUpAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster*, const pandora::ParticleFlowObject*> lar_content::SlidingConeClusterMopUpAlgorithm::ClusterToPfoMap
private

Definition at line 92 of file SlidingConeClusterMopUpAlgorithm.h.

Constructor & Destructor Documentation

lar_content::SlidingConeClusterMopUpAlgorithm::SlidingConeClusterMopUpAlgorithm ( )

Default constructor.

Definition at line 24 of file SlidingConeClusterMopUpAlgorithm.cc.

24  :
25  m_useVertex(true),
26  m_maxIterations(1000),
31  m_nConeFitLayers(40),
32  m_nConeFits(5),
34  m_maxConeLength(126.f),
37 {
38 }
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
unsigned int m_nConeFits
The number of cone fits to perform, spread roughly uniformly along the shower length.
unsigned int m_maxIterations
The maximum allowed number of algorithm iterations.
unsigned int m_nConeFitLayers
The number of layers over which to sum fitted direction to obtain cone fit.
unsigned int m_maxHitsToConsider2DCluster
The maximum number of hits in a 2d cluster to allow pick-up via sliding cone fits.
TFile f
Definition: plotHisto.C:6
float m_coneLengthMultiplier
The cone length multiplier to use when calculating bounded cluster fractions.
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
unsigned int m_minHitsToConsider3DShower
The minimum number of hits in a 3d shower cluster to attempt cone fits.
unsigned int m_maxHitsToConsider3DTrack
The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.
float m_coneBoundedFraction
The minimum cluster bounded fraction for association.
float m_coneTanHalfAngle
The cone tan half angle to use when calculating bounded cluster fractions.
float m_maxConeLength
The maximum allowed cone length to use when calculating bounded cluster fractions.

Member Function Documentation

void lar_content::SlidingConeClusterMopUpAlgorithm::GetAvailableTwoDClusters ( pandora::ClusterVector &  availableClusters2D) const
private

Get all available 2d clusters contained in the input cluster lists.

Parameters
availableClusters2Dto receive the sorted list of available 2d clusters

Definition at line 119 of file SlidingConeClusterMopUpAlgorithm.cc.

References lar_content::MopUpBaseAlgorithm::m_daughterListNames, m_maxHitsToConsider2DCluster, and lar_content::LArClusterHelper::SortByNHits().

Referenced by Run().

120 {
121  for (const std::string &clusterListName : m_daughterListNames)
122  {
123  const ClusterList *pClusterList(nullptr);
124 
125  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, clusterListName, pClusterList))
126  continue;
127 
128  for (const Cluster *const pCluster : *pClusterList)
129  {
130  if (!PandoraContentApi::IsAvailable(*this, pCluster))
131  continue;
132 
133  if (pCluster->GetNCaloHits() > m_maxHitsToConsider2DCluster)
134  continue;
135 
136  availableClusters2D.push_back(pCluster);
137  }
138  }
139 
140  std::sort(availableClusters2D.begin(), availableClusters2D.end(), LArClusterHelper::SortByNHits);
141 }
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.
pandora::StringVector m_daughterListNames
The list of potential daughter object list names.
unsigned int m_maxHitsToConsider2DCluster
The maximum number of hits in a 2d cluster to allow pick-up via sliding cone fits.
void lar_content::SlidingConeClusterMopUpAlgorithm::GetClusterMergeMap ( const pandora::Vertex *const  pVertex,
const pandora::ClusterVector &  clusters3D,
const pandora::ClusterVector &  availableClusters2D,
ClusterMergeMap clusterMergeMap 
) const
private

Get the cluster merge map describing all potential 3d cluster merges.

Parameters
pVertexthe neutrino interaction vertex, if available
clusters3Dthe sorted list of 3d clusters
availableClusters2Dthe sorted list of available 2d clusters
clusterMergeMapto receive the populated cluster merge map

Definition at line 145 of file SlidingConeClusterMopUpAlgorithm.cc.

References lar_content::CONE_BACKWARD_ONLY, lar_content::CONE_BOTH_DIRECTIONS, lar_content::CONE_FORWARD_ONLY, f, lar_content::SlidingConeClusterMopUpAlgorithm::ClusterMerge::GetBoundedFraction(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::ThreeDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::ThreeDSlidingFitResult::GetGlobalMinLayerPosition(), lar_content::SlidingConeClusterMopUpAlgorithm::ClusterMerge::GetParentCluster(), lar_content::ThreeDSlidingConeFitResult::GetSimpleConeList(), lar_content::ThreeDSlidingConeFitResult::GetSlidingFitResult(), lar_content::LArGeometryHelper::GetWireZPitch(), m_coneBoundedFraction, m_coneLengthMultiplier, m_coneTanHalfAngle, m_halfWindowLayers, m_maxConeLength, m_nConeFitLayers, m_nConeFits, min, and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by Run().

147 {
148  const float layerPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
149 
150  for (const Cluster *const pShowerCluster : clusters3D)
151  {
152  float coneLength3D(0.f);
153  SimpleConeList simpleConeList3D;
154 
155  try
156  {
157  const ThreeDSlidingConeFitResult slidingConeFitResult3D(pShowerCluster, m_halfWindowLayers, layerPitch);
158 
159  const CartesianVector &minLayerPosition(slidingConeFitResult3D.GetSlidingFitResult().GetGlobalMinLayerPosition());
160  const CartesianVector &maxLayerPosition(slidingConeFitResult3D.GetSlidingFitResult().GetGlobalMaxLayerPosition());
161  coneLength3D = std::min(m_coneLengthMultiplier * (maxLayerPosition - minLayerPosition).GetMagnitude(), m_maxConeLength);
162 
163  const float vertexToMinLayer(!pVertex ? 0.f : (pVertex->GetPosition() - minLayerPosition).GetMagnitude());
164  const float vertexToMaxLayer(!pVertex ? 0.f : (pVertex->GetPosition() - maxLayerPosition).GetMagnitude());
165  const ConeSelection coneSelection(!pVertex ? CONE_BOTH_DIRECTIONS : (vertexToMaxLayer > vertexToMinLayer) ? CONE_FORWARD_ONLY : CONE_BACKWARD_ONLY);
166 
167  slidingConeFitResult3D.GetSimpleConeList(m_nConeFitLayers, m_nConeFits, coneSelection, simpleConeList3D);
168  }
169  catch (const StatusCodeException &) {continue;}
170 
171  for (const Cluster *const pNearbyCluster2D : availableClusters2D)
172  {
173  ClusterMerge bestClusterMerge(nullptr, 0.f, 0.f);
174  const HitType hitType(LArClusterHelper::GetClusterHitType(pNearbyCluster2D));
175 
176  for (const SimpleCone &simpleCone3D : simpleConeList3D)
177  {
178  const CartesianVector coneBaseCentre3D(simpleCone3D.GetConeApex() + simpleCone3D.GetConeDirection() * coneLength3D);
179  const CartesianVector coneApex2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), simpleCone3D.GetConeApex(), hitType));
180  const CartesianVector coneBaseCentre2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), coneBaseCentre3D, hitType));
181 
182  const CartesianVector apexToBase2D(coneBaseCentre2D - coneApex2D);
183  const SimpleCone simpleCone2D(coneApex2D, apexToBase2D.GetUnitVector(), apexToBase2D.GetMagnitude(), m_coneTanHalfAngle);
184  const ClusterMerge clusterMerge(pShowerCluster, simpleCone2D.GetBoundedHitFraction(pNearbyCluster2D), simpleCone2D.GetMeanRT(pNearbyCluster2D));
185 
186  if (clusterMerge < bestClusterMerge)
187  bestClusterMerge = clusterMerge;
188  }
189 
190  if (bestClusterMerge.GetParentCluster() && (bestClusterMerge.GetBoundedFraction() > m_coneBoundedFraction))
191  clusterMergeMap[pNearbyCluster2D].push_back(bestClusterMerge);
192  }
193  }
194 
195  for (ClusterMergeMap::value_type &mapEntry : clusterMergeMap)
196  std::sort(mapEntry.second.begin(), mapEntry.second.end());
197 }
unsigned int m_nConeFits
The number of cone fits to perform, spread roughly uniformly along the shower length.
std::vector< SimpleCone > SimpleConeList
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
unsigned int m_nConeFitLayers
The number of layers over which to sum fitted direction to obtain cone fit.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
TFile f
Definition: plotHisto.C:6
float m_coneLengthMultiplier
The cone length multiplier to use when calculating bounded cluster fractions.
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
Int_t min
Definition: plot.C:26
float m_coneBoundedFraction
The minimum cluster bounded fraction for association.
float m_coneTanHalfAngle
The cone tan half angle to use when calculating bounded cluster fractions.
ConeSelection
ConeSelection enum.
float m_maxConeLength
The maximum allowed cone length to use when calculating bounded cluster fractions.
void lar_content::SlidingConeClusterMopUpAlgorithm::GetInteractionVertex ( const pandora::Vertex *&  pVertex) const
private

Get the neutrino interaction vertex if it is available and if the algorithm is configured to do so.

Parameters
pVertexto receive the neutrino interaction vertex

Definition at line 71 of file SlidingConeClusterMopUpAlgorithm.cc.

References m_useVertex.

Referenced by Run().

72 {
73  if (!m_useVertex)
74  return;
75 
76  const VertexList *pVertexList = nullptr;
77  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetCurrentList(*this, pVertexList));
78 
79  pVertex = ((pVertexList && (pVertexList->size() == 1) && (VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) : nullptr);
80 }
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
std::list< Vertex > VertexList
Definition: DCEL.h:178
template<typename T >
template const std::string lar_content::MopUpBaseAlgorithm::GetListName ( const T *const  pT) const
inherited

Find the name of the list hosting a specific object.

Parameters
pTthe address of the object
Returns
the name of the list

Definition at line 19 of file MopUpBaseAlgorithm.cc.

Referenced by lar_content::IsolatedClusterMopUpAlgorithm::DissolveClustersToHits(), lar_content::ClusterMopUpBaseAlgorithm::MakeClusterMerges(), and MakeClusterMerges().

20 {
21  std::string currentListName;
22  const MANAGED_CONTAINER<const T*> *pCurrentList(nullptr);
23  (void) PandoraContentApi::GetCurrentList(*this, pCurrentList, currentListName);
24 
25  if (pCurrentList && (pCurrentList->end() != std::find(pCurrentList->begin(), pCurrentList->end(), pT)))
26  return currentListName;
27 
28  for (const std::string &listName : m_daughterListNames)
29  {
30  const MANAGED_CONTAINER<const T*> *pList(nullptr);
31  (void) PandoraContentApi::GetList(*this, listName, pList);
32 
33  if (pList && (pList->end() != std::find(pList->begin(), pList->end(), pT)))
34  return listName;
35  }
36 
37  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
38 }
pandora::StringVector m_daughterListNames
The list of potential daughter object list names.
const Cluster * lar_content::PfoMopUpBaseAlgorithm::GetParentCluster ( const pandora::ClusterList &  clusterList,
const pandora::HitType  hitType 
)
staticinherited

Select the parent cluster (same hit type and most hits) using a provided cluster list and hit type.

Parameters
clusterListthe cluster list
hitTypethe hit type
Returns
the address of the parent cluster

Definition at line 60 of file PfoMopUpBaseAlgorithm.cc.

Referenced by MakeClusterMerges(), lar_content::SlidingConeClusterMopUpAlgorithm::ClusterMerge::operator<(), lar_content::SlidingConePfoMopUpAlgorithm::ClusterMerge::operator<(), and lar_content::MasterAlgorithm::StitchPfos().

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 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void lar_content::SlidingConeClusterMopUpAlgorithm::GetThreeDClusters ( pandora::ClusterVector &  clusters3D,
ClusterToPfoMap clusterToPfoMap 
) const
private

Get all 3d clusters contained in the input pfo lists and a mapping from clusters to pfos.

Parameters
clusters3Dto receive the sorted list of 3d clusters
clusterToPfoMapto receive the mapping from 3d cluster to pfo

Definition at line 84 of file SlidingConeClusterMopUpAlgorithm.cc.

References lar_content::LArPfoHelper::GetThreeDClusterList(), lar_content::LArPfoHelper::IsShower(), lar_content::LArPfoHelper::IsTrack(), m_inputPfoListNames, m_maxHitsToConsider3DTrack, m_minHitsToConsider3DShower, and lar_content::LArClusterHelper::SortByNHits().

Referenced by Run().

85 {
86  for (const std::string &pfoListName : m_inputPfoListNames)
87  {
88  const PfoList *pPfoList(nullptr);
89 
90  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, pfoListName, pPfoList))
91  continue;
92 
93  for (const Pfo *const pPfo : *pPfoList)
94  {
95  ClusterList pfoClusters3D;
96  LArPfoHelper::GetThreeDClusterList(pPfo, pfoClusters3D);
97 
98  for (const Cluster *const pCluster3D : pfoClusters3D)
99  {
100  if (LArPfoHelper::IsTrack(pPfo) && (pCluster3D->GetNCaloHits() > m_maxHitsToConsider3DTrack))
101  continue;
102 
103  if (LArPfoHelper::IsShower(pPfo) && (pCluster3D->GetNCaloHits() < m_minHitsToConsider3DShower))
104  continue;
105 
106  if (!clusterToPfoMap.insert(ClusterToPfoMap::value_type(pCluster3D, pPfo)).second)
107  throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
108 
109  clusters3D.push_back(pCluster3D);
110  }
111  }
112  }
113 
114  std::sort(clusters3D.begin(), clusters3D.end(), LArClusterHelper::SortByNHits);
115 }
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.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
unsigned int m_minHitsToConsider3DShower
The minimum number of hits in a 3d shower cluster to attempt cone fits.
unsigned int m_maxHitsToConsider3DTrack
The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
pandora::StringVector m_inputPfoListNames
The input pfo list names.
void lar_content::SlidingConeClusterMopUpAlgorithm::MakeClusterMerges ( const ClusterToPfoMap clusterToPfoMap,
const ClusterMergeMap clusterMergeMap 
) const
private

Make cluster merges based on the provided cluster merge map.

Parameters
clusterToPfoMapthe mapping from 3d cluster to pfo
clusterMergeMapthe populated cluster merge map

Definition at line 201 of file SlidingConeClusterMopUpAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::MopUpBaseAlgorithm::GetListName(), lar_content::PfoMopUpBaseAlgorithm::GetParentCluster(), and lar_content::LArClusterHelper::SortByNHits().

Referenced by Run().

202 {
203  ClusterVector daughterClusters;
204  for (const ClusterMergeMap::value_type &mapEntry : clusterMergeMap) daughterClusters.push_back(mapEntry.first);
205  std::sort(daughterClusters.begin(), daughterClusters.end(), LArClusterHelper::SortByNHits);
206 
207  for (ClusterVector::const_reverse_iterator rIter = daughterClusters.rbegin(), rIterEnd = daughterClusters.rend(); rIter != rIterEnd; ++rIter)
208  {
209  const Cluster *const pDaughterCluster(*rIter);
210  const HitType daughterHitType(LArClusterHelper::GetClusterHitType(pDaughterCluster));
211  const Cluster *const pParentCluster3D(clusterMergeMap.at(pDaughterCluster).at(0).GetParentCluster());
212 
213  const Pfo *const pParentPfo(clusterToPfoMap.at(pParentCluster3D));
214  const Cluster *const pParentCluster(this->GetParentCluster(pParentPfo->GetClusterList(), daughterHitType));
215 
216  if (pParentCluster)
217  {
218  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pParentCluster, pDaughterCluster,
219  this->GetListName(pParentCluster), this->GetListName(pDaughterCluster)));
220  }
221  else
222  {
223  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pParentPfo, pDaughterCluster));
224  }
225  }
226 }
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.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const std::string GetListName(const T *const pT) const
Find the name of the list hosting a specific object.
static const pandora::Cluster * GetParentCluster(const pandora::ClusterList &clusterList, const pandora::HitType hitType)
Select the parent cluster (same hit type and most hits) using a provided cluster list and hit type...
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void lar_content::PfoMopUpBaseAlgorithm::MergeAndDeletePfos ( const pandora::ParticleFlowObject *const  pPfoToEnlarge,
const pandora::ParticleFlowObject *const  pPfoToDelete 
) const
virtualinherited

Merge and delete a pair of pfos, with a specific set of conventions for cluster merging, vertex use, etc.

Parameters
pPfoToEnlargethe address of the pfo to enlarge
pPfoToDeletethe address of the pfo to delete (will become a dangling pointer)

Definition at line 20 of file PfoMopUpBaseAlgorithm.cc.

Referenced by lar_content::SlidingConePfoMopUpAlgorithm::MakePfoMerges(), and lar_content::VertexBasedPfoMopUpAlgorithm::MergePfos().

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 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const std::string GetListName(const T *const pT) const
Find the name of the list hosting a specific object.
static const pandora::Cluster * GetParentCluster(const pandora::ClusterList &clusterList, const pandora::HitType hitType)
Select the parent cluster (same hit type and most hits) using a provided cluster list and hit type...
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::vector< art::Ptr< recob::Vertex > > VertexVector
StatusCode lar_content::SlidingConeClusterMopUpAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::PfoMopUpBaseAlgorithm.

Definition at line 254 of file SlidingConeClusterMopUpAlgorithm.cc.

References m_coneBoundedFraction, m_coneLengthMultiplier, m_coneTanHalfAngle, m_halfWindowLayers, m_inputPfoListNames, m_maxConeLength, m_maxHitsToConsider2DCluster, m_maxHitsToConsider3DTrack, m_maxIterations, m_minHitsToConsider3DShower, m_nConeFitLayers, m_nConeFits, m_useVertex, and lar_content::PfoMopUpBaseAlgorithm::ReadSettings().

255 {
256  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
257  "InputPfoListNames", m_inputPfoListNames));
258 
259  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
260  "UseVertex", m_useVertex));
261 
262  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
263  "MaxIterations", m_maxIterations));
264 
265  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
266  "MaxHitsToConsider3DTrack", m_maxHitsToConsider3DTrack));
267 
268  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
269  "MinHitsToConsider3DShower", m_minHitsToConsider3DShower));
270 
271  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
272  "MaxHitsToConsider2DCluster", m_maxHitsToConsider2DCluster));
273 
274  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
275  "SlidingFitHalfWindow", m_halfWindowLayers));
276 
277  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
278  "NConeFitLayers", m_nConeFitLayers));
279 
280  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
281  "NConeFits", m_nConeFits));
282 
283  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
284  "ConeLengthMultiplier", m_coneLengthMultiplier));
285 
286  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
287  "MaxConeLength", m_maxConeLength));
288 
289  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
290  "ConeTanHalfAngle", m_coneTanHalfAngle));
291 
292  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
293  "ConeBoundedFraction", m_coneBoundedFraction));
294 
295  return PfoMopUpBaseAlgorithm::ReadSettings(xmlHandle);
296 }
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
unsigned int m_nConeFits
The number of cone fits to perform, spread roughly uniformly along the shower length.
unsigned int m_maxIterations
The maximum allowed number of algorithm iterations.
unsigned int m_nConeFitLayers
The number of layers over which to sum fitted direction to obtain cone fit.
unsigned int m_maxHitsToConsider2DCluster
The maximum number of hits in a 2d cluster to allow pick-up via sliding cone fits.
float m_coneLengthMultiplier
The cone length multiplier to use when calculating bounded cluster fractions.
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
unsigned int m_minHitsToConsider3DShower
The minimum number of hits in a 3d shower cluster to attempt cone fits.
unsigned int m_maxHitsToConsider3DTrack
The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_coneBoundedFraction
The minimum cluster bounded fraction for association.
pandora::StringVector m_inputPfoListNames
The input pfo list names.
float m_coneTanHalfAngle
The cone tan half angle to use when calculating bounded cluster fractions.
float m_maxConeLength
The maximum allowed cone length to use when calculating bounded cluster fractions.
StatusCode lar_content::SlidingConeClusterMopUpAlgorithm::Run ( )
private

Definition at line 42 of file SlidingConeClusterMopUpAlgorithm.cc.

References GetAvailableTwoDClusters(), GetClusterMergeMap(), GetInteractionVertex(), GetThreeDClusters(), m_useVertex, and MakeClusterMerges().

43 {
44  const Vertex *pVertex(nullptr);
45  this->GetInteractionVertex(pVertex);
46 
47  if (m_useVertex && !pVertex)
48  {
49  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
50  std::cout << "SlidingConeClusterMopUpAlgorithm - interaction vertex not available for use." << std::endl;
51  return STATUS_CODE_SUCCESS;
52  }
53 
54  ClusterVector clusters3D;
55  ClusterToPfoMap clusterToPfoMap;
56  this->GetThreeDClusters(clusters3D, clusterToPfoMap);
57 
58  ClusterVector availableClusters2D;
59  this->GetAvailableTwoDClusters(availableClusters2D);
60 
61  ClusterMergeMap clusterMergeMap;
62  this->GetClusterMergeMap(pVertex, clusters3D, availableClusters2D, clusterMergeMap);
63 
64  this->MakeClusterMerges(clusterToPfoMap, clusterMergeMap);
65 
66  return STATUS_CODE_SUCCESS;
67 }
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
std::unordered_map< const pandora::Cluster *, ClusterMergeList > ClusterMergeMap
void GetThreeDClusters(pandora::ClusterVector &clusters3D, ClusterToPfoMap &clusterToPfoMap) const
Get all 3d clusters contained in the input pfo lists and a mapping from clusters to pfos...
std::unordered_map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
void GetClusterMergeMap(const pandora::Vertex *const pVertex, const pandora::ClusterVector &clusters3D, const pandora::ClusterVector &availableClusters2D, ClusterMergeMap &clusterMergeMap) const
Get the cluster merge map describing all potential 3d cluster merges.
void MakeClusterMerges(const ClusterToPfoMap &clusterToPfoMap, const ClusterMergeMap &clusterMergeMap) const
Make cluster merges based on the provided cluster merge map.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void GetAvailableTwoDClusters(pandora::ClusterVector &availableClusters2D) const
Get all available 2d clusters contained in the input cluster lists.
void GetInteractionVertex(const pandora::Vertex *&pVertex) const
Get the neutrino interaction vertex if it is available and if the algorithm is configured to do so...

Member Data Documentation

float lar_content::SlidingConeClusterMopUpAlgorithm::m_coneBoundedFraction
private

The minimum cluster bounded fraction for association.

Definition at line 144 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConeClusterMopUpAlgorithm::m_coneLengthMultiplier
private

The cone length multiplier to use when calculating bounded cluster fractions.

Definition at line 141 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConeClusterMopUpAlgorithm::m_coneTanHalfAngle
private

The cone tan half angle to use when calculating bounded cluster fractions.

Definition at line 143 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

pandora::StringVector lar_content::MopUpBaseAlgorithm::m_daughterListNames
protectedinherited
unsigned int lar_content::SlidingConeClusterMopUpAlgorithm::m_halfWindowLayers
private

The number of layers to use for half-window of sliding fit.

Definition at line 138 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

pandora::StringVector lar_content::SlidingConeClusterMopUpAlgorithm::m_inputPfoListNames
private

The input pfo list names.

Definition at line 132 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetThreeDClusters(), and ReadSettings().

float lar_content::SlidingConeClusterMopUpAlgorithm::m_maxConeLength
private

The maximum allowed cone length to use when calculating bounded cluster fractions.

Definition at line 142 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

unsigned int lar_content::SlidingConeClusterMopUpAlgorithm::m_maxHitsToConsider2DCluster
private

The maximum number of hits in a 2d cluster to allow pick-up via sliding cone fits.

Definition at line 137 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetAvailableTwoDClusters(), and ReadSettings().

unsigned int lar_content::SlidingConeClusterMopUpAlgorithm::m_maxHitsToConsider3DTrack
private

The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.

Definition at line 135 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetThreeDClusters(), and ReadSettings().

unsigned int lar_content::SlidingConeClusterMopUpAlgorithm::m_maxIterations
private

The maximum allowed number of algorithm iterations.

Definition at line 134 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by ReadSettings().

unsigned int lar_content::SlidingConeClusterMopUpAlgorithm::m_minHitsToConsider3DShower
private

The minimum number of hits in a 3d shower cluster to attempt cone fits.

Definition at line 136 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetThreeDClusters(), and ReadSettings().

unsigned int lar_content::SlidingConeClusterMopUpAlgorithm::m_nConeFitLayers
private

The number of layers over which to sum fitted direction to obtain cone fit.

Definition at line 139 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

unsigned int lar_content::SlidingConeClusterMopUpAlgorithm::m_nConeFits
private

The number of cone fits to perform, spread roughly uniformly along the shower length.

Definition at line 140 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

bool lar_content::SlidingConeClusterMopUpAlgorithm::m_useVertex
private

Whether to use the interaction vertex to select useful cone directions.

Definition at line 133 of file SlidingConeClusterMopUpAlgorithm.h.

Referenced by GetInteractionVertex(), ReadSettings(), and Run().


The documentation for this class was generated from the following files: