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);
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>
173 template <
class AItemPtrs>
174 void seed(
const AItemPtrs& items)
232 template <
size_t... Is>
246 const std::array<size_t,
sizeof ...(divisions)>
m_divisions = {{divisions ...}};
SectoredLinearDivision< HoughBox, divisions... > BoxDivision
void fell()
Terminates the processing by striping all hit information from the tree.
typename Type< I >::Array Array
typename InBox::HoughBox HoughBox
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
void setSectorLevelSkip(int sectorLevelSkip)
Setter for number of levels to skip in first level to form a finer sectored hough space.
HoughBox constructHoughPlaneImpl(const std::index_sequence< Is... > &is)
Construct the box of the top node of the tree. Implementation unroling the indices.
typename HoughBox::template Type< I > Type
TupleGenerateN< Array, sizeof...(divisions)> Arrays
void setMaxLevel(int maxLevel)
Setter maximal level of the hough tree.
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
const Array< I > & getArray() const
Getter for the array of discrete value for coordinate I.
typename HoughBox::template HasType< T > HasType
void seed(const AItemPtrs &items)
Prepare the leave finding by filling the top node with given hits.
HoughBox::Delta m_overlaps
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
std::unique_ptr< HoughTree > m_houghTree
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< AHitPtr, HoughBox, BoxDivision > HoughTree
int getMaxLevel() const
Getter for the currently set maximal level.
const std::array< size_t, sizeof ...(divisions)> m_divisions
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
Abstract base class for different kinds of events.