|
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>
197 std::unique_ptr<Node>
buildTree(
int,
int,
int);
206 template<
typename T,
size_t D>
209 if (m_locked)
return;
210 m_rootNode = buildTree(0, m_idLength, 0);
221 template<
typename T,
size_t D>
224 if (
l >=
r )
return std::make_unique<Node>(
nullptr);
226 const int axis_ =
depth % D;
227 const int mid = (
l +
r ) >> 1;
229 std::nth_element( m_indices.begin()+
l, m_indices.begin()+
l+mid, m_indices.begin()+
r,
230 [
this, axis_](
size_t lcnt,
size_t rcnt) {
231 return m_datas[lcnt].getId(axis_) < m_datas[rcnt].getId(axis_);
234 std::unique_ptr<Node> node_ptr = std::make_unique<Node> ( m_datas.at(m_indices[mid]), m_indices[mid] );
235 node_ptr->axis = axis_;
237 node_ptr->leftPtr = buildTree(
l, mid,
depth+1 );
238 node_ptr->rightPtr = buildTree( mid+1,
r,
depth+1 );
252 template<
typename T,
size_t D>
257 if (
node ==
nullptr ) {
264 const double dist = dist_func(
query, point);
270 const int axis_ =
node->axis;
271 const Node* next_node = (
query.at(axis_) < point.
at(axis_))?
node->leftPtr.get() :
node->rightPtr.get();
274 nearestNeighborRec(
query, next_node,
r,
idx, dist_func );
278 proj[axis_] = point.
at(axis_);
282 const Node* next_node_opps = (
query.at(axis_) < point.
at(axis_))?
node->rightPtr.get() :
node->leftPtr.get();
283 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.
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)
Node(const KDPoint< T, D > &data, int idx)
KDPoint< T, D > at(size_t n)
std::unique_ptr< Node > leftPtr
std::unique_ptr< Node > m_rootNode
The root node of the tree.
KDPoint(const std::vector< T > &v)
const KDPoint< T, D > & dataRef
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::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.
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)
std::unique_ptr< Node > rightPtr