LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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 "Pandora/Algorithm.h"
12 
14 
17 
18 namespace lar_content
19 {
20 
21 template<typename, unsigned int> class KDTreeLinkerAlgo;
22 template<typename, unsigned int> class KDTreeNodeInfoT;
23 
24 //------------------------------------------------------------------------------------------------------------------------------------------
25 
29 class VertexSelectionBaseAlgorithm : public pandora::Algorithm
30 {
31 public:
36 
41  {
42  public:
49  VertexScore(const pandora::Vertex *const pVertex, const float score);
50 
56  const pandora::Vertex *GetVertex() const;
57 
63  float GetScore() const;
64 
72  bool operator< (const VertexScore &rhs) const;
73 
74  private:
75  const pandora::Vertex *m_pVertex;
76  float m_score;
77  };
78 
79  typedef std::vector<VertexScore> VertexScoreList;
80 
85  {
86  public:
92  float GetMinZCoordinate() const;
93 
99  float GetDecayConstant() const;
100 
107  void SetConstants(const float minZCoordinate, const float decayConstant);
108 
109  private:
110  pandora::InputFloat m_minZCoordinate;
111  pandora::InputFloat m_decayConstant;
112  };
113 
118  {
119  public:
127  SlidingFitData(const pandora::Cluster *const pCluster, const int slidingFitWindow, const float slidingFitPitch);
128 
134  const pandora::CartesianVector &GetMinLayerDirection() const;
135 
141  const pandora::CartesianVector &GetMaxLayerDirection() const;
142 
148  const pandora::CartesianVector &GetMinLayerPosition() const;
149 
155  const pandora::CartesianVector &GetMaxLayerPosition() const;
156 
162  const pandora::Cluster *GetCluster() const;
163 
164  private:
165  pandora::CartesianVector m_minLayerDirection;
166  pandora::CartesianVector m_maxLayerDirection;
167  pandora::CartesianVector m_minLayerPosition;
168  pandora::CartesianVector m_maxLayerPosition;
169  const pandora::Cluster *m_pCluster;
170  };
171 
172  typedef std::vector<SlidingFitData> SlidingFitDataList;
173 
178  {
179  public:
187  ShowerCluster(const pandora::ClusterList &clusterList, const int slidingFitWindow, const float slidingFitPitch);
188 
194  const pandora::ClusterList &GetClusters() const;
195 
201  const TwoDSlidingFitResult &GetFit() const;
202 
210  pandora::CartesianPointVector GetClusterListCoordinateVector(const pandora::ClusterList &clusterList) const;
211 
212  private:
213  pandora::ClusterList m_clusterList;
214  pandora::CartesianPointVector m_coordinateVector;
216  };
217 
218  typedef std::vector<ShowerCluster> ShowerClusterList;
219 
221  typedef std::vector<HitKDNode2D> HitKDNode2DList;
223 
224  typedef std::map<pandora::HitType, const pandora::ClusterList &> ClusterListMap;
225  typedef std::map<pandora::HitType, const SlidingFitDataList> SlidingFitDataListMap;
226  typedef std::map<pandora::HitType, const ShowerClusterList> ShowerClusterListMap;
227  typedef std::map<pandora::HitType, const std::reference_wrapper<HitKDTree2D> > KDTreeMap;
228 
229  typedef MvaFeatureTool<const VertexSelectionBaseAlgorithm *const, const pandora::Vertex * const, const SlidingFitDataListMap &,
230  const ClusterListMap &, const KDTreeMap &, const ShowerClusterListMap &, const float, float &> VertexFeatureTool;
231 
232 protected:
242  virtual void FilterVertexList(const pandora::VertexList *const pInputVertexList, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV,
243  HitKDTree2D &kdTreeW, pandora::VertexVector &filteredVertices) const;
244 
251  virtual void GetBeamConstants(const pandora::VertexVector &vertexVector, BeamConstants &beamConstants) const;
252 
263  virtual void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU,
264  HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const = 0;
265 
274  void GetClusterLists(const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV,
275  pandora::ClusterList &clusterListW) const;
276 
285  void CalculateClusterSlidingFits(const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits,
286  const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const;
287 
296  float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex * const pVertex) const;
297 
303  bool IsBeamModeOn() const;
304 
305  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
306 
307 private:
308  pandora::StatusCode Run();
309 
317  void InitializeKDTrees(HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW) const;
318 
328  bool IsVertexOnHit(const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const;
329 
338  bool IsVertexInGap(const pandora::Vertex *const pVertex, const pandora::HitType hitType) const;
339 
346  void SelectTopScoreVertices(VertexScoreList &vertexScoreList, pandora::VertexList &selectedVertexList) const;
347 
356  bool AcceptVertexLocation(const pandora::Vertex *const pVertex, const pandora::VertexList &selectedVertexList) const;
357 
366  static bool SortByVertexZPosition(const pandora::Vertex *const pLhs, const pandora::Vertex *const pRhs);
367 
368 private:
369  pandora::StringVector m_inputCaloHitListNames;
371 
373 
374  bool m_beamMode;
376 
378  unsigned int m_maxTopScoreSelections;
379 
381 
384 
387 
390 };
391 
392 //------------------------------------------------------------------------------------------------------------------------------------------
393 
394 inline float VertexSelectionBaseAlgorithm::GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex * const pVertex) const
395 {
396  const float vertexMinZ(std::max(pVertex->GetPosition().GetZ(), beamConstants.GetMinZCoordinate()));
397  return (beamConstants.GetMinZCoordinate() - vertexMinZ) * beamConstants.GetDecayConstant();
398 }
399 
400 //------------------------------------------------------------------------------------------------------------------------------------------
401 
403 {
404  return m_beamMode;
405 }
406 
407 //------------------------------------------------------------------------------------------------------------------------------------------
408 //------------------------------------------------------------------------------------------------------------------------------------------
409 
410 inline VertexSelectionBaseAlgorithm::VertexScore::VertexScore(const pandora::Vertex *const pVertex, const float score) :
411  m_pVertex(pVertex),
412  m_score(score)
413 {
414 }
415 
416 //------------------------------------------------------------------------------------------------------------------------------------------
417 
418 inline const pandora::Vertex *VertexSelectionBaseAlgorithm::VertexScore::GetVertex() const
419 {
420  return m_pVertex;
421 }
422 
423 //------------------------------------------------------------------------------------------------------------------------------------------
424 
426 {
427  return m_score;
428 }
429 
430 //------------------------------------------------------------------------------------------------------------------------------------------
431 
433 {
434  return (this->GetScore() > rhs.GetScore());
435 }
436 
437 //------------------------------------------------------------------------------------------------------------------------------------------
438 //------------------------------------------------------------------------------------------------------------------------------------------
439 
441 {
442  return m_minZCoordinate.Get();
443 }
444 
445 //------------------------------------------------------------------------------------------------------------------------------------------
446 
448 {
449  return m_decayConstant.Get();
450 }
451 
452 //------------------------------------------------------------------------------------------------------------------------------------------
453 
454 inline void VertexSelectionBaseAlgorithm::BeamConstants::SetConstants(const float minZCoordinate, const float decayConstant)
455 {
456  m_minZCoordinate = minZCoordinate;
457  m_decayConstant = decayConstant;
458 }
459 
460 //------------------------------------------------------------------------------------------------------------------------------------------
461 
462 inline const pandora::CartesianVector &VertexSelectionBaseAlgorithm::SlidingFitData::GetMinLayerDirection() const
463 {
464  return m_minLayerDirection;
465 }
466 
467 //------------------------------------------------------------------------------------------------------------------------------------------
468 
469 inline const pandora::CartesianVector &VertexSelectionBaseAlgorithm::SlidingFitData::GetMaxLayerDirection() const
470 {
471  return m_maxLayerDirection;
472 }
473 
474 //------------------------------------------------------------------------------------------------------------------------------------------
475 
476 inline const pandora::CartesianVector &VertexSelectionBaseAlgorithm::SlidingFitData::GetMinLayerPosition() const
477 {
478  return m_minLayerPosition;
479 }
480 
481 //------------------------------------------------------------------------------------------------------------------------------------------
482 
483 inline const pandora::CartesianVector &VertexSelectionBaseAlgorithm::SlidingFitData::GetMaxLayerPosition() const
484 {
485  return m_maxLayerPosition;
486 }
487 
488 //------------------------------------------------------------------------------------------------------------------------------------------
489 
490 inline const pandora::Cluster *VertexSelectionBaseAlgorithm::SlidingFitData::GetCluster() const
491 {
492  return m_pCluster;
493 }
494 
495 //------------------------------------------------------------------------------------------------------------------------------------------
496 
497 inline const pandora::ClusterList &VertexSelectionBaseAlgorithm::ShowerCluster::GetClusters() const
498 {
499  return m_clusterList;
500 }
501 
502 //------------------------------------------------------------------------------------------------------------------------------------------
503 
505 {
506  return m_twoDSlidingFitResult;
507 }
508 
509 } // namespace lar_content
510 
511 #endif // #ifndef LAR_VERTEX_SELECTION_BASE_ALGORITHM_H
const pandora::Cluster * m_pCluster
Pointer to the corresponding cluster.
float m_minCandidateScoreFraction
Ignore other top-scoring candidates with score less than a fraction of original.
pandora::CartesianPointVector m_coordinateVector
The coordinate vector.
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.
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
void SetConstants(const float minZCoordinate, const float decayConstant)
Set the beam constants.
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.
pandora::StringVector m_inputCaloHitListNames
The list of calo hit list names.
void GetClusterLists(const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get the cluster lists.
Class that implements the KDTree partition of 2D space and a closest point search algorithm...
void CalculateClusterSlidingFits(const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits, const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const
Calculate the cluster sliding fits.
const pandora::CartesianVector & GetMaxLayerDirection() const
Get the max layer direction.
TwoDSlidingFitResult m_twoDSlidingFitResult
The fit to the hits of the cluster list.
pandora::CartesianVector m_minLayerPosition
The position of the fit at the max layer.
bool IsBeamModeOn() const
Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction.
const pandora::CartesianVector & GetMinLayerPosition() const
Get the min layer position.
const pandora::ClusterList & GetClusters() const
Get the cluster 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.
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
pandora::CartesianVector m_maxLayerDirection
The direction of the fit at the min layer.
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...
Int_t max
Definition: plot.C:27
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
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.
pandora::CartesianVector m_minLayerDirection
The direction of the fit at the min layer.
bool IsVertexInGap(const pandora::Vertex *const pVertex, const pandora::HitType hitType) const
Whether the vertex lies in a registered gap.
Header file for the lar support vector machine class.
Header file for the lar two dimensional sliding fit result class.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
const TwoDSlidingFitResult & GetFit() const
Get the 2D sliding linear fit.
pandora::CartesianVector m_maxLayerPosition
The position of the fit at the max layer.
bool m_useDetectorGaps
Whether to account for registered detector gaps in vertex selection.
static bool SortByVertexZPosition(const pandora::Vertex *const pLhs, const pandora::Vertex *const pRhs)
Sort vertices by increasing z position.
VertexScore(const pandora::Vertex *const pVertex, const float score)
Constructor.
void InitializeKDTrees(HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW) const
Initialize kd trees with details of hits in algorithm-configured cluster lists.
const pandora::Vertex * m_pVertex
The address of the vertex.
bool operator<(const VertexScore &rhs) const
operator<
const pandora::Vertex * GetVertex() const
Get the address of the vertex.
const pandora::CartesianVector & GetMaxLayerPosition() const
Get the max layer position.
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.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
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...
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.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
Get the beam deweighting score for a vertex.
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.
MvaFeatureTool class template.
Definition: LArMvaHelper.h:27
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const pandora::CartesianVector & GetMinLayerDirection() const
Get the min layer direction.
std::list< Vertex > VertexList
Definition: DCEL.h:178
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.
const pandora::Cluster * GetCluster() const
Get a pointer to the corresponding cluster.
std::vector< art::Ptr< recob::Vertex > > VertexVector