12 template <
int mainGr
idSize,
int trkGr
idSize>
17 return VertexingError::EmptyInput;
21 if (!m_cfg.useHighestSumZPosition) {
23 mainGrid.maxCoeff(&zbin);
27 zbin = getHighestSumZPosition(mainGrid);
31 return (zbin - mainGridSize / 2 + 0.5f) * m_cfg.binSize;
34 template <
int mainGr
idSize,
int trkGr
idSize>
39 auto maxZRes = getMaxZPosition(mainGrid);
40 if (not maxZRes.ok()) {
41 return maxZRes.error();
43 float maxZ = *maxZRes;
46 auto widthRes = estimateSeedWidth(mainGrid, maxZ);
47 if (not widthRes.ok()) {
48 return widthRes.error();
50 float width = *widthRes;
51 std::pair<float, float> returnPair{maxZ, width};
55 template <
int mainGr
idSize,
int trkGr
idSize>
56 std::pair<int, Acts::ActsVectorF<trkGridSize>>
65 int dOffset = std::floor(d0 / m_cfg.binSize - 0.5) + 1;
67 int zBin = int(z0 / m_cfg.binSize + mainGridSize / 2.);
69 if (zBin < 0 || zBin >= mainGridSize) {
73 float binCtrD = dOffset * m_cfg.binSize;
74 float binCtrZ = (zBin + 0.5f) * m_cfg.binSize - m_cfg.zMinMax;
78 float distCtrD = d0 - binCtrD;
79 float distCtrZ = z0 - binCtrZ;
83 if ((
std::abs(dOffset) > trkGridSize - 1) / 2.) {
91 createTrackGrid(dOffset, cov, distCtrD, distCtrZ);
93 addTrackGridToMainGrid(zBin, trackGrid, mainGrid);
95 return {zBin, trackGrid};
98 template <
int mainGr
idSize,
int trkGr
idSize>
103 modifyMainGridWithTrackGrid(zBin, trkGrid, mainGrid, +1);
106 template <
int mainGr
idSize,
int trkGr
idSize>
111 modifyMainGridWithTrackGrid(zBin, trkGrid, mainGrid, -1);
114 template <
int mainGr
idSize,
int trkGr
idSize>
119 int modifyModeSign)
const {
120 int width = (trkGridSize - 1) / 2;
122 int leftOL = zBin -
width;
124 int rightOL = zBin + width - mainGridSize + 1;
126 int totalTrkSize = trkGridSize + leftOL;
127 mainGrid.segment(0, totalTrkSize) +=
128 modifyModeSign * trkGrid.segment(-leftOL, totalTrkSize);
132 int totalTrkSize = trkGridSize - rightOL;
133 mainGrid.segment(mainGridSize - totalTrkSize, totalTrkSize) +=
134 modifyModeSign * trkGrid.segment(0, totalTrkSize);
138 mainGrid.segment(zBin - width, trkGridSize) += modifyModeSign * trkGrid;
141 template <
int mainGr
idSize,
int trkGr
idSize>
145 float distCtrZ)
const {
148 int i = (trkGridSize - 1) / 2 + offset;
149 float d = (i -
static_cast<float>(trkGridSize) / 2 + 0.5f) * m_cfg.binSize;
152 for (
int j = 0; j < trkGridSize; j++) {
153 float z = (j -
static_cast<float>(trkGridSize) / 2 + 0.5f) * m_cfg.binSize;
154 trackGrid(j) = normal2D(d + distCtrD, z + distCtrZ, cov);
159 template <
int mainGr
idSize,
int trkGr
idSize>
164 return VertexingError::EmptyInput;
167 int zBin = int(maxZ / m_cfg.binSize + mainGridSize / 2.);
169 const float maxValue = mainGrid(zBin);
170 float gridValue = mainGrid(zBin);
174 while (gridValue > maxValue / 2) {
176 gridValue = mainGrid(rhmBin);
180 float deltaZ1 = (maxValue / 2 - mainGrid(rhmBin - 1)) *
181 (m_cfg.binSize / (mainGrid(rhmBin - 1) - mainGrid(rhmBin)));
185 gridValue = mainGrid(zBin);
186 while (gridValue > maxValue / 2) {
188 gridValue = mainGrid(lhmBin);
192 float deltaZ2 = (maxValue / 2 - mainGrid(lhmBin + 1)) *
193 (m_cfg.binSize / (mainGrid(rhmBin + 1) - mainGrid(rhmBin)));
197 rhmBin * m_cfg.binSize - deltaZ1 - lhmBin * m_cfg.binSize - deltaZ2;
200 float width = fwhm / 2.355f;
202 return std::isnormal(width) ? width : 0.0f;
205 template <
int mainGr
idSize,
int trkGr
idSize>
208 float det = cov.determinant();
209 float coef = 1 / (2 *
M_PI * std::sqrt(det));
212 (
cov(1, 1) * d * d - d * z * (
cov(0, 1) +
cov(1, 0)) +
cov(0, 0) * z *
z);
213 return coef * std::exp(expo);
216 template <
int mainGr
idSize,
int trkGr
idSize>
224 mainGrid.maxCoeff(&zbin);
225 int zFirstMax = zbin;
226 double firstDensity = mainGrid(zFirstMax);
227 double firstSum = getDensitySum(mainGrid, zFirstMax);
230 mainGrid[zFirstMax] = 0;
231 mainGrid.maxCoeff(&zbin);
232 int zSecondMax = zbin;
233 double secondDensity = mainGrid(zSecondMax);
234 double secondSum = 0;
235 if (firstDensity - secondDensity <
236 firstDensity * m_cfg.maxRelativeDensityDev) {
237 secondSum = getDensitySum(mainGrid, zSecondMax);
241 mainGrid[zSecondMax] = 0;
242 mainGrid.maxCoeff(&zbin);
243 int zThirdMax = zbin;
244 double thirdDensity = mainGrid(zThirdMax);
246 if (firstDensity - thirdDensity <
247 firstDensity * m_cfg.maxRelativeDensityDev) {
248 thirdSum = getDensitySum(mainGrid, zThirdMax);
252 mainGrid[zFirstMax] = firstDensity;
253 mainGrid[zSecondMax] = secondDensity;
256 if (secondSum > firstSum || secondSum > thirdSum) {
259 if (thirdSum > secondSum || thirdSum > firstSum) {
265 template <
int mainGr
idSize,
int trkGr
idSize>
268 double sum = mainGrid(pos);
272 sum += mainGrid(pos - 1);
274 if (pos + 1 <= mainGrid.size() - 1) {
275 sum += mainGrid(pos + 1);