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