Belle II Software development
NDFinderPeakFinder Class Reference

Classes

struct  DeletionBounds
 

Public Member Functions

 NDFinderPeakFinder (const PeakFindingParameters &parameters)
 
void setNewPlane (c3array &houghSpace)
 
std::vector< HoughPeakfindPeaks ()
 

Private Member Functions

std::array< c3index, 2 > getSectionBounds (const unsigned short quadrant, const unsigned section)
 
void iterateOverSection (const std::array< c3index, 2 > &sectionBounds, std::vector< HoughPeak > &candidatePeaks)
 
HoughPeak getSectionPeak (const std::array< c3index, 2 > &sectionBounds)
 
void deletePeakSurroundings (const HoughPeak &peak)
 
void clearHoughSpaceRow (const DeletionBounds &bounds)
 

Private Attributes

PeakFindingParameters m_peakFindingParams
 
c3array * m_houghSpace {0}
 

Detailed Description

Definition at line 52 of file NDFinderPeakFinder.h.

Constructor & Destructor Documentation

◆ NDFinderPeakFinder()

NDFinderPeakFinder ( const PeakFindingParameters & parameters)
inlineexplicit

Definition at line 66 of file NDFinderPeakFinder.h.

66: m_peakFindingParams(parameters) {}

Member Function Documentation

◆ clearHoughSpaceRow()

void clearHoughSpaceRow ( const DeletionBounds & bounds)
private

Definition at line 124 of file NDFinderPeakFinder.cc.

125{
126 for (c3index phiIdx = bounds.phiLowerBound; phiIdx < bounds.phiUpperBound; ++phiIdx) {
127 c3index phiIdxMod = (phiIdx + m_peakFindingParams.nPhi) % m_peakFindingParams.nPhi;
128 (*m_houghSpace)[bounds.omega][phiIdxMod][bounds.cot] = 0;
129 }
130}

◆ deletePeakSurroundings()

void deletePeakSurroundings ( const HoughPeak & peak)
private

Definition at line 81 of file NDFinderPeakFinder.cc.

82{
83 c3index omegaPeak = peak.cell[0];
84 c3index phiPeak = peak.cell[1];
85
86 c3index omegaLowerBound = std::max<unsigned short>(0, omegaPeak - m_peakFindingParams.omegaTrim);
87 c3index omegaUpperBound = std::min<unsigned short>(m_peakFindingParams.nOmega, omegaPeak + m_peakFindingParams.omegaTrim + 1);
88
89 for (c3index cotIdx = 0; cotIdx < m_peakFindingParams.nCot; ++cotIdx) {
90 for (c3index omegaIdx = omegaLowerBound; omegaIdx < omegaUpperBound; ++omegaIdx) {
91 c3index phiCell = phiPeak + omegaPeak - omegaIdx;
92 c3index relativePhi = phiCell - phiPeak;
93
94 if (relativePhi > 0) {
95 DeletionBounds firstBounds = {
96 phiCell - m_peakFindingParams.phiTrim,
97 static_cast<c3index>(phiCell + m_peakFindingParams.phiTrim + std::floor(2.4 * relativePhi)),
98 omegaIdx,
99 cotIdx
100 };
101 clearHoughSpaceRow(firstBounds);
102 } else if (relativePhi < 0) {
103 DeletionBounds secondBounds = {
104 static_cast<c3index>(phiCell - m_peakFindingParams.phiTrim + std::ceil(2.4 * relativePhi)),
105 phiCell + m_peakFindingParams.phiTrim + 1,
106 omegaIdx,
107 cotIdx
108 };
109 clearHoughSpaceRow(secondBounds);
110 } else {
111 DeletionBounds thirdBounds = {
112 phiCell - m_peakFindingParams.phiTrim,
113 phiCell + m_peakFindingParams.phiTrim + 1,
114 omegaIdx,
115 cotIdx
116 };
117 clearHoughSpaceRow(thirdBounds);
118 }
119 }
120 }
121}

◆ findPeaks()

std::vector< HoughPeak > findPeaks ( )

Definition at line 19 of file NDFinderPeakFinder.cc.

20{
21 std::vector<HoughPeak> candidatePeaks;
22 c3array houghSpaceBackup = *m_houghSpace;
23 for (unsigned short quadrant = 0; quadrant < 4; ++quadrant) {
24 for (unsigned short section = 0; section < 4; ++section) {
25 std::array<c3index, 2> sectionBounds = getSectionBounds(quadrant, section);
26 iterateOverSection(sectionBounds, candidatePeaks);
27 if (m_peakFindingParams.iterations > 1) *m_houghSpace = houghSpaceBackup;
28 }
29 }
30 return candidatePeaks;
31}

◆ getSectionBounds()

std::array< c3index, 2 > getSectionBounds ( const unsigned short quadrant,
const unsigned section )
private

Definition at line 34 of file NDFinderPeakFinder.cc.

35{
36 c3index quadrantSize = m_peakFindingParams.nPhi / 4;
37 c3index quadrantOffset = m_peakFindingParams.nPhi / 8;
38 c3index sectionSize = quadrantSize / 4;
39
40 c3index quadrantStart = quadrant * quadrantSize + quadrantOffset;
41 c3index sectionStart = quadrantStart + section * sectionSize;
42 c3index sectionEnd = sectionStart + sectionSize;
43
44 return {sectionStart, sectionEnd};
45}

◆ getSectionPeak()

HoughPeak getSectionPeak ( const std::array< c3index, 2 > & sectionBounds)
private

Definition at line 59 of file NDFinderPeakFinder.cc.

60{
61 unsigned int peakValue = 0;
62 cell_index peakCell = {0, 0, 0};
63 for (c3index omegaIdx = 0; omegaIdx < m_peakFindingParams.nOmega; ++omegaIdx) {
64 for (c3index phiIdx = sectionBounds[0]; phiIdx < sectionBounds[1]; ++phiIdx) {
65 c3index phiIdxMod = phiIdx % m_peakFindingParams.nPhi;
66 for (c3index cotIdx = 0; cotIdx < m_peakFindingParams.nCot; ++cotIdx) {
67 if ((*m_houghSpace)[omegaIdx][phiIdxMod][cotIdx] > peakValue) {
68 peakValue = (*m_houghSpace)[omegaIdx][phiIdxMod][cotIdx];
69 peakCell = {omegaIdx, phiIdxMod, cotIdx};
70 }
71 }
72 }
73 }
74 HoughPeak peak;
75 peak.cell = peakCell;
76 peak.weight = peakValue;
77 return peak;
78}

◆ iterateOverSection()

void iterateOverSection ( const std::array< c3index, 2 > & sectionBounds,
std::vector< HoughPeak > & candidatePeaks )
private

Definition at line 48 of file NDFinderPeakFinder.cc.

50{
51 for (unsigned short _ = 0; _ < m_peakFindingParams.iterations; ++_) {
52 HoughPeak sectionPeak = getSectionPeak(sectionBounds);
53 if (sectionPeak.weight > 0) candidatePeaks.push_back(sectionPeak);
54 if (m_peakFindingParams.iterations > 1) deletePeakSurroundings(sectionPeak);
55 }
56}

◆ setNewPlane()

void setNewPlane ( c3array & houghSpace)
inline

Definition at line 69 of file NDFinderPeakFinder.h.

69{ m_houghSpace = &houghSpace; }

Member Data Documentation

◆ m_houghSpace

c3array* m_houghSpace {0}
private

Definition at line 87 of file NDFinderPeakFinder.h.

87{0};

◆ m_peakFindingParams

PeakFindingParameters m_peakFindingParams
private

Definition at line 85 of file NDFinderPeakFinder.h.


The documentation for this class was generated from the following files: