Belle II Software  release-06-02-00
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/trackFindingCDC/findlets/base/Findlet.h>
11 #include <framework/datastore/StoreArray.h>
12 
13 #include <string>
14 #include <vector>
15 
16 namespace Belle2 {
21  class ModuleParamList;
22 
23  namespace vxdHoughTracking {
24  class VXDHoughState;
25 
31  class SingleHoughSpaceFastInterceptFinder : public TrackFindingCDC::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  inline unsigned short layerFilter(std::bitset<8>& layer)
53  {
54  uint layercount = layer.count();
55  return (layercount >= 3 ? layercount : 0);
56  }
57 
66  void fastInterceptFinder2d(const std::vector<VXDHoughState*>& hits, uint xmin, uint xmax, uint ymin, uint ymax,
67  uint currentRecursion);
68 
71  void FindHoughSpaceCluster();
72 
76  void DepthFirstSearch(uint lastIndexX, uint lastIndexY);
77 
78  // Parameters
81 
84 
87 
90 
92  double m_param_minimumX = -3.168;
94  double m_param_maximumX = 3.168;
95 
104 
105  // class variables
107  double m_unitX = 0;
109  double m_unitY = 0;
110 
113  std::array<double, 16385> m_HSSinValuesLUT = {0};
115  std::array<double, 16385> m_HSCosValuesLUT = {0};
117  std::array<double, 16384> m_HSCenterSinValuesLUT = {0};
119  std::array<double, 16384> m_HSCenterCosValuesLUT = {0};
121  std::array<double, 16385> m_HSYLUT = {0};
123  std::array<double, 16384> m_HSYCenterLUT = {0};
125  std::array<double, 16385> m_HSXLUT = {0};
127  std::array<double, 16384> m_HSXCenterLUT = {0};
128 
143  struct paircompare {
145  bool operator()(const std::pair<uint, uint>& lhs, const std::pair<uint, uint>& rhs) const
146  {return ((int)rhs.second - (int)lhs.second) * 16384 < (int)rhs.first - (int)lhs.first;}
147  };
153  std::map<std::pair<uint, uint>, std::pair<int, std::vector<VXDHoughState*>>, paircompare> m_activeSectors;
154 
156  uint m_clusterCount = 0;
158  uint m_clusterSize = 0;
159 
161  std::pair<uint, uint> m_clusterInitialPosition = std::make_pair(0, 0);
163  std::pair<int, int> m_clusterCoG = std::make_pair(0, 0);
164 
166  std::vector<VXDHoughState*> m_currentTrackCandidate;
167 
169  std::vector<std::vector<VXDHoughState*>> m_trackCandidates;
170 
171  };
172 
173  }
175 }
The Module parameter list class.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition: Findlet.h:26
Interface for an algorithm part that needs to receive the module processing signals.
Findlet for finding intersections of sinosoidal curves in the 2D Hough space by iteratively calling f...
std::array< double, 16384 > m_HSCenterSinValuesLUT
sine values of the Hough Space sector center coordinates
uint m_param_MinimumHSClusterSize
minimum cluster size of sectors belonging to intercepts in the Hough Space
unsigned short layerFilter(std::bitset< 8 > &layer)
layer filter, checks if at least hits from 3 layers are in a set of hits
double m_param_maximumX
maximum x value of the Hough Space, defaults to the value for u-side
std::array< double, 16384 > m_HSYCenterLUT
y values of the Hough Space sector centers
std::array< double, 16385 > m_HSYLUT
y values of the Hough Space sector boarders
std::array< double, 16384 > m_HSCenterCosValuesLUT
cosine values of the Hough Space sector center coordinates
std::map< std::pair< uint, uint >, std::pair< int, std::vector< VXDHoughState * > >, paircompare > m_activeSectors
Map containing only active HS sectors, i.e.
std::array< double, 16385 > m_HSXLUT
x values of the Hough Space sector boarders
std::vector< std::vector< VXDHoughState * > > m_trackCandidates
vector containing track candidates, consisting of the found intersection values in the Hough Space
uint m_param_nVerticalSectors
number of sectors of the Hough Space on the vertical axis
void DepthFirstSearch(uint lastIndexX, uint lastIndexY)
Perform depth first search recursive algorithm to find clusters in the Hough Space.
uint m_param_maxRecursionLevel
maximum number of recursive calls of fastInterceptFinder2d
std::pair< uint, uint > m_clusterInitialPosition
start cell of the recursive cluster finding in the Hough Space
void fastInterceptFinder2d(const std::vector< VXDHoughState * > &hits, uint xmin, uint xmax, uint ymin, uint ymax, uint currentRecursion)
find intercepts in the 2D Hough Space by recursively calling itself until no hits are assinged to a g...
std::pair< int, int > m_clusterCoG
center of gravity containing describing the current best track parameters in the Hough Space
double m_param_minimumX
minimum x value of the Hough Space, defaults to the value for u-side
uint m_param_nAngleSectors
number of sectors of the Hough Space on the horizontal axis
double m_param_verticalHoughSpaceSize
vertical size of the Hough Space, defaults to the value for u-side
std::array< double, 16385 > m_HSSinValuesLUT
Look-Up-Tables for values as cache to speed up calculation sine values of the Hough Space sector boar...
uint m_param_MaximumHSClusterSizeX
maximum cluster size in x of sectors belonging to intercepts in the Hough Space
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...
uint m_param_MaximumHSClusterSize
maximum cluster size of sectors belonging to intercepts in the Hough Space
std::vector< VXDHoughState * > m_currentTrackCandidate
the current track candidate
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
std::array< double, 16385 > m_HSCosValuesLUT
cosine values of the Hough Space sector boarder coordinates
std::array< double, 16384 > m_HSXCenterLUT
x values of the Hough Space sector centers
uint m_param_MaximumHSClusterSizeY
maximum cluster size in y of sectors belonging to intercepts in the Hough Space
Abstract base class for different kinds of events.
this sorting makes sure the clusters can be searched from bottom left of the HS to top right normally...
bool operator()(const std::pair< uint, uint > &lhs, const std::pair< uint, uint > &rhs) const
comparison operator for the active HS sector map