9 template <
typename Index,
typename Value>
class TKDTree :
public TObject
14 TKDTree(Index npoints, Index ndim, UInt_t bsize);
15 TKDTree(Index npoints, Index ndim, UInt_t bsize, Value **data);
20 Double_t
Distance(
const Value *point, Index ind, Int_t type=2)
const;
21 void DistanceToNode(
const Value *point, Index inode, Value &min, Value &max, Int_t type=2);
24 Int_t
GetLeft(Int_t inode)
const {
return inode*2+1;}
25 Int_t
GetRight(Int_t inode)
const {
return (inode+1)*2;}
26 Int_t
GetParent(Int_t inode)
const {
return (inode-1)/2;}
30 void GetNodePointsIndexes(Int_t node, Int_t &first1, Int_t &last1, Int_t &first2, Int_t &last2)
const;
51 Index
FindNode(
const Value * point)
const;
52 void FindPoint(Value * point, Index &index, Int_t &iter);
53 void FindInRange(Value *point, Value range, std::vector<Index> &res);
54 void FindBNodeA(Value * point, Value * delta, Int_t &inode);
58 Value
KOrdStat(Index ntotal, Value *a, Index k, Index *index)
const;
63 void SetData(Index npoints, Index ndim, UInt_t bsize, Value **data);
64 Int_t
SetData(Index idim, Value *data);
66 void Spread(Index ntotal, Value *a, Index *index, Value &min, Value &max)
const;
74 void UpdateRange(Index inode, Value *point, Value range, std::vector<Index> &res);
double dist(Rotation3D const &r1, Rotation3D const &r2)
void Spread(Index ntotal, Value *a, Index *index, Value &min, Value &max) const
Calculate spread of the array a.
Int_t GetParent(Int_t inode) const
Int_t fOffset
cross node - node that begins the last row (with terminal nodes only)
void SetData(Index npoints, Index ndim, UInt_t bsize, Value **data)
Set the data array. See the constructor function comments for details.
Index FindNode(const Value *point) const
returns the index of the terminal node to which point belongs (index in the fAxis, fValue, etc arrays) returns -1 in case of failure
Index * GetPointsIndexes(Int_t node) const
return the indices of the points in that terminal node for all the nodes except last, the size is fBucketSize for the last node it's fOffsetfBucketSize
TKDTree< Int_t, Float_t > TKDTreeIF
Bool_t IsTerminal(Index inode) const
void FindBNodeA(Value *point, Value *delta, Int_t &inode)
find the smallest node covering the full range - start
Int_t GetOffset()
cross node
void FindInRange(Value *point, Value range, std::vector< Index > &res)
Find all points in the sphere of a given radius "range" around the given point 1st argument - the poi...
void MakeBoundariesExact()
Build boundaries for each node.
Index GetNPointsNode(Int_t node) const
Get number of points in this node for all the terminal nodes except last, the size is fBucketSize for...
void SetOwner(Int_t owner)
Double_t Distance(const Value *point, Index ind, Int_t type=2) const
Find the distance between point of the first argument and the point at index value ind Type argument ...
Int_t GetCrossNode()
smallest terminal row
void Build()
Build the kd-tree.
Int_t GetRight(Int_t inode) const
void FindPoint(Value *point, Index &index, Int_t &iter)
find the index of point works only if we keep fData pointers
TKDTree()
Default constructor. Nothing is built.
Index * fIndPoints
nodes boundaries
Class implementing a kd-tree.
void UpdateNearestNeighbors(Index inode, const Value *point, Int_t kNN, Index *ind, Value *dist)
Update the nearest neighbors values by examining the node inode.
Int_t fRowT0
array of points indexes
~TKDTree()
Destructor By default, the original data is not owned by kd-tree and is not deleted with it...
Value KOrdStat(Index ntotal, Value *a, Index k, Index *index) const
copy of the TMath::KOrdStat because I need an Index work array
TKDTree< Index, Value > & operator=(const TKDTree< Index, Value > &)
Int_t GetLeft(Int_t inode) const
TKDTreeIF * TKDTreeTestBuild()
Index * GetIndPoints()
offset in fIndPoints
void GetNodePointsIndexes(Int_t node, Int_t &first1, Int_t &last1, Int_t &first2, Int_t &last2) const
Return the indices of points in that node Indices are returned as the first and last value of the par...
void FindNearestNeighbors(const Value *point, Int_t k, Index *ind, Value *dist)
Find kNN nearest neighbors to the point in the first argument Returns 1 on success, 0 on failure Arrays ind and dist are provided by the user and are assumed to be at least kNN elements long.
void CookBoundaries(const Int_t node, Bool_t left)
define index of this terminal node
void DistanceToNode(const Value *point, Index inode, Value &min, Value &max, Int_t type=2)
Find the minimal and maximal distance from a given point to a given node.
TKDTree< Int_t, Double_t > TKDTreeID
void MakeBoundaries(Value *range=0x0)
Build boundaries for each node.
Value * GetBoundariesExact()
Get the boundaries.
Int_t fCrossNode
smallest terminal row - first row that contains terminal nodes
Value GetNodeValue(Int_t id) const
void UpdateRange(Index inode, Value *point, Value range, std::vector< Index > &res)
Internal recursive function with the implementation of range searches.
Int_t fNNodes
0 - not owner, 2 - owner of the pointer array, 1 - owner of the whole 2-d array
Value * GetBoundaries()
Get the boundaries.
UChar_t GetNodeAxis(Int_t id) const
Int_t GetTotalNodes() const
Value * GetBoundaryExact(const Int_t node)
Get a boundary.
Value * fBoundaries
data points
Value * GetBoundary(const Int_t node)
Get a boundary.