Belle II Software development
SimpleBoxDivisionHoughTree.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9#include <tracking/trackFindingCDC/hough/trees/BoxDivisionHoughTree.h>
10
11namespace Belle2 {
16 namespace TrackFindingCDC {
17
19 template<class AHitPtr, class AInBoxAlgorithm, size_t divisionX, size_t divisionY>
20 class SimpleBoxDivisionHoughTree : public BoxDivisionHoughTree<AHitPtr, typename AInBoxAlgorithm::HoughBox, divisionX, divisionY> {
21
22 private:
25
27 using HoughBox = typename AInBoxAlgorithm::HoughBox;
28
30 template <size_t I>
31 using Width = typename HoughBox::template Width<I>;
32
33 public:
36 float maximumY,
37 Width<0> overlapX = 0,
38 Width<1> overlapY = 0)
39 : Super(0)
40 , m_maximumX(maximumX)
41 , m_maximumY(maximumY)
42 , m_overlapX(overlapX)
43 , m_overlapY(overlapY)
44 {
45 }
46
48 // cppcheck-suppress duplInheritedMember ; intentionally hides the base class member, which it extends and then calls
50 {
51 Super::template constructArray<0>(-getMaximumX(), getMaximumX(), getOverlapX());
52 Super::template constructArray<1>(-getMaximumY(), getMaximumY(), getOverlapY());
53
55 }
56
58 std::vector<std::pair<HoughBox, std::vector<AHitPtr>>>
59 findSingleBest(const TrackingUtilities::Weight& minWeight)
60 {
61 AInBoxAlgorithm inBoxAlgorithm;
62 auto skipLowWeightNode = [minWeight](const typename Super::Node * node) {
63 return not(node->getWeight() >= minWeight);
64 };
65 auto found = this->getTree()->findHeaviestLeafSingle(inBoxAlgorithm, this->getMaxLevel(), skipLowWeightNode);
66
67 std::vector<std::pair<HoughBox, std::vector<AHitPtr>>> result;
68 if (found) {
69 // Move the found content over. unique_ptr still destroys the left overs.
70 result.push_back(std::move(*found));
71 }
72 return result;
73 }
74
76 float getMaximumX() const
77 {
78 return m_maximumX;
79 }
80
82 float getMaximumY() const
83 {
84 return m_maximumY;
85 }
86
89 {
90 return m_overlapX;
91 }
92
95 {
96 return m_overlapY;
97 }
98
99 private:
101 float m_maximumX = 0;
102
104 float m_maximumY = 0;
105
108
111 };
112 }
114}
void constructArray(double lowerBound, double upperBound, Width< I > nBinOverlap=0, Width< I > nBinWidth=0)
void initialize()
Initialize the tree with the given values.
float getMaximumY() const
Return the maximum value in y direction.
SimpleBoxDivisionHoughTree(float maximumX, float maximumY, Width< 0 > overlapX=0, Width< 1 > overlapY=0)
Constructor using the given maximal level.
BoxDivisionHoughTree< AHitPtr, typename AInBoxAlgorithm::HoughBox, divisionX, divisionY > Super
The Super class.
Width< 0 > getOverlapX() const
Return the overlap in x direction.
std::vector< std::pair< HoughBox, std::vector< AHitPtr > > > findSingleBest(const TrackingUtilities::Weight &minWeight)
Find only the leave with the highest weight = number of items.
float getMaximumX() const
Return the maximum value in x direction.
typename AInBoxAlgorithm::HoughBox HoughBox
The HoughBox we use.
typename HoughBox::template Width< I > Width
Type of the width in coordinate I.
Width< 1 > getOverlapY() const
Return the overlap in y direction.
std::unique_ptr< std::pair< ADomain, std::vector< T > > > findHeaviestLeafSingle(AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode)
Go through all children until the maxLevel is reached and find the leaf with the highest weight.
Abstract base class for different kinds of events.