Skip to content

Commit

Permalink
Merge branch 'main' of github.com:acts-project/acts into central-trut…
Browse files Browse the repository at this point in the history
…h-matching
  • Loading branch information
andiwand committed Feb 14, 2024
2 parents 98685d5 + d5f264e commit c77ec1a
Show file tree
Hide file tree
Showing 37 changed files with 311 additions and 208 deletions.
Binary file modified CI/physmon/reference/performance_amvf_gridseeder_ttbar_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_orthogonal_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_truth_estimated_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_truth_smeared_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_ttbar_hist.root
Binary file not shown.
11 changes: 4 additions & 7 deletions Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class AdaptiveGridDensityVertexFinder {
double d0SignificanceCut = maxD0TrackSignificance * maxD0TrackSignificance;
double z0SignificanceCut = maxZ0TrackSignificance * maxZ0TrackSignificance;
bool estimateSeedWidth = false;

// Function to extract parameters from InputTrack
InputTrack::Extractor extractParameters;
};

/// @brief The State struct
Expand Down Expand Up @@ -99,10 +102,7 @@ class AdaptiveGridDensityVertexFinder {
/// @param cfg Configuration object
/// @param func Function extracting BoundTrackParameters from InputTrack
/// object
AdaptiveGridDensityVertexFinder(
const Config& cfg,
const std::function<BoundTrackParameters(const InputTrack&)>& func)
: m_cfg(cfg), m_extractParameters(func) {}
AdaptiveGridDensityVertexFinder(const Config& cfg) : m_cfg(cfg) {}

private:
/// @brief Checks if a track passes the selection criteria for seeding
Expand All @@ -114,9 +114,6 @@ class AdaptiveGridDensityVertexFinder {

// The configuration object
const Config m_cfg;

/// @brief Function to extract track parameters,
std::function<BoundTrackParameters(const InputTrack&)> m_extractParameters;
};

} // namespace Acts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ auto Acts::AdaptiveGridDensityVertexFinder<vfitter_t>::find(
state.mainDensityMap = DensityMap();
// Fill with track densities
for (auto trk : trackVector) {
const BoundTrackParameters& trkParams = m_extractParameters(trk);
const BoundTrackParameters& trkParams = m_cfg.extractParameters(trk);
// Take only tracks that fulfill selection criteria
if (!doesPassTrackSelection(trkParams)) {
continue;
Expand Down
26 changes: 15 additions & 11 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ class AdaptiveMultiVertexFinder {
// true, useTime of the vertex fitter configuration should also be set to
// true, and time seeding should be enabled.
bool useTime = false;

// Function to extract parameters from InputTrack
InputTrack::Extractor extractParameters;
}; // Config struct

/// State struct for fulfilling interface
Expand All @@ -171,15 +174,19 @@ class AdaptiveMultiVertexFinder {
/// BoundTrackParameters
///
/// @param cfg Configuration object
/// @param func Function extracting BoundTrackParameters from InputTrack
/// @param logger The logging instance
AdaptiveMultiVertexFinder(
Config cfg, std::function<BoundTrackParameters(const InputTrack&)> func,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFinder", Logging::INFO))
: m_cfg(std::move(cfg)),
m_extractParameters(std::move(func)),
m_logger(std::move(logger)) {}
AdaptiveMultiVertexFinder(Config cfg,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFinder",
Logging::INFO))
: m_cfg(std::move(cfg)), m_logger(std::move(logger)) {
if (!m_cfg.extractParameters.connected()) {
throw std::invalid_argument(
"AdaptiveMultiVertexFinder: "
"No function to extract parameters "
"from InputTrack provided.");
}
}

AdaptiveMultiVertexFinder(AdaptiveMultiVertexFinder&&) = default;

Expand All @@ -199,9 +206,6 @@ class AdaptiveMultiVertexFinder {
/// Configuration object
Config m_cfg;

/// @brief Function to extract track parameters,
std::function<BoundTrackParameters(const InputTrack&)> m_extractParameters;

/// Logging instance
std::unique_ptr<const Logger> m_logger;

Expand Down
9 changes: 5 additions & 4 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::getIPSignificance(
}

auto estRes = m_cfg.ipEstimator.getImpactParameters(
m_extractParameters(track), newVtx, vertexingOptions.geoContext,
m_cfg.extractParameters(track), newVtx, vertexingOptions.geoContext,
vertexingOptions.magFieldContext, m_cfg.useTime);
if (!estRes.ok()) {
return estRes.error();
Expand Down Expand Up @@ -234,7 +234,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::
const VertexingOptions& vertexingOptions) const
-> Result<void> {
for (const auto& trk : tracks) {
auto params = m_extractParameters(trk);
auto params = m_cfg.extractParameters(trk);
auto pos = params.position(vertexingOptions.geoContext);
// If track is too far away from vertex, do not consider checking the IP
// significance
Expand Down Expand Up @@ -275,7 +275,8 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::
double newZ = 0;
bool nearTrackFound = false;
for (const auto& trk : seedTracks) {
auto pos = m_extractParameters(trk).position(vertexingOptions.geoContext);
auto pos =
m_cfg.extractParameters(trk).position(vertexingOptions.geoContext);
auto zDistance = std::abs(pos[eZ] - vtx.position()[eZ]);
if (zDistance < smallestDeltaZ) {
smallestDeltaZ = zDistance;
Expand Down Expand Up @@ -448,7 +449,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::
double smallestDeltaZ = std::numeric_limits<double>::max();
auto smallestDzSeedIter = seedTracks.end();
for (unsigned int i = 0; i < seedTracks.size(); i++) {
auto pos = m_extractParameters(seedTracks[i]).position(geoCtx);
auto pos = m_cfg.extractParameters(seedTracks[i]).position(geoCtx);
double zDistance = std::abs(pos[eZ] - vtx.position()[eZ]);
if (zDistance < smallestDeltaZ) {
smallestDeltaZ = zDistance;
Expand Down
27 changes: 14 additions & 13 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,28 @@ class AdaptiveMultiVertexFitter {

// Use time information when calculating the vertex compatibility
bool useTime{false};

// Function to extract parameters from InputTrack
InputTrack::Extractor extractParameters;
};

/// @brief Constructor for user-defined InputTrack_t type !=
/// BoundTrackParameters
///
/// @param cfg Configuration object
/// @param func Function extracting BoundTrackParameters from InputTrack_t
/// object
/// @param logger The logging instance
AdaptiveMultiVertexFitter(
Config cfg, std::function<BoundTrackParameters(const InputTrack&)> func,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFitter", Logging::INFO))
: m_cfg(std::move(cfg)),
m_extractParameters(std::move(func)),
m_logger(std::move(logger)) {}
AdaptiveMultiVertexFitter(Config cfg,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFitter",
Logging::INFO))
: m_cfg(std::move(cfg)), m_logger(std::move(logger)) {
if (!m_cfg.extractParameters.connected()) {
throw std::invalid_argument(
"AdaptiveMultiVertexFitter: No function to extract parameters "
"from InputTrack_t provided.");
}
}

/// @brief Adds a new vertex to an existing multi-vertex fit.
/// 1. The 3D impact parameters are calculated for all tracks associated
Expand Down Expand Up @@ -200,11 +206,6 @@ class AdaptiveMultiVertexFitter {
/// Configuration object
const Config m_cfg;

/// @brief Function to extract track parameters,
/// InputTrack_t objects are BoundTrackParameters by default, function to be
/// overwritten to return BoundTrackParameters for other InputTrack_t objects.
std::function<BoundTrackParameters(const InputTrack&)> m_extractParameters;

/// Logging instance
std::unique_ptr<const Logger> m_logger;

Expand Down
14 changes: 7 additions & 7 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Acts::AdaptiveMultiVertexFitter<linearizer_t>::prepareVertexForFit(
for (const auto& trk : vtxInfo.trackLinks) {
auto res = m_cfg.ipEst.estimate3DImpactParameters(
vertexingOptions.geoContext, vertexingOptions.magFieldContext,
m_extractParameters(trk), seedPos, state.ipState);
m_cfg.extractParameters(trk), seedPos, state.ipState);
if (!res.ok()) {
return res.error();
}
Expand All @@ -233,8 +233,8 @@ Acts::AdaptiveMultiVertexFitter<linearizer_t>::setAllVertexCompatibilities(
if (vtxInfo.impactParams3D.find(trk) == vtxInfo.impactParams3D.end()) {
auto res = m_cfg.ipEst.estimate3DImpactParameters(
vertexingOptions.geoContext, vertexingOptions.magFieldContext,
m_extractParameters(trk), VectorHelpers::position(vtxInfo.linPoint),
state.ipState);
m_cfg.extractParameters(trk),
VectorHelpers::position(vtxInfo.linPoint), state.ipState);
if (!res.ok()) {
return res.error();
}
Expand Down Expand Up @@ -289,9 +289,9 @@ Acts::AdaptiveMultiVertexFitter<linearizer_t>::setWeightsAndUpdate(
// relinearize
if (!trkAtVtx.isLinearized || vtxInfo.relinearize) {
auto result = linearizer.linearizeTrack(
m_extractParameters(trk), vtxInfo.linPoint[3], *vtxPerigeeSurface,
vertexingOptions.geoContext, vertexingOptions.magFieldContext,
state.linearizerState);
m_cfg.extractParameters(trk), vtxInfo.linPoint[3],
*vtxPerigeeSurface, vertexingOptions.geoContext,
vertexingOptions.magFieldContext, state.linearizerState);
if (!result.ok()) {
return result.error();
}
Expand Down Expand Up @@ -393,7 +393,7 @@ void Acts::AdaptiveMultiVertexFitter<linearizer_t>::logDebugData(
for (std::size_t trkInd = 0; trkInd < trks.size(); ++trkInd) {
const auto& trkAtVtx =
state.tracksAtVerticesMap.at(std::make_pair(trks[trkInd], vtx));
const auto& trkParams = m_extractParameters(trkAtVtx.originalParams);
const auto& trkParams = m_cfg.extractParameters(trkAtVtx.originalParams);
ACTS_DEBUG(trkInd << ". track parameters:\n" << trkParams.parameters());
ACTS_DEBUG(trkInd << ". track covariance matrix:\n"
<< trkParams.covariance().value());
Expand Down
28 changes: 15 additions & 13 deletions Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,27 @@ class FullBilloirVertexFitter {
struct Config {
/// Maximum number of iterations in fitter
int maxIterations = 5;

// Function to extract parameters from InputTrack
InputTrack::Extractor extractParameters;
};

/// @brief Constructor for user-defined InputTrack type
///
/// @param cfg Configuration object
/// @param func Function extracting BoundTrackParameters from InputTrack
/// object
/// @param logger Logging instance
FullBilloirVertexFitter(
const Config& cfg,
std::function<BoundTrackParameters(const InputTrack&)> func,
std::unique_ptr<const Logger> logger =
getDefaultLogger("FullBilloirVertexFitter", Logging::INFO))
: m_cfg(cfg),
extractParameters(std::move(func)),
m_logger(std::move(logger)) {}
FullBilloirVertexFitter(const Config& cfg,
std::unique_ptr<const Logger> logger =
getDefaultLogger("FullBilloirVertexFitter",
Logging::INFO))
: m_cfg(cfg), m_logger(std::move(logger)) {
if (!m_cfg.extractParameters.connected()) {
throw std::invalid_argument(
"FullBilloirVertexFitter: "
"No function to extract parameters "
"provided.");
}
}

/// @brief Fit method, fitting vertex for provided tracks with constraint
///
Expand All @@ -101,9 +106,6 @@ class FullBilloirVertexFitter {
/// Configuration object
Config m_cfg;

/// @brief Function to extract track parameters,
std::function<BoundTrackParameters(const InputTrack&)> extractParameters;

/// Logging instance
std::unique_ptr<const Logger> m_logger;

Expand Down
5 changes: 3 additions & 2 deletions Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Acts::Result<Acts::Vertex> Acts::FullBilloirVertexFitter<linearizer_t>::fit(
for (std::size_t iTrack = 0; iTrack < nTracks; ++iTrack) {
const InputTrack& trackContainer = paramVector[iTrack];

const auto& trackParams = extractParameters(trackContainer);
const auto& trackParams = m_cfg.extractParameters(trackContainer);

auto result = linearizer.linearizeTrack(
trackParams, linPoint[3], *perigeeSurface,
Expand Down Expand Up @@ -324,7 +324,8 @@ Acts::Result<Acts::Vertex> Acts::FullBilloirVertexFitter<linearizer_t>::fit(
paramVec[eBoundTime] = linPoint[FreeIndices::eFreeTime];
BoundTrackParameters refittedParams(
perigee, paramVec, covDeltaP[iTrack],
extractParameters(billoirTrack.originalTrack).particleHypothesis());
m_cfg.extractParameters(billoirTrack.originalTrack)
.particleHypothesis());
TrackAtVertex trackAtVertex(billoirTrack.chi2, refittedParams,
billoirTrack.originalTrack);
tracksAtVertex.push_back(std::move(trackAtVertex));
Expand Down
30 changes: 15 additions & 15 deletions Core/include/Acts/Vertexing/GaussianTrackDensity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class GaussianTrackDensity {
// Corresponding cut values
double d0SignificanceCut;
double z0SignificanceCut;

// Function to extract parameters from InputTrack
InputTrack::Extractor extractParameters;
};

/// @brief The State struct
Expand All @@ -87,11 +90,14 @@ class GaussianTrackDensity {
std::vector<TrackEntry> trackEntries;
};

/// Default constructor
GaussianTrackDensity() = default;

/// Constructor with config
GaussianTrackDensity(const Config& cfg) : m_cfg(cfg) {}
GaussianTrackDensity(const Config& cfg) : m_cfg(cfg) {
if (!m_cfg.extractParameters.connected()) {
throw std::invalid_argument(
"GaussianTrackDensity: "
"No parameter extractor provided.");
}
}

/// @brief Calculates z position of global maximum with Gaussian width
/// for density function.
Expand All @@ -113,9 +119,7 @@ class GaussianTrackDensity {
///
/// @return Pair of position of global maximum and Gaussian width
std::pair<double, double> globalMaximumWithWidth(
State& state, const std::vector<InputTrack>& trackList,
const std::function<BoundTrackParameters(const InputTrack&)>&
extractParameters) const;
State& state, const std::vector<InputTrack>& trackList) const;

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

private:
/// The configuration
Expand All @@ -140,10 +142,8 @@ class GaussianTrackDensity {
/// @param trackList All input tracks
/// @param extractParameters Function extracting BoundTrackParameters from
/// InputTrack
Result<void> addTracks(
State& state, const std::vector<InputTrack>& trackList,
const std::function<BoundTrackParameters(const InputTrack&)>&
extractParameters) const;
Result<void> addTracks(State& state,
const std::vector<InputTrack>& trackList) const;

/// @brief Evaluate the density function and its two first
/// derivatives at the specified coordinate along the beamline
Expand Down
18 changes: 6 additions & 12 deletions Core/include/Acts/Vertexing/GaussianTrackDensity.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ namespace Acts {

inline std::pair<double, double>
Acts::GaussianTrackDensity::globalMaximumWithWidth(
State& state, const std::vector<InputTrack>& trackList,
const std::function<BoundTrackParameters(const InputTrack&)>&
extractParameters) const {
auto result = addTracks(state, trackList, extractParameters);
State& state, const std::vector<InputTrack>& trackList) const {
auto result = addTracks(state, trackList);
if (!result.ok()) {
return std::make_pair(0., 0.);
}
Expand Down Expand Up @@ -66,18 +64,14 @@ Acts::GaussianTrackDensity::globalMaximumWithWidth(
}

inline double Acts::GaussianTrackDensity::globalMaximum(
State& state, const std::vector<InputTrack>& trackList,
const std::function<BoundTrackParameters(const InputTrack&)>&
extractParameters) const {
return globalMaximumWithWidth(state, trackList, extractParameters).first;
State& state, const std::vector<InputTrack>& trackList) const {
return globalMaximumWithWidth(state, trackList).first;
}

inline Result<void> Acts::GaussianTrackDensity::addTracks(
State& state, const std::vector<InputTrack>& trackList,
const std::function<BoundTrackParameters(const InputTrack&)>&
extractParameters) const {
State& state, const std::vector<InputTrack>& trackList) const {
for (auto trk : trackList) {
const BoundTrackParameters& boundParams = extractParameters(trk);
const BoundTrackParameters& boundParams = m_cfg.extractParameters(trk);
// Get required track parameters
const double d0 = boundParams.parameters()[BoundIndices::eBoundLoc0];
const double z0 = boundParams.parameters()[BoundIndices::eBoundLoc1];
Expand Down
Loading

0 comments on commit c77ec1a

Please sign in to comment.