37 int portionSize = high - low;
40 assert(portionSize > 0);
42 if (portionSize == 1) {
64 double medianVal = eltList[medianId].dim2;
66 rightRegion.
dim2min = medianVal;
70 double medianVal = eltList[medianId].dim1;
72 rightRegion.
dim1min = medianVal;
80 node->
left =
recBuild(eltList, low, medianId, depth, leftRegion);
81 node->
right =
recBuild(eltList, medianId, high, depth, rightRegion);
98 int nbrElts = high - low;
99 int median = (nbrElts & 1) ? nbrElts / 2
116 while (eltList[i].dim2 < elt.
dim2) i++;
117 while (eltList[j].dim2 > elt.
dim2) j--;
119 while (eltList[i].dim1 < elt.
dim1) i++;
120 while (eltList[j].dim1 > elt.
dim1) j--;
124 swap(eltList[i], eltList[j]);
129 if (j < median) l =
i;
130 if (i > median) m = j;
147 std::vector<KDTreeNodeInfo> &recHits)
156 std::vector<KDTreeNodeInfo> &recHits)
159 assert(current != 0);
162 assert (!(((current->
left == 0) && (current->
right != 0)) ||
163 ((current->
left != 0) && (current->
right == 0))));
165 if ((current->
left == 0) && (current->
right == 0)) {
170 recHits.push_back(current->
rh);
210 std::vector<KDTreeNodeInfo> &recHits)
213 assert(current != 0);
215 if ((current->
left == 0) && (current->
right == 0))
216 recHits.push_back(current->
rh);
void setAttributs(const KDTreeBox ®ionBox, const KDTreeNodeInfo &rhinfo)
int medianSearch(int low, int high, int treeDepth)
void build(std::vector< KDTreeNodeInfoT< DATA, DIM > > &eltList, const KDTreeBoxT< DIM > ®ion)
KDTreeNodeT< DATA, DIM > * recBuild(int low, int hight, int depth, const KDTreeBoxT< DIM > ®ion)
void search(const KDTreeBoxT< DIM > &searchBox, std::vector< KDTreeNodeInfoT< DATA, DIM > > &resRecHitList)
void addSubtree(const KDTreeNodeT< DATA, DIM > *current)
KDTreeNodeT< DATA, DIM > * nodePool_
KDTreeNodeT< DATA, DIM > * root_
void swap(KDTreeNodeInfo &e1, KDTreeNodeInfo &e2)
KDTreeNodeT< DATA, DIM > * getNextNode()
std::vector< std::vector< double > > tmp
static const char root_[]
void recSearch(const KDTreeNodeT< DATA, DIM > *current, const KDTreeBoxT< DIM > &trackBox)