1 #ifndef KDTreeLinkerAlgoTemplated_h 2 #define KDTreeLinkerAlgoTemplated_h 12 template <
typename DATA,
unsigned DIM=2>
84 template <
typename DATA,
unsigned DIM >
104 template <
typename DATA,
unsigned DIM >
113 const int nbrElts = high - low;
114 int median = nbrElts/2 - ( 1 - 1*(nbrElts&1) );
128 const unsigned thedim = treeDepth %
DIM;
138 if (j < median) l =
i;
139 if (i > median) m = j;
147 template <
typename DATA,
unsigned DIM >
160 template <
typename DATA,
unsigned DIM >
174 if ((current->
left == 0) && (current->
right == 0)) {
177 bool isInside =
true;
178 for(
unsigned i = 0;
i <
DIM; ++
i ) {
179 const auto thedim = current->
info.dims[
i];
180 isInside *= thedim >= trackBox.
dimmin[
i] && thedim <= trackBox.
dimmax[
i];
186 bool isFullyContained =
true;
187 bool hasIntersection =
true;
189 for(
unsigned i = 0;
i <
DIM; ++
i ) {
190 const auto regionmin = current->
left->region.dimmin[
i];
191 const auto regionmax = current->
left->region.dimmax[
i];
192 isFullyContained *= ( regionmin >= trackBox.
dimmin[
i] &&
193 regionmax <= trackBox.
dimmax[
i] );
194 hasIntersection *= ( regionmin < trackBox.
dimmax[
i] && regionmax > trackBox.
dimmin[
i]);
196 if( isFullyContained ) {
198 }
else if ( hasIntersection ) {
202 isFullyContained =
true;
203 hasIntersection =
true;
205 for(
unsigned i = 0;
i <
DIM; ++
i ) {
206 const auto regionmin = current->
right->region.dimmin[
i];
207 const auto regionmax = current->
right->region.dimmax[
i];
208 isFullyContained *= ( regionmin >= trackBox.
dimmin[
i] &&
209 regionmax <= trackBox.
dimmax[
i] );
210 hasIntersection *= ( regionmin < trackBox.
dimmax[
i] && regionmax > trackBox.
dimmin[
i]);
212 if( isFullyContained ) {
214 }
else if ( hasIntersection ) {
220 template <
typename DATA,
unsigned DIM >
227 if ((current->
left == 0) && (current->
right == 0))
238 template <
typename DATA,
unsigned DIM>
247 template <
typename DATA,
unsigned DIM>
254 template <
typename DATA,
unsigned DIM>
265 template <
typename DATA,
unsigned DIM>
274 template <
typename DATA,
unsigned DIM>
288 template <
typename DATA,
unsigned DIM>
295 int portionSize = high - low;
300 if (portionSize == 1) {
320 unsigned thedim = depth %
DIM;
321 auto medianVal = (*initialEltList)[medianId].dims[thedim];
322 leftRegion.
dimmax[thedim] = medianVal;
323 rightRegion.
dimmin[thedim] = medianVal;
329 node->
left =
recBuild(low, medianId, depth, leftRegion);
KDTreeNodeT< DATA, DIM > * right
KDTreeNodeT< DATA, DIM > * left
std::array< float, DIM > dimmin
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)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
KDTreeNodeT< DATA, DIM > * nodePool_
KDTreeNodeT< DATA, DIM > * root_
KDTreeNodeT< DATA, DIM > * getNextNode()
std::array< float, DIM > dims
KDTreeNodeInfoT< DATA, DIM > info
std::vector< KDTreeNodeInfoT< DATA, DIM > > * closestNeighbour
void recSearch(const KDTreeNodeT< DATA, DIM > *current, const KDTreeBoxT< DIM > &trackBox)
std::array< float, DIM > dimmax
void setAttributs(const KDTreeBoxT< DIM > ®ionBox, const KDTreeNodeInfoT< DATA, DIM > &infoToStore)
std::vector< KDTreeNodeInfoT< DATA, DIM > > * initialEltList