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/trackFindingCDC/utilities/StringManipulation.h>
13#include <tracking/trackFindingCDC/utilities/Algorithms.h>
14#include <vxd/dataobjects/VxdID.h>
15#include <framework/core/ModuleParamList.h>
16#include <framework/core/ModuleParamList.templateDetails.h>
19using namespace TrackFindingCDC;
20using namespace vxdHoughTracking;
34 "Number of angle sectors (= x-axis) dividing the Hough space.",
m_nAngleSectors);
37 "Number of vertical sectors (= y-axis) dividing the Hough space.",
m_nVerticalSectors);
43 "Minimum x value of the Hough space.",
m_minimumX);
46 "Maximum x value of the Hough space.",
m_maximumX);
68 B2ERROR(
"The maximum number of recursions (maximumRecursionLevel) must not be larger than 14, but it is " <<
70 ", please choose a smaller value for maximumRecursionLevel, and / or for nAngleSectors and / or nVerticalSectors.");
99 std::vector<std::vector<VXDHoughState*>>& rawTrackCandidates)
104 const std::vector<VXDHoughState*> currentEventHitList = TrackFindingCDC::as_pointers<VXDHoughState>(hits);
113 std::sort(trackCand.begin(), trackCand.end(),
116 (a->getDataCache().layer > b->getDataCache().layer) or
117 (a->getDataCache().layer == b->getDataCache().layer
118 and a->getHit()->getPosition().Perp() > b->getHit()->getPosition().Perp());
121 rawTrackCandidates.emplace_back(trackCand);
131 uint ymax, uint currentRecursion)
133 std::vector<VXDHoughState*> containedHits;
134 containedHits.reserve(hits.size());
135 std::bitset<8> layerHits;
140 const uint centerx = xmin + (uint)((xmax - xmin) / 2);
141 const uint centery = ymin + (uint)((ymax - ymin) / 2);
142 const uint xIndexCache[3] = {xmin, centerx, xmax};
143 const uint yIndexCache[3] = {ymin, centery, ymax};
145 for (
int i = 0; i < 2 ; ++i) {
146 const uint left = xIndexCache[i];
147 const uint right = xIndexCache[i + 1];
148 const uint localIndexX = left;
150 if (left == right)
continue;
162 for (
int j = 0; j < 2; ++j) {
163 const uint lowerIndex = yIndexCache[j];
164 const uint upperIndex = yIndexCache[j + 1];
166 if (lowerIndex == upperIndex)
continue;
168 const uint localIndexY = lowerIndex;
169 const double& localUpperCoordinate =
m_HSYLUT[lowerIndex];
170 const double& localLowerCoordinate =
m_HSYLUT[upperIndex];
174 containedHits.clear();
181 const double derivativeyLeft = m * -sinLeft + a * cosLeft;
182 const double derivativeyRight = m * -sinRight + a * cosRight;
183 const double derivativeyCenter = m * -sinCenter + a * cosCenter;
187 if (derivativeyLeft < 0 and derivativeyRight < 0 and derivativeyCenter < 0)
continue;
189 const double yLeft = m * cosLeft + a * sinLeft;
190 const double yRight = m * cosRight + a * sinRight;
191 const double yCenter = m * cosCenter + a * sinCenter;
194 if ((yLeft <= localUpperCoordinate and yRight >= localLowerCoordinate) or
195 (yCenter <= localUpperCoordinate and yLeft >= localLowerCoordinate and yRight >= localLowerCoordinate) or
196 (yCenter >= localLowerCoordinate and yLeft <= localUpperCoordinate and yRight <= localUpperCoordinate)) {
197 layerHits[hitData.
layer] =
true;
198 containedHits.emplace_back(hit);
225 if (currentCell.second.first > -1)
continue;
252 for (uint currentIndexY = lastIndexY; currentIndexY >= lastIndexY - 1; currentIndexY--) {
255 for (uint currentIndexX = lastIndexX; currentIndexX <= lastIndexX + 1; currentIndexX++) {
260 if (lastIndexX == currentIndexX && lastIndexY == currentIndexY)
continue;
266 auto activeSector =
m_activeSectors.find({currentIndexX, currentIndexY});
268 if (activeSector !=
m_activeSectors.end() and activeSector->second.first < 0 ) {
The Module parameter list class.
void initialize() override
Receive and dispatch signal before the start of the event processing.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
std::array< double, 16384 > m_HSCenterSinValuesLUT
sine values of the Hough Space sector center coordinates
uint m_nVerticalSectors
number of sectors of the Hough Space on the vertical axis
void FindHoughSpaceCluster()
Find Hough Space clusters.
uint m_MinimumHSClusterSize
minimum cluster size of sectors belonging to intercepts in the Hough Space
uint m_clusterSize
size of the current cluster
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.
uint m_nAngleSectors
number of sectors of the Hough Space on the horizontal axis
void initialize() override
Create the store arrays.
SingleHoughSpaceFastInterceptFinder()
Find intercepts in the 2D Hough space.
double m_unitX
HS unit size in x.
std::array< double, 16385 > m_HSXLUT
x values of the Hough Space sector boarders
double m_minimumX
minimum x value of the Hough Space, defaults to the value for u-side
std::vector< std::vector< VXDHoughState * > > m_trackCandidates
vector containing track candidates, consisting of the found intersection values in the Hough Space
double m_verticalHoughSpaceSize
vertical size of the Hough Space, defaults to the value for u-side
unsigned short layerFilter(const std::bitset< 8 > &layer)
layer filter, checks if at least hits from 3 layers are in a set of hits
void DepthFirstSearch(uint lastIndexX, uint lastIndexY)
Perform depth first search recursive algorithm to find clusters in the Hough Space.
double m_unitY
HS unit size in y.
uint m_clusterCount
count the clusters
std::pair< uint, uint > m_clusterInitialPosition
start cell of the recursive cluster finding in the Hough Space
uint m_MaximumHSClusterSizeX
maximum cluster size in x of sectors belonging to intercepts 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 assigned to a g...
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...
std::vector< VXDHoughState * > m_currentTrackCandidate
the current track candidate
double m_maximumX
maximum x value of the Hough Space, defaults to the value for u-side
uint m_MaximumHSClusterSizeY
maximum cluster size in y 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.
uint m_MaximumHSClusterSize
maximum cluster size 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...
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_maxRecursionLevel
maximum number of recursive calls of FastInterceptFinder2d
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