1 #ifndef COMMONTOOLS_RECOALGOS_FKDTREE_H 2 #define COMMONTOOLS_RECOALGOS_FKDTREE_H 21 const std::array<unsigned int, 32> MultiplyDeBruijnBitPosition{{0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16,
22 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17,
23 24, 7, 19, 27, 23, 6, 26, 5, 4, 31}};
24 unsigned int ilog2(
unsigned int v) {
30 return MultiplyDeBruijnBitPosition[(
unsigned int)(
v * 0x07C4ACDDU) >> 27];
34 template <
class TYPE,
unsigned int numberOfDimensions>
52 std::vector<unsigned int>& foundPoints) {
64 unsigned int numberOfindicesToVisitThisDepth;
65 unsigned int numberOfSonsToVisitNext;
66 unsigned int firstSonToVisitNext;
72 numberOfindicesToVisitThisDepth = indicesToVisit.
size();
74 for (
unsigned int visitedindicesThisDepth = 0; visitedindicesThisDepth < numberOfindicesToVisitThisDepth;
75 visitedindicesThisDepth++) {
76 index = indicesToVisit[visitedindicesThisDepth];
87 numberOfSonsToVisitNext =
93 numberOfSonsToVisitNext =
98 for (
unsigned int whichSon = 0; whichSon < numberOfSonsToVisitNext; ++whichSon) {
99 indicesToVisit.
push_back(firstSonToVisitNext + whichSon);
103 indicesToVisit.
pop_front(numberOfindicesToVisitThisDepth);
115 for (
unsigned int i = 0;
i < numberOfDimensions; ++
i)
130 unsigned int firstIndexInDepth = (1 <<
depth) - 1;
132 for (
unsigned int indexInDepth = 0; indexInDepth <
maxDepth; ++indexInDepth) {
133 unsigned int indexInArray = firstIndexInDepth + indexInDepth;
134 unsigned int leftSonIndexInArray = 2 * indexInArray + 1;
135 unsigned int rightSonIndexInArray = leftSonIndexInArray + 1;
143 points.begin() +
theIntervalMin[indexInArray] + whichElementInInterval,
148 return a.getId() <
b.getId();
168 unsigned int firstIndexInDepth = (1 <<
theDepth) - 1;
169 for (
unsigned int indexInArray = firstIndexInDepth; indexInArray <
theNumberOfPoints; ++indexInArray) {
195 return length -
index / 2;
216 for (
unsigned int i = 0;
i < numberOfDimensions; ++
i) {
225 for (
unsigned int i = 0;
i < numberOfDimensions; ++
i)
231 for (
unsigned int i = 0;
i < numberOfDimensions; ++
i)
std::array< std::vector< TYPE >, numberOfDimensions > theDimensions
unsigned int rightSonIndex(unsigned int index) const
unsigned int size() const
std::vector< unsigned int > theIds
std::vector< unsigned int > theIntervalMin
double intersection(double r12)
unsigned int partition_complete_kdtree(unsigned int length)
void search(const FKDPoint< TYPE, numberOfDimensions > &minPoint, const FKDPoint< TYPE, numberOfDimensions > &maxPoint, std::vector< unsigned int > &foundPoints)
void build(std::vector< FKDPoint< TYPE, numberOfDimensions > > &points)
void push_back(const T &value)
unsigned int theNumberOfPoints
void add_at_position(const FKDPoint< TYPE, numberOfDimensions > &point, const unsigned int position)
void add_at_position(FKDPoint< TYPE, numberOfDimensions > &&point, const unsigned int position)
static int position[264][3]
std::vector< unsigned int > theIntervalLength
bool intersects(unsigned int index, const FKDPoint< TYPE, numberOfDimensions > &minPoint, const FKDPoint< TYPE, numberOfDimensions > &maxPoint, int dimension) const
unsigned int leftSonIndex(unsigned int index) const
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
bool is_in_the_box(unsigned int index, const FKDPoint< TYPE, numberOfDimensions > &minPoint, const FKDPoint< TYPE, numberOfDimensions > &maxPoint) const