11 template <
typename input_track_t>
12 std::pair<double, double>
14 State& state,
const std::vector<const input_track_t*>& trackList,
17 addTracks(state, trackList, extractParameters);
19 double maxPosition = 0.;
20 double maxDensity = 0.;
21 double maxSecondDerivative = 0.;
24 double trialZ = track.z;
26 auto [density, firstDerivative, secondDerivative] =
27 trackDensityAndDerivatives(state, trialZ);
28 if (secondDerivative >= 0. || density <= 0.) {
31 std::tie(maxPosition, maxDensity, maxSecondDerivative) =
32 updateMaximum(trialZ, density, secondDerivative, maxPosition,
33 maxDensity, maxSecondDerivative);
35 trialZ +=
stepSize(density, firstDerivative, secondDerivative);
36 std::tie(density, firstDerivative, secondDerivative) =
37 trackDensityAndDerivatives(state, trialZ);
39 if (secondDerivative >= 0. || density <= 0.) {
42 std::tie(maxPosition, maxDensity, maxSecondDerivative) =
43 updateMaximum(trialZ, density, secondDerivative, maxPosition,
44 maxDensity, maxSecondDerivative);
45 trialZ +=
stepSize(density, firstDerivative, secondDerivative);
46 std::tie(density, firstDerivative, secondDerivative) =
47 trackDensityAndDerivatives(state, trialZ);
48 if (secondDerivative >= 0. || density <= 0.) {
51 std::tie(maxPosition, maxDensity, maxSecondDerivative) =
52 updateMaximum(trialZ, density, secondDerivative, maxPosition,
53 maxDensity, maxSecondDerivative);
56 return std::make_pair(maxPosition,
57 std::sqrt(-(maxDensity / maxSecondDerivative)));
60 template <
typename input_track_t>
62 State& state,
const std::vector<const input_track_t*>& trackList,
65 return globalMaximumWithWidth(state, trackList, extractParameters).first;
68 template <
typename input_track_t>
70 State& state,
const std::vector<const input_track_t*>& trackList,
73 for (
auto trk : trackList) {
79 const auto perigeeCov = *(boundParams.
covariance());
86 const double covDeterminant = (perigeeCov.block<2, 2>(0, 0)).determinant();
89 if ((covDD <= 0) || (d0 * d0 / covDD > m_cfg.d0SignificanceCut) ||
90 (covZZ <= 0) || (covDeterminant <= 0)) {
96 -(d0 * d0 * covZZ + z0 * z0 * covDD + 2. * d0 * z0 * covDZ) /
97 (2. * covDeterminant);
98 const double linearTerm =
99 (d0 * covDZ + z0 * covDD) /
101 const double quadraticTerm = -covDD / (2. * covDeterminant);
102 double discriminant =
103 linearTerm * linearTerm -
104 4. * quadraticTerm * (constantTerm + 2. * m_cfg.z0SignificanceCut);
105 if (discriminant < 0) {
110 discriminant = std::sqrt(discriminant);
111 const double zMax = (-linearTerm - discriminant) / (2. * quadraticTerm);
112 const double zMin = (-linearTerm + discriminant) / (2. * quadraticTerm);
113 constantTerm -= std::log(2. *
M_PI * std::sqrt(covDeterminant));
115 state.
trackEntries.emplace_back(z0, constantTerm, linearTerm, quadraticTerm,
120 template <
typename input_track_t>
121 std::tuple<double, double, double>
123 State& state,
double z)
const {
131 template <
typename input_track_t>
132 std::tuple<double, double, double>
134 double newZ,
double newValue,
double newSecondDerivative,
double maxZ,
135 double maxValue,
double maxSecondDerivative)
const {
136 if (newValue > maxValue) {
139 maxSecondDerivative = newSecondDerivative;
141 return {maxZ, maxValue, maxSecondDerivative};
144 template <
typename input_track_t>
147 return (m_cfg.isGaussianShaped ? (y * dy) / (dy * dy - y * ddy) : -dy / ddy);
150 template <
typename input_track_t>
156 double qPrime = entry.
c1 + 2. *
m_z * entry.
c2;
157 double deltaPrime = delta * qPrime;