|  | ATLAS Offline Software
    | 
 
 
 
Go to the documentation of this file.
    4 #ifndef TRIGTOOLS_TRIG_VSI_KDPOINT 
    5 #define TRIGTOOLS_TRIG_VSI_KDPOINT 
   28 template<
typename T, 
size_t D>
 
   46          for (
auto itr = 
bg; itr != 
bg + D; ++itr) {
 
   56          for ( 
size_t i = 0; 
i < D; 
i++ ) {
 
   66          for ( 
size_t i = 0; 
i < D; 
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++ ) {
 
  104          for ( 
size_t i = 0; 
i < D; 
i++ ) {
 
  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 );
 
  147 template<
typename I, 
typename T, 
size_t D>
 
  158 template<
typename T, 
size_t D>
 
  195       std::unique_ptr<Node> 
buildTree(
int, 
int, 
int);
 
  204 template<
typename T, 
size_t D>
 
  207    if (m_locked) 
return;
 
  208    m_rootNode = buildTree(0, m_idLength, 0);
 
  219 template<
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;
 
  227    std::nth_element( m_indices.begin()+
l, m_indices.begin()+
l+mid, m_indices.begin()+
r,
 
  228                      [
this, axis_](
size_t lcnt, 
size_t rcnt) {
 
  229                         return m_datas[lcnt].getId(axis_) < m_datas[rcnt].getId(axis_);
 
  232    std::unique_ptr<Node> node_ptr = std::make_unique<Node> ( m_datas.at(m_indices[mid]), m_indices[mid] );
 
  233    node_ptr->axis  = axis_;
 
  235    node_ptr->leftPtr  = buildTree( 
l,     mid,  
depth+1 );
 
  236    node_ptr->rightPtr = buildTree( mid+1, 
r,    
depth+1 );
 
  250 template<
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();
 
  272    nearestNeighborRec( 
query, next_node, 
r, 
idx, dist_func );
 
  276    proj[axis_] = point.
at(axis_); 
 
  280       const Node* next_node_opps = (
query.at(axis_) < point.
at(axis_))? 
node->rightPtr.get() : 
node->leftPtr.get();
 
  281       nearestNeighborRec( 
query, next_node_opps, 
r, 
idx, dist_func );
 
  
char data[hepevt_bytes_allocation_ATLAS]
const KDPoint< T, D > operator*(const I &other) const
Multiply each elements except weights.
@ depth
pointing depth of the shower as calculated in egammaqgcld
KDPoint< T, D > average(const KDPoint< T, D > &p)
Return average point of this point and given point.
KDPoint(std::array< T, D > &&arr)
T at(size_t i) const
Return i-th element. If given i exceeds the size, return NaN.
std::vector< size_t > m_indices
A list of indices of points in m_datas.
Node(const KDPoint< T, D > &data, int idx)
const KDPoint< T, D > operator-(const KDPoint< T, D > &other) const
Subtract each elements except weights.
KDPoint(std::initializer_list< T > list)
std::array< T, D > m_point
KDTree(std::vector< KDPoint< T, D >> &v_data)
KDPoint< T, D > at(size_t n)
std::unique_ptr< Node > m_rootNode
The root node of the tree.
KDPoint(const std::vector< T > &v)
const KDPoint< T, D > operator*(const I &b, const KDPoint< T, D > &p)
std::unique_ptr< Node > buildTree(int, int, int)
recursive function to create tree structure.
std::unique_ptr< Node > leftPtr
std::vector< KDPoint< T, D > > m_datas
Container of the points.
KDPoint(std::array< T, D > &arr)
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.
const KDPoint< T, D > operator+(const KDPoint< T, D > &other) const
Add each elements except weights.
double getWeight() const
Return the weight of the point.
void setWeight(double w)
Set the weight to given value.
const KDPoint< T, D > operator/(const I &other) const
Divide each elements except weights.
std::unique_ptr< Node > rightPtr
Class for k-dimensional point.
T & operator[](size_t i)
Return i-th element.
static KDPoint< T, D > average(const std::vector< KDPoint< T, D >> &)
KDPoint< T, D > & operator+=(const KDPoint< T, D > &other)
void genTree()
Command to generate tree.
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
const std::array< T, D > & getPos() const
KDPoint< T, D > & operator-=(const KDPoint< T, D > &other)
const KDPoint< T, D > & dataRef