Belle II Software  release-08-01-10
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 
11 namespace 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  void initialize()
49  {
50  Super::template constructArray<0>(-getMaximumX(), getMaximumX(), getOverlapX());
51  Super::template constructArray<1>(-getMaximumY(), getMaximumY(), getOverlapY());
52 
54  }
55 
57  std::vector<std::pair<HoughBox, std::vector<AHitPtr>>>
58  findSingleBest(const Weight& minWeight)
59  {
60  AInBoxAlgorithm inBoxAlgorithm;
61  auto skipLowWeightNode = [minWeight](const typename Super::Node * node) {
62  return not(node->getWeight() >= minWeight);
63  };
64  auto found = this->getTree()->findHeaviestLeafSingle(inBoxAlgorithm, this->getMaxLevel(), skipLowWeightNode);
65 
66  std::vector<std::pair<HoughBox, std::vector<AHitPtr>>> result;
67  if (found) {
68  // Move the found content over. unique_ptr still destroys the left overs.
69  result.push_back(std::move(*found));
70  }
71  return result;
72  }
73 
75  float getMaximumX() const
76  {
77  return m_maximumX;
78  }
79 
81  float getMaximumY() const
82  {
83  return m_maximumY;
84  }
85 
88  {
89  return m_overlapX;
90  }
91 
94  {
95  return m_overlapY;
96  }
97 
98  private:
100  float m_maximumX = 0;
101 
103  float m_maximumY = 0;
104 
107 
110  };
111  }
113 }
A fast hough algorithm with rectangular boxes, which are split linearly by a fixed number of division...
void initialize()
Initialise the algorithm by constructing the hough tree from the parameters.
typename HoughTree::Node Node
Type of the nodes used in the tree for the search.
HoughTree * getTree() const
Getter for the tree used in the search in the hough plane.
Convenience class for the typical usage-case: A box divisioned hough tree with maximum and minimum va...
std::vector< std::pair< HoughBox, std::vector< AHitPtr > > > findSingleBest(const Weight &minWeight)
Find only the leave with the highest weight = number of items.
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.
Width< 0 > getOverlapX() const
Return the overlap in x direction.
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.