4#ifndef TRIGTOOLS_TRIG_VSI_KDPOINT
5#define TRIGTOOLS_TRIG_VSI_KDPOINT
28template<
typename T,
size_t D>
41 for (
size_t i = 0; i < D; i++) {
if (i < v.size())
m_point[i] = v[i]; }
45 auto bg = list.begin();
46 for (
auto itr = bg; itr != bg + D; ++itr) {
47 size_t i = std::distance(bg, itr);
56 for (
size_t i = 0; i < D; i++ ) {
57 tmp[i] = this->m_point[i] + other.m_point[i];
66 for (
size_t i = 0; i < D; i++ ) {
67 tmp[i] = this->m_point[i] - other.m_point[i];
74 for (
size_t i = 0; i < D; i++ ) {
75 this->m_point[i] += other.m_point.at(i);
82 for (
size_t i = 0; i < D; i++ ) {
83 this->m_point[i] -= other.m_point.at(i);
93 for (
size_t i = 0; i < D; i++ ) {
94 tmp[i] = this->m_point[i] * other;
104 for (
size_t i = 0; i < D; i++ ) {
105 tmp[i] = this->m_point[i] / other;
128 inline T
at(
size_t i)
const {
return (i < D)?
m_point[i] : TMath::QuietNaN(); };
140 tmp = ( *
this * this->m_weight + p * p.m_weight ) / ( this->m_weight + p.m_weight );
147template<
typename I,
typename T,
size_t D>
158template<
typename T,
size_t D>
195 std::unique_ptr<Node>
buildTree(
int,
int,
int);
204template<
typename T,
size_t D>
219template<
typename T,
size_t D>
222 if ( l >=
r )
return std::make_unique<Node>(
nullptr);
224 const int axis_ =
depth % D;
225 const int mid = ( l +
r ) >> 1;
228 [
this, axis_](
size_t lcnt,
size_t rcnt) {
229 return m_datas[lcnt].getId(axis_) < m_datas[rcnt].getId(axis_);
233 node_ptr->axis = axis_;
250template<
typename T,
size_t D>
255 if (
node ==
nullptr ) {
262 const double dist = dist_func(
query, point);
268 const int axis_ =
node->axis;
269 const Node* next_node = (
query.at(axis_) < point.
at(axis_))?
node->leftPtr.get() :
node->rightPtr.get();
276 proj[axis_] = point.
at(axis_);
280 const Node* next_node_opps = (
query.at(axis_) < point.
at(axis_))?
node->rightPtr.get() :
node->leftPtr.get();
char data[hepevt_bytes_allocation_ATLAS]
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Class for k-dimensional point.
const KDPoint< T, D > operator+(const KDPoint< T, D > &other) const
Add each elements except weights.
void setWeight(double w)
Set the weight to given value.
const KDPoint< T, D > operator*(const I &other) const
Multiply each elements except weights.
KDPoint(std::initializer_list< T > list)
const std::array< T, D > & getPos() const
KDPoint(const std::vector< T > &v)
KDPoint< T, D > & operator-=(const KDPoint< T, D > &other)
T & operator[](size_t i)
Return i-th element.
T at(size_t i) const
Return i-th element. If given i exceeds the size, return NaN.
const KDPoint< T, D > operator/(const I &other) const
Divide each elements except weights.
double getWeight() const
Return the weight of the point.
const KDPoint< T, D > operator-(const KDPoint< T, D > &other) const
Subtract each elements except weights.
KDPoint(std::array< T, D > &arr)
KDPoint< T, D > & operator+=(const KDPoint< T, D > &other)
static KDPoint< T, D > average(const std::vector< KDPoint< T, D > > &)
KDPoint(std::array< T, D > &&arr)
std::array< T, D > m_point
KDPoint< T, D > average(const KDPoint< T, D > &p)
Return average point of this point and given point.
KDTree(std::vector< KDPoint< T, D > > &v_data)
std::vector< KDPoint< T, D > > m_datas
Container of the points.
std::unique_ptr< Node > buildTree(int, int, int)
recursive function to create tree structure.
std::vector< size_t > m_indices
A list of indices of points in m_datas.
std::unique_ptr< Node > m_rootNode
The root node of the tree.
void genTree()
Command to generate tree.
void nearestNeighborRec(const KDPoint< T, D > &, const Node *, double &, int &, std::function< double(const KDPoint< T, D > &, const KDPoint< T, D > &)> &)
recursive function for nearest neighbor searching.
KDPoint< T, D > at(size_t n)
std::string depth
tag string for intendation
const KDPoint< T, D > operator*(const I &b, const KDPoint< T, D > &p)
std::unique_ptr< Node > rightPtr
Node(const KDPoint< T, D > &data, int idx)
const KDPoint< T, D > & dataRef
std::unique_ptr< Node > leftPtr