9 template <
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 trackDensityMap =
state.trackDensities.at(trk);
26 m_cfg.gridDensity.subtractTrack(trackDensityMap,
state.mainDensityMap);
28 if (not couldRemoveTracks) {
32 std::vector<Vertex<InputTrack_t>> seedVec{vertexingOptions.constraint};
36 state.mainDensityMap.clear();
38 for (
auto trk : trackVector) {
41 if (not doesPassTrackSelection(trkParams)) {
42 if (
m_cfg.cacheGridStateForTrackRemoval) {
43 state.trackSelectionMap[trk] =
false;
47 auto trackDensityMap =
48 m_cfg.gridDensity.addTrack(trkParams,
state.mainDensityMap);
50 if (
m_cfg.cacheGridStateForTrackRemoval) {
51 state.trackDensities[trk] = trackDensityMap;
52 state.trackSelectionMap[trk] =
true;
55 state.isInitialized =
true;
60 if (not
state.mainDensityMap.empty()) {
61 if (not
m_cfg.estimateSeedWidth) {
63 auto maxZTRes =
m_cfg.gridDensity.getMaxZTPosition(
state.mainDensityMap);
66 return maxZTRes.error();
68 z = (*maxZTRes).first;
71 auto maxZTResAndWidth =
72 m_cfg.gridDensity.getMaxZTPositionAndWidth(
state.mainDensityMap);
74 if (!maxZTResAndWidth.ok()) {
75 return maxZTResAndWidth.error();
77 z = (*maxZTResAndWidth).first.first;
78 width = (*maxZTResAndWidth).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 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)) {
128 double constantTerm =
129 -(d0 * d0 * covZZ + z0 * z0 * covDD + 2. * d0 * z0 * covDZ) /
130 (2. * covDeterminant);
131 const double linearTerm = (d0 * covDZ + z0 * covDD) / covDeterminant;
132 const double quadraticTerm = -covDD / (2. * covDeterminant);
133 double discriminant =
134 linearTerm * linearTerm -
135 4. * quadraticTerm * (constantTerm + 2. *
m_cfg.z0SignificanceCut);
136 if (discriminant < 0) {