Belle II Software development
SimpleHitBasedHoughTree.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
10#include <tracking/trackFindingCDC/hough/perigee/StereoHitContained.h>
11#include <tracking/trackFindingCDC/hough/trees/BoxDivisionHoughTree.h>
12#include <tracking/trackFindingCDC/hough/perigee/CurvRep.h>
13
14#include <vector>
15
16namespace Belle2 {
21 namespace TrackFindingCDC {
22
28 template<class AHitPtr,
29 class InBox,
30 size_t ... divisions>
32 public BoxDivisionHoughTree<AHitPtr, typename InBox::HoughBox, divisions...> {
33
34 private:
36 using Super = BoxDivisionHoughTree<AHitPtr, typename InBox::HoughBox, divisions...>;
37
38 public:
40 using Node = typename Super::Node;
41
43 using HoughBox = typename InBox::HoughBox;
44
45 public:
47 explicit SimpleHitBasedHoughTree(size_t maxLevel, float curlCurv = NAN) :
48 Super(maxLevel),
49 m_curlCurv(curlCurv),
51 {}
52
53 public:
55 std::vector<std::pair<HoughBox, std::vector<AHitPtr> > >
56 find(const Weight& minWeight, const double maxCurv = NAN)
57 {
58 auto skipHighCurvatureAndLowWeightNode = [minWeight, maxCurv](const Node * node) {
59 const HoughBox& houghBox = *node;
60 return not(node->getWeight() >= minWeight and not(getLowerCurv(houghBox) > maxCurv));
61 };
63 this->getMaxLevel(),
64 skipHighCurvatureAndLowWeightNode);
65 }
66
68 std::vector<std::pair<HoughBox, std::vector<AHitPtr> > >
69 findBest(const Weight& minWeight, const double maxCurv = NAN)
70 {
71 auto skipHighCurvatureAndLowWeightNode = [minWeight, maxCurv](const Node * node) {
72 const HoughBox& houghBox = *node;
73 return not(node->getWeight() >= minWeight and not(getLowerCurv(houghBox) > maxCurv));
74 };
76 this->getMaxLevel(),
77 skipHighCurvatureAndLowWeightNode);
78 }
79
81 std::vector<std::pair<HoughBox, std::vector<AHitPtr> > >
82 findSingleBest(const Weight& minWeight, const double maxCurv = NAN)
83 {
84 auto skipHighCurvatureAndLowWeightNode = [minWeight, maxCurv](const Node * node) {
85 const HoughBox& houghBox = *node;
86 return not(node->getWeight() >= minWeight and not(getLowerCurv(houghBox) > maxCurv));
87 };
88 std::unique_ptr<std::pair<HoughBox, std::vector<AHitPtr> > > found =
90 this->getMaxLevel(),
91 skipHighCurvatureAndLowWeightNode);
92
93 std::vector<std::pair<HoughBox, std::vector<AHitPtr> > > result;
94 if (found) {
95 // Move the found content over. unique_ptr still destroys the left overs.
96 result.push_back(std::move(*found));
97 }
98 return result;
99 }
100
102 template<class ALeafProcessor>
103 void findUsing(ALeafProcessor& leafProcessor)
104 {
106 leafProcessor);
107 }
108
109 private:
111 double m_curlCurv = 0.018;
112
115 };
116 }
118}
A fast hough algorithm with rectangular boxes, which are split linearly by a fixed number of division...
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.
A convenience class based on a BoxDivisionHoughTree for "hit-like" classes.
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.
std::vector< std::pair< HoughBox, std::vector< AHitPtr > > > find(const Weight &minWeight, const double maxCurv=NAN)
Find disjoint leaves heavier than minWeight.
void findUsing(ALeafProcessor &leafProcessor)
Fill and walk the tree using invoking the leaf processor on each encountered node.
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.
typename InBox::HoughBox HoughBox
Type of the hough box.
SimpleHitBasedHoughTree(size_t maxLevel, float curlCurv=NAN)
Constructor using the given maximal level.
double m_curlCurv
Curvature below which a trajectory is considered non curling.
StereoHitContained< InBox > m_stereoHitContainedInBox
Predicate checking if a hit is in the realm of the sweeped object.
typename Super::Node Node
Type of the node in the hough tree.
Predicate class to check for the containment of axial and stereo hits in some hough space part.
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...
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.
void fillWalk(AItemInDomainMeasure &weightItemInDomain, AIsLeafPredicate &isLeaf)
Walk through the children and fill them if necessary until isLeaf returns true.
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.
Abstract base class for different kinds of events.