9#include <tracking/trackFindingCDC/hough/trees/WeightedFastHoughTree.h>
10#include <tracking/trackFindingCDC/hough/baseelements/SectoredLinearDivision.h>
12#include <tracking/trackFindingCDC/numerics/LookupTable.h>
14#include <tracking/trackFindingCDC/utilities/TupleGenerate.h>
27 namespace TrackFindingCDC {
33 template <
class AItemPtr,
class AHoughBox,
size_t ... divisions>
109 static_assert(std::is_integral<Width<I> >::value,
"Method only applicable to discrete axes");
112 const size_t nBins = std::pow(division, granularityLevel);
114 if (nBinWidth == 0) {
115 nBinWidth = nBinOverlap + 1;
118 B2ASSERT(
"Width " << nBinWidth <<
"is not bigger than overlap " << nBinOverlap,
119 nBinOverlap < nBinWidth);
121 const auto nPositions = (nBinWidth - nBinOverlap) * nBins + nBinOverlap + 1;
122 std::get<I>(
m_arrays) = linspace<float>(lowerBound, upperBound, nPositions);
130 std::get<I>(
m_arrays) = std::move(array);
135 if (std::is_integral<
Width<I> >::value) {
138 const long int nBins = std::pow(division, granularityLevel);
139 const long int nPositions = std::get<I>(
m_arrays).size();
140 const long int nWidthTimeNBins = nPositions - 1 + (nBins - 1) * overlap;
142 B2ASSERT(
"Not enough positions in array to cover all bins.\n"
143 "Expected: positions = " << nBins - (nBins - 1) * overlap + 1 <<
" at least.\n"
144 "Actual: positions = " << nPositions <<
" (overlap = " << overlap <<
", bins = " << nBins <<
")\n",
145 nWidthTimeNBins >= nBins);
147 B2ASSERT(
"Number of positions in array introduces inhomogeneous width at the highest granularity level.\n"
148 "Expected: positions = 'width * bins - (bins - 1) * overlap + 1'\n"
149 "Actual: positions = " << nPositions <<
" (overlap = " << overlap <<
", bins = " << nBins <<
")\n",
150 nWidthTimeNBins % nBins == 0);
156 std::enable_if_t< HasType<T>::value,
void>
159 assignArray<TypeIndex<T>::value>(std::move(array), overlap);
173 template <
class AItemPtrs>
174 void seed(
const AItemPtrs& items)
232 template <
size_t... Is>
252 const std::array<size_t,
sizeof ...(divisions)>
m_divisions = {{divisions ...}};
A fast hough algorithm with rectangular boxes, which are split linearly by a fixed number of division...
void fell()
Terminates the processing by striping all hit information from the tree.
typename Type< I >::Array Array
Type of the discrete value array to coordinate index I.
AHoughBox HoughBox
Type of the box in the hough space.
void initialize()
Initialise the algorithm by constructing the hough tree from the parameters.
void raze()
Release all memory that the tree acquired during the runs.
typename HoughTree::Node Node
Type of the nodes used in the tree for the search.
void setSectorLevelSkip(int sectorLevelSkip)
Setter for number of levels to skip in first level to form a finer sectored hough space.
Arrays m_arrays
A tuple of value arrays providing the memory for the discrete bin bounds.
HoughBox constructHoughPlaneImpl(const std::index_sequence< Is... > &is)
Construct the box of the top node of the tree. Implementation unroling the indices.
int m_sectorLevelSkip
Number of levels to skip in first level to form a finer sectored hough space.
typename HoughBox::template Type< I > Type
Type of the coordinate I.
TupleGenerateN< Array, sizeof...(divisions)> Arrays
Tuple type of the discrete value arrays.
void setMaxLevel(int maxLevel)
Setter maximal level of the hough tree.
int m_maxLevel
Number of the maximum tree level.
size_t getDivision(size_t i) const
Getter the number of divisions at each level for coordinate index I.
typename HoughBox::template TypeIndex< T > TypeIndex
Function to get the coordinate index from its type.
const Array< I > & getArray() const
Getter for the array of discrete value for coordinate I.
typename HoughBox::template HasType< T > HasType
Predicate that the given type is indeed a coordinate of the hough space.
void seed(const AItemPtrs &items)
Prepare the leave finding by filling the top node with given hits.
HoughBox::Delta m_overlaps
An tuple of division overlaps in each coordinate.
HoughBox constructHoughPlane()
Construct the box of the top node of the tree.
int getSectorLevelSkip() const
Getter for number of levels to skip in first level to form a finer sectored hough space.
typename HoughBox::template Width< I > Width
Type of the width in coordinate I.
std::unique_ptr< HoughTree > m_houghTree
Dynamic hough tree structure traversed in the leaf search.
void assignArray(Array< I > array, Width< I > overlap=0)
Provide an externally constructed array by coordinate index.
std::enable_if_t< HasType< T >::value, void > assignArray(Array< TypeIndex< T >::value > array, Width< TypeIndex< T >::value > overlap=0)
Provide an externally constructed array by coordinate type.
WeightedFastHoughTree< AItemPtr, HoughBox, BoxDivision > HoughTree
Type of the fast hough tree structure.
int getMaxLevel() const
Getter for the currently set maximal level.
const std::array< size_t, sizeof ...(divisions)> m_divisions
Array of the number of divisions at each level.
BoxDivisionHoughTree(int maxLevel, int sectorLevelSkip=0)
Constructor using the given maximal level.
void constructArray(double lowerBound, double upperBound, Width< I > nBinOverlap=0, Width< I > nBinWidth=0)
Construct the discrete value array at coordinate index I.
HoughTree * getTree() const
Getter for the tree used in the search in the hough plane.
Factory object that constructs sub boxes from a given box with optional overlaps.
Dynamic tree structure with weighted items in each node which are markable through out the tree.
typename Super::Node Node
Type of the node in the tree.
Abstract base class for different kinds of events.