LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::VertexSelectionBaseAlgorithm Class Referenceabstract

VertexSelectionBaseAlgorithm class. More...

#include "VertexSelectionBaseAlgorithm.h"

Inheritance diagram for lar_content::VertexSelectionBaseAlgorithm:
lar_content::EnergyKickVertexSelectionAlgorithm lar_content::HitAngleVertexSelectionAlgorithm lar_content::SvmVertexSelectionAlgorithm

Classes

class  BeamConstants
 Beam constants class. More...
 
class  ShowerCluster
 Shower cluster class. More...
 
class  SlidingFitData
 Sliding fit data class. More...
 
class  VertexScore
 VertexScore class. More...
 

Public Types

typedef std::vector< VertexScoreVertexScoreList
 
typedef std::vector< SlidingFitDataSlidingFitDataList
 
typedef std::vector< ShowerClusterShowerClusterList
 
typedef KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
 
typedef std::vector< HitKDNode2DHitKDNode2DList
 
typedef KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
 
typedef std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
 Map array of cluster lists for passing to tools. More...
 
typedef std::map< pandora::HitType, const SlidingFitDataListSlidingFitDataListMap
 Map of sliding fit data lists for passing to tools. More...
 
typedef std::map< pandora::HitType, const ShowerClusterListShowerClusterListMap
 Map of shower cluster lists for passing to tools. More...
 
typedef std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
 Map array of hit kd trees for passing to tools. More...
 
typedef MvaFeatureTool< const VertexSelectionBaseAlgorithm *const, const pandora::Vertex *const, const SlidingFitDataListMap &, const ClusterListMap &, const KDTreeMap &, const ShowerClusterListMap &, const float, float & > VertexFeatureTool
 The base type for the vertex feature tools. More...
 

Public Member Functions

 VertexSelectionBaseAlgorithm ()
 Default constructor. More...
 

Protected Member Functions

virtual void FilterVertexList (const pandora::VertexList *const pInputVertexList, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, pandora::VertexVector &filteredVertices) const
 Filter the input list of vertices to obtain a reduced number of vertex candidates. More...
 
virtual void GetBeamConstants (const pandora::VertexVector &vertexVector, BeamConstants &beamConstants) const
 Get the beam score constants for a provided list of candidate vertices. More...
 
virtual void GetVertexScoreList (const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const =0
 Get the vertex score list for a provided list of candidate vertices. More...
 
void GetClusterLists (const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
 Get the cluster lists. More...
 
void CalculateClusterSlidingFits (const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits, const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const
 Calculate the cluster sliding fits. More...
 
float GetBeamDeweightingScore (const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
 Get the beam deweighting score for a vertex. More...
 
bool IsBeamModeOn () const
 Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Member Functions

pandora::StatusCode Run ()
 
void InitializeKDTrees (HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW) const
 Initialize kd trees with details of hits in algorithm-configured cluster lists. More...
 
bool IsVertexOnHit (const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const
 Whether the vertex lies on a hit in the specified view. More...
 
bool IsVertexInGap (const pandora::Vertex *const pVertex, const pandora::HitType hitType) const
 Whether the vertex lies in a registered gap. More...
 
void SelectTopScoreVertices (VertexScoreList &vertexScoreList, pandora::VertexList &selectedVertexList) const
 From the top-scoring candidate vertices, select a subset for further investigation. More...
 
bool AcceptVertexLocation (const pandora::Vertex *const pVertex, const pandora::VertexList &selectedVertexList) const
 Whether to accept a candidate vertex, based on its spatial position in relation to other selected candidates. More...
 

Static Private Member Functions

static bool SortByVertexZPosition (const pandora::Vertex *const pLhs, const pandora::Vertex *const pRhs)
 Sort vertices by increasing z position. More...
 

Private Attributes

pandora::StringVector m_inputCaloHitListNames
 The list of calo hit list names. More...
 
std::string m_outputVertexListName
 The name under which to save the output vertex list. More...
 
bool m_replaceCurrentVertexList
 Whether to replace the current vertex list with the output list. More...
 
bool m_beamMode
 Whether to run in beam mode, assuming neutrinos travel in positive z-direction. More...
 
float m_nDecayLengthsInZSpan
 The number of score decay lengths to use over the course of the vertex z-span. More...
 
bool m_selectSingleVertex
 Whether to make a final decision and select just one vertex candidate. More...
 
unsigned int m_maxTopScoreSelections
 Max number of top-scoring vertex candidate to select for output. More...
 
float m_maxOnHitDisplacement
 Max hit-vertex displacement for declaring vertex to lie on a hit in each view. More...
 
float m_minCandidateDisplacement
 Ignore other top-scoring candidates located in close proximity to original. More...
 
float m_minCandidateScoreFraction
 Ignore other top-scoring candidates with score less than a fraction of original. More...
 
bool m_useDetectorGaps
 Whether to account for registered detector gaps in vertex selection. More...
 
float m_gapTolerance
 The tolerance to use when querying whether a sampling point is in a gap, units cm. More...
 
bool m_isEmptyViewAcceptable
 Whether views entirely empty of hits are classed as 'acceptable' for candidate filtration. More...
 
unsigned int m_minVertexAcceptableViews
 The minimum number of views in which a candidate must sit on/near a hit or in a gap (or view can be empty) More...
 

Detailed Description

Member Typedef Documentation

typedef std::map<pandora::HitType, const pandora::ClusterList &> lar_content::VertexSelectionBaseAlgorithm::ClusterListMap

Map array of cluster lists for passing to tools.

Definition at line 224 of file VertexSelectionBaseAlgorithm.h.

Definition at line 220 of file VertexSelectionBaseAlgorithm.h.

Definition at line 222 of file VertexSelectionBaseAlgorithm.h.

typedef std::map<pandora::HitType, const std::reference_wrapper<HitKDTree2D> > lar_content::VertexSelectionBaseAlgorithm::KDTreeMap

Map array of hit kd trees for passing to tools.

Definition at line 227 of file VertexSelectionBaseAlgorithm.h.

Map of shower cluster lists for passing to tools.

Definition at line 226 of file VertexSelectionBaseAlgorithm.h.

Map of sliding fit data lists for passing to tools.

Definition at line 225 of file VertexSelectionBaseAlgorithm.h.

typedef MvaFeatureTool<const VertexSelectionBaseAlgorithm *const, const pandora::Vertex * const, const SlidingFitDataListMap &, const ClusterListMap &, const KDTreeMap &, const ShowerClusterListMap &, const float, float &> lar_content::VertexSelectionBaseAlgorithm::VertexFeatureTool

The base type for the vertex feature tools.

Definition at line 230 of file VertexSelectionBaseAlgorithm.h.

Constructor & Destructor Documentation

lar_content::VertexSelectionBaseAlgorithm::VertexSelectionBaseAlgorithm ( )

Default constructor.

Definition at line 22 of file VertexSelectionBaseAlgorithm.cc.

22  :
24  m_beamMode(true),
31  m_useDetectorGaps(true),
32  m_gapTolerance(0.f),
35 {
36 }
float m_minCandidateScoreFraction
Ignore other top-scoring candidates with score less than a fraction of original.
TFile f
Definition: plotHisto.C:6
unsigned int m_maxTopScoreSelections
Max number of top-scoring vertex candidate to select for output.
bool m_useDetectorGaps
Whether to account for registered detector gaps in vertex selection.
bool m_beamMode
Whether to run in beam mode, assuming neutrinos travel in positive z-direction.
bool m_isEmptyViewAcceptable
Whether views entirely empty of hits are classed as &#39;acceptable&#39; for candidate filtration.
bool m_selectSingleVertex
Whether to make a final decision and select just one vertex candidate.
unsigned int m_minVertexAcceptableViews
The minimum number of views in which a candidate must sit on/near a hit or in a gap (or view can be e...
float m_nDecayLengthsInZSpan
The number of score decay lengths to use over the course of the vertex z-span.
float m_minCandidateDisplacement
Ignore other top-scoring candidates located in close proximity to original.
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
float m_gapTolerance
The tolerance to use when querying whether a sampling point is in a gap, units cm.
float m_maxOnHitDisplacement
Max hit-vertex displacement for declaring vertex to lie on a hit in each view.

Member Function Documentation

bool lar_content::VertexSelectionBaseAlgorithm::AcceptVertexLocation ( const pandora::Vertex *const  pVertex,
const pandora::VertexList &  selectedVertexList 
) const
private

Whether to accept a candidate vertex, based on its spatial position in relation to other selected candidates.

Parameters
pVertexthe address of the vertex
selectedVertexListthe selected vertex list
Returns
boolean

Definition at line 268 of file VertexSelectionBaseAlgorithm.cc.

References m_minCandidateDisplacement.

Referenced by SelectTopScoreVertices().

269 {
270  const CartesianVector &position(pVertex->GetPosition());
271  const float minCandidateDisplacementSquared(m_minCandidateDisplacement * m_minCandidateDisplacement);
272 
273  for (const Vertex *const pSelectedVertex : selectedVertexList)
274  {
275  if (pVertex == pSelectedVertex)
276  return false;
277 
278  if ((position - pSelectedVertex->GetPosition()).GetMagnitudeSquared() < minCandidateDisplacementSquared)
279  return false;
280  }
281 
282  return true;
283 }
float m_minCandidateDisplacement
Ignore other top-scoring candidates located in close proximity to original.
void lar_content::VertexSelectionBaseAlgorithm::CalculateClusterSlidingFits ( const pandora::ClusterList &  inputClusterList,
const unsigned int  minClusterCaloHits,
const unsigned int  slidingFitWindow,
SlidingFitDataList slidingFitDataList 
) const
protected

Calculate the cluster sliding fits.

Parameters
inputClusterListthe input cluster list
minClusterCaloHitsthe minimum number of cluster calo hits
slidingFitWindowthe sliding fit window
slidingFitDataListthe list of sliding fits to fill

Definition at line 119 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::LArGeometryHelper::GetWireZPitch(), min, and lar_content::LArClusterHelper::SortByNHits().

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList(), and lar_content::SvmVertexSelectionAlgorithm::GetVertexScoreList().

121 {
122  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
123 
124  ClusterVector sortedClusters(inputClusterList.begin(), inputClusterList.end());
125  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
126 
127  for (const Cluster * const pCluster : sortedClusters)
128  {
129  if (pCluster->GetNCaloHits() < minClusterCaloHits)
130  continue;
131 
132  // Make sure the window size is such that there are not more layers than hits (following TwoDSlidingLinearFit calculation).
133  const unsigned int newSlidingFitWindow(std::min(static_cast<int>(pCluster->GetNCaloHits()), static_cast<int>(slidingFitPitch * slidingFitWindow)));
134  slidingFitDataList.emplace_back(pCluster, newSlidingFitWindow, slidingFitPitch);
135  }
136 }
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 float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Int_t min
Definition: plot.C:26
void lar_content::VertexSelectionBaseAlgorithm::FilterVertexList ( const pandora::VertexList *const  pInputVertexList,
HitKDTree2D kdTreeU,
HitKDTree2D kdTreeV,
HitKDTree2D kdTreeW,
pandora::VertexVector &  filteredVertices 
) const
protectedvirtual

Filter the input list of vertices to obtain a reduced number of vertex candidates.

Parameters
pInputVertexListthe address of the input vertex list
kdTreeUthe kd tree for u hits
kdTreeVthe kd tree for v hits
kdTreeWthe kd tree for w hits
filteredVerticesto receive the filtered vertex list

Definition at line 40 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::KDTreeLinkerAlgo< DATA, DIM >::empty(), IsVertexInGap(), IsVertexOnHit(), m_isEmptyViewAcceptable, m_minVertexAcceptableViews, and SortByVertexZPosition().

Referenced by Run().

42 {
43  for (const Vertex *const pVertex : *pInputVertexList)
44  {
45  unsigned int nAcceptableViews(0);
46 
47  if ((m_isEmptyViewAcceptable && kdTreeU.empty()) || this->IsVertexOnHit(pVertex, TPC_VIEW_U, kdTreeU) || this->IsVertexInGap(pVertex, TPC_VIEW_U))
48  ++nAcceptableViews;
49 
50  if ((m_isEmptyViewAcceptable && kdTreeV.empty()) || this->IsVertexOnHit(pVertex, TPC_VIEW_V, kdTreeV) || this->IsVertexInGap(pVertex, TPC_VIEW_V))
51  ++nAcceptableViews;
52 
53  if ((m_isEmptyViewAcceptable && kdTreeW.empty()) || this->IsVertexOnHit(pVertex, TPC_VIEW_W, kdTreeW) || this->IsVertexInGap(pVertex, TPC_VIEW_W))
54  ++nAcceptableViews;
55 
56  if (nAcceptableViews >= m_minVertexAcceptableViews)
57  filteredVertices.push_back(pVertex);
58  }
59 
60  std::sort(filteredVertices.begin(), filteredVertices.end(), SortByVertexZPosition);
61 }
bool IsVertexOnHit(const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const
Whether the vertex lies on a hit in the specified view.
bool IsVertexInGap(const pandora::Vertex *const pVertex, const pandora::HitType hitType) const
Whether the vertex lies in a registered gap.
static bool SortByVertexZPosition(const pandora::Vertex *const pLhs, const pandora::Vertex *const pRhs)
Sort vertices by increasing z position.
bool m_isEmptyViewAcceptable
Whether views entirely empty of hits are classed as &#39;acceptable&#39; for candidate filtration.
unsigned int m_minVertexAcceptableViews
The minimum number of views in which a candidate must sit on/near a hit or in a gap (or view can be e...
void lar_content::VertexSelectionBaseAlgorithm::GetBeamConstants ( const pandora::VertexVector &  vertexVector,
BeamConstants beamConstants 
) const
protectedvirtual

Get the beam score constants for a provided list of candidate vertices.

Parameters
vertexVectorthe vertex vector
beamConstantsto receive the beam constants

Definition at line 65 of file VertexSelectionBaseAlgorithm.cc.

References f, m_beamMode, m_nDecayLengthsInZSpan, max, and lar_content::VertexSelectionBaseAlgorithm::BeamConstants::SetConstants().

Referenced by Run().

66 {
67  if (!m_beamMode)
68  return;
69 
70  if (vertexVector.empty())
71  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
72 
73  float minZCoordinate(std::numeric_limits<float>::max()), maxZCoordinate(-std::numeric_limits<float>::max());
74 
75  for (const Vertex *const pVertex : vertexVector)
76  {
77  if (pVertex->GetPosition().GetZ() < minZCoordinate)
78  minZCoordinate = pVertex->GetPosition().GetZ();
79 
80  if (pVertex->GetPosition().GetZ() > maxZCoordinate)
81  maxZCoordinate = pVertex->GetPosition().GetZ();
82  }
83 
84  const float zSpan(maxZCoordinate - minZCoordinate);
85  const float decayConstant((zSpan < std::numeric_limits<float>::epsilon()) ? 0.f : (m_nDecayLengthsInZSpan / zSpan));
86  beamConstants.SetConstants(minZCoordinate, decayConstant);
87 }
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
bool m_beamMode
Whether to run in beam mode, assuming neutrinos travel in positive z-direction.
float m_nDecayLengthsInZSpan
The number of score decay lengths to use over the course of the vertex z-span.
float lar_content::VertexSelectionBaseAlgorithm::GetBeamDeweightingScore ( const BeamConstants beamConstants,
const pandora::Vertex *const  pVertex 
) const
inlineprotected

Get the beam deweighting score for a vertex.

Parameters
beamConstantsthe beam constants
pVertexaddress of the vertex
Returns
the score

Definition at line 394 of file VertexSelectionBaseAlgorithm.h.

References lar_content::VertexSelectionBaseAlgorithm::BeamConstants::GetDecayConstant(), lar_content::VertexSelectionBaseAlgorithm::BeamConstants::GetMinZCoordinate(), and max.

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList(), and lar_content::SvmVertexSelectionAlgorithm::PopulateVertexFeatureInfoMap().

395 {
396  const float vertexMinZ(std::max(pVertex->GetPosition().GetZ(), beamConstants.GetMinZCoordinate()));
397  return (beamConstants.GetMinZCoordinate() - vertexMinZ) * beamConstants.GetDecayConstant();
398 }
Int_t max
Definition: plot.C:27
void lar_content::VertexSelectionBaseAlgorithm::GetClusterLists ( const pandora::StringVector &  inputClusterListNames,
pandora::ClusterList &  clusterListU,
pandora::ClusterList &  clusterListV,
pandora::ClusterList &  clusterListW 
) const
protected

Get the cluster lists.

Parameters
inputClusterListNamesthe input cluster list names
clusterListUthe U-view cluster list to populate
clusterListVthe V-view cluster list to populate
clusterListWthe W-view cluster list to populate

Definition at line 91 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType().

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList(), and lar_content::SvmVertexSelectionAlgorithm::GetVertexScoreList().

93 {
94  for (const std::string &clusterListName : inputClusterListNames)
95  {
96  const ClusterList *pClusterList(NULL);
97  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, clusterListName, pClusterList));
98 
99  if (!pClusterList || pClusterList->empty())
100  {
101  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
102  std::cout << "EnergyKickVertexSelectionAlgorithm: unable to find cluster list " << clusterListName << std::endl;
103 
104  continue;
105  }
106 
107  const HitType hitType(LArClusterHelper::GetClusterHitType(*(pClusterList->begin())));
108 
109  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
110  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
111 
112  ClusterList &clusterList((TPC_VIEW_U == hitType) ? clusterListU : (TPC_VIEW_V == hitType) ? clusterListV : clusterListW);
113  clusterList.insert(clusterList.end(), pClusterList->begin(), pClusterList->end());
114  }
115 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
virtual void lar_content::VertexSelectionBaseAlgorithm::GetVertexScoreList ( const pandora::VertexVector &  vertexVector,
const BeamConstants beamConstants,
HitKDTree2D kdTreeU,
HitKDTree2D kdTreeV,
HitKDTree2D kdTreeW,
VertexScoreList vertexScoreList 
) const
protectedpure virtual

Get the vertex score list for a provided list of candidate vertices.

Parameters
vertexVectorthe vertex vector
beamConstantsthe beam constants
kdTreeUthe kd tree for u hits
kdTreeVthe kd tree for v hits
kdTreeWthe kd tree for w hits
vertexScoreListto receive the vertex score list

Implemented in lar_content::SvmVertexSelectionAlgorithm, lar_content::EnergyKickVertexSelectionAlgorithm, and lar_content::HitAngleVertexSelectionAlgorithm.

Referenced by Run().

void lar_content::VertexSelectionBaseAlgorithm::InitializeKDTrees ( HitKDTree2D kdTreeU,
HitKDTree2D kdTreeV,
HitKDTree2D kdTreeW 
) const
private

Initialize kd trees with details of hits in algorithm-configured cluster lists.

Parameters
kdTreeUthe kd tree for u hits
kdTreeVthe kd tree for v hits
kdTreeWthe kd tree for w hits

Definition at line 184 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::KDTreeLinkerAlgo< DATA, DIM >::build(), lar_content::KDTreeLinkerAlgo< DATA, DIM >::empty(), lar_content::fill_and_bound_2d_kd_tree(), and m_inputCaloHitListNames.

Referenced by Run().

185 {
186  for (const std::string &caloHitListName : m_inputCaloHitListNames)
187  {
188  const CaloHitList *pCaloHitList = NULL;
189  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, caloHitListName, pCaloHitList));
190 
191  if (!pCaloHitList || pCaloHitList->empty())
192  {
193  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
194  std::cout << "VertexSelectionBaseAlgorithm: unable to find calo hit list " << caloHitListName << std::endl;
195 
196  continue;
197  }
198 
199  const HitType hitType((*(pCaloHitList->begin()))->GetHitType());
200 
201  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
202  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
203 
204  HitKDTree2D &kdTree((TPC_VIEW_U == hitType) ? kdTreeU : (TPC_VIEW_V == hitType) ? kdTreeV : kdTreeW);
205 
206  if (!kdTree.empty())
207  throw StatusCodeException(STATUS_CODE_FAILURE);
208 
209  HitKDNode2DList hitKDNode2DList;
210  KDTreeBox hitsBoundingRegion2D(fill_and_bound_2d_kd_tree(*pCaloHitList, hitKDNode2DList));
211  kdTree.build(hitKDNode2DList, hitsBoundingRegion2D);
212  }
213 }
pandora::StringVector m_inputCaloHitListNames
The list of calo hit list names.
KDTreeBox fill_and_bound_2d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 2 > > &nodes)
fill_and_bound_2d_kd_tree
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
KDTreeBoxT< 2 > KDTreeBox
bool lar_content::VertexSelectionBaseAlgorithm::IsBeamModeOn ( ) const
inlineprotected

Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction.

Returns
boolean

Definition at line 402 of file VertexSelectionBaseAlgorithm.h.

References m_beamMode.

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList().

403 {
404  return m_beamMode;
405 }
bool m_beamMode
Whether to run in beam mode, assuming neutrinos travel in positive z-direction.
bool lar_content::VertexSelectionBaseAlgorithm::IsVertexInGap ( const pandora::Vertex *const  pVertex,
const pandora::HitType  hitType 
) const
private

Whether the vertex lies in a registered gap.

Parameters
pVertexthe address of the vertex
hitTypethe relevant hit type
Returns
boolean

Definition at line 230 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::LArGeometryHelper::IsInGap3D(), m_gapTolerance, and m_useDetectorGaps.

Referenced by FilterVertexList().

231 {
232  if (!m_useDetectorGaps)
233  return false;
234 
235  return LArGeometryHelper::IsInGap3D(this->GetPandora(), pVertex->GetPosition(), hitType, m_gapTolerance);
236 }
bool m_useDetectorGaps
Whether to account for registered detector gaps in vertex selection.
float m_gapTolerance
The tolerance to use when querying whether a sampling point is in a gap, units cm.
static bool IsInGap3D(const pandora::Pandora &pandora, const pandora::CartesianVector &testPoint3D, const pandora::HitType hitType, const float gapTolerance=0.f)
Whether a 3D test point lies in a registered gap with the associated hit type.
bool lar_content::VertexSelectionBaseAlgorithm::IsVertexOnHit ( const pandora::Vertex *const  pVertex,
const pandora::HitType  hitType,
HitKDTree2D kdTree 
) const
private

Whether the vertex lies on a hit in the specified view.

Parameters
pVertexthe address of the vertex
hitTypethe relevant hit type
kdTreethe relevant kd tree
Returns
boolean

Definition at line 217 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::build_2d_kd_search_region(), m_maxOnHitDisplacement, lar_content::LArGeometryHelper::ProjectPosition(), and lar_content::KDTreeLinkerAlgo< DATA, DIM >::search().

Referenced by FilterVertexList().

218 {
219  const CartesianVector vertexPosition2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), hitType));
221 
222  HitKDNode2DList found;
223  kdTree.search(searchRegionHits, found);
224 
225  return (!found.empty());
226 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
KDTreeBox build_2d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float z_span)
build_2d_kd_search_region
KDTreeBoxT< 2 > KDTreeBox
float m_maxOnHitDisplacement
Max hit-vertex displacement for declaring vertex to lie on a hit in each view.
StatusCode lar_content::VertexSelectionBaseAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protected

Definition at line 349 of file VertexSelectionBaseAlgorithm.cc.

References m_beamMode, m_gapTolerance, m_inputCaloHitListNames, m_isEmptyViewAcceptable, m_maxOnHitDisplacement, m_maxTopScoreSelections, m_minCandidateDisplacement, m_minCandidateScoreFraction, m_minVertexAcceptableViews, m_nDecayLengthsInZSpan, m_outputVertexListName, m_replaceCurrentVertexList, m_selectSingleVertex, and m_useDetectorGaps.

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::ReadSettings(), and lar_content::SvmVertexSelectionAlgorithm::ReadSettings().

350 {
351  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
352  "InputCaloHitListNames", m_inputCaloHitListNames));
353 
354  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
355  "OutputVertexListName", m_outputVertexListName));
356 
357  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
358  "ReplaceCurrentVertexList", m_replaceCurrentVertexList));
359 
360  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
361  "BeamMode", m_beamMode));
362 
363  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
364  "NDecayLengthsInZSpan", m_nDecayLengthsInZSpan));
365 
366  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
367  "SelectSingleVertex", m_selectSingleVertex));
368 
369  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
370  "MaxTopScoreSelections", m_maxTopScoreSelections));
371 
372  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
373  "MaxOnHitDisplacement", m_maxOnHitDisplacement));
374 
375  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
376  "MinCandidateDisplacement", m_minCandidateDisplacement));
377 
378  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
379  "MinCandidateScoreFraction", m_minCandidateScoreFraction));
380 
381  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
382  "UseDetectorGaps", m_useDetectorGaps));
383 
384  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
385  "GapTolerance", m_gapTolerance));
386 
387  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
388  "IsEmptyViewAcceptable", m_isEmptyViewAcceptable));
389 
390  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
391  "MinVertexAcceptableViews", m_minVertexAcceptableViews));
392 
393  return STATUS_CODE_SUCCESS;
394 }
float m_minCandidateScoreFraction
Ignore other top-scoring candidates with score less than a fraction of original.
std::string m_outputVertexListName
The name under which to save the output vertex list.
pandora::StringVector m_inputCaloHitListNames
The list of calo hit list names.
unsigned int m_maxTopScoreSelections
Max number of top-scoring vertex candidate to select for output.
bool m_useDetectorGaps
Whether to account for registered detector gaps in vertex selection.
bool m_beamMode
Whether to run in beam mode, assuming neutrinos travel in positive z-direction.
bool m_isEmptyViewAcceptable
Whether views entirely empty of hits are classed as &#39;acceptable&#39; for candidate filtration.
bool m_selectSingleVertex
Whether to make a final decision and select just one vertex candidate.
unsigned int m_minVertexAcceptableViews
The minimum number of views in which a candidate must sit on/near a hit or in a gap (or view can be e...
float m_nDecayLengthsInZSpan
The number of score decay lengths to use over the course of the vertex z-span.
float m_minCandidateDisplacement
Ignore other top-scoring candidates located in close proximity to original.
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
float m_gapTolerance
The tolerance to use when querying whether a sampling point is in a gap, units cm.
float m_maxOnHitDisplacement
Max hit-vertex displacement for declaring vertex to lie on a hit in each view.
StatusCode lar_content::VertexSelectionBaseAlgorithm::Run ( )
private

Definition at line 140 of file VertexSelectionBaseAlgorithm.cc.

References FilterVertexList(), GetBeamConstants(), GetVertexScoreList(), InitializeKDTrees(), m_outputVertexListName, m_replaceCurrentVertexList, and SelectTopScoreVertices().

141 {
142  const VertexList *pInputVertexList(NULL);
143  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pInputVertexList));
144 
145  if (!pInputVertexList || pInputVertexList->empty())
146  {
147  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
148  std::cout << "VertexSelectionBaseAlgorithm: unable to find current vertex list " << std::endl;
149 
150  return STATUS_CODE_SUCCESS;
151  }
152 
153  HitKDTree2D kdTreeU, kdTreeV, kdTreeW;
154  this->InitializeKDTrees(kdTreeU, kdTreeV, kdTreeW);
155 
156  VertexVector filteredVertices;
157  this->FilterVertexList(pInputVertexList, kdTreeU, kdTreeV, kdTreeW, filteredVertices);
158 
159  if (filteredVertices.empty())
160  return STATUS_CODE_SUCCESS;
161 
162  BeamConstants beamConstants;
163  this->GetBeamConstants(filteredVertices, beamConstants);
164 
165  VertexScoreList vertexScoreList;
166  this->GetVertexScoreList(filteredVertices, beamConstants, kdTreeU, kdTreeV, kdTreeW, vertexScoreList);
167 
168  VertexList selectedVertexList;
169  this->SelectTopScoreVertices(vertexScoreList, selectedVertexList);
170 
171  if (!selectedVertexList.empty())
172  {
173  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, m_outputVertexListName, selectedVertexList));
174 
176  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*this, m_outputVertexListName));
177  }
178 
179  return STATUS_CODE_SUCCESS;
180 }
virtual void FilterVertexList(const pandora::VertexList *const pInputVertexList, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, pandora::VertexVector &filteredVertices) const
Filter the input list of vertices to obtain a reduced number of vertex candidates.
std::string m_outputVertexListName
The name under which to save the output vertex list.
virtual void GetBeamConstants(const pandora::VertexVector &vertexVector, BeamConstants &beamConstants) const
Get the beam score constants for a provided list of candidate vertices.
void InitializeKDTrees(HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW) const
Initialize kd trees with details of hits in algorithm-configured cluster lists.
virtual void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const =0
Get the vertex score list for a provided list of candidate vertices.
void SelectTopScoreVertices(VertexScoreList &vertexScoreList, pandora::VertexList &selectedVertexList) const
From the top-scoring candidate vertices, select a subset for further investigation.
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
std::list< Vertex > VertexList
Definition: DCEL.h:178
std::vector< art::Ptr< recob::Vertex > > VertexVector
void lar_content::VertexSelectionBaseAlgorithm::SelectTopScoreVertices ( VertexScoreList vertexScoreList,
pandora::VertexList &  selectedVertexList 
) const
private

From the top-scoring candidate vertices, select a subset for further investigation.

Parameters
vertexScoreListthe vertex score list
selectedVertexListto receive the selected vertex list

Definition at line 240 of file VertexSelectionBaseAlgorithm.cc.

References AcceptVertexLocation(), f, m_maxTopScoreSelections, m_minCandidateScoreFraction, and m_selectSingleVertex.

Referenced by Run().

241 {
242  float bestScore(0.f);
243  std::sort(vertexScoreList.begin(), vertexScoreList.end());
244 
245  for (const VertexScore &vertexScore : vertexScoreList)
246  {
247  if (selectedVertexList.size() >= m_maxTopScoreSelections)
248  break;
249 
250  if (!selectedVertexList.empty() && !this->AcceptVertexLocation(vertexScore.GetVertex(), selectedVertexList))
251  continue;
252 
253  if (!selectedVertexList.empty() && (vertexScore.GetScore() < m_minCandidateScoreFraction * bestScore))
254  continue;
255 
256  selectedVertexList.push_back(vertexScore.GetVertex());
257 
259  return;
260 
261  if (vertexScore.GetScore() > bestScore)
262  bestScore = vertexScore.GetScore();
263  }
264 }
float m_minCandidateScoreFraction
Ignore other top-scoring candidates with score less than a fraction of original.
TFile f
Definition: plotHisto.C:6
bool AcceptVertexLocation(const pandora::Vertex *const pVertex, const pandora::VertexList &selectedVertexList) const
Whether to accept a candidate vertex, based on its spatial position in relation to other selected can...
unsigned int m_maxTopScoreSelections
Max number of top-scoring vertex candidate to select for output.
bool m_selectSingleVertex
Whether to make a final decision and select just one vertex candidate.
bool lar_content::VertexSelectionBaseAlgorithm::SortByVertexZPosition ( const pandora::Vertex *const  pLhs,
const pandora::Vertex *const  pRhs 
)
staticprivate

Sort vertices by increasing z position.

Parameters
pLhsaddress of the lhs vertex
pRhsaddress of the rhs vertex
Returns
whether lhs should precedes rhs

Definition at line 287 of file VertexSelectionBaseAlgorithm.cc.

Referenced by FilterVertexList().

288 {
289  const CartesianVector deltaPosition(pRhs->GetPosition() - pLhs->GetPosition());
290 
291  if (std::fabs(deltaPosition.GetZ()) > std::numeric_limits<float>::epsilon())
292  return (deltaPosition.GetZ() > std::numeric_limits<float>::epsilon());
293 
294  if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
295  return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
296 
297  // ATTN No way to distinguish between vertices if still have a tie in y coordinate
298  return (deltaPosition.GetY() > std::numeric_limits<float>::epsilon());
299 }

Member Data Documentation

bool lar_content::VertexSelectionBaseAlgorithm::m_beamMode
private

Whether to run in beam mode, assuming neutrinos travel in positive z-direction.

Definition at line 374 of file VertexSelectionBaseAlgorithm.h.

Referenced by GetBeamConstants(), IsBeamModeOn(), and ReadSettings().

float lar_content::VertexSelectionBaseAlgorithm::m_gapTolerance
private

The tolerance to use when querying whether a sampling point is in a gap, units cm.

Definition at line 386 of file VertexSelectionBaseAlgorithm.h.

Referenced by IsVertexInGap(), and ReadSettings().

pandora::StringVector lar_content::VertexSelectionBaseAlgorithm::m_inputCaloHitListNames
private

The list of calo hit list names.

Definition at line 369 of file VertexSelectionBaseAlgorithm.h.

Referenced by InitializeKDTrees(), and ReadSettings().

bool lar_content::VertexSelectionBaseAlgorithm::m_isEmptyViewAcceptable
private

Whether views entirely empty of hits are classed as 'acceptable' for candidate filtration.

Definition at line 388 of file VertexSelectionBaseAlgorithm.h.

Referenced by FilterVertexList(), and ReadSettings().

float lar_content::VertexSelectionBaseAlgorithm::m_maxOnHitDisplacement
private

Max hit-vertex displacement for declaring vertex to lie on a hit in each view.

Definition at line 380 of file VertexSelectionBaseAlgorithm.h.

Referenced by IsVertexOnHit(), and ReadSettings().

unsigned int lar_content::VertexSelectionBaseAlgorithm::m_maxTopScoreSelections
private

Max number of top-scoring vertex candidate to select for output.

Definition at line 378 of file VertexSelectionBaseAlgorithm.h.

Referenced by ReadSettings(), and SelectTopScoreVertices().

float lar_content::VertexSelectionBaseAlgorithm::m_minCandidateDisplacement
private

Ignore other top-scoring candidates located in close proximity to original.

Definition at line 382 of file VertexSelectionBaseAlgorithm.h.

Referenced by AcceptVertexLocation(), and ReadSettings().

float lar_content::VertexSelectionBaseAlgorithm::m_minCandidateScoreFraction
private

Ignore other top-scoring candidates with score less than a fraction of original.

Definition at line 383 of file VertexSelectionBaseAlgorithm.h.

Referenced by ReadSettings(), and SelectTopScoreVertices().

unsigned int lar_content::VertexSelectionBaseAlgorithm::m_minVertexAcceptableViews
private

The minimum number of views in which a candidate must sit on/near a hit or in a gap (or view can be empty)

Definition at line 389 of file VertexSelectionBaseAlgorithm.h.

Referenced by FilterVertexList(), and ReadSettings().

float lar_content::VertexSelectionBaseAlgorithm::m_nDecayLengthsInZSpan
private

The number of score decay lengths to use over the course of the vertex z-span.

Definition at line 375 of file VertexSelectionBaseAlgorithm.h.

Referenced by GetBeamConstants(), and ReadSettings().

std::string lar_content::VertexSelectionBaseAlgorithm::m_outputVertexListName
private

The name under which to save the output vertex list.

Definition at line 370 of file VertexSelectionBaseAlgorithm.h.

Referenced by ReadSettings(), and Run().

bool lar_content::VertexSelectionBaseAlgorithm::m_replaceCurrentVertexList
private

Whether to replace the current vertex list with the output list.

Definition at line 372 of file VertexSelectionBaseAlgorithm.h.

Referenced by ReadSettings(), and Run().

bool lar_content::VertexSelectionBaseAlgorithm::m_selectSingleVertex
private

Whether to make a final decision and select just one vertex candidate.

Definition at line 377 of file VertexSelectionBaseAlgorithm.h.

Referenced by ReadSettings(), and SelectTopScoreVertices().

bool lar_content::VertexSelectionBaseAlgorithm::m_useDetectorGaps
private

Whether to account for registered detector gaps in vertex selection.

Definition at line 385 of file VertexSelectionBaseAlgorithm.h.

Referenced by IsVertexInGap(), and ReadSettings().


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