![]() |
Belle II Software development
|
Sorts CDC hits spatially using KD-tree nearest neighbor traversal. More...
#include <Utils.h>
Public Member Functions | |
| HitOrderer ()=default | |
| Constructor. | |
| ~HitOrderer ()=default | |
| Destructor. | |
Static Public Member Functions | |
| static std::vector< int > | orderHits (const double startingX, const double startingY, std::vector< KDTHit > kdtHits) |
| Sort hits spatially based on proximity to a starting position. | |
Static Private Member Functions | |
| static KDTNode * | buildKDTree (std::vector< KDTHit >::iterator begin, std::vector< KDTHit >::iterator end, const int depth, KDTNodePool &pool, const size_t insertionSortThreshold=10) |
| Recursively builds a balanced KD-tree from a range of KDTHits. | |
| template<typename Iterator, typename Compare> | |
| static void | insertionSort (Iterator begin, Iterator end, Compare cmp) |
| Sorts a small range using insertion sort for performance. | |
| static void | freeKDTree (KDTNode *node) |
| Recursively frees all nodes in a KD-tree. | |
| static void | nearestNeighbor (const KDTNode *node, const KDTHit &query, KDTHit &best, double &bestDist) |
| Finds the closest unused neighbor to a query hit in the KD-tree. | |
| static bool | markUsed (KDTNode *node, const KDTHit &hit) |
| Marks a KD-tree node as used if its hit index matches the given hit. | |
Sorts CDC hits spatially using KD-tree nearest neighbor traversal.
Constructs a 2D KD-tree from hit coordinates and performs iterative nearest-neighbor selection starting from a reference point to obtain a spatially coherent hit ordering.
|
staticprivate |
Recursively builds a balanced KD-tree from a range of KDTHits.
The KD-tree is built by recursively selecting median splits along alternating axes (x, y), using either std::nth_element or insertion sort for small partitions.
| begin | Iterator to the beginning of the KDTHit range. |
| end | Iterator to the end of the KDTHit range. |
| depth | Current tree depth, used to alternate axis. |
| pool | Object pool used to allocate KD-tree nodes. |
| insertionSortThreshold | Switch to insertion sort for small ranges. |
Definition at line 57 of file Utils.cc.
|
staticprivate |
Recursively frees all nodes in a KD-tree.
| node | Root node of the KD-tree to deallocate. |
Definition at line 150 of file Utils.cc.
|
inlinestaticprivate |
Sorts a small range using insertion sort for performance.
| Iterator | Type of iterator. |
| Compare | Comparison function type. |
| begin | Iterator to the beginning of the range. |
| end | Iterator to the end of the range. |
| cmp | Comparator function for sorting. |
Definition at line 47 of file Utils.cc.
Marks a KD-tree node as used if its hit index matches the given hit.
Used to ensure that hits are not reused in subsequent nearest-neighbor queries.
| node | Root of the KD-tree. |
| hit | Hit to match by index. |
Definition at line 126 of file Utils.cc.
|
staticprivate |
Finds the closest unused neighbor to a query hit in the KD-tree.
The function recursively traverses the KD-tree and updates the best match and distance if a closer unused hit is found.
| node | Root of the KD-tree. |
| query | Query hit to compare against. |
| best | Best match found so far (output). |
| bestDist | Squared distance to the best match (output). |
Definition at line 93 of file Utils.cc.
|
static |
Sort hits spatially based on proximity to a starting position.
Builds a KD-tree from the input position and performs an iterative nearest-neighbor traversal to generate a spatially ordered list of hit indices.
| startingX | Starting X position |
| startingY | Starting Y position |
| kdtHits | Vector of hits to order |
Definition at line 159 of file Utils.cc.