Belle II Software  release-05-02-19
SimpleBoxDivisionHoughTree.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun, Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 #include <tracking/trackFindingCDC/hough/trees/BoxDivisionHoughTree.h>
12 
13 namespace Belle2 {
18  namespace TrackFindingCDC {
19 
21  template<class AHitPtr, class AInBoxAlgorithm, size_t divisionX, size_t divisionY>
22  class SimpleBoxDivisionHoughTree : public BoxDivisionHoughTree<AHitPtr, typename AInBoxAlgorithm::HoughBox, divisionX, divisionY> {
23 
24  private:
26  using Super = BoxDivisionHoughTree<AHitPtr, typename AInBoxAlgorithm::HoughBox, divisionX, divisionY>;
27 
29  using HoughBox = typename AInBoxAlgorithm::HoughBox;
30 
32  template <size_t I>
33  using Width = typename HoughBox::template Width<I>;
34 
35  public:
38  float maximumY,
39  Width<0> overlapX = 0,
40  Width<1> overlapY = 0)
41  : Super(0)
42  , m_maximumX(maximumX)
43  , m_maximumY(maximumY)
44  , m_overlapX(overlapX)
45  , m_overlapY(overlapY)
46  {
47  }
48 
50  void initialize()
51  {
52  Super::template constructArray<0>(-getMaximumX(), getMaximumX(), getOverlapX());
53  Super::template constructArray<1>(-getMaximumY(), getMaximumY(), getOverlapY());
54 
56  }
57 
59  std::vector<std::pair<HoughBox, std::vector<AHitPtr>>>
60  findSingleBest(const Weight& minWeight)
61  {
62  AInBoxAlgorithm inBoxAlgorithm;
63  auto skipLowWeightNode = [minWeight](const typename Super::Node * node) {
64  return not(node->getWeight() >= minWeight);
65  };
66  auto found = this->getTree()->findHeaviestLeafSingle(inBoxAlgorithm, this->getMaxLevel(), skipLowWeightNode);
67 
68  std::vector<std::pair<HoughBox, std::vector<AHitPtr>>> result;
69  if (found) {
70  // Move the found content over. unique_ptr still destroys the left overs.
71  result.push_back(std::move(*found));
72  }
73  return result;
74  }
75 
77  float getMaximumX() const
78  {
79  return m_maximumX;
80  }
81 
83  float getMaximumY() const
84  {
85  return m_maximumY;
86  }
87 
89  Width<0> getOverlapX() const
90  {
91  return m_overlapX;
92  }
93 
95  Width<1> getOverlapY() const
96  {
97  return m_overlapY;
98  }
99 
100  private:
102  float m_maximumX = 0;
103 
105  float m_maximumY = 0;
106 
108  Width<0> m_overlapX = 0;
109 
111  Width<1> m_overlapY = 0;
112  };
113  }
115 }
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::m_overlapX
Width< 0 > m_overlapX
The overlap in X direction.
Definition: SimpleBoxDivisionHoughTree.h:116
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::SimpleBoxDivisionHoughTree
SimpleBoxDivisionHoughTree(float maximumX, float maximumY, Width< 0 > overlapX=0, Width< 1 > overlapY=0)
Constructor using the given maximal level.
Definition: SimpleBoxDivisionHoughTree.h:45
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::Width
typename HoughBox::template Width< I > Width
Type of the width in coordinate I.
Definition: SimpleBoxDivisionHoughTree.h:41
Belle2::TrackFindingCDC::BoxDivisionHoughTree< AHitPointerType, AHitDecisionAlgorithm ::HoughBox, divisionX, divisionY >::Width
typename HoughBox::template Width< I > Width
Type of the width in coordinate I.
Definition: BoxDivisionHoughTree.h:70
Belle2::TrackFindingCDC::WeightedFastHoughTree::findHeaviestLeafSingle
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.
Definition: WeightedFastHoughTree.h:188
Belle2::TrackFindingCDC::BoxDivisionHoughTree< AHitPtr, AInBoxAlgorithm::HoughBox, divisionX, divisionY >::getTree
HoughTree * getTree() const
Getter for the tree used in the search in the hough plane.
Definition: BoxDivisionHoughTree.h:204
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::m_maximumX
float m_maximumX
The maximum value in X direction.
Definition: SimpleBoxDivisionHoughTree.h:110
Belle2::TrackFindingCDC::BoxDivisionHoughTree
A fast hough algorithm with rectangular boxes, which are split linearly by a fixed number of division...
Definition: BoxDivisionHoughTree.h:44
Belle2::TrackFindingCDC::BoxDivisionHoughTree::Node
typename HoughTree::Node Node
Type of the nodes used in the tree for the search.
Definition: BoxDivisionHoughTree.h:73
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::getMaximumY
float getMaximumY() const
Return the maximum value in y direction.
Definition: SimpleBoxDivisionHoughTree.h:91
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::getOverlapX
Width< 0 > getOverlapX() const
Return the overlap in x direction.
Definition: SimpleBoxDivisionHoughTree.h:97
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::BoxDivisionHoughTree::initialize
void initialize()
Initialise the algorithm by constructing the hough tree from the parameters.
Definition: BoxDivisionHoughTree.h:174
Belle2::TrackFindingCDC::BoxDivisionHoughTree< AHitPtr, AInBoxAlgorithm::HoughBox, divisionX, divisionY >::getMaxLevel
int getMaxLevel() const
Getter for the currently set maximal level.
Definition: BoxDivisionHoughTree.h:210
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::findSingleBest
std::vector< std::pair< HoughBox, std::vector< AHitPtr > > > findSingleBest(const Weight &minWeight)
Find only the leave with the highest weight = number of items.
Definition: SimpleBoxDivisionHoughTree.h:68
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::getOverlapY
Width< 1 > getOverlapY() const
Return the overlap in y direction.
Definition: SimpleBoxDivisionHoughTree.h:103
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::initialize
void initialize()
Initialize the tree with the given values.
Definition: SimpleBoxDivisionHoughTree.h:58
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::Super
BoxDivisionHoughTree< AHitPtr, typename AInBoxAlgorithm::HoughBox, divisionX, divisionY > Super
The Super class.
Definition: SimpleBoxDivisionHoughTree.h:34
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::HoughBox
typename AInBoxAlgorithm::HoughBox HoughBox
The HoughBox we use.
Definition: SimpleBoxDivisionHoughTree.h:37
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::getMaximumX
float getMaximumX() const
Return the maximum value in x direction.
Definition: SimpleBoxDivisionHoughTree.h:85
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::m_maximumY
float m_maximumY
The maximum value in y direction.
Definition: SimpleBoxDivisionHoughTree.h:113
Belle2::TrackFindingCDC::SimpleBoxDivisionHoughTree::m_overlapY
Width< 1 > m_overlapY
The overlap in Y direction.
Definition: SimpleBoxDivisionHoughTree.h:119