Skip to content

Commit

Permalink
fix: Regularize GainMatrixSmoother inverse (#1298)
Browse files Browse the repository at this point in the history
issue: #1215

mitigate singular covariance matrix in kalman smoother by adding a regularization term $\lambda I$
  • Loading branch information
andiwand committed Jul 6, 2022
1 parent f95a332 commit d3bddc9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
run: >
echo "::group::Dependencies"
&& git config --global safe.directory "$GITHUB_WORKSPACE"
&& pip3 install histcmp==0.4.1
&& pip3 install histcmp==0.4.4
&& /usr/local/bin/download_geant4_data.sh
&& source /usr/local/bin/thisroot.sh
&& source /usr/local/bin/thisdd4hep_only.sh
Expand Down
4 changes: 3 additions & 1 deletion CI/physmon/phys_perf_mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ run \
run \
$outdir/acts_analysis_residuals_and_pulls.root \
$refdir/acts_analysis_residuals_and_pulls.root \
--title "full_chain_odd" \
--title "analysis_residuals_and_pulls" \
# -o $outdir/analysis_residuals_and_pulls.html \
# -p $outdir/analysis_residuals_and_pulls \


exit $ec
Binary file modified CI/physmon/reference/acts_analysis_residuals_and_pulls.root
Binary file not shown.
2 changes: 1 addition & 1 deletion CI/physmon/reference/commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
53187e47b
eff9322ee
Binary file modified CI/physmon/reference/performance_ckf_tracks_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_tracks_truth_estimated.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_tracks_truth_smeared.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_truth_tracking.root
Binary file not shown.
9 changes: 7 additions & 2 deletions Core/src/TrackFitting/GainMatrixSmoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,23 @@ Result<void> GainMatrixSmoother::operator()(const GeometryContext& gctx,
assert(prev_ts.hasPredicted());
assert(prev_ts.hasJacobian());

static constexpr double epsilon = 1e-13;
auto regularization = BoundMatrix::Identity() * epsilon;

ACTS_VERBOSE("Calculate smoothing matrix:");
ACTS_VERBOSE("Filtered covariance:\n" << ts.filteredCovariance());
ACTS_VERBOSE("Jacobian:\n" << prev_ts.jacobian());
ACTS_VERBOSE("Prev. predicted covariance\n"
<< prev_ts.predictedCovariance() << "\n, inverse: \n"
<< prev_ts.predictedCovariance().inverse());
<< prev_ts.predictedCovariance().inverse()
<< "\n, regularized inverse: \n"
<< (prev_ts.predictedCovariance() + regularization).inverse());

// Gain smoothing matrix
// NB: The jacobian stored in a state is the jacobian from previous
// state to this state in forward propagation
BoundMatrix G = ts.filteredCovariance() * prev_ts.jacobian().transpose() *
prev_ts.predictedCovariance().inverse();
(prev_ts.predictedCovariance() + regularization).inverse();

if (G.hasNaN()) {
error = KalmanFitterError::SmoothFailed; // set to error
Expand Down
36 changes: 18 additions & 18 deletions Examples/Python/tests/root_file_hashes.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: 67e0899d0891a0b330555c07dbd31952698d3888262b3fb827331b3a43b8e8ea
test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: 9b1a1b432d6c82a60f08fdfd84f90ee566bdd2a86bee1c755cb064e71222712e
test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: 8aced789d276585738847435b391b366a8e8b9c2df484d489d4ac50c2e5e8ed3
test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: 89ac1fc3666535e28a1b418083d218af58e67282427198dd10df9f8c72baed9a
test_ckf_tracks_example[generic-full_seeding]__performance_seeding_trees.root: 4890c1f1fb8618f59d4e5c2c0338af0595f2b92847b8eaced8a24e0fc1eb2934
test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 18f1328a34920b2485bc129aa7ac0ab2bd13432fbd6e379295e3c4ee3a62006f
test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: f323c0d6bfa66429e74f103269489e9b70a85f92e5cf319d6b5a91834a339226
test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 16a933f89aa76d68793d41849bacf2b8380df90ebe3ec791ee3742748c6971c2
test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 8cc0119f78086f32fd7ff2ba507b20f3aefa0bc96c61440a14bb25e72952df4a
test_ckf_tracks_example[odd-full_seeding]__performance_seeding_trees.root: 74a1754b03812343dfbec54276152294ce92da3e35d6ad43a393580101b9a678
test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: 9e2afb3defe3f4f32d7fe5b4ca342654e4ca97d585569985998e229dfa8f0da6
test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: 94267dea26347dea32a235c5bd034f2fc52bf5ab40be42be311aa7ef89bd7f09
test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: df7b7527f491377e3e1038d0d71834710ce849c23672d367c3291854a23fb375
test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: ba703c1a69830b14c3dfa2c56139383e8768198e72db259d0e5fe2b6cc128843
test_ckf_tracks_example[generic-truth_estimated]__performance_seeding_trees.root: 471373aceff30b77fc0844eef16fd423911f46981ebe7e78a6cbb239c315d04f
test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: 97addf782956d98ed77c67d8b006237beb28ff870d183d2fd5837591c23798b4
test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 11926164d0ca1d957f45915f6b987ee0f45d371efdfb7b2743822022a2076514
test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: 5afb75e663c1bb9141df6bebaac58b63722331945325d9d1884ec5ce57253d4d
test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 5de964b93dd0ee8b1ed867225d2c17936694855f2fb32f1bba5883f2488d291e
test_ckf_tracks_example[odd-truth_estimated]__performance_seeding_trees.root: 8c2d04afba265cb02919100a9ec1349cb797363ed65f5e651bf7e80a5a86c9c2
test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: 47bad97dbb46dc27d20de9650cc8eb7980bd1fe28e4f9e5f157ea2a284e261f5
test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: 6dc5cea98aea326115cfa7aa510f4c899e9a74f7bfc7e9f01786f6ead217a645
test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: d42bdb444a67ffa560d2eec79eab5c44a4cc1599f3b4b3733d15b8495ca1bea7
test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: 0d87a3613093d6f65da8d0995d63d47583599897c91f7a1738f0544b704d2fca
test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: 6cf6e4015887f7ab83d6ff8d0d4aab8b5229f1a2f0fee0fdd6015eb4df8746c8
test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: 7927a51d44b233c387cf15c12a34a7d648290ddf7f2cbb6fc9fcc7a361935656
test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: e67e6ebf7d837a74cc59ef35ce8e04922086102dc1db55ea65b7ecaa0366c10b
test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: 2350fe7e204e3c2309dde51319e9b494d5d4ce6e0309ac53b19c1ac0c1d1cc40



Expand Down Expand Up @@ -55,14 +55,14 @@ test_root_clusters_writer[configKwConstructor]__clusters.root: 7e452af7243d282dd
test_root_clusters_writer[kwargsConstructor]__clusters.root: 7e452af7243d282dd0a8f5aa2844e150ef44364980bf3641718899068a1a1ecb
test_root_material_writer__material.root: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

test_truth_tracking_kalman[generic-0.0]__trackstates_fitter.root: 7b9492a1f194c53b92b2b6b6f1979c1cbd8512d0f332d68454cda2c54f26d624
test_truth_tracking_kalman[generic-0.0]__tracksummary_fitter.root: 43eafc39203045dd6ee7bb3ae1ab0c6f24ff09bb6e91ee2a24fd2eaf1b3181cc
test_truth_tracking_kalman[generic-0.0]__trackstates_fitter.root: 46cc81fbcc5c7a0d73c883a757f165a7009779edeecf9473cfb664b9fcb29fc7
test_truth_tracking_kalman[generic-0.0]__tracksummary_fitter.root: 6f943909df8e41aa37922ead0868746c75357f7a1472590aa416a84ee44f679d
test_truth_tracking_kalman[generic-0.0]__performance_track_finder.root: 2ce5d720a0c97f3e01140efee711a4b6c5b59b97850c1f04c97aa2dcfa3106e3
test_truth_tracking_kalman[generic-1000.0]__trackstates_fitter.root: 9983c0ac8249030c6a3fcb60e43e6fadd6ffb4f9b964665adbda4fbf62047988
test_truth_tracking_kalman[generic-1000.0]__tracksummary_fitter.root: b3f1a97bf8dbd707a21dd1cd05cad94ad99772ef8597433f4c2b77449e0b5f47
test_truth_tracking_kalman[generic-1000.0]__performance_track_finder.root: 2ce5d720a0c97f3e01140efee711a4b6c5b59b97850c1f04c97aa2dcfa3106e3
test_truth_tracking_kalman[odd-0.0]__trackstates_fitter.root: ae88a75d5b2e7c2fd55392f20d52dba420e543d45e7bccf40ea441e2dd0015aa
test_truth_tracking_kalman[odd-0.0]__tracksummary_fitter.root: 030fecde00868bee06ce95fe77ab380456a357cf277da237fcd3ed6334c9aba3
test_truth_tracking_kalman[odd-0.0]__trackstates_fitter.root: 26e829263697601391ba39ed2630cb8f46ef4b33991642b0f672186d625498a1
test_truth_tracking_kalman[odd-0.0]__tracksummary_fitter.root: 911bb37a062a3538023c39f82ab9eb6d74c3c7a630eab0ba3e54259f0d714a52
test_truth_tracking_kalman[odd-0.0]__performance_track_finder.root: 76a990d595b6e097da2bed447783bd63044956e5649a5dd6fd7a6a3434786877
test_truth_tracking_kalman[odd-1000.0]__trackstates_fitter.root: 5ea6ca504f89355267e10c94408490d500d8389fe9bb043c544dfe91d3e80f20
test_truth_tracking_kalman[odd-1000.0]__tracksummary_fitter.root: c7b3ff9d8d3c19ac378ed7f7c63f396fe504674999efb3131d1009a9c5d3bf2f
Expand All @@ -78,6 +78,6 @@ test_digitization_example_input__particles.root: 78a89f365177423d0834ea6f1bd8afe

test_vertex_fitting_reading[Truth-False-100]__performance_vertexing.root: 489b058ee78b4d01075fc2c594ffeed4af07c306122e577857b1b7e9357888cf
test_vertex_fitting_reading[Iterative-False-100]__performance_vertexing.root: 85754514dff6640401af5cafc8dffb7ffa02ffd9358f658d89c9c39b623111e3
test_vertex_fitting_reading[Iterative-True-100]__performance_vertexing.root: 52604a12106ba8f9a5b355ae1a421d375cabb3ac1c7fcd56e34fc35c3ea7d37d
test_vertex_fitting_reading[Iterative-True-100]__performance_vertexing.root: 3b4458295eb721cdee0f0a978cb8701c24f41855ca31e78ce198d3408a631c52
test_vertex_fitting_reading[AMVF-False-100]__performance_vertexing.root: 8fb55f5aceae330e7738986030d9d1726b9f0b825449d22f7a13f7580890b7d5
test_vertex_fitting_reading[AMVF-True-100]__performance_vertexing.root: 04c73eb824bc0ce1f966264ca080bc04ee5fcfdc310f82d8faccbd102100102d
test_vertex_fitting_reading[AMVF-True-100]__performance_vertexing.root: 202f06dce026f63e5cb55eab956fbeaf94ba0fb08270919cfcf11de022a08c35

0 comments on commit d3bddc9

Please sign in to comment.