1 #ifndef KDTreeLinkerAlgoTemplated_h 2 #define KDTreeLinkerAlgoTemplated_h 12 template <
typename DATA,
unsigned DIM=2>
84 template <
typename DATA,
unsigned DIM >
89 if (!eltList.empty()) {
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 ==
nullptr) && (current->
right ==
nullptr)) {
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 ==
nullptr) && (current->
right ==
nullptr))
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 recBuild(int low, int hight, int depth)
std::vector< DATA > * closestNeighbour
std::vector< KDTreeNodeInfo< DATA > > * initialEltList
KDTreeNodes< DATA > nodePool_
void addSubtree(const KDTreeNodeT< DATA, DIM > *current)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< KDTreeNodeInfoT< DATA, DIM > > * initialEltList
void search(const KDTreeBox &searchBox, std::vector< DATA > &resRecHitList)
std::vector< KDTreeNodeInfoT< DATA, DIM > > * closestNeighbour
std::array< float, DIM > dims
void build(std::vector< KDTreeNodeInfo< DATA > > &eltList, const KDTreeBox ®ion)
KDTreeNodeT< DATA, DIM > * getNextNode()
KDTreeNodeInfoT< DATA, DIM > info
KDTreeNodeT< DATA, DIM > * root_
std::array< float, DIM > dimmax
void setAttributs(const KDTreeBoxT< DIM > ®ionBox, const KDTreeNodeInfoT< DATA, DIM > &infoToStore)
KDTreeNodeT< DATA, DIM > * nodePool_
int medianSearch(int low, int high, int treeDepth)
void recSearch(int current, float dimCurrMin, float dimCurrMax, float dimOtherMin, float dimOtherMax)