Belle II Software development
SingleHoughSpaceFastInterceptFinder.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/trackingUtilities/findlets/base/Findlet.h>
11
12#include <bitset>
13#include <array>
14#include <unordered_map>
15
16namespace Belle2 {
21 class ModuleParamList;
22
23 namespace vxdHoughTracking {
24 class VXDHoughState;
25
31 class SingleHoughSpaceFastInterceptFinder : public TrackingUtilities::Findlet<VXDHoughState, std::vector<VXDHoughState*>> {
34
35 public:
38
40 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override;
41
43 void initialize() override;
44
46 void apply(std::vector<VXDHoughState>& hits, std::vector<std::vector<VXDHoughState*>>& rawTrackCandidates) override;
47
48 private:
49
52 static inline unsigned short layerFilter(const std::bitset<8>& layer)
53 {
54 ushort layercount = static_cast<ushort>(layer.count());
55 return (layercount >= 3 ? layercount : 0);
56 }
57
66 void fastInterceptFinder2d(const std::vector<VXDHoughState*>& hits, const ushort xmin, const ushort xmax,
67 const ushort ymin, const ushort ymax, const ushort currentRecursion);
68
72
75 void DepthFirstSearch(const uint lastGlobalSectorIndex);
76
77 // Parameters
80
82 ushort m_nAngleSectors = 512;
83
85 ushort m_nVerticalSectors = 512;
86
89
91 float m_minimumX = -3.168;
93 float m_maximumX = 3.168;
94
103
104 // class variables
106 float m_unitX = 0;
108 float m_unitY = 0;
109
112 static const ushort c_maxAllowedRecusionLevel = 10;
114 static constexpr ushort c_maxHSSectorNumber = (1 << c_maxAllowedRecusionLevel);
116 static constexpr ushort c_xIndexBitMask = c_maxHSSectorNumber - 1;
118 static constexpr ushort c_maxLUTSize = c_maxHSSectorNumber + 1;
119
122 std::array<float, c_maxLUTSize> m_HSSinValuesLUT = {0};
124 std::array<float, c_maxLUTSize> m_HSCosValuesLUT = {0};
126 std::array<float, c_maxHSSectorNumber> m_HSCenterSinValuesLUT = {0};
128 std::array<float, c_maxHSSectorNumber> m_HSCenterCosValuesLUT = {0};
129
132 std::unordered_map<uint, std::vector<VXDHoughState*>> m_activeSectorsMap;
134 std::vector<uint> m_activeSectorsIndices;
135
137 ushort m_clusterCount = 0;
139 ushort m_clusterSize = 0;
140
142 std::pair<ushort, ushort> m_clusterInitialPosition = std::make_pair(0, 0);
143
145 std::vector<VXDHoughState*> m_currentTrackCandidate;
146
148 std::vector<std::vector<VXDHoughState*>> m_trackCandidates;
149
150 };
151
152 }
154}
The Module parameter list class.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition Findlet.h:26
std::unordered_map< uint, std::vector< VXDHoughState * > > m_activeSectorsMap
Map containing only active HS sectors, i.e.
ushort m_maxRecursionLevel
maximum number of recursive calls of FastInterceptFinder2d
static unsigned short layerFilter(const std::bitset< 8 > &layer)
layer filter, checks if at least hits from 3 layers are in a set of hits
std::array< float, c_maxLUTSize > m_HSSinValuesLUT
Look-Up-Tables for values as cache to speed up calculation sine values of the Hough Space sector boar...
std::vector< uint > m_activeSectorsIndices
Cache the global indices of the active sectors for sorted access.
std::vector< std::vector< VXDHoughState * > > m_trackCandidates
vector containing track candidates, consisting of the found intersection values in the Hough Space
ushort m_nVerticalSectors
number of sectors of the Hough Space on the vertical axis
float m_minimumX
minimum x value of the Hough Space, defaults to the value for u-side
std::pair< ushort, ushort > m_clusterInitialPosition
start cell of the recursive cluster finding in the Hough Space
std::array< float, c_maxHSSectorNumber > m_HSCenterSinValuesLUT
sine values of the Hough Space sector center coordinates
TrackingUtilities::Findlet< VXDHoughState, std::vector< VXDHoughState * > > Super
Parent class.
void fastInterceptFinder2d(const std::vector< VXDHoughState * > &hits, const ushort xmin, const ushort xmax, const ushort ymin, const ushort ymax, const ushort currentRecursion)
find intercepts in the 2D Hough Space by recursively calling itself until no hits are assigned to a g...
ushort m_MaximumHSClusterSizeX
maximum cluster size in x of sectors belonging to intercepts in the Hough Space
ushort m_MaximumHSClusterSize
maximum cluster size of sectors belonging to intercepts in the Hough Space
static const ushort c_maxAllowedRecusionLevel
Define some magic numbers Maximum allowed recursion level.
static constexpr ushort c_maxLUTSize
Look-Up-Table size including the right-most value.
ushort m_nAngleSectors
number of sectors of the Hough Space on the horizontal axis
static constexpr ushort c_maxHSSectorNumber
Maximum number of HS sectors in x and y, also the size of some of the the Look-Up-Tables (LUTs) below...
std::array< float, c_maxLUTSize > m_HSCosValuesLUT
cosine values of the Hough Space sector boarder coordinates
std::array< float, c_maxHSSectorNumber > m_HSCenterCosValuesLUT
cosine values of the Hough Space sector center coordinates
std::vector< VXDHoughState * > m_currentTrackCandidate
the current track candidate
ushort m_MinimumHSClusterSize
minimum cluster size of sectors belonging to intercepts in the Hough Space
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
void apply(std::vector< VXDHoughState > &hits, std::vector< std::vector< VXDHoughState * > > &rawTrackCandidates) override
Load in the prepared hits and create track candidates for further processing like hit filtering and f...
float m_verticalHoughSpaceSize
vertical size of the Hough Space, defaults to the value for u-side
static constexpr ushort c_xIndexBitMask
Bit mask for coordinate transformation, creates all-ones for the coordinate system conversion.
float m_maximumX
maximum x value of the Hough Space, defaults to the value for u-side
void DepthFirstSearch(const uint lastGlobalSectorIndex)
Perform depth first search recursive algorithm to find clusters in the Hough Space.
ushort m_MaximumHSClusterSizeY
maximum cluster size in y of sectors belonging to intercepts in the Hough Space
Simple container for hit information to be used during intercept finding.
Abstract base class for different kinds of events.