Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
VertexSelectionBaseAlgorithm.h
Go to the documentation of this file.
1
8#ifndef LAR_VERTEX_SELECTION_BASE_ALGORITHM_H
9#define LAR_VERTEX_SELECTION_BASE_ALGORITHM_H 1
10
11#include "Objects/Vertex.h"
12#include "Pandora/Algorithm.h"
13
15
18
19namespace lar_content
20{
21
22template <typename, unsigned int>
23class KDTreeLinkerAlgo;
24template <typename, unsigned int>
25class KDTreeNodeInfoT;
26
27//------------------------------------------------------------------------------------------------------------------------------------------
28
33{
34public:
39
44 {
45 public:
52 VertexScore(const pandora::Vertex *const pVertex, const float score);
53
59 const pandora::Vertex *GetVertex() const;
60
66 float GetScore() const;
67
75 bool operator<(const VertexScore &rhs) const;
76
77 private:
79 float m_score;
80 };
81
82 typedef std::vector<VertexScore> VertexScoreList;
83
88 {
89 public:
95 float GetMinZCoordinate() const;
96
102 float GetDecayConstant() const;
103
110 void SetConstants(const float minZCoordinate, const float decayConstant);
111
112 private:
115 };
116
174
175 typedef std::vector<SlidingFitData> SlidingFitDataList;
176
181 {
182 public:
190 ShowerCluster(const pandora::ClusterList &clusterList, const int slidingFitWindow, const float slidingFitPitch);
191
197 const pandora::ClusterList &GetClusters() const;
198
204 const TwoDSlidingFitResult &GetFit() const;
205
214
215 private:
219 };
220
221 typedef std::vector<ShowerCluster> ShowerClusterList;
222
224 typedef std::vector<HitKDNode2D> HitKDNode2DList;
226
227 typedef std::map<pandora::HitType, const pandora::ClusterList &> ClusterListMap;
228 typedef std::map<pandora::HitType, const SlidingFitDataList> SlidingFitDataListMap;
229 typedef std::map<pandora::HitType, const ShowerClusterList> ShowerClusterListMap;
230 typedef std::map<pandora::HitType, const std::reference_wrapper<HitKDTree2D>> KDTreeMap;
231
232 typedef MvaFeatureTool<const VertexSelectionBaseAlgorithm *const, const pandora::Vertex *const, const SlidingFitDataListMap &,
233 const ClusterListMap &, const KDTreeMap &, const ShowerClusterListMap &, const float, float &>
235
236protected:
246 virtual void FilterVertexList(const pandora::VertexList *const pInputVertexList, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV,
247 HitKDTree2D &kdTreeW, pandora::VertexVector &filteredVertices) const;
248
255 virtual void GetBeamConstants(const pandora::VertexVector &vertexVector, BeamConstants &beamConstants) const;
256
267 virtual void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU,
268 HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const = 0;
269
278 void GetClusterLists(const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU,
279 pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const;
280
289 void CalculateClusterSlidingFits(const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits,
290 const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const;
291
300 float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const;
301
307 bool IsBeamModeOn() const;
308
317 float GetVertexEnergy(const pandora::Vertex *const pVertex, const KDTreeMap &kdTreeMap) const;
318
328 float VertexHitEnergy(const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const;
329
331
332private:
334
342 void InitializeKDTrees(HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW) const;
343
353 bool IsVertexOnHit(const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const;
354
363 bool IsVertexInGap(const pandora::Vertex *const pVertex, const pandora::HitType hitType) const;
364
371 void SelectTopScoreVertices(VertexScoreList &vertexScoreList, pandora::VertexList &selectedVertexList) const;
372
381 bool AcceptVertexLocation(const pandora::Vertex *const pVertex, const pandora::VertexList &selectedVertexList) const;
382
391 static bool SortByVertexZPosition(const pandora::Vertex *const pLhs, const pandora::Vertex *const pRhs);
392
393private:
396
398
401
404
406
409
412
415};
416
417//------------------------------------------------------------------------------------------------------------------------------------------
418
419inline float VertexSelectionBaseAlgorithm::GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
420{
421 const float vertexMinZ(std::max(pVertex->GetPosition().GetZ(), beamConstants.GetMinZCoordinate()));
422 return (beamConstants.GetMinZCoordinate() - vertexMinZ) * beamConstants.GetDecayConstant();
423}
424
425//------------------------------------------------------------------------------------------------------------------------------------------
426
428{
429 return m_beamMode;
430}
431
432//------------------------------------------------------------------------------------------------------------------------------------------
433//------------------------------------------------------------------------------------------------------------------------------------------
434
435inline VertexSelectionBaseAlgorithm::VertexScore::VertexScore(const pandora::Vertex *const pVertex, const float score) :
436 m_pVertex(pVertex),
437 m_score(score)
438{
439}
440
441//------------------------------------------------------------------------------------------------------------------------------------------
442
444{
445 return m_pVertex;
446}
447
448//------------------------------------------------------------------------------------------------------------------------------------------
449
451{
452 return m_score;
453}
454
455//------------------------------------------------------------------------------------------------------------------------------------------
456
458{
459 return (this->GetScore() > rhs.GetScore());
460}
461
462//------------------------------------------------------------------------------------------------------------------------------------------
463//------------------------------------------------------------------------------------------------------------------------------------------
464
466{
467 return m_minZCoordinate.Get();
468}
469
470//------------------------------------------------------------------------------------------------------------------------------------------
471
473{
474 return m_decayConstant.Get();
475}
476
477//------------------------------------------------------------------------------------------------------------------------------------------
478
479inline void VertexSelectionBaseAlgorithm::BeamConstants::SetConstants(const float minZCoordinate, const float decayConstant)
480{
481 m_minZCoordinate = minZCoordinate;
482 m_decayConstant = decayConstant;
483}
484
485//------------------------------------------------------------------------------------------------------------------------------------------
486
488{
489 return m_minLayerDirection;
490}
491
492//------------------------------------------------------------------------------------------------------------------------------------------
493
495{
496 return m_maxLayerDirection;
497}
498
499//------------------------------------------------------------------------------------------------------------------------------------------
500
502{
503 return m_minLayerPosition;
504}
505
506//------------------------------------------------------------------------------------------------------------------------------------------
507
509{
510 return m_maxLayerPosition;
511}
512
513//------------------------------------------------------------------------------------------------------------------------------------------
514
516{
517 return m_pCluster;
518}
519
520//------------------------------------------------------------------------------------------------------------------------------------------
521
523{
524 return m_clusterList;
525}
526
527//------------------------------------------------------------------------------------------------------------------------------------------
528
530{
531 return m_twoDSlidingFitResult;
532}
533
534} // namespace lar_content
535
536#endif // #ifndef LAR_VERTEX_SELECTION_BASE_ALGORITHM_H
Header file for the algorithm class.
Header file for the lar support vector machine class.
Header file for the lar two dimensional sliding fit result class.
Header file for the vertex class.
Class that implements the KDTree partition of 2D space and a closest point search algorithm.
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
MvaFeatureTool class template.
void SetConstants(const float minZCoordinate, const float decayConstant)
Set the beam constants.
pandora::CartesianPointVector m_coordinateVector
The coordinate vector.
const pandora::ClusterList & GetClusters() const
Get the cluster list.
const TwoDSlidingFitResult & GetFit() const
Get the 2D sliding linear fit.
TwoDSlidingFitResult m_twoDSlidingFitResult
The fit to the hits of the cluster list.
pandora::CartesianPointVector GetClusterListCoordinateVector(const pandora::ClusterList &clusterList) const
Get the coordinate vector for a cluster list.
const pandora::Cluster * m_pCluster
Pointer to the corresponding cluster.
const pandora::CartesianVector & GetMinLayerDirection() const
Get the min layer direction.
pandora::CartesianVector m_minLayerDirection
The direction of the fit at the min layer.
const pandora::CartesianVector & GetMaxLayerDirection() const
Get the max layer direction.
pandora::CartesianVector m_maxLayerDirection
The direction of the fit at the min layer.
const pandora::CartesianVector & GetMaxLayerPosition() const
Get the max layer position.
const pandora::Cluster * GetCluster() const
Get a pointer to the corresponding cluster.
const pandora::CartesianVector & GetMinLayerPosition() const
Get the min layer position.
pandora::CartesianVector m_maxLayerPosition
The position of the fit at the max layer.
pandora::CartesianVector m_minLayerPosition
The position of the fit at the max layer.
const pandora::Vertex * m_pVertex
The address of the vertex.
const pandora::Vertex * GetVertex() const
Get the address of the vertex.
VertexScore(const pandora::Vertex *const pVertex, const float score)
Constructor.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
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...
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
std::string m_outputVertexListName
The name under which to save the output vertex list.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
float m_nDecayLengthsInZSpan
The number of score decay lengths to use over the course of the vertex z-span.
void InitializeKDTrees(HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW) const
Initialize kd trees with details of hits in algorithm-configured cluster lists.
float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
Get the beam deweighting score for a vertex.
void GetClusterLists(const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get the cluster lists.
float m_maxOnHitDisplacement
Max hit-vertex displacement for declaring vertex to lie on a hit in each view.
pandora::StringVector m_inputCaloHitListNames
The list of calo hit list names.
void CalculateClusterSlidingFits(const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits, const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const
Calculate the cluster sliding fits.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
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...
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
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.
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.
float m_minCandidateScoreFraction
Ignore other top-scoring candidates with score less than a fraction of original.
static bool SortByVertexZPosition(const pandora::Vertex *const pLhs, const pandora::Vertex *const pRhs)
Sort vertices by increasing z position.
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.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
void SelectTopScoreVertices(VertexScoreList &vertexScoreList, pandora::VertexList &selectedVertexList) const
From the top-scoring candidate vertices, select a subset for further investigation.
float GetVertexEnergy(const pandora::Vertex *const pVertex, const KDTreeMap &kdTreeMap) const
Calculate the energy of a vertex candidate by summing values from all three planes.
bool IsBeamModeOn() const
Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction.
bool m_selectSingleVertex
Whether to make a final decision and select just one vertex candidate.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
float m_minCandidateDisplacement
Ignore other top-scoring candidates located in close proximity to original.
bool m_beamMode
Whether to run in beam mode, assuming neutrinos travel in positive z-direction.
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.
pandora::StatusCode Run()
Run the algorithm.
bool IsVertexInGap(const pandora::Vertex *const pVertex, const pandora::HitType hitType) const
Whether the vertex lies in a registered gap.
bool m_isEmptyViewAcceptable
Whether views entirely empty of hits are classed as 'acceptable' for candidate filtration.
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.
virtual void GetBeamConstants(const pandora::VertexVector &vertexVector, BeamConstants &beamConstants) const
Get the beam score constants for a provided list of candidate vertices.
unsigned int m_maxTopScoreSelections
Max number of top-scoring vertex candidate to select for output.
float VertexHitEnergy(const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const
Finds the energy of the nearest hit to the vertex candidate in this view.
Algorithm class. Algorithm addresses are held only by the algorithm manager. They have a fully define...
Definition Algorithm.h:21
CartesianVector class.
float GetZ() const
Get the cartesian z coordinate.
Cluster class.
Definition Cluster.h:31
Vertex class.
Definition Vertex.h:26
const CartesianVector & GetPosition() const
Get the vertex position.
Definition Vertex.h:103
HitType
Calorimeter hit type enum.
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< std::string > StringVector
std::vector< CartesianVector > CartesianPointVector
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
std::vector< const Vertex * > VertexVector