LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::VertexBasedPfoMopUpAlgorithm Class Reference

VertexBasedPfoMopUpAlgorithm class. More...

#include "VertexBasedPfoMopUpAlgorithm.h"

Inheritance diagram for lar_content::VertexBasedPfoMopUpAlgorithm:
lar_content::PfoMopUpBaseAlgorithm lar_content::MopUpBaseAlgorithm lar_content::ShowerPfoMopUpAlgorithm

Classes

class  ClusterAssociation
 ClusterAssociation class. More...
 
class  ConeParameters
 ConeParameters class. More...
 
class  PfoAssociation
 PfoAssociation class. More...
 

Public Member Functions

 VertexBasedPfoMopUpAlgorithm ()
 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 Types

typedef std::vector< PfoAssociationPfoAssociationList
 
typedef std::map< pandora::HitType, ClusterAssociationHitTypeToAssociationMap
 
typedef std::set< pandora::HitType > HitTypeSet
 
typedef std::map< pandora::HitType, const pandora::Cluster * > HitTypeToClusterMap
 

Protected Member Functions

pandora::StatusCode Run ()
 
virtual bool IsVertexAssociated (const pandora::CartesianVector &vertex2D, const LArPointingCluster &pointingCluster) const
 Whether a specified pfo is associated with a specified vertex. More...
 
virtual PfoAssociation GetPfoAssociation (const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo, HitTypeToAssociationMap &hitTypeToAssociationMap) const
 Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter candidate pfo. More...
 
void GetInputPfos (const pandora::Vertex *const pVertex, pandora::PfoList &vertexPfos, pandora::PfoList &nonVertexPfos) const
 Get the list of input pfos and divide them into vertex-associated and non-vertex-associated lists. More...
 
bool IsVertexAssociated (const pandora::Pfo *const pPfo, const pandora::Vertex *const pVertex) const
 Whether a specified pfo is associated with a specified vertex. More...
 
void GetPfoAssociations (const pandora::Vertex *const pVertex, const pandora::PfoList &vertexPfos, const pandora::PfoList &nonVertexPfos, PfoAssociationList &pfoAssociationList) const
 Get the list of associations between vertex-associated pfos and non-vertex-associated pfos. More...
 
PfoAssociation GetPfoAssociation (const pandora::Vertex *const pVertex, const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo) const
 Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter candidate pfo. More...
 
ClusterAssociation GetClusterAssociation (const pandora::Vertex *const pVertex, const pandora::Cluster *const pVertexCluster, const pandora::Cluster *const pDaughterCluster) const
 Get cluster association details between a vertex-associated cluster and a non-vertex associated daughter candidate cluster. More...
 
bool ProcessPfoAssociations (const PfoAssociationList &pfoAssociationList) const
 Process the list of pfo associations, merging the best-matching pfo. More...
 
void MergePfos (const PfoAssociation &pfoAssociation) const
 Merge the vertex and daughter pfos (deleting daughter pfo, merging clusters, etc.) described in the specified pfoAssociation. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Protected Attributes

std::string m_trackPfoListName
 The input track pfo list name. More...
 
std::string m_showerPfoListName
 The input shower pfo list name. More...
 
float m_minVertexLongitudinalDistance
 Vertex association check: min longitudinal distance cut. More...
 
float m_maxVertexTransverseDistance
 Vertex association check: max transverse distance cut. More...
 
unsigned int m_minVertexAssociatedHitTypes
 The min number of vertex associated hit types for a vertex associated pfo. More...
 
float m_coneAngleCentile
 Cluster cone angle is defined using specified centile of distribution of hit half angles. More...
 
float m_maxConeCosHalfAngle
 Maximum value for cosine of cone half angle. More...
 
float m_maxConeLengthMultiplier
 Consider hits as bound if inside cone, with projected distance less than N times cone length. More...
 
float m_directionTanAngle
 Direction determination, look for vertex inside triangle with apex shifted along the cluster length. More...
 
float m_directionApexShift
 Direction determination, look for vertex inside triangle with apex shifted along the cluster length. More...
 
float m_meanBoundedFractionCut
 Cut on association info (mean bounded fraction) for determining pfo merges. More...
 
float m_maxBoundedFractionCut
 Cut on association info (max bounded fraction) for determining pfo merges. More...
 
float m_minBoundedFractionCut
 Cut on association info (min bounded fraction) for determining pfo merges. More...
 
unsigned int m_minConsistentDirections
 The minimum number of consistent cluster directions to allow a pfo merge. More...
 
unsigned int m_minConsistentDirectionsTrack
 The minimum number of consistent cluster directions to allow a merge involving a track pfo. More...
 
pandora::StringVector m_daughterListNames
 The list of potential daughter object list names. More...
 

Detailed Description

Member Typedef Documentation

typedef std::set<pandora::HitType> lar_content::VertexBasedPfoMopUpAlgorithm::HitTypeSet
protected

Definition at line 344 of file VertexBasedPfoMopUpAlgorithm.h.

Definition at line 258 of file VertexBasedPfoMopUpAlgorithm.h.

typedef std::map<pandora::HitType, const pandora::Cluster *> lar_content::VertexBasedPfoMopUpAlgorithm::HitTypeToClusterMap
protected

Definition at line 345 of file VertexBasedPfoMopUpAlgorithm.h.

Constructor & Destructor Documentation

lar_content::VertexBasedPfoMopUpAlgorithm::VertexBasedPfoMopUpAlgorithm ( )

Default constructor.

Definition at line 26 of file VertexBasedPfoMopUpAlgorithm.cc.

26  :
33  m_directionTanAngle(1.732f),
34  m_directionApexShift(0.333f),
40 {
41 }
unsigned int m_minVertexAssociatedHitTypes
The min number of vertex associated hit types for a vertex associated pfo.
float m_maxConeLengthMultiplier
Consider hits as bound if inside cone, with projected distance less than N times cone length...
float m_coneAngleCentile
Cluster cone angle is defined using specified centile of distribution of hit half angles...
unsigned int m_minConsistentDirections
The minimum number of consistent cluster directions to allow a pfo merge.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
float m_maxBoundedFractionCut
Cut on association info (max bounded fraction) for determining pfo merges.
TFile f
Definition: plotHisto.C:6
float m_directionApexShift
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
float m_meanBoundedFractionCut
Cut on association info (mean bounded fraction) for determining pfo merges.
float m_directionTanAngle
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
unsigned int m_minConsistentDirectionsTrack
The minimum number of consistent cluster directions to allow a merge involving a track pfo...
float m_maxConeCosHalfAngle
Maximum value for cosine of cone half angle.
float m_minBoundedFractionCut
Cut on association info (min bounded fraction) for determining pfo merges.

Member Function Documentation

VertexBasedPfoMopUpAlgorithm::ClusterAssociation lar_content::VertexBasedPfoMopUpAlgorithm::GetClusterAssociation ( const pandora::Vertex *const  pVertex,
const pandora::Cluster *const  pVertexCluster,
const pandora::Cluster *const  pDaughterCluster 
) const
protected

Get cluster association details between a vertex-associated cluster and a non-vertex associated daughter candidate cluster.

Parameters
pVertexthe address of the vertex
pVertexClusterthe address of the vertex-associated cluster
pDaughterClusterthe address of the non-vertex-associated cluster
Returns
the cluster association details

Definition at line 208 of file VertexBasedPfoMopUpAlgorithm.cc.

References lar_content::VertexBasedPfoMopUpAlgorithm::ConeParameters::GetBoundedFraction(), lar_content::LArVertexHelper::GetClusterDirectionInZ(), lar_content::LArClusterHelper::GetClusterHitType(), m_coneAngleCentile, m_directionApexShift, m_directionTanAngle, m_maxConeCosHalfAngle, m_maxConeLengthMultiplier, and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by GetPfoAssociations().

210 {
211  const HitType vertexHitType(LArClusterHelper::GetClusterHitType(pVertexCluster));
212  const CartesianVector vertexPosition2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), vertexHitType));
213 
214  const ConeParameters coneParameters(pVertexCluster, vertexPosition2D, m_coneAngleCentile, m_maxConeCosHalfAngle);
215  const float boundedFraction(coneParameters.GetBoundedFraction(pDaughterCluster, m_maxConeLengthMultiplier));
216 
217  const LArVertexHelper::ClusterDirection vertexClusterDirection(
218  LArVertexHelper::GetClusterDirectionInZ(this->GetPandora(), pVertex, pVertexCluster, m_directionTanAngle, m_directionApexShift));
219  const LArVertexHelper::ClusterDirection daughterClusterDirection(
220  LArVertexHelper::GetClusterDirectionInZ(this->GetPandora(), pVertex, pDaughterCluster, m_directionTanAngle, m_directionApexShift));
221  const bool isConsistentDirection(vertexClusterDirection == daughterClusterDirection);
222 
223  return ClusterAssociation(pVertexCluster, pDaughterCluster, boundedFraction, isConsistentDirection);
224 }
float m_maxConeLengthMultiplier
Consider hits as bound if inside cone, with projected distance less than N times cone length...
float m_coneAngleCentile
Cluster cone angle is defined using specified centile of distribution of hit half angles...
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
float m_directionApexShift
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
float m_directionTanAngle
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
float m_maxConeCosHalfAngle
Maximum value for cosine of cone half angle.
HitType
Definition: HitType.h:12
static ClusterDirection GetClusterDirectionInZ(const pandora::Pandora &pandora, const pandora::Vertex *const pVertex, const pandora::Cluster *const pCluster, const float tanAngle, const float apexShift)
Get the direction of the cluster in z, using a projection of the provided vertex. ...
void lar_content::VertexBasedPfoMopUpAlgorithm::GetInputPfos ( const pandora::Vertex *const  pVertex,
pandora::PfoList &  vertexPfos,
pandora::PfoList &  nonVertexPfos 
) const
protected

Get the list of input pfos and divide them into vertex-associated and non-vertex-associated lists.

Parameters
pVertexthe address of the 3d vertex
vertexPfosto receive the list of vertex-associated pfos
nonVertexPfosto receive the list of nonvertex-associated pfos

Definition at line 101 of file VertexBasedPfoMopUpAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), IsVertexAssociated(), m_minVertexAssociatedHitTypes, m_showerPfoListName, m_trackPfoListName, and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by Run().

102 {
103  StringVector listNames;
104  listNames.push_back(m_trackPfoListName);
105  listNames.push_back(m_showerPfoListName);
106 
107  for (const std::string &listName : listNames)
108  {
109  const PfoList *pPfoList(nullptr);
110 
111  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, listName, pPfoList))
112  continue;
113 
114  for (const Pfo *const pPfo : *pPfoList)
115  {
116  PfoList &pfoTargetList(this->IsVertexAssociated(pPfo, pVertex) ? vertexPfos : nonVertexPfos);
117  pfoTargetList.push_back(pPfo);
118  }
119  }
120 }
virtual bool IsVertexAssociated(const pandora::CartesianVector &vertex2D, const LArPointingCluster &pointingCluster) const
Whether a specified pfo is associated with a specified vertex.
std::string m_trackPfoListName
The input track pfo list name.
std::string m_showerPfoListName
The input shower pfo list name.
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.
virtual PfoAssociation lar_content::VertexBasedPfoMopUpAlgorithm::GetPfoAssociation ( const pandora::Pfo *const  pVertexPfo,
const pandora::Pfo *const  pDaughterPfo,
HitTypeToAssociationMap hitTypeToAssociationMap 
) const
protectedvirtual

Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter candidate pfo.

Parameters
pVertexPfothe address of the vertex-associated pfo
pDaughterPfothe address of the non-vertex-associated pfo
hitTypeToAssociationMapthe hit type to association map
Returns
the pfo association details

Reimplemented in lar_content::ShowerPfoMopUpAlgorithm.

Referenced by GetPfoAssociations(), and Run().

PfoAssociation lar_content::VertexBasedPfoMopUpAlgorithm::GetPfoAssociation ( const pandora::Vertex *const  pVertex,
const pandora::Pfo *const  pVertexPfo,
const pandora::Pfo *const  pDaughterPfo 
) const
protected

Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter candidate pfo.

Parameters
pVertexthe address of the 3d vertex
pVertexPfothe address of the vertex-associated pfo
pDaughterPfothe address of the non-vertex-associated pfo
Returns
the pfo association details
void lar_content::VertexBasedPfoMopUpAlgorithm::GetPfoAssociations ( const pandora::Vertex *const  pVertex,
const pandora::PfoList &  vertexPfos,
const pandora::PfoList &  nonVertexPfos,
PfoAssociationList pfoAssociationList 
) const
protected

Get the list of associations between vertex-associated pfos and non-vertex-associated pfos.

Parameters
pVertexthe address of the 3d vertex
vertexPfosthe list of vertex-associated pfos
nonVertexPfosthe list of nonvertex-associated pfos
pfoAssociationListto receive the pfo association list

Definition at line 158 of file VertexBasedPfoMopUpAlgorithm.cc.

References GetClusterAssociation(), lar_content::LArClusterHelper::GetClusterHitType(), and GetPfoAssociation().

Referenced by Run().

160 {
161  for (const Pfo *const pVertexPfo : vertexPfos)
162  {
163  for (const Pfo *const pDaughterPfo : nonVertexPfos)
164  {
165  try
166  {
167  const PfoAssociation pfoAssociation(this->GetPfoAssociation(pVertex, pVertexPfo, pDaughterPfo));
168  pfoAssociationList.push_back(pfoAssociation);
169  }
170  catch (StatusCodeException &)
171  {
172  }
173  }
174  }
175 }
virtual PfoAssociation GetPfoAssociation(const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo, HitTypeToAssociationMap &hitTypeToAssociationMap) const
Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter cand...
virtual bool lar_content::VertexBasedPfoMopUpAlgorithm::IsVertexAssociated ( const pandora::CartesianVector &  vertex2D,
const LArPointingCluster pointingCluster 
) const
protectedvirtual

Whether a specified pfo is associated with a specified vertex.

Parameters
vertex2Dthe 2d vertex position
pointingClusterthe pointing cluster
Returns
boolean

Reimplemented in lar_content::ShowerPfoMopUpAlgorithm.

Referenced by GetInputPfos(), and Run().

bool lar_content::VertexBasedPfoMopUpAlgorithm::IsVertexAssociated ( const pandora::Pfo *const  pPfo,
const pandora::Vertex *const  pVertex 
) const
protected

Whether a specified pfo is associated with a specified vertex.

Parameters
pPfothe address of the pfo
pVertexthe address of the 3d vertex
Returns
boolean
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 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
void lar_content::VertexBasedPfoMopUpAlgorithm::MergePfos ( const PfoAssociation pfoAssociation) const
protected

Merge the vertex and daughter pfos (deleting daughter pfo, merging clusters, etc.) described in the specified pfoAssociation.

Parameters
pfoAssociationthe pfo association details

Definition at line 267 of file VertexBasedPfoMopUpAlgorithm.cc.

References lar_content::VertexBasedPfoMopUpAlgorithm::PfoAssociation::GetDaughterPfo(), lar_content::VertexBasedPfoMopUpAlgorithm::PfoAssociation::GetVertexPfo(), m_showerPfoListName, m_trackPfoListName, and lar_content::PfoMopUpBaseAlgorithm::MergeAndDeletePfos().

Referenced by ProcessPfoAssociations().

268 {
269  const PfoList *pTrackPfoList(nullptr), *pShowerPfoList(nullptr);
270  (void)PandoraContentApi::GetList(*this, m_trackPfoListName, pTrackPfoList);
271  (void)PandoraContentApi::GetList(*this, m_showerPfoListName, pShowerPfoList);
272 
273  if (!pTrackPfoList && !pShowerPfoList)
274  throw StatusCodeException(STATUS_CODE_FAILURE);
275 
276  const Pfo *const pVertexPfo(pfoAssociation.GetVertexPfo());
277  const bool isvertexTrack(pTrackPfoList && (pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pVertexPfo)));
278  const Pfo *pDaughterPfo(pfoAssociation.GetDaughterPfo());
279  const bool isDaughterShower(pShowerPfoList && (pShowerPfoList->end() != std::find(pShowerPfoList->begin(), pShowerPfoList->end(), pDaughterPfo)));
280 
281  this->MergeAndDeletePfos(pVertexPfo, pDaughterPfo);
282 
283  if (isvertexTrack && isDaughterShower)
284  {
285  const PfoList vertexPfoList(1, pVertexPfo);
286 
287  PandoraContentApi::ParticleFlowObject::Metadata metadata;
288  metadata.m_particleId = E_MINUS;
289  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pVertexPfo, metadata));
290 
291  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, m_trackPfoListName, m_showerPfoListName, vertexPfoList));
292  }
293 }
std::string m_trackPfoListName
The input track pfo list name.
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::string m_showerPfoListName
The input shower pfo list name.
bool lar_content::VertexBasedPfoMopUpAlgorithm::ProcessPfoAssociations ( const PfoAssociationList pfoAssociationList) const
protected

Process the list of pfo associations, merging the best-matching pfo.

Parameters
pfoAssociationListthe pfo association list
Returns
whether a pfo merge was made

Definition at line 228 of file VertexBasedPfoMopUpAlgorithm.cc.

References m_maxBoundedFractionCut, m_meanBoundedFractionCut, m_minBoundedFractionCut, m_minConsistentDirections, m_minConsistentDirectionsTrack, m_trackPfoListName, and MergePfos().

Referenced by Run().

229 {
230  const PfoList *pTrackPfoList(nullptr);
231  (void)PandoraContentApi::GetList(*this, m_trackPfoListName, pTrackPfoList);
232 
233  for (const PfoAssociation &pfoAssociation : pfoAssociationList)
234  {
235  if ((pfoAssociation.GetMeanBoundedFraction() < m_meanBoundedFractionCut) ||
236  (pfoAssociation.GetMaxBoundedFraction() < m_maxBoundedFractionCut) || (pfoAssociation.GetMinBoundedFraction() < m_minBoundedFractionCut) ||
237  (pfoAssociation.GetNConsistentDirections() < m_minConsistentDirections))
238  {
239  continue;
240  }
241 
242  if (pTrackPfoList)
243  {
244  if ((pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetVertexPfo())) &&
245  (pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetDaughterPfo())))
246  {
247  continue;
248  }
249 
250  if (((pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetVertexPfo())) ||
251  (pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetDaughterPfo()))) &&
252  (pfoAssociation.GetNConsistentDirections() < m_minConsistentDirectionsTrack))
253  {
254  continue;
255  }
256  }
257 
258  this->MergePfos(pfoAssociation);
259  return true;
260  }
261 
262  return false;
263 }
unsigned int m_minConsistentDirections
The minimum number of consistent cluster directions to allow a pfo merge.
void MergePfos(const PfoAssociation &pfoAssociation) const
Merge the vertex and daughter pfos (deleting daughter pfo, merging clusters, etc.) described in the s...
float m_maxBoundedFractionCut
Cut on association info (max bounded fraction) for determining pfo merges.
float m_meanBoundedFractionCut
Cut on association info (mean bounded fraction) for determining pfo merges.
unsigned int m_minConsistentDirectionsTrack
The minimum number of consistent cluster directions to allow a merge involving a track pfo...
std::string m_trackPfoListName
The input track pfo list name.
float m_minBoundedFractionCut
Cut on association info (min bounded fraction) for determining pfo merges.
StatusCode lar_content::VertexBasedPfoMopUpAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protectedvirtual

Reimplemented from lar_content::PfoMopUpBaseAlgorithm.

Definition at line 508 of file VertexBasedPfoMopUpAlgorithm.cc.

References m_coneAngleCentile, lar_content::MopUpBaseAlgorithm::m_daughterListNames, m_directionApexShift, m_directionTanAngle, m_maxBoundedFractionCut, m_maxConeCosHalfAngle, m_maxConeLengthMultiplier, m_maxVertexTransverseDistance, m_meanBoundedFractionCut, m_minBoundedFractionCut, m_minConsistentDirections, m_minConsistentDirectionsTrack, m_minVertexAssociatedHitTypes, m_minVertexLongitudinalDistance, m_showerPfoListName, m_trackPfoListName, and lar_content::PfoMopUpBaseAlgorithm::ReadSettings().

Referenced by lar_content::ShowerPfoMopUpAlgorithm::ReadSettings().

509 {
510  PANDORA_RETURN_RESULT_IF_AND_IF(
511  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrackPfoListName", m_trackPfoListName));
512 
513  PANDORA_RETURN_RESULT_IF_AND_IF(
514  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ShowerPfoListName", m_showerPfoListName));
515 
516  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
517  XmlHelper::ReadValue(xmlHandle, "MinVertexLongitudinalDistance", m_minVertexLongitudinalDistance));
518 
519  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
520  XmlHelper::ReadValue(xmlHandle, "MaxVertexTransverseDistance", m_maxVertexTransverseDistance));
521 
522  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
523  XmlHelper::ReadValue(xmlHandle, "MinVertexAssociatedHitTypes", m_minVertexAssociatedHitTypes));
524 
525  PANDORA_RETURN_RESULT_IF_AND_IF(
526  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConeAngleCentile", m_coneAngleCentile));
527 
528  PANDORA_RETURN_RESULT_IF_AND_IF(
529  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxConeCosHalfAngle", m_maxConeCosHalfAngle));
530 
531  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
532  XmlHelper::ReadValue(xmlHandle, "MaxConeLengthMultiplier", m_maxConeLengthMultiplier));
533 
534  PANDORA_RETURN_RESULT_IF_AND_IF(
535  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DirectionTanAngle", m_directionTanAngle));
536 
537  PANDORA_RETURN_RESULT_IF_AND_IF(
538  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DirectionApexShift", m_directionApexShift));
539 
540  PANDORA_RETURN_RESULT_IF_AND_IF(
541  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MeanBoundedFractionCut", m_meanBoundedFractionCut));
542 
543  PANDORA_RETURN_RESULT_IF_AND_IF(
544  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxBoundedFractionCut", m_maxBoundedFractionCut));
545 
546  PANDORA_RETURN_RESULT_IF_AND_IF(
547  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinBoundedFractionCut", m_minBoundedFractionCut));
548 
549  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
550  XmlHelper::ReadValue(xmlHandle, "MinConsistentDirections", m_minConsistentDirections));
551 
552  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
553  XmlHelper::ReadValue(xmlHandle, "MinConsistentDirectionsTrack", m_minConsistentDirectionsTrack));
554 
557 
558  return PfoMopUpBaseAlgorithm::ReadSettings(xmlHandle);
559 }
unsigned int m_minVertexAssociatedHitTypes
The min number of vertex associated hit types for a vertex associated pfo.
float m_maxConeLengthMultiplier
Consider hits as bound if inside cone, with projected distance less than N times cone length...
float m_coneAngleCentile
Cluster cone angle is defined using specified centile of distribution of hit half angles...
unsigned int m_minConsistentDirections
The minimum number of consistent cluster directions to allow a pfo merge.
pandora::StringVector m_daughterListNames
The list of potential daughter object list names.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
float m_maxBoundedFractionCut
Cut on association info (max bounded fraction) for determining pfo merges.
float m_directionApexShift
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
float m_meanBoundedFractionCut
Cut on association info (mean bounded fraction) for determining pfo merges.
float m_directionTanAngle
Direction determination, look for vertex inside triangle with apex shifted along the cluster length...
unsigned int m_minConsistentDirectionsTrack
The minimum number of consistent cluster directions to allow a merge involving a track pfo...
float m_maxConeCosHalfAngle
Maximum value for cosine of cone half angle.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::string m_trackPfoListName
The input track pfo list name.
std::string m_showerPfoListName
The input shower pfo list name.
float m_minBoundedFractionCut
Cut on association info (min bounded fraction) for determining pfo merges.
StatusCode lar_content::VertexBasedPfoMopUpAlgorithm::Run ( )
protected

Definition at line 45 of file VertexBasedPfoMopUpAlgorithm.cc.

References lar_content::LArPointingCluster::GetInnerVertex(), GetInputPfos(), lar_content::LArPointingCluster::GetOuterVertex(), GetPfoAssociation(), GetPfoAssociations(), lar_content::LArPointingClusterHelper::IsNode(), IsVertexAssociated(), m_maxVertexTransverseDistance, m_minVertexLongitudinalDistance, and ProcessPfoAssociations().

46 {
47  const VertexList *pVertexList = nullptr;
48  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetCurrentList(*this, pVertexList));
49 
50  const Vertex *const pSelectedVertex(
51  (pVertexList && (pVertexList->size() == 1) && (VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) : nullptr);
52 
53  if (!pSelectedVertex)
54  {
55  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
56  std::cout << "VertexBasedPfoMopUp: unable to find vertex in current list " << std::endl;
57 
58  return STATUS_CODE_SUCCESS;
59  }
60 
61  while (true)
62  {
63  PfoList vertexPfos, nonVertexPfos;
64  this->GetInputPfos(pSelectedVertex, vertexPfos, nonVertexPfos);
65 
66  PfoAssociationList pfoAssociationList;
67  this->GetPfoAssociations(pSelectedVertex, vertexPfos, nonVertexPfos, pfoAssociationList);
68 
69  std::sort(pfoAssociationList.begin(), pfoAssociationList.end());
70  const bool pfoMergeMade(this->ProcessPfoAssociations(pfoAssociationList));
71 
72  if (!pfoMergeMade)
73  break;
74  }
75 
76  return STATUS_CODE_SUCCESS;
77 }
void GetPfoAssociations(const pandora::Vertex *const pVertex, const pandora::PfoList &vertexPfos, const pandora::PfoList &nonVertexPfos, PfoAssociationList &pfoAssociationList) const
Get the list of associations between vertex-associated pfos and non-vertex-associated pfos...
bool ProcessPfoAssociations(const PfoAssociationList &pfoAssociationList) const
Process the list of pfo associations, merging the best-matching pfo.
void GetInputPfos(const pandora::Vertex *const pVertex, pandora::PfoList &vertexPfos, pandora::PfoList &nonVertexPfos) const
Get the list of input pfos and divide them into vertex-associated and non-vertex-associated lists...
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::list< Vertex > VertexList
Definition: DCEL.h:169

Member Data Documentation

float lar_content::VertexBasedPfoMopUpAlgorithm::m_coneAngleCentile
protected

Cluster cone angle is defined using specified centile of distribution of hit half angles.

Definition at line 354 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetClusterAssociation(), and ReadSettings().

pandora::StringVector lar_content::MopUpBaseAlgorithm::m_daughterListNames
protectedinherited
float lar_content::VertexBasedPfoMopUpAlgorithm::m_directionApexShift
protected

Direction determination, look for vertex inside triangle with apex shifted along the cluster length.

Definition at line 359 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetClusterAssociation(), and ReadSettings().

float lar_content::VertexBasedPfoMopUpAlgorithm::m_directionTanAngle
protected

Direction determination, look for vertex inside triangle with apex shifted along the cluster length.

Definition at line 358 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetClusterAssociation(), and ReadSettings().

float lar_content::VertexBasedPfoMopUpAlgorithm::m_maxBoundedFractionCut
protected

Cut on association info (max bounded fraction) for determining pfo merges.

Definition at line 362 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by ProcessPfoAssociations(), ReadSettings(), and lar_content::ShowerPfoMopUpAlgorithm::ShowerPfoMopUpAlgorithm().

float lar_content::VertexBasedPfoMopUpAlgorithm::m_maxConeCosHalfAngle
protected

Maximum value for cosine of cone half angle.

Definition at line 355 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetClusterAssociation(), and ReadSettings().

float lar_content::VertexBasedPfoMopUpAlgorithm::m_maxConeLengthMultiplier
protected

Consider hits as bound if inside cone, with projected distance less than N times cone length.

Definition at line 356 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetClusterAssociation(), and ReadSettings().

float lar_content::VertexBasedPfoMopUpAlgorithm::m_maxVertexTransverseDistance
protected
float lar_content::VertexBasedPfoMopUpAlgorithm::m_meanBoundedFractionCut
protected

Cut on association info (mean bounded fraction) for determining pfo merges.

Definition at line 361 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by ProcessPfoAssociations(), ReadSettings(), and lar_content::ShowerPfoMopUpAlgorithm::ShowerPfoMopUpAlgorithm().

float lar_content::VertexBasedPfoMopUpAlgorithm::m_minBoundedFractionCut
protected

Cut on association info (min bounded fraction) for determining pfo merges.

Definition at line 363 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by ProcessPfoAssociations(), ReadSettings(), and lar_content::ShowerPfoMopUpAlgorithm::ShowerPfoMopUpAlgorithm().

unsigned int lar_content::VertexBasedPfoMopUpAlgorithm::m_minConsistentDirections
protected

The minimum number of consistent cluster directions to allow a pfo merge.

Definition at line 365 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by ProcessPfoAssociations(), ReadSettings(), and lar_content::ShowerPfoMopUpAlgorithm::ShowerPfoMopUpAlgorithm().

unsigned int lar_content::VertexBasedPfoMopUpAlgorithm::m_minConsistentDirectionsTrack
protected

The minimum number of consistent cluster directions to allow a merge involving a track pfo.

Definition at line 366 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by ProcessPfoAssociations(), ReadSettings(), and lar_content::ShowerPfoMopUpAlgorithm::ShowerPfoMopUpAlgorithm().

unsigned int lar_content::VertexBasedPfoMopUpAlgorithm::m_minVertexAssociatedHitTypes
protected

The min number of vertex associated hit types for a vertex associated pfo.

Definition at line 352 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetInputPfos(), and ReadSettings().

float lar_content::VertexBasedPfoMopUpAlgorithm::m_minVertexLongitudinalDistance
protected

Vertex association check: min longitudinal distance cut.

Definition at line 350 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by lar_content::ShowerPfoMopUpAlgorithm::IsVertexAssociated(), ReadSettings(), and Run().

std::string lar_content::VertexBasedPfoMopUpAlgorithm::m_showerPfoListName
protected

The input shower pfo list name.

Definition at line 348 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetInputPfos(), MergePfos(), and ReadSettings().

std::string lar_content::VertexBasedPfoMopUpAlgorithm::m_trackPfoListName
protected

The input track pfo list name.

Definition at line 347 of file VertexBasedPfoMopUpAlgorithm.h.

Referenced by GetInputPfos(), MergePfos(), ProcessPfoAssociations(), and ReadSettings().


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