13 const double d0SignificanceCut,
14 const double z0SignificanceCut)
const {
23 const double covDeterminant = covDD * covZZ - covDZ * covDZ;
26 if ((covDD <= 0) || (d0 * d0 / covDD > d0SignificanceCut) || (covZZ <= 0) ||
27 (covDeterminant <= 0)) {
33 -(d0 * d0 * covZZ + z0 * z0 * covDD + 2. * d0 * z0 * covDZ) /
34 (2. * covDeterminant);
35 const double linearTerm =
36 (d0 * covDZ + z0 * covDD) /
38 const double quadraticTerm = -covDD / (2. * covDeterminant);
40 linearTerm * linearTerm -
41 4. * quadraticTerm * (constantTerm + 2. * z0SignificanceCut);
42 if (discriminant < 0) {
47 discriminant = std::sqrt(discriminant);
48 const double zMax = (-linearTerm - discriminant) / (2. * quadraticTerm);
49 const double zMin = (-linearTerm + discriminant) / (2. * quadraticTerm);
50 constantTerm -= std::log(2. *
M_PI * std::sqrt(covDeterminant));
51 state.
trackEntries.emplace_back(z0, constantTerm, linearTerm, quadraticTerm,
57 double maxPosition = 0.;
58 double maxDensity = 0.;
59 double maxSecondDerivative = 0.;
62 double trialZ =
track.z;
64 double firstDerivative = 0.;
65 double secondDerivative = 0.;
66 density = trackDensity(state, trialZ, firstDerivative, secondDerivative);
67 if (secondDerivative >= 0. || density <= 0.) {
70 updateMaximum(trialZ, density, secondDerivative, maxPosition, maxDensity,
72 trialZ += stepSize(density, firstDerivative, secondDerivative);
73 density = trackDensity(state, trialZ, firstDerivative, secondDerivative);
74 if (secondDerivative >= 0. || density <= 0.) {
77 updateMaximum(trialZ, density, secondDerivative, maxPosition, maxDensity,
79 trialZ += stepSize(density, firstDerivative, secondDerivative);
80 density = trackDensity(state, trialZ, firstDerivative, secondDerivative);
81 if (secondDerivative >= 0. || density <= 0.) {
84 updateMaximum(trialZ, density, secondDerivative, maxPosition, maxDensity,
88 return std::make_pair(maxPosition,
89 std::sqrt(-(maxDensity / maxSecondDerivative)));
93 return globalMaximumWithWidth(state).first;
97 double firstDerivative = 0;
98 double secondDerivative = 0;
99 return trackDensity(state, z, firstDerivative, secondDerivative);
103 double& firstDerivative,
104 double& secondDerivative)
const {
112 return densityResult.
density();
116 double newSecondDerivative,
double&
maxZ,
118 double& maxSecondDerivative)
const {
119 if (newValue > maxValue) {
122 maxSecondDerivative = newSecondDerivative;
127 return (m_cfg.isGaussianShaped ? (y * dy) / (dy * dy - y * ddy) : -dy / ddy);
134 double delta = std::exp(entry.
c0 + m_z * (entry.
c1 + m_z * entry.
c2));
135 double qPrime = entry.
c1 + 2. * m_z * entry.
c2;
136 double deltaPrime = delta * qPrime;
138 m_firstDerivative += deltaPrime;
139 m_secondDerivative += 2. * entry.
c2 * delta + qPrime * deltaPrime;