CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KDTreeLinkerAlgo.h
Go to the documentation of this file.
1 #ifndef KDTreeLinkerAlgo_h
2 #define KDTreeLinkerAlgo_h
3 
5 
6 #include <vector>
7 
8 // Class that implements the KDTree partition of 2D space and
9 // a closest point search algorithme.
11 {
12  public:
14 
15  // Dtor calls clear()
17 
18  // Here we build the KD tree from the "eltList" in the space define by "region".
19  void build(std::vector<KDTreeNodeInfo> &eltList,
20  const KDTreeBox &region);
21 
22  // Here we search in the KDTree for all points that would be
23  // contained in the given searchbox. The founded points are stored in resRecHitList.
24  void search(const KDTreeBox &searchBox,
25  std::vector<KDTreeNodeInfo> &resRecHitList);
26 
27  // This method clears all allocated structures.
28  void clear();
29 
30  private:
31  // The KDTree root
33 
34  // The node pool allow us to do just 1 call to new for each tree building.
38 
39  private:
40  // Basic swap function.
41  void swap(KDTreeNodeInfo &e1, KDTreeNodeInfo &e2);
42 
43  // Get next node from the node pool.
45 
46  //Fast median search with Wirth algorithm in eltList between low and high indexes.
47  int medianSearch(std::vector<KDTreeNodeInfo> &eltList,
48  int low,
49  int high,
50  int treeDepth);
51 
52  // Recursif kdtree builder. Is called by build()
53  KDTreeNode *recBuild(std::vector<KDTreeNodeInfo> &eltList,
54  int low,
55  int hight,
56  int depth,
57  const KDTreeBox& region);
58 
59  // Recursif kdtree search. Is called by search()
60  void recSearch(const KDTreeNode *current,
61  const KDTreeBox &trackBox,
62  std::vector<KDTreeNodeInfo> &recHits);
63 
64  // Add all elements of an subtree to the closest elements. Used during the recSearch().
65  void addSubtree(const KDTreeNode *current,
66  std::vector<KDTreeNodeInfo> &recHits);
67 
68  // This method frees the KDTree.
69  void clearTree();
70 };
71 
72 #endif
void addSubtree(const KDTreeNode *current, std::vector< KDTreeNodeInfo > &recHits)
KDTreeNode * nodePool_
KDTreeNode * getNextNode()
KDTreeNode * recBuild(std::vector< KDTreeNodeInfo > &eltList, int low, int hight, int depth, const KDTreeBox &region)
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox &region)
void search(const KDTreeBox &searchBox, std::vector< KDTreeNodeInfo > &resRecHitList)
void swap(KDTreeNodeInfo &e1, KDTreeNodeInfo &e2)
void recSearch(const KDTreeNode *current, const KDTreeBox &trackBox, std::vector< KDTreeNodeInfo > &recHits)
KDTreeNode * root_
int medianSearch(std::vector< KDTreeNodeInfo > &eltList, int low, int high, int treeDepth)