Skip to content

Commit

Permalink
fix: Wire optional seed result in TrackDensityVertexFinder after #2917
Browse files Browse the repository at this point in the history
 (#3002)

In #2917 I changed the way how "no more seeds" is communicated in our vertexing code but forgot to wire this for the `TrackDensityVertexFinder` correctly.
  • Loading branch information
andiwand authored Mar 1, 2024
1 parent 3d96535 commit abdddc6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
Binary file modified CI/physmon/reference/performance_ivf_truth_estimated_hist.root
Binary file not shown.
6 changes: 3 additions & 3 deletions Core/include/Acts/Vertexing/GaussianTrackDensity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class GaussianTrackDensity {
/// InputTrack
///
/// @return Pair of position of global maximum and Gaussian width
std::pair<double, double> globalMaximumWithWidth(
Result<std::optional<std::pair<double, double>>> globalMaximumWithWidth(
State& state, const std::vector<InputTrack>& trackList) const;

/// @brief Calculates the z position of the global maximum
Expand All @@ -128,8 +128,8 @@ class GaussianTrackDensity {
/// InputTrack
///
/// @return z position of the global maximum
double globalMaximum(State& state,
const std::vector<InputTrack>& trackList) const;
Result<std::optional<double>> globalMaximum(
State& state, const std::vector<InputTrack>& trackList) const;

private:
/// The configuration
Expand Down
26 changes: 18 additions & 8 deletions Core/src/Vertexing/GaussianTrackDensity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

namespace Acts {

std::pair<double, double> Acts::GaussianTrackDensity::globalMaximumWithWidth(
Result<std::optional<std::pair<double, double>>>
Acts::GaussianTrackDensity::globalMaximumWithWidth(
State& state, const std::vector<InputTrack>& trackList) const {
auto result = addTracks(state, trackList);
if (!result.ok()) {
return std::make_pair(0., 0.);
return result.error();
}

double maxPosition = 0.;
Expand Down Expand Up @@ -58,15 +59,24 @@ std::pair<double, double> Acts::GaussianTrackDensity::globalMaximumWithWidth(
maxDensity, maxSecondDerivative);
}

return (maxSecondDerivative == 0.)
? std::make_pair(0., 0.)
: std::make_pair(maxPosition,
std::sqrt(-(maxDensity / maxSecondDerivative)));
if (maxSecondDerivative == 0.) {
return std::nullopt;
}

return std::pair{maxPosition, std::sqrt(-(maxDensity / maxSecondDerivative))};
}

double Acts::GaussianTrackDensity::globalMaximum(
Result<std::optional<double>> Acts::GaussianTrackDensity::globalMaximum(
State& state, const std::vector<InputTrack>& trackList) const {
return globalMaximumWithWidth(state, trackList).first;
auto maxRes = globalMaximumWithWidth(state, trackList);
if (!maxRes.ok()) {
return maxRes.error();
}
const auto& maxOpt = *maxRes;
if (!maxOpt.has_value()) {
return std::nullopt;
}
return maxOpt->first;
}

Result<void> Acts::GaussianTrackDensity::addTracks(
Expand Down
13 changes: 10 additions & 3 deletions Core/src/Vertexing/TrackDensityVertexFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ Acts::Result<std::vector<Acts::Vertex>> Acts::TrackDensityVertexFinder::find(
GaussianTrackDensity::State densityState(trackVector.size());

// Calculate z seed position
std::pair<double, double> zAndWidth =
m_cfg.trackDensityEstimator.globalMaximumWithWidth(densityState,
trackVector);
auto zAndWidthRes = m_cfg.trackDensityEstimator.globalMaximumWithWidth(
densityState, trackVector);
if (!zAndWidthRes.ok()) {
return zAndWidthRes.error();
}
const auto& zAndWidthOpt = *zAndWidthRes;
if (!zAndWidthOpt) {
return std::vector<Vertex>();
}
const auto& zAndWidth = *zAndWidthOpt;

double z = zAndWidth.first;

Expand Down

0 comments on commit abdddc6

Please sign in to comment.