LArSoft  v09_93_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::SlidingConePfoMopUpAlgorithm Class Reference

SlidingConePfoMopUpAlgorithm class. More...

#include "SlidingConePfoMopUpAlgorithm.h"

Inheritance diagram for lar_content::SlidingConePfoMopUpAlgorithm:
lar_content::PfoMopUpBaseAlgorithm lar_content::MopUpBaseAlgorithm

Classes

class  ClusterMerge
 ClusterMerge class. More...
 

Public Member Functions

 SlidingConePfoMopUpAlgorithm ()
 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
 
typedef std::unordered_map< const pandora::Cluster *, bool > VertexAssociationMap
 
typedef std::unordered_map< const pandora::Cluster *, const pandora::Cluster * > ClusterReplacementMap
 

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 GetClusterMergeMap (const pandora::Vertex *const pVertex, const pandora::ClusterVector &clusters3D, const ClusterToPfoMap &clusterToPfoMap, ClusterMergeMap &clusterMergeMap) const
 Get the cluster merge map describing all potential 3d cluster merges. More...
 
bool IsVertexAssociated (const pandora::Cluster *const pCluster, const pandora::Vertex *const pVertex, VertexAssociationMap &vertexAssociationMap, const ThreeDSlidingFitResult *const pSlidingFitResult=nullptr) const
 Whether a 3D cluster is nodally associated with a provided vertex. More...
 
bool IsVertexAssociated (const pandora::Cluster *const pCluster, const pandora::CartesianVector &vertexPosition, const ThreeDSlidingFitResult *const pSlidingFitResult=nullptr) const
 Whether a 3D cluster is nodally associated with a provided vertex. More...
 
bool MakePfoMerges (const ClusterToPfoMap &clusterToPfoMap, const ClusterMergeMap &clusterMergeMap) const
 Make pfo 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...
 
bool m_legacyMode
 Whether to use the legacy cone generation. 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_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_coneTanHalfAngle1
 The cone tan half angle to use when calculating bounded cluster fractions 1. More...
 
float m_coneBoundedFraction1
 The minimum cluster bounded fraction for association 1. More...
 
float m_coneTanHalfAngle2
 The cone tan half angle to use when calculating bounded cluster fractions 2. More...
 
float m_coneBoundedFraction2
 The minimum cluster bounded fraction for association 2. More...
 
float m_minVertexLongitudinalDistance
 Vertex association check: min longitudinal distance cut. More...
 
float m_maxVertexTransverseDistance
 Vertex association check: max transverse distance cut. More...
 

Detailed Description

Member Typedef Documentation

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

Definition at line 102 of file SlidingConePfoMopUpAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster *, const pandora::Cluster *> lar_content::SlidingConePfoMopUpAlgorithm::ClusterReplacementMap
private

Definition at line 154 of file SlidingConePfoMopUpAlgorithm.h.

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

Definition at line 92 of file SlidingConePfoMopUpAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster *, bool> lar_content::SlidingConePfoMopUpAlgorithm::VertexAssociationMap
private

Definition at line 115 of file SlidingConePfoMopUpAlgorithm.h.

Constructor & Destructor Documentation

lar_content::SlidingConePfoMopUpAlgorithm::SlidingConePfoMopUpAlgorithm ( )

Default constructor.

Definition at line 25 of file SlidingConePfoMopUpAlgorithm.cc.

25  :
26  m_useVertex(true),
27  m_legacyMode(true),
28  m_maxIterations(1000),
32  m_nConeFitLayers(20),
33  m_nConeFits(5),
35  m_maxConeLength(126.f),
42 {
43 }
float m_coneBoundedFraction2
The minimum cluster bounded fraction for association 2.
float m_maxConeLength
The maximum allowed cone length to use when calculating bounded cluster fractions.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
float m_coneLengthMultiplier
The cone length multiplier to use when calculating bounded cluster fractions.
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
TFile f
Definition: plotHisto.C:6
bool m_legacyMode
Whether to use the legacy cone generation.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
unsigned int m_nConeFitLayers
The number of layers over which to sum fitted direction to obtain cone fit.
unsigned int m_maxHitsToConsider3DTrack
The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.
float m_coneTanHalfAngle1
The cone tan half angle to use when calculating bounded cluster fractions 1.
float m_coneBoundedFraction1
The minimum cluster bounded fraction for association 1.
unsigned int m_maxIterations
The maximum allowed number of algorithm iterations.
unsigned int m_minHitsToConsider3DShower
The minimum number of hits in a 3d shower cluster to attempt cone fits.
unsigned int m_nConeFits
The number of cone fits to perform, spread roughly uniformly along the shower length.
float m_coneTanHalfAngle2
The cone tan half angle to use when calculating bounded cluster fractions 2.
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.

Member Function Documentation

void lar_content::SlidingConePfoMopUpAlgorithm::GetClusterMergeMap ( const pandora::Vertex *const  pVertex,
const pandora::ClusterVector &  clusters3D,
const ClusterToPfoMap clusterToPfoMap,
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
clusterToPfoMapthe mapping from 3d cluster to pfo
clusterMergeMapto receive the populated cluster merge map

Definition at line 125 of file SlidingConePfoMopUpAlgorithm.cc.

References lar_content::CONE_BACKWARD_ONLY, lar_content::CONE_BOTH_DIRECTIONS, lar_content::CONE_FORWARD_ONLY, f, lar_content::SlidingConePfoMopUpAlgorithm::ClusterMerge::GetBoundedFraction1(), lar_content::SlidingConePfoMopUpAlgorithm::ClusterMerge::GetBoundedFraction2(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::ThreeDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::ThreeDSlidingFitResult::GetGlobalMinLayerPosition(), lar_content::LArPointingCluster::GetInnerVertex(), lar_content::LArPointingCluster::GetOuterVertex(), lar_content::SlidingConePfoMopUpAlgorithm::ClusterMerge::GetParentCluster(), lar_content::LArPointingCluster::Vertex::GetPosition(), lar_content::ThreeDSlidingConeFitResult::GetSimpleConeList(), lar_content::ThreeDSlidingConeFitResult::GetSlidingFitResult(), lar_content::LArGeometryHelper::GetWirePitch(), lar_content::LArPointingClusterHelper::IsNode(), lar_content::LArPfoHelper::IsShower(), IsVertexAssociated(), m_coneBoundedFraction1, m_coneBoundedFraction2, m_coneLengthMultiplier, m_coneTanHalfAngle1, m_coneTanHalfAngle2, m_halfWindowLayers, m_legacyMode, m_maxConeLength, m_maxVertexTransverseDistance, m_minHitsToConsider3DShower, m_minVertexLongitudinalDistance, m_nConeFitLayers, and m_nConeFits.

Referenced by Run().

127 {
128  VertexAssociationMap vertexAssociationMap;
129  const float pitchU{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_U)};
130  const float pitchV{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_V)};
131  const float pitchW{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_W)};
132  const float pitchMax{std::max({pitchU, pitchV, pitchW})};
133 
134  for (const Cluster *const pShowerCluster : clusters3D)
135  {
136  if ((pShowerCluster->GetNCaloHits() < m_minHitsToConsider3DShower) || !LArPfoHelper::IsShower(clusterToPfoMap.at(pShowerCluster)))
137  continue;
138 
139  float coneLength(0.f);
140  SimpleConeList simpleConeList;
141  bool isShowerVertexAssociated(false);
142 
143  try
144  {
145  float layerPitch{0.f};
146  const HitType view{LArClusterHelper::GetClusterHitType(pShowerCluster)};
147  if (view == TPC_VIEW_U || view == TPC_VIEW_V || view == TPC_VIEW_W)
148  layerPitch = LArGeometryHelper::GetWirePitch(this->GetPandora(), view);
149  else
150  layerPitch = pitchMax;
151 
152  const ThreeDSlidingConeFitResult slidingConeFitResult3D(pShowerCluster, m_halfWindowLayers, layerPitch);
153 
154  const CartesianVector &minLayerPosition(slidingConeFitResult3D.GetSlidingFitResult().GetGlobalMinLayerPosition());
155  const CartesianVector &maxLayerPosition(slidingConeFitResult3D.GetSlidingFitResult().GetGlobalMaxLayerPosition());
156  coneLength = std::min(m_coneLengthMultiplier * (maxLayerPosition - minLayerPosition).GetMagnitude(), m_maxConeLength);
157 
158  const float vertexToMinLayer(!pVertex ? 0.f : (pVertex->GetPosition() - minLayerPosition).GetMagnitude());
159  const float vertexToMaxLayer(!pVertex ? 0.f : (pVertex->GetPosition() - maxLayerPosition).GetMagnitude());
160  const ConeSelection coneSelection(!pVertex ? CONE_BOTH_DIRECTIONS
161  : (vertexToMaxLayer > vertexToMinLayer) ? CONE_FORWARD_ONLY
163 
164  slidingConeFitResult3D.GetSimpleConeList(m_nConeFitLayers, m_nConeFits, coneSelection, simpleConeList, m_coneTanHalfAngle1, m_legacyMode);
165  isShowerVertexAssociated =
166  this->IsVertexAssociated(pShowerCluster, pVertex, vertexAssociationMap, &(slidingConeFitResult3D.GetSlidingFitResult()));
167  }
168  catch (const StatusCodeException &)
169  {
170  continue;
171  }
172 
173  for (const Cluster *const pNearbyCluster : clusters3D)
174  {
175  if (pNearbyCluster == pShowerCluster)
176  continue;
177 
178  ClusterMerge bestClusterMerge(nullptr, 0.f, 0.f);
179 
180  for (const SimpleCone &simpleCone : simpleConeList)
181  {
182  const float boundedFraction1(simpleCone.GetBoundedHitFraction(pNearbyCluster, coneLength, m_coneTanHalfAngle1));
183  const float boundedFraction2(simpleCone.GetBoundedHitFraction(pNearbyCluster, coneLength, m_coneTanHalfAngle2));
184  const ClusterMerge clusterMerge(pShowerCluster, boundedFraction1, boundedFraction2);
185 
186  if (clusterMerge < bestClusterMerge)
187  bestClusterMerge = clusterMerge;
188  }
189 
190  if (isShowerVertexAssociated && this->IsVertexAssociated(pNearbyCluster, pVertex, vertexAssociationMap))
191  continue;
192 
193  if (bestClusterMerge.GetParentCluster() && (bestClusterMerge.GetBoundedFraction1() > m_coneBoundedFraction1) &&
194  (bestClusterMerge.GetBoundedFraction2() > m_coneBoundedFraction2))
195  clusterMergeMap[pNearbyCluster].push_back(bestClusterMerge);
196  }
197  }
198 
199  for (ClusterMergeMap::value_type &mapEntry : clusterMergeMap)
200  std::sort(mapEntry.second.begin(), mapEntry.second.end());
201 }
float m_coneBoundedFraction2
The minimum cluster bounded fraction for association 2.
float m_maxConeLength
The maximum allowed cone length to use when calculating bounded cluster fractions.
float m_coneLengthMultiplier
The cone length multiplier to use when calculating bounded cluster fractions.
std::vector< SimpleCone > SimpleConeList
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
TFile f
Definition: plotHisto.C:6
bool IsVertexAssociated(const pandora::Cluster *const pCluster, const pandora::Vertex *const pVertex, VertexAssociationMap &vertexAssociationMap, const ThreeDSlidingFitResult *const pSlidingFitResult=nullptr) const
Whether a 3D cluster is nodally associated with a provided vertex.
bool m_legacyMode
Whether to use the legacy cone generation.
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
unsigned int m_nConeFitLayers
The number of layers over which to sum fitted direction to obtain cone fit.
float m_coneTanHalfAngle1
The cone tan half angle to use when calculating bounded cluster fractions 1.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
float m_coneBoundedFraction1
The minimum cluster bounded fraction for association 1.
std::unordered_map< const pandora::Cluster *, bool > VertexAssociationMap
HitType
Definition: HitType.h:12
ConeSelection
ConeSelection enum.
unsigned int m_minHitsToConsider3DShower
The minimum number of hits in a 3d shower cluster to attempt cone fits.
unsigned int m_nConeFits
The number of cone fits to perform, spread roughly uniformly along the shower length.
float m_coneTanHalfAngle2
The cone tan half angle to use when calculating bounded cluster fractions 2.
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
void lar_content::SlidingConePfoMopUpAlgorithm::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 79 of file SlidingConePfoMopUpAlgorithm.cc.

References m_useVertex.

Referenced by Run().

80 {
81  if (!m_useVertex)
82  return;
83 
84  const VertexList *pVertexList = nullptr;
85  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetCurrentList(*this, pVertexList));
86 
87  pVertex =
88  ((pVertexList && (pVertexList->size() == 1) && (VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) : nullptr);
89 }
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
std::list< Vertex > VertexList
Definition: DCEL.h:169
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 lar_content::SlidingConeClusterMopUpAlgorithm::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 61 of file PfoMopUpBaseAlgorithm.cc.

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

62 {
63  unsigned int mostHits(0);
64  const Cluster *pBestParentCluster(nullptr);
65 
66  for (const Cluster *const pParentCluster : clusterList)
67  {
68  if (hitType != LArClusterHelper::GetClusterHitType(pParentCluster))
69  continue;
70 
71  const unsigned int nParentHits(pParentCluster->GetNCaloHits());
72 
73  if (nParentHits > mostHits)
74  {
75  mostHits = nParentHits;
76  pBestParentCluster = pParentCluster;
77  }
78  }
79 
80  return pBestParentCluster;
81 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void lar_content::SlidingConePfoMopUpAlgorithm::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 93 of file SlidingConePfoMopUpAlgorithm.cc.

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

Referenced by Run().

94 {
95  for (const std::string &pfoListName : m_inputPfoListNames)
96  {
97  const PfoList *pPfoList(nullptr);
98 
99  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, pfoListName, pPfoList))
100  continue;
101 
102  for (const Pfo *const pPfo : *pPfoList)
103  {
104  ClusterList pfoClusters3D;
105  LArPfoHelper::GetThreeDClusterList(pPfo, pfoClusters3D);
106 
107  for (const Cluster *const pCluster3D : pfoClusters3D)
108  {
109  if (LArPfoHelper::IsTrack(pPfo) && (pCluster3D->GetNCaloHits() > m_maxHitsToConsider3DTrack))
110  continue;
111 
112  if (!clusterToPfoMap.insert(ClusterToPfoMap::value_type(pCluster3D, pPfo)).second)
113  throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
114 
115  clusters3D.push_back(pCluster3D);
116  }
117  }
118  }
119 
120  std::sort(clusters3D.begin(), clusters3D.end(), LArClusterHelper::SortByNHits);
121 }
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.
unsigned int m_maxHitsToConsider3DTrack
The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.
pandora::StringVector m_inputPfoListNames
The input pfo list names.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
bool lar_content::SlidingConePfoMopUpAlgorithm::IsVertexAssociated ( const pandora::Cluster *const  pCluster,
const pandora::Vertex *const  pVertex,
VertexAssociationMap vertexAssociationMap,
const ThreeDSlidingFitResult *const  pSlidingFitResult = nullptr 
) const
private

Whether a 3D cluster is nodally associated with a provided vertex.

Parameters
pClusterthe address of the cluster
pVertexthe address of the vertex
vertexAssociationMapthe vertex association map, which caches the results for efficiency
pSlidingFitResultthe address of a 3D sliding linear fit, if available, which aids pointing cluster construction efficiency
Returns
boolean

Referenced by GetClusterMergeMap().

bool lar_content::SlidingConePfoMopUpAlgorithm::IsVertexAssociated ( const pandora::Cluster *const  pCluster,
const pandora::CartesianVector &  vertexPosition,
const ThreeDSlidingFitResult *const  pSlidingFitResult = nullptr 
) const
private

Whether a 3D cluster is nodally associated with a provided vertex.

Parameters
pClusterthe address of the cluster
vertexPositionthe vertex position
pSlidingFitResultthe address of a 3D sliding linear fit, if available, which aids pointing cluster construction efficiency
Returns
boolean
bool lar_content::SlidingConePfoMopUpAlgorithm::MakePfoMerges ( const ClusterToPfoMap clusterToPfoMap,
const ClusterMergeMap clusterMergeMap 
) const
private

Make pfo merges based on the provided cluster merge map.

Parameters
clusterToPfoMapthe mapping from 3d cluster to pfo
clusterMergeMapthe populated cluster merge map
Returns
whether a pfo merge has been made

Definition at line 259 of file SlidingConePfoMopUpAlgorithm.cc.

References lar_content::PfoMopUpBaseAlgorithm::MergeAndDeletePfos(), and lar_content::LArClusterHelper::SortByNHits().

Referenced by Run().

260 {
261  ClusterVector daughterClusters;
262  for (const ClusterMergeMap::value_type &mapEntry : clusterMergeMap)
263  daughterClusters.push_back(mapEntry.first);
264  std::sort(daughterClusters.begin(), daughterClusters.end(), LArClusterHelper::SortByNHits);
265 
266  bool pfosMerged(false);
267  ClusterReplacementMap clusterReplacementMap;
268 
269  for (ClusterVector::const_reverse_iterator rIter = daughterClusters.rbegin(), rIterEnd = daughterClusters.rend(); rIter != rIterEnd; ++rIter)
270  {
271  const Cluster *const pDaughterCluster(*rIter);
272 
273  if (clusterReplacementMap.count(pDaughterCluster))
274  throw StatusCodeException(STATUS_CODE_FAILURE);
275 
276  const Cluster *pParentCluster(clusterMergeMap.at(pDaughterCluster).at(0).GetParentCluster());
277 
278  if (clusterReplacementMap.count(pParentCluster))
279  pParentCluster = clusterReplacementMap.at(pParentCluster);
280 
281  // ATTN Sign there was a reciprocal relationship in the cluster merge map (already actioned once)
282  if (pDaughterCluster == pParentCluster)
283  continue;
284 
285  // Key book-keeping on clusters and use cluster->pfo lookup
286  const Pfo *const pDaughterPfo(clusterToPfoMap.at(pDaughterCluster));
287  const Pfo *const pParentPfo(clusterToPfoMap.at(pParentCluster));
288  this->MergeAndDeletePfos(pParentPfo, pDaughterPfo);
289  pfosMerged = true;
290 
291  // Simple/placeholder book-keeping for reciprocal relationships and progressive merges
292  clusterReplacementMap[pDaughterCluster] = pParentCluster;
293 
294  for (ClusterReplacementMap::value_type &mapEntry : clusterReplacementMap)
295  {
296  if (pDaughterCluster == mapEntry.second)
297  mapEntry.second = pParentCluster;
298  }
299  }
300 
301  return pfosMerged;
302 }
std::unordered_map< const pandora::Cluster *, const pandora::Cluster * > ClusterReplacementMap
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 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.
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 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, !=,
49  PandoraContentApi::MergeAndDeleteClusters(
50  *this, pParentCluster, pDaughterCluster, this->GetListName(pParentCluster), this->GetListName(pDaughterCluster)));
51  }
52  else
53  {
54  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPfoToEnlarge, pDaughterCluster));
55  }
56  }
57 }
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...
HitType
Definition: HitType.h:12
std::vector< art::Ptr< recob::Vertex > > VertexVector
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::vector< art::Ptr< recob::Cluster > > ClusterVector
StatusCode lar_content::SlidingConePfoMopUpAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::PfoMopUpBaseAlgorithm.

Definition at line 330 of file SlidingConePfoMopUpAlgorithm.cc.

References m_coneBoundedFraction1, m_coneBoundedFraction2, m_coneLengthMultiplier, m_coneTanHalfAngle1, m_coneTanHalfAngle2, lar_content::MopUpBaseAlgorithm::m_daughterListNames, m_halfWindowLayers, m_inputPfoListNames, m_legacyMode, m_maxConeLength, m_maxHitsToConsider3DTrack, m_maxIterations, m_maxVertexTransverseDistance, m_minHitsToConsider3DShower, m_minVertexLongitudinalDistance, m_nConeFitLayers, m_nConeFits, m_useVertex, and lar_content::PfoMopUpBaseAlgorithm::ReadSettings().

331 {
332  PANDORA_RETURN_RESULT_IF_AND_IF(
333  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "InputPfoListNames", m_inputPfoListNames));
334 
335  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "UseVertex", m_useVertex));
336 
337  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "LegacyMode", m_legacyMode));
338 
339  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxIterations", m_maxIterations));
340 
341  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
342  XmlHelper::ReadValue(xmlHandle, "MaxHitsToConsider3DTrack", m_maxHitsToConsider3DTrack));
343 
344  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
345  XmlHelper::ReadValue(xmlHandle, "MinHitsToConsider3DShower", m_minHitsToConsider3DShower));
346 
347  PANDORA_RETURN_RESULT_IF_AND_IF(
348  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_halfWindowLayers));
349 
350  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NConeFitLayers", m_nConeFitLayers));
351 
352  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NConeFits", m_nConeFits));
353 
354  PANDORA_RETURN_RESULT_IF_AND_IF(
355  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConeLengthMultiplier", m_coneLengthMultiplier));
356 
357  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxConeLength", m_maxConeLength));
358 
359  PANDORA_RETURN_RESULT_IF_AND_IF(
360  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConeTanHalfAngle1", m_coneTanHalfAngle1));
361 
362  PANDORA_RETURN_RESULT_IF_AND_IF(
363  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConeBoundedFraction1", m_coneBoundedFraction1));
364 
365  PANDORA_RETURN_RESULT_IF_AND_IF(
366  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConeTanHalfAngle2", m_coneTanHalfAngle2));
367 
368  PANDORA_RETURN_RESULT_IF_AND_IF(
369  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConeBoundedFraction2", m_coneBoundedFraction2));
370 
371  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
372  XmlHelper::ReadValue(xmlHandle, "MinVertexLongitudinalDistance", m_minVertexLongitudinalDistance));
373 
374  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
375  XmlHelper::ReadValue(xmlHandle, "MaxVertexTransverseDistance", m_maxVertexTransverseDistance));
376 
378 
379  return PfoMopUpBaseAlgorithm::ReadSettings(xmlHandle);
380 }
float m_coneBoundedFraction2
The minimum cluster bounded fraction for association 2.
float m_maxConeLength
The maximum allowed cone length to use when calculating bounded cluster fractions.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
float m_coneLengthMultiplier
The cone length multiplier to use when calculating bounded cluster fractions.
pandora::StringVector m_daughterListNames
The list of potential daughter object list names.
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
bool m_legacyMode
Whether to use the legacy cone generation.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
unsigned int m_nConeFitLayers
The number of layers over which to sum fitted direction to obtain cone fit.
unsigned int m_maxHitsToConsider3DTrack
The maximum number of hits in a 3d track cluster to warrant inclusion in algorithm.
float m_coneTanHalfAngle1
The cone tan half angle to use when calculating bounded cluster fractions 1.
pandora::StringVector m_inputPfoListNames
The input pfo list names.
float m_coneBoundedFraction1
The minimum cluster bounded fraction for association 1.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_maxIterations
The maximum allowed number of algorithm iterations.
unsigned int m_minHitsToConsider3DShower
The minimum number of hits in a 3d shower cluster to attempt cone fits.
unsigned int m_nConeFits
The number of cone fits to perform, spread roughly uniformly along the shower length.
float m_coneTanHalfAngle2
The cone tan half angle to use when calculating bounded cluster fractions 2.
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
StatusCode lar_content::SlidingConePfoMopUpAlgorithm::Run ( )
private

Definition at line 47 of file SlidingConePfoMopUpAlgorithm.cc.

References GetClusterMergeMap(), GetInteractionVertex(), GetThreeDClusters(), m_maxIterations, m_useVertex, and MakePfoMerges().

48 {
49  const Vertex *pVertex(nullptr);
50  this->GetInteractionVertex(pVertex);
51 
52  if (m_useVertex && !pVertex)
53  {
54  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
55  std::cout << "SlidingConePfoMopUpAlgorithm - interaction vertex not available for use." << std::endl;
56  return STATUS_CODE_SUCCESS;
57  }
58 
59  unsigned int nIterations(0);
60 
61  while (nIterations++ < m_maxIterations)
62  {
63  ClusterVector clusters3D;
64  ClusterToPfoMap clusterToPfoMap;
65  this->GetThreeDClusters(clusters3D, clusterToPfoMap);
66 
67  ClusterMergeMap clusterMergeMap;
68  this->GetClusterMergeMap(pVertex, clusters3D, clusterToPfoMap, clusterMergeMap);
69 
70  if (!this->MakePfoMerges(clusterToPfoMap, clusterMergeMap))
71  break;
72  }
73 
74  return STATUS_CODE_SUCCESS;
75 }
void GetClusterMergeMap(const pandora::Vertex *const pVertex, const pandora::ClusterVector &clusters3D, const ClusterToPfoMap &clusterToPfoMap, ClusterMergeMap &clusterMergeMap) const
Get the cluster merge map describing all potential 3d cluster merges.
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...
std::unordered_map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
bool MakePfoMerges(const ClusterToPfoMap &clusterToPfoMap, const ClusterMergeMap &clusterMergeMap) const
Make pfo merges based on the provided cluster merge map.
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...
bool m_useVertex
Whether to use the interaction vertex to select useful cone directions.
unsigned int m_maxIterations
The maximum allowed number of algorithm iterations.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::unordered_map< const pandora::Cluster *, ClusterMergeList > ClusterMergeMap

Member Data Documentation

float lar_content::SlidingConePfoMopUpAlgorithm::m_coneBoundedFraction1
private

The minimum cluster bounded fraction for association 1.

Definition at line 168 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConePfoMopUpAlgorithm::m_coneBoundedFraction2
private

The minimum cluster bounded fraction for association 2.

Definition at line 170 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConePfoMopUpAlgorithm::m_coneLengthMultiplier
private

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

Definition at line 165 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConePfoMopUpAlgorithm::m_coneTanHalfAngle1
private

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

Definition at line 167 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConePfoMopUpAlgorithm::m_coneTanHalfAngle2
private

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

Definition at line 169 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

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

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

Definition at line 162 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

pandora::StringVector lar_content::SlidingConePfoMopUpAlgorithm::m_inputPfoListNames
private

The input pfo list names.

Definition at line 156 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetThreeDClusters(), and ReadSettings().

bool lar_content::SlidingConePfoMopUpAlgorithm::m_legacyMode
private

Whether to use the legacy cone generation.

Definition at line 158 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConePfoMopUpAlgorithm::m_maxConeLength
private

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

Definition at line 166 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

unsigned int lar_content::SlidingConePfoMopUpAlgorithm::m_maxHitsToConsider3DTrack
private

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

Definition at line 160 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetThreeDClusters(), and ReadSettings().

unsigned int lar_content::SlidingConePfoMopUpAlgorithm::m_maxIterations
private

The maximum allowed number of algorithm iterations.

Definition at line 159 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by ReadSettings(), and Run().

float lar_content::SlidingConePfoMopUpAlgorithm::m_maxVertexTransverseDistance
private

Vertex association check: max transverse distance cut.

Definition at line 172 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

unsigned int lar_content::SlidingConePfoMopUpAlgorithm::m_minHitsToConsider3DShower
private

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

Definition at line 161 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

float lar_content::SlidingConePfoMopUpAlgorithm::m_minVertexLongitudinalDistance
private

Vertex association check: min longitudinal distance cut.

Definition at line 171 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

unsigned int lar_content::SlidingConePfoMopUpAlgorithm::m_nConeFitLayers
private

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

Definition at line 163 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

unsigned int lar_content::SlidingConePfoMopUpAlgorithm::m_nConeFits
private

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

Definition at line 164 of file SlidingConePfoMopUpAlgorithm.h.

Referenced by GetClusterMergeMap(), and ReadSettings().

bool lar_content::SlidingConePfoMopUpAlgorithm::m_useVertex
private

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

Definition at line 157 of file SlidingConePfoMopUpAlgorithm.h.

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


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