Skip to content

Commit

Permalink
Merge branch 'main' into tweak-amvf-options-with-time
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand authored Feb 28, 2024
2 parents fc12aff + 6a25545 commit 4dc7c56
Show file tree
Hide file tree
Showing 66 changed files with 1,493 additions and 974 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,7 @@ jobs:
PYTEST_MD_REPORT_OUTPUT: pytest.md
run: >
/usr/local/bin/geant4-config --install-datasets
&& source /usr/local/bin/thisroot.sh
&& source /usr/local/bin/thisdd4hep_only.sh
&& source /usr/local/bin/geant4.sh
&& source build/python/setup.sh
&& export PYTHONPATH=/usr/local/python:$PYTHONPATH
&& export LD_LIBRARY_PATH=$PWD/build/thirdparty/OpenDataDetector/factory:$LD_LIBRARY_PATH
&& source build/this_acts_withdeps.sh
&& pip3 install -r Examples/Python/tests/requirements.txt
&& pip3 install pytest-md-report
&& pytest -rFsv -k "not exatrkx" -v
Expand Down Expand Up @@ -195,13 +190,8 @@ jobs:
&& pip3 install histcmp==0.6.5 spyral-cli==1.1.1 matplotlib
&& pip3 install -r Examples/Scripts/requirements.txt
&& /usr/local/bin/geant4-config --install-datasets
&& source /usr/local/bin/thisroot.sh
&& source /usr/local/bin/thisdd4hep_only.sh
&& source /usr/local/bin/geant4.sh
&& source build/python/setup.sh
&& export LD_LIBRARY_PATH=$PWD/build/thirdparty/OpenDataDetector/factory:$LD_LIBRARY_PATH
&& source build/this_acts_withdeps.sh
&& echo "::endgroup::"
&& export PYTHONPATH="${PYTHONPATH}":"${GITHUB_WORKSPACE}/Examples/Scripts/Python"
&& CI/physmon/phys_perf_mon.sh all physmon
&& cat physmon/summary.md >> $GITHUB_STEP_SUMMARY
Expand Down
17 changes: 3 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ test_exatrkx_python:
script:
- apt-get update -y
- apt-get install -y python3 libxxhash0
- source /usr/local/bin/thisroot.sh
- source build/python/setup.sh
- source build/this_acts_withdeps.sh
- git clone $CLONE_URL src
- cd src
- git checkout $HEAD_SHA
Expand Down Expand Up @@ -205,12 +204,7 @@ linux_test_examples:
- cd ..

- /usr/local/bin/geant4-config --install-datasets
- "source /usr/local/bin/thisroot.sh || true"
- "source /usr/local/bin/thisdd4hep_only.sh || true"
- "source /usr/local/bin/geant4.sh || true"
- source build/python/setup.sh
- export PYTHONPATH=/usr/local/python:$PYTHONPATH
- export LD_LIBRARY_PATH=$PWD/build/thirdparty/OpenDataDetector/factory:$LD_LIBRARY_PATH
- source build/this_acts_withdeps.sh
- cd src
- pip3 install -r Examples/Python/tests/requirements.txt
- pytest -rFsv -k "not exatrkx" -v
Expand Down Expand Up @@ -240,13 +234,8 @@ linux_physmon:
- pip3 install histcmp==0.6.5 spyral-cli==1.1.0 matplotlib
- pip3 install -r src/Examples/Scripts/requirements.txt
- /usr/local/bin/geant4-config --install-datasets
- "source /usr/local/bin/thisroot.sh || true"
- "source /usr/local/bin/thisdd4hep_only.sh || true"
- "source /usr/local/bin/geant4.sh || true"
- source build/python/setup.sh
- export LD_LIBRARY_PATH=$PWD/build/thirdparty/OpenDataDetector/factory:$LD_LIBRARY_PATH
- source build/this_acts_withdeps.sh
- cd src
- export PYTHONPATH="${PYTHONPATH}":"${PWD}/Examples/Scripts/Python"
- CI/physmon/phys_perf_mon.sh all physmon

###############################
Expand Down
Binary file modified CI/physmon/reference/performance_ambi_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_gridseeder_ttbar_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_amvf_ttbar_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_ttbar.root
Binary file not shown.
Binary file modified CI/physmon/reference/tracksummary_ckf_ttbar_hist.root
Binary file not shown.
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AdaptiveMultiVertexFitter {
struct State {
State(const MagneticFieldProvider& field,
const Acts::MagneticFieldContext& magContext)
: ipState(field.makeCache(magContext)),
: ipState{field.makeCache(magContext)},
fieldCache(field.makeCache(magContext)) {}
// Vertex collection to be fitted
std::vector<Vertex*> vertexCollection;
Expand Down
62 changes: 31 additions & 31 deletions Core/include/Acts/Vertexing/ImpactPointEstimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
Expand Down Expand Up @@ -47,11 +48,6 @@ class ImpactPointEstimator {
public:
/// State struct
struct State {
/// @brief The state constructor
///
/// @param fieldCacheIn The magnetic field cache
State(MagneticFieldProvider::Cache fieldCacheIn)
: fieldCache(std::move(fieldCacheIn)) {}
/// Magnetic field cache
MagneticFieldProvider::Cache fieldCache;
};
Expand Down Expand Up @@ -139,18 +135,22 @@ class ImpactPointEstimator {
/// compatible.
///
/// @tparam nDim Number of dimensions used to compute compatibility
/// @note If nDim = 3 we only consider spatial dimensions; if nDim = 4, we
/// also consider time. Other values are not allowed.
/// @note If @p nDim = 3 we only consider spatial dimensions; if nDim = 4, we
/// also consider time. Other values are not allowed.
/// @param gctx The Geometry context
/// @param trkParams Track parameters at point of closest
/// approach in 3D as retrieved by estimate3DImpactParameters
/// @param vertexPos The vertex position
///
/// @return The compatibility value
template <unsigned int nDim>
template <int nDim>
Result<double> getVertexCompatibility(
const GeometryContext& gctx, const BoundTrackParameters* trkParams,
const ActsVector<nDim>& vertexPos) const;
const ActsVector<nDim>& vertexPos) const {
static_assert(nDim == 3 || nDim == 4,
"Only 3D and 4D vertex positions allowed");
return getVertexCompatibility(gctx, trkParams, {vertexPos.data(), nDim});
}

/// @brief Calculate the distance between a track and a vertex by finding the
/// corresponding 3D PCA. Returns also the momentum direction at the 3D PCA.
Expand All @@ -160,17 +160,27 @@ class ImpactPointEstimator {
/// tracks we use the Newton method.
///
/// @tparam nDim Number of dimensions used to compute compatibility
/// @note If nDim = 3 we only consider spatial dimensions; if nDim = 4, we
/// also consider time. Other values are not allowed.
/// @note If @p nDim = 3 we only consider spatial dimensions; if nDim = 4, we
/// also consider time. Other values are not allowed.
/// @param gctx Geometry context
/// @param trkParams Track parameters
/// @param vtxPos Vertex position
/// @param state The state object
template <unsigned int nDim>
template <int nDim>
Result<std::pair<Acts::ActsVector<nDim>, Acts::Vector3>>
getDistanceAndMomentum(const GeometryContext& gctx,
const BoundTrackParameters& trkParams,
const ActsVector<nDim>& vtxPos, State& state) const;
const ActsVector<nDim>& vtxPos, State& state) const {
static_assert(nDim == 3 || nDim == 4,
"Only 3D and 4D vertex positions allowed");
auto res =
getDistanceAndMomentum(gctx, trkParams, {vtxPos.data(), nDim}, state);
if (!res.ok()) {
return res.error();
}
auto& [distance, momentum] = *res;
return std::pair{distance.template head<nDim>(), momentum};
}

/// @brief Calculates the impact parameters of a track w.r.t. a vertex. The
/// corresponding errors are approximated by summing the variances of the
Expand Down Expand Up @@ -219,6 +229,14 @@ class ImpactPointEstimator {
const MagneticFieldContext& mctx) const;

private:
Result<std::pair<Acts::Vector4, Acts::Vector3>> getDistanceAndMomentum(
const GeometryContext& gctx, const BoundTrackParameters& trkParams,
Eigen::Map<const ActsDynamicVector> vtxPos, State& state) const;

Result<double> getVertexCompatibility(
const GeometryContext& gctx, const BoundTrackParameters* trkParams,
Eigen::Map<const ActsDynamicVector> vertexPos) const;

/// Configuration object
const Config m_cfg;

Expand All @@ -227,24 +245,6 @@ class ImpactPointEstimator {

/// Private access to logging instance
const Logger& logger() const { return *m_logger; }

/// @brief Performs a Newton approximation to retrieve a point
/// of closest approach in 3D to a reference position
///
/// @param helixCenter Position of the helix center
/// @param vtxPos Vertex position
/// @param phi Azimuthal momentum angle
/// @note Modifying phi corresponds to moving along the track. This function
/// optimizes phi until we reach a 3D PCA.
/// @param theta Polar momentum angle (constant along the track)
/// @param rho Signed helix radius
///
/// @return Phi value at 3D PCA
Result<double> performNewtonOptimization(const Vector3& helixCenter,
const Vector3& vtxPos, double phi,
double theta, double rho) const;
};

} // namespace Acts

#include "Acts/Vertexing/ImpactPointEstimator.ipp"
2 changes: 1 addition & 1 deletion Core/include/Acts/Vertexing/IterativeVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class IterativeVertexFinder final : public IVertexFinder {
State(const MagneticFieldProvider& field,
const Acts::MagneticFieldContext& _magContext)
: magContext(_magContext),
ipState(field.makeCache(magContext)),
ipState{field.makeCache(magContext)},
fieldCache(field.makeCache(magContext)) {}

std::reference_wrapper<const Acts::MagneticFieldContext> magContext;
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Vertexing/VertexingError.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum class VertexingError {
NotConverged,
ElementNotFound,
NoCovariance,
InvalidInput,
};

std::error_code make_error_code(Acts::VertexingError e);
Expand Down
17 changes: 11 additions & 6 deletions Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Acts/Vertexing/AdaptiveMultiVertexFitter.hpp"

#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "Acts/Vertexing/KalmanVertexUpdater.hpp"
#include "Acts/Vertexing/VertexingError.hpp"

Expand Down Expand Up @@ -236,14 +237,17 @@ Acts::Result<void> Acts::AdaptiveMultiVertexFitter::setAllVertexCompatibilities(
// Set compatibility with current vertex
Acts::Result<double> compatibilityResult(0.);
if (m_cfg.useTime) {
compatibilityResult = m_cfg.ipEst.template getVertexCompatibility<4>(
compatibilityResult = m_cfg.ipEst.getVertexCompatibility(
vertexingOptions.geoContext, &(vtxInfo.impactParams3D.at(trk)),
vtxInfo.oldPosition);
} else {
compatibilityResult = m_cfg.ipEst.template getVertexCompatibility<3>(
Acts::Vector3 vertexPosOnly =
VectorHelpers::position(vtxInfo.oldPosition);
compatibilityResult = m_cfg.ipEst.getVertexCompatibility(
vertexingOptions.geoContext, &(vtxInfo.impactParams3D.at(trk)),
VectorHelpers::position(vtxInfo.oldPosition));
vertexPosOnly);
}

if (!compatibilityResult.ok()) {
return compatibilityResult.error();
}
Expand Down Expand Up @@ -288,9 +292,10 @@ Acts::Result<void> Acts::AdaptiveMultiVertexFitter::setWeightsAndUpdate(
trkAtVtx.linearizedState = *result;
trkAtVtx.isLinearized = true;
}
// Update the vertex with the new track. The second template argument
// corresponds to the number of fitted vertex dimensions (i.e., 3 if we
// only fit spatial coordinates and 4 if we also fit time).
// Update the vertex with the new track. The second template
// argument corresponds to the number of fitted vertex dimensions
// (i.e., 3 if we only fit spatial coordinates and 4 if we also fit
// time).
KalmanVertexUpdater::updateVertexWithTrack(*vtx, trkAtVtx,
m_cfg.useTime ? 4 : 3);
} else {
Expand Down
1 change: 1 addition & 0 deletions Core/src/Vertexing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ target_sources(
NumericalTrackLinearizer.cpp
TrackDensityVertexFinder.cpp
GaussianTrackDensity.cpp
ImpactPointEstimator.cpp
)
Loading

0 comments on commit 4dc7c56

Please sign in to comment.