Belle II Software development
Clusterizend Class Reference

Clustering module. More...

#include <Clusterizend.h>

Classes

struct  DeletionBounds
 Struct containing the deletion bounds of a omega row. More...
 

Public Member Functions

 Clusterizend (const ClustererParameters &parameters)
 To set custom clustering parameters.
 
void setNewPlane (c3array &houghSpace)
 Set a new Hough space for clustering and track finding.
 
std::vector< SimpleClustermakeClusters ()
 Create all the clusters in the Hough space.
 

Private Member Functions

std::array< c3index, 2 > getSectionBounds (const unsigned short quadrant, const unsigned section)
 Get the phi bounds of one quadrant section.
 
void iterateOverSection (const std::array< c3index, 2 > &sectionBounds, std::vector< SimpleCluster > &candidateClusters)
 Iterate m_clustererParams.iterations times over one section.
 
std::pair< cell_index, unsigned int > getSectionPeak (const std::array< c3index, 2 > &sectionBounds)
 Returns the global section peak index and weight.
 
SimpleCluster createCluster (const cell_index &peakCell)
 Creates the surrounding cluster (fixed shape) around the section peak index.
 
void deletePeakSurroundings (const cell_index &peakCell)
 Deletes the surroundings of such a cluster.
 
void clearHoughSpaceRow (const DeletionBounds &bounds)
 Method to delete a omega row for the cluster deletion in deletePeakSurroundings method.
 

Private Attributes

ClustererParameters m_clustererParams
 The struct holding the cluster parameters.
 
c3arraym_houghSpace {0}
 Pointer to the Hough space.
 

Detailed Description

Clustering module.

Definition at line 71 of file Clusterizend.h.

Constructor & Destructor Documentation

◆ Clusterizend()

Clusterizend ( const ClustererParameters & parameters)
inlineexplicit

To set custom clustering parameters.

Definition at line 85 of file Clusterizend.h.

85: m_clustererParams(parameters) {}

Member Function Documentation

◆ clearHoughSpaceRow()

void clearHoughSpaceRow ( const DeletionBounds & bounds)
private

Method to delete a omega row for the cluster deletion in deletePeakSurroundings method.

Definition at line 163 of file Clusterizend.cc.

164{
165 for (c3index phiIdx = bounds.phiLowerBound; phiIdx < bounds.phiUpperBound; ++phiIdx) {
166 c3index phiIdxMod = (phiIdx + m_clustererParams.nPhi) % m_clustererParams.nPhi;
167 (*m_houghSpace)[bounds.omega][phiIdxMod][bounds.cot] = 0;
168 }
169}
ClustererParameters m_clustererParams
The struct holding the cluster parameters.
c3array::index c3index
index of Hough space 3D array

◆ createCluster()

SimpleCluster createCluster ( const cell_index & peakCell)
private

Creates the surrounding cluster (fixed shape) around the section peak index.

Definition at line 84 of file Clusterizend.cc.

85{
86 c3index omegaPeak = peakCell[0];
87 c3index phiPeak = peakCell[1];
88 c3index cotPeak = peakCell[2];
89
90 c3index cotLower = cotPeak - 1;
91 c3index cotUpper = cotPeak + 1;
92
93 c3index phiLeft = (phiPeak - 1 + m_clustererParams.nPhi) % m_clustererParams.nPhi;
94 c3index phiRight = (phiPeak + 1 + m_clustererParams.nPhi) % m_clustererParams.nPhi;
95
96 c3index omegaUpperRight = omegaPeak - 1;
97 c3index omegaLowerLeft = omegaPeak + 1;
98
99 // Add in-bound cells to the cluster:
100 SimpleCluster fixedCluster;
101 fixedCluster.appendCell(peakCell);
102 fixedCluster.appendCell({omegaPeak, phiLeft, cotPeak});
103 fixedCluster.appendCell({omegaPeak, phiRight, cotPeak});
104 if (cotLower >= 0) {
105 fixedCluster.appendCell({omegaPeak, phiPeak, cotLower});
106 }
107 if (cotUpper < m_clustererParams.nCot) {
108 fixedCluster.appendCell({omegaPeak, phiPeak, cotUpper});
109 }
110 if (omegaUpperRight >= 0) {
111 fixedCluster.appendCell({omegaUpperRight, phiRight, cotPeak});
112 }
113 if (omegaLowerLeft < m_clustererParams.nOmega) {
114 fixedCluster.appendCell({omegaLowerLeft, phiLeft, cotPeak});
115 }
116 return fixedCluster;
117}
void appendCell(const cell_index &newClusterCell)
Add a track-space cell to the cluster.

◆ deletePeakSurroundings()

void deletePeakSurroundings ( const cell_index & peakCell)
private

Deletes the surroundings of such a cluster.

Definition at line 120 of file Clusterizend.cc.

121{
122 c3index omegaPeak = peakCell[0];
123 c3index phiPeak = peakCell[1];
124
125 c3index omegaLowerBound = std::max<unsigned short>(0, omegaPeak - m_clustererParams.omegaTrim);
126 c3index omegaUpperBound = std::min<unsigned short>(m_clustererParams.nOmega, omegaPeak + m_clustererParams.omegaTrim + 1);
127
128 for (c3index cotIdx = 0; cotIdx < m_clustererParams.nCot; ++cotIdx) {
129 for (c3index omegaIdx = omegaLowerBound; omegaIdx < omegaUpperBound; ++omegaIdx) {
130 c3index phiCell = phiPeak + omegaPeak - omegaIdx;
131 c3index relativePhi = phiCell - phiPeak;
132
133 if (relativePhi > 0) {
134 DeletionBounds firstBounds = {
135 phiCell - m_clustererParams.phiTrim,
136 static_cast<c3index>(phiCell + m_clustererParams.phiTrim + std::floor(2.4 * relativePhi)),
137 omegaIdx,
138 cotIdx
139 };
140 clearHoughSpaceRow(firstBounds);
141 } else if (relativePhi < 0) {
142 DeletionBounds secondBounds = {
143 static_cast<c3index>(phiCell - m_clustererParams.phiTrim + std::ceil(2.4 * relativePhi)),
144 phiCell + m_clustererParams.phiTrim + 1,
145 omegaIdx,
146 cotIdx
147 };
148 clearHoughSpaceRow(secondBounds);
149 } else {
150 DeletionBounds thirdBounds = {
151 phiCell - m_clustererParams.phiTrim,
152 phiCell + m_clustererParams.phiTrim + 1,
153 omegaIdx,
154 cotIdx
155 };
156 clearHoughSpaceRow(thirdBounds);
157 }
158 }
159 }
160}
void clearHoughSpaceRow(const DeletionBounds &bounds)
Method to delete a omega row for the cluster deletion in deletePeakSurroundings method.
Struct containing the deletion bounds of a omega row.

◆ getSectionBounds()

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

Get the phi bounds of one quadrant section.

Definition at line 34 of file Clusterizend.cc.

35{
36 c3index quadrantSize = m_clustererParams.nPhi / 4;
37 c3index quadrantOffset = m_clustererParams.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()

std::pair< cell_index, unsigned int > getSectionPeak ( const std::array< c3index, 2 > & sectionBounds)
private

Returns the global section peak index and weight.

Definition at line 65 of file Clusterizend.cc.

66{
67 unsigned int peakValue = 0;
68 cell_index peakCell = {0, 0, 0};
69 for (c3index omegaIdx = 0; omegaIdx < m_clustererParams.nOmega; ++omegaIdx) {
70 for (c3index phiIdx = sectionBounds[0]; phiIdx < sectionBounds[1]; ++phiIdx) {
71 c3index phiIdxMod = phiIdx % m_clustererParams.nPhi;
72 for (c3index cotIdx = 0; cotIdx < m_clustererParams.nCot; ++cotIdx) {
73 if ((*m_houghSpace)[omegaIdx][phiIdxMod][cotIdx] > peakValue) {
74 peakValue = (*m_houghSpace)[omegaIdx][phiIdxMod][cotIdx];
75 peakCell = {omegaIdx, phiIdxMod, cotIdx};
76 }
77 }
78 }
79 }
80 return {peakCell, peakValue};
81}
c3array * m_houghSpace
Pointer to the Hough space.
std::array< c3index, 3 > cell_index
The cell index of one Hough space bin.

◆ iterateOverSection()

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

Iterate m_clustererParams.iterations times over one section.

Definition at line 48 of file Clusterizend.cc.

49{
50 for (unsigned short _ = 0; _ < m_clustererParams.iterations; ++_) {
51 auto [sectionPeak, peakWeight] = getSectionPeak(sectionBounds);
52 // Ignore the cluster if the peak weight is below 10 (reduces processing)
53 if (peakWeight < 10) {
54 break;
55 }
56 SimpleCluster newCluster = createCluster(sectionPeak);
57 newCluster.setPeakCell(sectionPeak);
58 newCluster.setPeakWeight(peakWeight);
59 candidateClusters.push_back(newCluster);
60 if (m_clustererParams.iterations > 1) deletePeakSurroundings(sectionPeak);
61 }
62}
SimpleCluster createCluster(const cell_index &peakCell)
Creates the surrounding cluster (fixed shape) around the section peak index.
std::pair< cell_index, unsigned int > getSectionPeak(const std::array< c3index, 2 > &sectionBounds)
Returns the global section peak index and weight.
void deletePeakSurroundings(const cell_index &peakCell)
Deletes the surroundings of such a cluster.
void setPeakCell(const cell_index &peakCell)
Set the peak index (found as the section peak) of the cluster.
void setPeakWeight(const unsigned int peakWeight)
Set the weight of the peak cluster cell.

◆ makeClusters()

std::vector< SimpleCluster > makeClusters ( )

Create all the clusters in the Hough space.

Definition at line 19 of file Clusterizend.cc.

20{
21 std::vector<SimpleCluster> candidateClusters;
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, candidateClusters);
27 if (m_clustererParams.iterations > 1) *m_houghSpace = houghSpaceBackup;
28 }
29 }
30 return candidateClusters;
31}
std::array< c3index, 2 > getSectionBounds(const unsigned short quadrant, const unsigned section)
Get the phi bounds of one quadrant section.
void iterateOverSection(const std::array< c3index, 2 > &sectionBounds, std::vector< SimpleCluster > &candidateClusters)
Iterate m_clustererParams.iterations times over one section.
boost::multi_array< unsigned short, 3 > c3array
The Hough space is a 3D array (omega, phi, cot)

◆ setNewPlane()

void setNewPlane ( c3array & houghSpace)
inline

Set a new Hough space for clustering and track finding.

Definition at line 88 of file Clusterizend.h.

88{ m_houghSpace = &houghSpace; }

Member Data Documentation

◆ m_clustererParams

ClustererParameters m_clustererParams
private

The struct holding the cluster parameters.

Definition at line 106 of file Clusterizend.h.

◆ m_houghSpace

c3array* m_houghSpace {0}
private

Pointer to the Hough space.

Definition at line 108 of file Clusterizend.h.

108{0};

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