Skip to content

Commit

Permalink
Merge branch 'main' into fix-vertex-truth-finding
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Feb 20, 2024
2 parents c387000 + 139fe6f commit b690dc4
Show file tree
Hide file tree
Showing 15 changed files with 417 additions and 657 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
run: >
echo "::group::Dependencies"
&& git config --global safe.directory "$GITHUB_WORKSPACE"
&& pip3 install histcmp==0.6.3 spyral-cli==1.1.1 matplotlib
&& 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
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ linux_physmon:
- cd ..

- git config --global safe.directory "$GITHUB_WORKSPACE"
- pip3 install histcmp==0.6.2 spyral-cli==1.1.0 matplotlib
- 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"
Expand Down
5 changes: 2 additions & 3 deletions CI/physmon/phys_perf_mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ set -e
set -x


mode=${1:all}
mode=${1:-all}
if ! [[ $mode = @(all|kalman|gsf|fullchains|vertexing|simulation) ]]; then
echo "Usage: $0 <all|kalman|gsf|fullchains|vertexing|simulation> (outdir)"
exit 1
fi

outdir=${2:physmon}
[ -z "$outdir" ] && outdir=physmon
outdir=${2:-physmon}
mkdir -p $outdir

refdir=CI/physmon/reference
Expand Down
13 changes: 4 additions & 9 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "Acts/Vertexing/KalmanVertexTrackUpdater.hpp"
#include "Acts/Vertexing/KalmanVertexUpdater.hpp"
#include "Acts/Vertexing/VertexingError.hpp"

Expand Down Expand Up @@ -291,11 +290,8 @@ inline Acts::Result<void> Acts::AdaptiveMultiVertexFitter::setWeightsAndUpdate(
// 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).
if (m_cfg.useTime) {
KalmanVertexUpdater::updateVertexWithTrack<4>(*vtx, trkAtVtx);
} else {
KalmanVertexUpdater::updateVertexWithTrack<3>(*vtx, trkAtVtx);
}
KalmanVertexUpdater::updateVertexWithTrack(*vtx, trkAtVtx,
m_cfg.useTime ? 4 : 3);
} else {
ACTS_VERBOSE("Track weight too low. Skip track.");
}
Expand Down Expand Up @@ -354,9 +350,8 @@ inline void Acts::AdaptiveMultiVertexFitter::doVertexSmoothing(
// vertex. 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).
KalmanVertexTrackUpdater::update(trkAtVtx, vtx->fullPosition(),
vtx->fullCovariance(),
m_cfg.useTime ? 4 : 3);
KalmanVertexUpdater::updateTrackWithVertex(trkAtVtx, *vtx,
m_cfg.useTime ? 4 : 3);
}
}
}
Expand Down
60 changes: 0 additions & 60 deletions Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.hpp

This file was deleted.

104 changes: 24 additions & 80 deletions Core/include/Acts/Vertexing/KalmanVertexUpdater.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// This file is part of the Acts project.
//
// Copyright (C) 2019-2023 CERN for the benefit of the Acts project
// Copyright (C) 2019-2024 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Vertexing/TrackAtVertex.hpp"
#include "Acts/Vertexing/Vertex.hpp"

namespace Acts {

class Vertex;
struct TrackAtVertex;

namespace KalmanVertexUpdater {

/// KalmanVertexUpdater
Expand All @@ -35,91 +34,36 @@ namespace KalmanVertexUpdater {
/// CERN-THESIS-2010-027
/// Section 5.3.5

/// Cache object, the comments indicate the names of the variables in Ref. (1)
/// @tparam nDimVertex number of dimensions of the vertex. Can be 3 (if we only
/// fit its spatial coordinates) or 4 (if we also fit time).
template <unsigned int nDimVertex>
struct Cache {
using VertexVector = ActsVector<nDimVertex>;
using VertexMatrix = ActsSquareMatrix<nDimVertex>;
// \tilde{x_k}
VertexVector newVertexPos = VertexVector::Zero();
// C_k
VertexMatrix newVertexCov = VertexMatrix::Zero();
// C_k^-1
VertexMatrix newVertexWeight = VertexMatrix::Zero();
// C_{k-1}^-1
VertexMatrix oldVertexWeight = VertexMatrix::Zero();
// W_k
SquareMatrix3 wMat = SquareMatrix3::Zero();
};

/// @brief Updates vertex with knowledge of new track
/// @note KalmanVertexUpdater updates the vertex when trk is added to the fit.
/// However, it does not add the track to the TrackAtVertex list. This to be
/// done manually after calling the method.
///
/// @tparam nDimVertex number of dimensions of the vertex. Can be 3 (if we only
/// fit its spatial coordinates) or 4 (if we also fit time).
///
/// @param vtx Vertex to be updated
/// @param trk Track to be used for updating the vertex
template <unsigned int nDimVertex>
void updateVertexWithTrack(Vertex& vtx, TrackAtVertex& trk);

namespace detail {
void updateVertexWithTrack(Vector4& vtxPos, SquareMatrix4& vtxCov,
std::pair<double, double>& fitQuality,
TrackAtVertexRef trk, int sign,
/// @param nDimVertex number of dimensions of the vertex. Can be 3 (if we only
/// fit its spatial coordinates) or 4 (if we also fit time).
void updateVertexWithTrack(Vertex& vtx, TrackAtVertex& trk,
unsigned int nDimVertex);

// These two functions only exist so we can compile calculateUpdate in a
// compilation unit
void calculateUpdate3(const Vector4& vtxPos, const SquareMatrix4& vtxCov,
const Acts::LinearizedTrack& linTrack,
const double trackWeight, const int sign,
Cache<3>& cache);

void calculateUpdate4(const Vector4& vtxPos, const SquareMatrix4& vtxCov,
const Acts::LinearizedTrack& linTrack,
const double trackWeight, const int sign,
Cache<4>& cache);
} // namespace detail
/// Based on
/// Ref. (1):
/// R. Frühwirth et al.
/// Vertex reconstruction and track bundling at the lep collider using robust
/// algorithms
/// Computer Physics Comm.: 96 (1996) 189
/// Chapter 2.1

/// @brief Calculates updated vertex position and covariance as well as the
/// updated track momentum when adding/removing linTrack. Saves the result in
/// cache.
/// @brief Refits a single track with the knowledge of
/// the vertex it has originated from
///
/// @tparam nDimVertex number of dimensions of the vertex. Can be 3 (if we only
/// @param track Track to update
/// @param vtx Vertex to use for updating the track
/// @param nDimVertex number of dimensions of the vertex. Can be 3 (if we only
/// fit its spatial coordinates) or 4 (if we also fit time).
///
/// @param vtxPos Vertex position
/// @param vtxCov Vertex covariance matrix
/// @param linTrack Linearized track to be added or removed
/// @param trackWeight Track weight
/// @param sign +1 (add track) or -1 (remove track)
/// @note Tracks are removed during the smoothing procedure to compute
/// the chi2 of the track wrt the updated vertex position
/// @param[in,out] cache A cache to store the results of this function
template <unsigned int nDimVertex>
void calculateUpdate(const Vector4& vtxPos, const SquareMatrix4& vtxCov,
const Acts::LinearizedTrack& linTrack,
const double trackWeight, const int sign,
Cache<nDimVertex>& cache) {
static_assert(nDimVertex == 3 || nDimVertex == 4,
"The vertex dimension must either be 3 (when fitting the "
"spatial coordinates) or 4 (when fitting the spatial "
"coordinates + time).");
if constexpr (nDimVertex == 3) {
detail::calculateUpdate3(vtxPos, vtxCov, linTrack, trackWeight, sign,
cache);
} else if constexpr (nDimVertex == 4) {
detail::calculateUpdate4(vtxPos, vtxCov, linTrack, trackWeight, sign,
cache);
}
}

} // Namespace KalmanVertexUpdater
} // Namespace Acts
void updateTrackWithVertex(TrackAtVertex& track, const Vertex& vtx,
unsigned int nDimVertex);

#include "KalmanVertexUpdater.ipp"
} // namespace KalmanVertexUpdater
} // namespace Acts
18 changes: 0 additions & 18 deletions Core/include/Acts/Vertexing/KalmanVertexUpdater.ipp

This file was deleted.

19 changes: 0 additions & 19 deletions Core/include/Acts/Vertexing/TrackAtVertex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,6 @@ struct TrackAtVertex {
bool isLinearized = false;
};

struct TrackAtVertexRef {
BoundTrackParameters& fittedParams;
double& chi2Track;
double& ndf;
double& vertexCompatibility;
double& trackWeight;
LinearizedTrack& linearizedState;
bool isLinearized;

TrackAtVertexRef(TrackAtVertex& track)
: fittedParams(track.fittedParams),
chi2Track(track.chi2Track),
ndf(track.ndf),
vertexCompatibility(track.vertexCompatibility),
trackWeight(track.trackWeight),
linearizedState(track.linearizedState),
isLinearized(track.isLinearized) {}
};

} // namespace Acts

template <>
Expand Down
1 change: 0 additions & 1 deletion Core/src/Vertexing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target_sources(
ActsCore
PRIVATE
AdaptiveGridTrackDensity.cpp
KalmanVertexTrackUpdater.cpp
KalmanVertexUpdater.cpp
FsmwMode1dFinder.cpp
VertexingError.cpp
Expand Down
Loading

0 comments on commit b690dc4

Please sign in to comment.