LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
kdTree.h
Go to the documentation of this file.
1 
9 #ifndef kdTree_h
10 #define kdTree_h
11 
12 // Framework Includes
13 #include "fhiclcpp/ParameterSet.h"
14 
15 // Algorithm includes
17 
18 // std includes
19 #include <vector>
20 #include <list>
21 #include <set>
22 #include <map>
23 //------------------------------------------------------------------------------------------------------------------------------------------
24 
25 namespace lar_cluster3d
26 {
30 class kdTree
31 {
32 public:
38  kdTree(fhicl::ParameterSet const &pset);
39 
43  virtual ~kdTree();
44 
50  void configure(fhicl::ParameterSet const &pset);
51 
55  class KdTreeNode;
56 
57  using KdTreeNodeVec = std::vector<KdTreeNode>;
58  using KdTreeNodeList = std::list<KdTreeNode>;
59  using Hit3DVec = std::vector<const reco::ClusterHit3D*>;
60 
68 
69  using CandPair = std::pair<double,const reco::ClusterHit3D*>;
70  using CandPairList = std::list<CandPair>;
71 
72  size_t FindNearestNeighbors(const reco::ClusterHit3D*, const KdTreeNode&, CandPairList&, float&) const;
73  bool FindEntry(const reco::ClusterHit3D*, const KdTreeNode&, CandPairList&, float&, bool&, int) const;
74  bool FindEntryBrute(const reco::ClusterHit3D*, const KdTreeNode&, int) const;
75 
80 
85 
86  float getTimeToExecute() const {return m_timeToBuild;}
87 
88 private:
89 
93  bool consistentPairs(const reco::ClusterHit3D* pair1, const reco::ClusterHit3D* pair2, float& hitSeparation) const;
94 
96 
98  mutable float m_timeToBuild;
101 
102 };
103 
108 {
109 public:
114  null
115  };
116 
117  KdTreeNode(SplitAxis axis, float axisVal, const KdTreeNode& left, const KdTreeNode& right) :
118  m_splitAxis(axis),
119  m_axisValue(axisVal),
120  m_clusterHit3D(0),
121  m_leftTree(left),
122  m_rightTree(right)
123  {}
124 
126  m_splitAxis(SplitAxis::leaf),
127  m_axisValue(0.),
128  m_clusterHit3D(hit),
129  m_leftTree(*this),
130  m_rightTree(*this)
131  {}
132 
133  KdTreeNode() : m_splitAxis(SplitAxis::null),
134  m_axisValue(0.),
135  m_clusterHit3D(0),
136  m_leftTree(*this),
137  m_rightTree(*this)
138  {}
139 
140  bool isLeafNode() const {return m_splitAxis == SplitAxis::leaf;}
141  bool isNullNode() const {return m_splitAxis == SplitAxis::null;}
142 
143  SplitAxis getSplitAxis() const {return m_splitAxis;}
144  float getAxisValue() const {return m_axisValue;}
145  const reco::ClusterHit3D* getClusterHit3D() const {return m_clusterHit3D;}
146  const KdTreeNode& leftTree() const {return m_leftTree;}
147  const KdTreeNode& rightTree() const {return m_rightTree;}
148 
149 private:
150 
152  float m_axisValue;
156 };
157 
158 } // namespace lar_cluster3d
159 #endif
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
kdTree class definiton
Definition: kdTree.h:30
intermediate_table::iterator iterator
const KdTreeNode & m_leftTree
Definition: kdTree.h:154
void configure(fhicl::ParameterSet const &pset)
Configure our kdTree...
Definition: kdTree.cxx:45
std::list< KdTreeNode > KdTreeNodeList
Definition: kdTree.h:58
size_t FindNearestNeighbors(const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &) const
Definition: kdTree.cxx:178
float m_pairSigmaPeakTime
Consider hits consistent if "significance" less than this.
Definition: kdTree.h:99
kdTree(fhicl::ParameterSet const &pset)
Constructor.
Definition: kdTree.cxx:32
std::vector< const reco::ClusterHit3D * > Hit3DVec
Definition: kdTree.h:59
std::list< std::unique_ptr< reco::ClusterHit3D >> HitPairList
Definition: Cluster3D.h:319
float DistanceBetweenNodes(const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
Definition: kdTree.cxx:324
const KdTreeNode & m_rightTree
Definition: kdTree.h:155
define a kd tree node
Definition: kdTree.h:107
float m_refLeafBestDist
Set neighborhood distance to this when ref leaf found.
Definition: kdTree.h:100
std::pair< double, const reco::ClusterHit3D * > CandPair
Definition: kdTree.h:69
KdTreeNode(const reco::ClusterHit3D *hit)
Definition: kdTree.h:125
virtual ~kdTree()
Destructor.
Definition: kdTree.cxx:39
std::list< const reco::ClusterHit3D * > HitPairListPtr
Definition: Cluster3D.h:315
bool m_enableMonitoring
Definition: kdTree.h:97
bool consistentPairs(const reco::ClusterHit3D *pair1, const reco::ClusterHit3D *pair2, float &hitSeparation) const
The bigger question: are two pairs of hits consistent?
Definition: kdTree.cxx:280
Detector simulation of raw signals on wires.
std::list< CandPair > CandPairList
Definition: kdTree.h:70
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
bool FindEntry(const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &, bool &, int) const
Definition: kdTree.cxx:215
bool FindEntryBrute(const reco::ClusterHit3D *, const KdTreeNode &, int) const
Definition: kdTree.cxx:260
KdTreeNode(SplitAxis axis, float axisVal, const KdTreeNode &left, const KdTreeNode &right)
Definition: kdTree.h:117
const KdTreeNode & rightTree() const
Definition: kdTree.h:147
const reco::ClusterHit3D * getClusterHit3D() const
Definition: kdTree.h:145
std::vector< KdTreeNode > KdTreeNodeVec
Definition: kdTree.h:57
float getTimeToExecute() const
Definition: kdTree.h:86
KdTreeNode & BuildKdTree(Hit3DVec::iterator, Hit3DVec::iterator, KdTreeNodeList &, int depth=0) const
Given an input set of ClusterHit3D objects, build a kd tree structure.
Definition: kdTree.cxx:120
const KdTreeNode & leftTree() const
Definition: kdTree.h:146
SplitAxis getSplitAxis() const
Definition: kdTree.h:143
const reco::ClusterHit3D * m_clusterHit3D
Definition: kdTree.h:153