Belle II Software  release-05-02-19
SimpleHitBasedHoughTree.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/hough/perigee/StereoHitContained.h>
13 #include <tracking/trackFindingCDC/hough/trees/BoxDivisionHoughTree.h>
14 #include <tracking/trackFindingCDC/hough/perigee/CurvRep.h>
15 
16 #include <vector>
17 
18 namespace Belle2 {
23  namespace TrackFindingCDC {
24 
30  template<class AHitPtr,
31  class InBox,
32  size_t ... divisions>
33  class SimpleHitBasedHoughTree :
34  public BoxDivisionHoughTree<AHitPtr, typename InBox::HoughBox, divisions...> {
35 
36  private:
38  using Super = BoxDivisionHoughTree<AHitPtr, typename InBox::HoughBox, divisions...>;
39 
40  public:
42  using Node = typename Super::Node;
43 
45  using HoughBox = typename InBox::HoughBox;
46 
47  public:
49  SimpleHitBasedHoughTree(size_t maxLevel, float curlCurv = NAN) :
50  Super(maxLevel),
51  m_curlCurv(curlCurv),
53  {}
54 
55  public:
57  std::vector<std::pair<HoughBox, std::vector<AHitPtr> > >
58  find(const Weight& minWeight, const double maxCurv = NAN)
59  {
60  auto skipHighCurvatureAndLowWeightNode = [minWeight, maxCurv](const Node * node) {
61  const HoughBox& houghBox = *node;
62  return not(node->getWeight() >= minWeight and not(getLowerCurv(houghBox) > maxCurv));
63  };
65  this->getMaxLevel(),
66  skipHighCurvatureAndLowWeightNode);
67  }
68 
70  std::vector<std::pair<HoughBox, std::vector<AHitPtr> > >
71  findBest(const Weight& minWeight, const double maxCurv = NAN)
72  {
73  auto skipHighCurvatureAndLowWeightNode = [minWeight, maxCurv](const Node * node) {
74  const HoughBox& houghBox = *node;
75  return not(node->getWeight() >= minWeight and not(getLowerCurv(houghBox) > maxCurv));
76  };
78  this->getMaxLevel(),
79  skipHighCurvatureAndLowWeightNode);
80  }
81 
83  std::vector<std::pair<HoughBox, std::vector<AHitPtr> > >
84  findSingleBest(const Weight& minWeight, const double maxCurv = NAN)
85  {
86  auto skipHighCurvatureAndLowWeightNode = [minWeight, maxCurv](const Node * node) {
87  const HoughBox& houghBox = *node;
88  return not(node->getWeight() >= minWeight and not(getLowerCurv(houghBox) > maxCurv));
89  };
90  std::unique_ptr<std::pair<HoughBox, std::vector<AHitPtr> > > found =
92  this->getMaxLevel(),
93  skipHighCurvatureAndLowWeightNode);
94 
95  std::vector<std::pair<HoughBox, std::vector<AHitPtr> > > result;
96  if (found) {
97  // Move the found content over. unique_ptr still destroys the left overs.
98  result.push_back(std::move(*found));
99  }
100  return result;
101  }
102 
104  template<class ALeafProcessor>
105  void findUsing(ALeafProcessor& leafProcessor)
106  {
108  leafProcessor);
109  }
110 
111  private:
113  double m_curlCurv = 0.018;
114 
117  };
118  }
120 }
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::find
std::vector< std::pair< HoughBox, std::vector< AHitPtr > > > find(const Weight &minWeight, const double maxCurv=NAN)
Find disjoint leaves heavier than minWeight.
Definition: SimpleHitBasedHoughTree.h:66
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::SimpleHitBasedHoughTree
SimpleHitBasedHoughTree(size_t maxLevel, float curlCurv=NAN)
Constructor using the given maximal level.
Definition: SimpleHitBasedHoughTree.h:57
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::findSingleBest
std::vector< std::pair< HoughBox, std::vector< AHitPtr > > > findSingleBest(const Weight &minWeight, const double maxCurv=NAN)
Find the best trajectory from the single heaviest bin heavier than minWeight.
Definition: SimpleHitBasedHoughTree.h:92
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::SimpleHitBasedHoughTree::m_stereoHitContainedInBox
StereoHitContained< InBox > m_stereoHitContainedInBox
Predicate checking if a hit is in the realm of the sweeped object.
Definition: SimpleHitBasedHoughTree.h:124
Belle2::TrackFindingCDC::BoxDivisionHoughTree< AHitPtr, InBox::HoughBox, divisions... >::getTree
HoughTree * getTree() const
Getter for the tree used in the search in the hough plane.
Definition: BoxDivisionHoughTree.h:204
Belle2::TrackFindingCDC::WeightedFastHoughTree::fillWalk
void fillWalk(AItemInDomainMeasure &weightItemInDomain, AIsLeafPredicate &isLeaf)
Walk through the children and fill them if necessary until isLeaf returns true.
Definition: WeightedFastHoughTree.h:249
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::SimpleHitBasedHoughTree::Node
typename Super::Node Node
Type of the node in the hough tree.
Definition: SimpleHitBasedHoughTree.h:50
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::findBest
std::vector< std::pair< HoughBox, std::vector< AHitPtr > > > findBest(const Weight &minWeight, const double maxCurv=NAN)
Find the best trajectory and repeat the process until no bin heavier than minWeight can be found.
Definition: SimpleHitBasedHoughTree.h:79
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::WeightedFastHoughTree::findHeaviestLeafRepeated
std::vector< std::pair< ADomain, std::vector< T > > > findHeaviestLeafRepeated(AItemInDomainMeasure &weightItemInDomain, int maxLevel, const Weight minWeight=NAN)
Go through all children until maxLevel is reached and find the heaviest leaves.
Definition: WeightedFastHoughTree.h:145
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::BoxDivisionHoughTree< AHitPtr, InBox::HoughBox, divisions... >::getMaxLevel
int getMaxLevel() const
Getter for the currently set maximal level.
Definition: BoxDivisionHoughTree.h:210
Belle2::TrackFindingCDC::BoxDivisionHoughTree< AHitPtr, InBox::HoughBox, divisions... >::BoxDivisionHoughTree
BoxDivisionHoughTree(int maxLevel, int sectorLevelSkip=0)
Constructor using the given maximal level.
Definition: BoxDivisionHoughTree.h:77
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::Super
BoxDivisionHoughTree< AHitPtr, typename InBox::HoughBox, divisions... > Super
Type of the base class.
Definition: SimpleHitBasedHoughTree.h:46
Belle2::TrackFindingCDC::WeightedFastHoughTree::findLeavesDisjoint
std::vector< std::pair< ADomain, std::vector< T > > > findLeavesDisjoint(AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode)
Find all children node at maximum level and add them to the result list. Skip nodes if skipNode retur...
Definition: WeightedFastHoughTree.h:104
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::m_curlCurv
double m_curlCurv
Curvature below which a trajectory is considered non curling.
Definition: SimpleHitBasedHoughTree.h:121
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::findUsing
void findUsing(ALeafProcessor &leafProcessor)
Fill and walk the tree using invoking the leaf processor on each encountered node.
Definition: SimpleHitBasedHoughTree.h:113
Belle2::TrackFindingCDC::SimpleHitBasedHoughTree::HoughBox
typename InBox::HoughBox HoughBox
Type of the hough box.
Definition: SimpleHitBasedHoughTree.h:53
Belle2::TrackFindingCDC::StereoHitContained< InBox >