9 template <
int mainGr
idSize,
int trkGr
idSize,
typename vfitter_t>
11 const std::vector<const InputTrack_t*>& trackVector,
15 if (
m_cfg.cacheGridStateForTrackRemoval &&
state.isInitialized &&
16 !
state.tracksToRemove.empty()) {
18 bool couldRemoveTracks =
false;
19 for (
auto trk :
state.tracksToRemove) {
20 if (not
state.trackSelectionMap.at(trk)) {
24 couldRemoveTracks =
true;
25 auto binAndTrackGrid =
state.binAndTrackGridMap.at(trk);
26 m_cfg.gridDensity.removeTrackGridFromMainGrid(
27 binAndTrackGrid.first, binAndTrackGrid.second,
state.mainGrid);
29 if (not couldRemoveTracks) {
33 std::vector<Vertex<InputTrack_t>> seedVec{vertexingOptions.constraint};
37 state.mainGrid = MainGridVector::Zero();
39 for (
auto trk : trackVector) {
42 if (not doesPassTrackSelection(trkParams)) {
43 if (
m_cfg.cacheGridStateForTrackRemoval) {
44 state.trackSelectionMap[trk] =
false;
48 auto binAndTrackGrid =
49 m_cfg.gridDensity.addTrack(trkParams,
state.mainGrid);
51 if (
m_cfg.cacheGridStateForTrackRemoval) {
52 state.binAndTrackGridMap[trk] = binAndTrackGrid;
53 state.trackSelectionMap[trk] =
true;
56 state.isInitialized =
true;
61 if (
state.mainGrid != MainGridVector::Zero()) {
62 if (not
m_cfg.estimateSeedWidth) {
64 auto maxZres =
m_cfg.gridDensity.getMaxZPosition(
state.mainGrid);
67 return maxZres.error();
72 auto maxZres =
m_cfg.gridDensity.getMaxZPositionAndWidth(
state.mainGrid);
75 return maxZres.error();
78 width = (*maxZres).second;
83 Vector3 seedPos = vertexingOptions.constraint.position() +
Vector3(0., 0., z);
91 seedCov(2, 2) = width *
width;
96 std::vector<Vertex<InputTrack_t>> seedVec{returnVertex};
101 template <
int mainGr
idSize,
int trkGr
idSize,
typename vfitter_t>
108 if (not trk.covariance().has_value()) {
111 const auto perigeeCov = *(trk.covariance());
118 const double covDeterminant = covDD * covZZ - covDZ * covDZ;
121 if ((covDD <= 0) || (d0 * d0 / covDD >
m_cfg.d0SignificanceCut) ||
122 (covZZ <= 0) || (covDeterminant <= 0)) {
127 double constantTerm =
128 -(d0 * d0 * covZZ + z0 * z0 * covDD + 2. * d0 * z0 * covDZ) /
129 (2. * covDeterminant);
130 const double linearTerm = (d0 * covDZ + z0 * covDD) / covDeterminant;
131 const double quadraticTerm = -covDD / (2. * covDeterminant);
132 double discriminant =
133 linearTerm * linearTerm -
134 4. * quadraticTerm * (constantTerm + 2. *
m_cfg.z0SignificanceCut);
135 if (discriminant < 0) {