8#include <tracking/vxdHoughTracking/findlets/SingleHoughSpaceFastInterceptFinder.h>
9#include <tracking/vxdHoughTracking/entities/VXDHoughState.h>
10#include <tracking/spacePointCreation/SpacePoint.h>
11#include <tracking/spacePointCreation/SpacePointTrackCand.h>
12#include <tracking/trackingUtilities/utilities/StringManipulation.h>
13#include <tracking/trackingUtilities/utilities/Algorithms.h>
14#include <vxd/dataobjects/VxdID.h>
15#include <framework/core/ModuleParamList.h>
18using namespace TrackingUtilities;
19using namespace vxdHoughTracking;
33 "Number of angle sectors (= x-axis) dividing the Hough space.",
m_nAngleSectors);
36 "Number of vertical sectors (= y-axis) dividing the Hough space.",
m_nVerticalSectors);
42 "Minimum x value of the Hough space.",
m_minimumX);
45 "Maximum x value of the Hough space.",
m_maximumX);
67 B2ASSERT(
"The maximum number of recursions (maximumRecursionLevel) must not be larger than " <<
c_maxAllowedRecusionLevel <<
69 ", please choose a smaller value for maximumRecursionLevel, and / or for nAngleSectors and / or nVerticalSectors.",
71 B2ASSERT(
"The maximum number of angleSectors must not be larger than " <<
c_maxHSSectorNumber <<
72 ", but it is " <<
m_nAngleSectors <<
", please choose a smaller value for nAngleSectors.",
74 B2ASSERT(
"The maximum number of verticalSectors must not be larger than " <<
c_maxHSSectorNumber <<
75 ", but it is " <<
m_nVerticalSectors <<
", please choose a smaller value for nAngleSectors.",
99 std::vector<std::vector<VXDHoughState*>>& rawTrackCandidates)
105 const std::vector<VXDHoughState*> currentEventHitList = TrackingUtilities::as_pointers<VXDHoughState>(hits);
114 std::sort(trackCand.begin(), trackCand.end(),
117 (a->getDataCache().layer > b->getDataCache().layer) or
118 (a->getDataCache().layer == b->getDataCache().layer
119 and a->getHit()->getPosition().Perp2() > b->getHit()->getPosition().Perp2());
122 rawTrackCandidates.emplace_back(trackCand);
131 const ushort xmin,
const ushort xmax,
const ushort ymin,
const ushort ymax,
const ushort currentRecursion)
133 std::vector<VXDHoughState*> containedHits;
134 containedHits.reserve(hits.size());
135 std::bitset<8> layerHits;
140 const ushort centerx = xmin + (ushort)((xmax - xmin) >> 1);
141 const ushort centery = ymin + (ushort)((ymax - ymin) >> 1);
142 const ushort xIndexCache[3] = {xmin, centerx, xmax};
143 const ushort yIndexCache[3] = {ymin, centery, ymax};
145 for (
int i = 0; i < 2 ; ++i) {
146 const ushort left = xIndexCache[i];
147 const ushort right = xIndexCache[i + 1];
148 const ushort localIndexX = left;
150 if (left == right)
continue;
162 for (
int j = 0; j < 2; ++j) {
163 const ushort lowerIndex = yIndexCache[j];
164 const ushort upperIndex = yIndexCache[j + 1];
166 if (lowerIndex == upperIndex)
continue;
168 const ushort localIndexY = lowerIndex;
176 containedHits.clear();
183 const float derivativeyLeft = m * -sinLeft + a * cosLeft;
184 const float derivativeyRight = m * -sinRight + a * cosRight;
185 const float derivativeyCenter = m * -sinCenter + a * cosCenter;
189 if (derivativeyLeft < 0 and derivativeyRight < 0 and derivativeyCenter < 0)
continue;
191 const float yLeft = m * cosLeft + a * sinLeft;
192 const float yRight = m * cosRight + a * sinRight;
193 const float yCenter = m * cosCenter + a * sinCenter;
196 if ((yLeft <= localUpperCoordinate and yRight >= localLowerCoordinate) or
197 (yCenter <= localUpperCoordinate and yLeft >= localLowerCoordinate and yRight >= localLowerCoordinate) or
198 (yCenter >= localLowerCoordinate and yLeft <= localUpperCoordinate and yRight <= localUpperCoordinate)) {
199 layerHits[hitData.
layer] =
true;
200 containedHits.emplace_back(hit);
281 const ushort lastLocalIndexX = (lastGlobalSectorIndex &
c_xIndexBitMask);
285 for (ushort currentLocalIndexY = lastLocalIndexY; currentLocalIndexY >= lastLocalIndexY - 1; currentLocalIndexY--) {
292 for (ushort currentLocalIndexX = lastLocalIndexX; currentLocalIndexX <= lastLocalIndexX + 1; currentLocalIndexX++) {
302 if (currentGlobalSectorIndex == lastGlobalSectorIndex) {
The Module parameter list class.
void initialize() override
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
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
float m_unitX
HS unit size in x.
void FindHoughSpaceCluster()
Find Hough Space clusters.
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.
void initialize() override
Create the store arrays.
SingleHoughSpaceFastInterceptFinder()
Find intercepts in the 2D Hough space.
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.
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
ushort m_clusterCount
count the clusters
ushort m_clusterSize
size of the current cluster
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
float m_unitY
HS unit size in y.
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.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.
Cache containing the most important information of this state which will often be needed.
float yConformal
conformal transformed y coordinate of this hit
unsigned short layer
Geometrical Layer this state is based on.
float xConformal
conformal transformed x coordinate of this hit