Skip to content

Commit

Permalink
fix: Set proper time cov in TrackParamsEstimationAlgorithm (#2137)
Browse files Browse the repository at this point in the history
The time covariance we currently set in `TrackParamsEstimationAlgorithm` causes numerical instabilities. In this PR I set something more reasonable which fixes downstream issues for the vertexing

Besides that I linked the subloggers in the CKF properly and removed the regularization term from the KF filter and smoothing as this seems to be stable now
  • Loading branch information
andiwand committed Jun 2, 2023
1 parent daedabf commit b400a1b
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 40 deletions.
Binary file modified CI/physmon/reference/performance_ambi_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ambi_seeded.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_ckf_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_seeded.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_truth_estimated.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_orthogonal_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ivf_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/tracksummary_ckf_orthogonal_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/tracksummary_ckf_seeded_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/tracksummary_ckf_truth_estimated_hist.root
Binary file not shown.
7 changes: 2 additions & 5 deletions Core/src/TrackFitting/GainMatrixSmoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ Result<void> GainMatrixSmoother::calculate(
const GetParameters& predicted, const GetCovariance& predictedCovariance,
const GetCovariance& smoothedCovariance, const GetCovariance& jacobian,
const Logger& logger) const {
static constexpr double epsilon = 1e-13;
auto regularization = BoundMatrix::Identity() * epsilon;

ACTS_VERBOSE("Prev. predicted covariance\n"
<< predictedCovariance(prev_ts) << "\n, inverse: \n"
<< predictedCovariance(prev_ts).inverse()
<< "\n, regularized inverse: \n"
<< (predictedCovariance(prev_ts) + regularization).inverse());
<< predictedCovariance(prev_ts).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 = filteredCovariance(ts) * jacobian(prev_ts).transpose() *
(predictedCovariance(prev_ts) + regularization).inverse();
predictedCovariance(prev_ts).inverse();

if (G.hasNaN()) {
// error = KalmanFitterError::SmoothFailed; // set to error
Expand Down
5 changes: 1 addition & 4 deletions Core/src/TrackFitting/GainMatrixUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ std::tuple<double, std::error_code> GainMatrixUpdater::visitMeasurement(
CovarianceMatrix m =
((CovarianceMatrix::Identity() - H * K) * calibratedCovariance).eval();

static constexpr double epsilon = 1e-13;
m.diagonal().array() += epsilon;

chi2 = (residual.transpose() * (m.inverse()) * residual).value();
chi2 = (residual.transpose() * m.inverse() * residual).value();

ACTS_VERBOSE("Chi2: " << chi2);
return true; // continue execution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class TrackParamsEstimationAlgorithm final : public IAlgorithm {
/// q/p resolution.
double sigmaQOverP = 0.1 / Acts::UnitConstants::GeV;
/// Time resolution.
double sigmaT0 = 1400 * Acts::UnitConstants::s;
/// Inflate tracks
double sigmaT0 = 10 * Acts::UnitConstants::ns;
/// Inflate inital covariance.
std::array<double, 6> initialVarInflation = {1., 1., 1., 1., 1., 1.};
};

Expand Down
18 changes: 13 additions & 5 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def addSeeding(
seedingAlgorithm: SeedingAlgorithm = SeedingAlgorithm.Default,
truthSeedRanges: Optional[TruthSeedRanges] = TruthSeedRanges(),
particleSmearingSigmas: ParticleSmearingSigmas = ParticleSmearingSigmas(),
initialSigmas: Optional[list] = None,
initialVarInflation: Optional[list] = None,
seedFinderConfigArg: SeedFinderConfigArg = SeedFinderConfigArg(),
seedFinderOptionsArg: SeedFinderOptionsArg = SeedFinderOptionsArg(),
Expand Down Expand Up @@ -194,9 +195,12 @@ def addSeeding(
particleSmearingSigmas : ParticleSmearingSigmas(d0, d0PtA, d0PtB, z0, z0PtA, z0PtB, t0, phi, theta, pRel)
ParticleSmearing configuration.
Defaults specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp
initialSigmas : list
Sets the initial covariance matrix diagonal. This is ignored in case of TruthSmearing.
Defaults specified in Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp
initialVarInflation : list
List of 6 scale factors to inflate the initial covariance matrix
Defaults (all 1) specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp
Defaults specified in Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp
seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, arithmeticAverageCotTheta, deltaZMax, maxPtScattering, zBinEdges, zBinsCustomLooping, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers)
SeedFinderConfig settings. deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers are ranges specified as a tuple of (min,max). beamPos is specified as (x,y).
Defaults specified in Core/include/Acts/Seeding/SeedFinderConfig.hpp
Expand Down Expand Up @@ -293,9 +297,7 @@ def addSeeding(
houghTransformConfig.outputProtoTracks = "prototracks"
houghTransformConfig.outputSeeds = "seeds"
houghTransformConfig.trackingGeometry = trackingGeometry
inputProtoTracks, inputSeeds = addHoughTransformSeeding(
s, houghTransformConfig, logLevel
)
seeds = addHoughTransformSeeding(s, houghTransformConfig, logLevel)
else:
logger.fatal("unknown seedingAlgorithm %s", seedingAlgorithm)

Expand All @@ -306,6 +308,12 @@ def addSeeding(
trackingGeometry=trackingGeometry,
magneticField=field,
**acts.examples.defaultKWArgs(
sigmaLoc0=initialSigmas[0] if initialSigmas is not None else None,
sigmaLoc1=initialSigmas[1] if initialSigmas is not None else None,
sigmaPhi=initialSigmas[2] if initialSigmas is not None else None,
sigmaTheta=initialSigmas[3] if initialSigmas is not None else None,
sigmaQOverP=initialSigmas[4] if initialSigmas is not None else None,
sigmaT0=initialSigmas[5] if initialSigmas is not None else None,
initialVarInflation=initialVarInflation,
),
)
Expand Down Expand Up @@ -750,7 +758,7 @@ def addHoughTransformSeeding(
sequence.addAlgorithm(ht)
# potentially HT can be extended to also produce seeds, but it is not yet implemented yet
# configuration option (outputSeeds) exists
return config.outputProtoTracks, ""
return ht.config.outputSeeds


def addSeedPerformanceWriters(
Expand Down
48 changes: 24 additions & 24 deletions Examples/Python/tests/root_file_hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ test_itk_seeding__particles_final.root: e7699af6835ca90f730ad5186989c611d782e8b9
test_itk_seeding__particles_initial.root: 88315e93ed4cb5d40a8721502048a9d1fc100e0a7d504e25fd4502c8302f1578
test_propagation__propagation_steps.root: 174301b25784dbb881196b658f2d7f99c0a2ea688a0129e6110fc19aa5cf8e54
test_material_recording__geant4_material_tracks.root: e411152d370775463c22b19a351dfc7bfe40b51985e10a7c1a010aebde80715d
test_truth_tracking_kalman[generic-0.0]__trackstates_fitter.root: 3f99b6c0e1a6bdfb339e3d162e034b72a034c9ee2d56f0579322f0915b360d8d
test_truth_tracking_kalman[generic-0.0]__tracksummary_fitter.root: a6794a05025e86fd480d42c510d38e5de551de351b06e9f63684bed27e3113a5
test_truth_tracking_kalman[generic-0.0]__trackstates_fitter.root: 7e933e0219728ad8c139c2c8d0a7b09d133108a2c3053b0e1972189e34534592
test_truth_tracking_kalman[generic-0.0]__tracksummary_fitter.root: c90a1b50955db2c0847689e691a6c551c75e6e7f803d126a83ad942de6a65eff
test_truth_tracking_kalman[generic-0.0]__performance_track_finder.root: 7fc6f717723c9eddcbf44820b384b373cee6f04b72f79902f938f35e3ff9b470
test_truth_tracking_kalman[generic-1000.0]__trackstates_fitter.root: 8c7e4f81a2e089fb692fe262eb0100317b41f9e076fd2a03dd0df73bb74656a6
test_truth_tracking_kalman[generic-1000.0]__tracksummary_fitter.root: b533d624fd0dfe69d737c79272f157de7a8bf8bf7ad6e41485b94bffa4bb30a0
test_truth_tracking_kalman[generic-1000.0]__trackstates_fitter.root: 2298c2ae839e8208bc640e7208d2dc406f3316042c50f23ff0a65e4652a0bc2c
test_truth_tracking_kalman[generic-1000.0]__tracksummary_fitter.root: e34f7a1b7d2fac6e560e39247bee548efbddc941ef78a8d2425644037ba5c1ef
test_truth_tracking_kalman[generic-1000.0]__performance_track_finder.root: 7fc6f717723c9eddcbf44820b384b373cee6f04b72f79902f938f35e3ff9b470
test_truth_tracking_kalman[odd-0.0]__trackstates_fitter.root: e25f23687eb5ea893687f806ba202c4c4f88e003ec4e707617f6b3b17aee1143
test_truth_tracking_kalman[odd-0.0]__tracksummary_fitter.root: a7440004008ecbf48cc49e284574438d7c118d939a00668989b7df83db1b6feb
test_truth_tracking_kalman[odd-0.0]__trackstates_fitter.root: 4093d18a84cd01ddec712adadcf8f271e7dd1fa473a734f44b80963477fc4f54
test_truth_tracking_kalman[odd-0.0]__tracksummary_fitter.root: a081319d21b910405836cee3dcb5b5b2a6f02e6bacf66df7fda2a9820d21a786
test_truth_tracking_kalman[odd-0.0]__performance_track_finder.root: 39aec6316cceb90e314e16b02947faa691c18f57c3a851a25e547a8fc05a4593
test_truth_tracking_kalman[odd-1000.0]__trackstates_fitter.root: 25dd2cd396133da19b8f320d14d673a9cc0f6c1eff81696529e7ff404cec9e39
test_truth_tracking_kalman[odd-1000.0]__tracksummary_fitter.root: 50573cc669f2ae2a99f9d02aa67a3af90b4069b97a6d185d23c2d6efc0ed497d
test_truth_tracking_kalman[odd-1000.0]__trackstates_fitter.root: 11f863960ba24d32832a620e3a4447fd8efceda09b620bdaef35a5fcc54a5676
test_truth_tracking_kalman[odd-1000.0]__tracksummary_fitter.root: 474eaf25f007c71c9dd6d233f6c174ef00f77901d1103586282e09cdfa0d7701
test_truth_tracking_kalman[odd-1000.0]__performance_track_finder.root: 39aec6316cceb90e314e16b02947faa691c18f57c3a851a25e547a8fc05a4593
test_truth_tracking_gsf[generic]__trackstates_gsf.root: 51f7fd5b3341318faab1207efe9a0d3307bf668bf9694acff72ec6c817fdc627
test_truth_tracking_gsf[generic]__tracksummary_gsf.root: 58f3c49623e8f8eca923d57e63bbd5141cb53bc9b5cae2d6c7ff29cfe6de5724
test_truth_tracking_gsf[odd]__trackstates_gsf.root: d19f8074bd13ceb7e99116716d5bc41e9fc1cf654827d950ff3648810f9e4f0d
test_truth_tracking_gsf[odd]__tracksummary_gsf.root: eca15065441132c58f6c46d1f7bede0df47c59c2402b33e3710994702d8e25d7
test_truth_tracking_gsf[generic]__trackstates_gsf.root: 787294f42fadbd14827ae47133ba90d657999fa815df3fa01e3ddc3c0709d880
test_truth_tracking_gsf[generic]__tracksummary_gsf.root: 93bd70fac407df47d156328319ae1671bba57077e0cc5775a14bdaedb4e87369
test_truth_tracking_gsf[odd]__trackstates_gsf.root: 8ea8bdeda5ba2d4fbedd5b25b1d9f01a47980f9ae5398ad157b40ec5fa070cda
test_truth_tracking_gsf[odd]__tracksummary_gsf.root: b2d3b02d7a4f4649cdfa597a21ca83544b3df6c5bad956a22a9a68d0f6c7403f
test_particle_gun__particles.root: 8549ba6e20338004ab8ba299fc65e1ee5071985b46df8f77f887cb6fef56a8ec
test_material_mapping__material-map_tracks.root: 4e1c866038f0c06b099aa74fd01c3d875f07b89f54898f90debd9b558d8e4025
test_material_mapping__propagation-material.root: 646b8e2bbacec40d0bc4132236f9ab3f03b088e656e6e9b80c47ae03eaf6eab5
Expand All @@ -49,22 +49,22 @@ test_digitization_example_input[smeared]__particles.root: 8549ba6e20338004ab8ba2
test_digitization_example_input[smeared]__measurements.root: 97d695ea55114aa3cb6c967c43e820472ceb8129afbb4f1f22bf1b3eca55ced9
test_digitization_example_input[geometric]__particles.root: 8549ba6e20338004ab8ba299fc65e1ee5071985b46df8f77f887cb6fef56a8ec
test_digitization_example_input[geometric]__measurements.root: 9e7ab4e553966728306c0aa70496b95e440165d40ea89483fc5f7295988debe6
test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: cdec247ca426ff518becedd150f9450519c4fa9ca8df4d8b87e9eb956848324b
test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: 7dced297570030fca8159fe252b5eb456ebd253cdf7dd5836b5e4c8fc26cd0bc
test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: c85f29c499769b7c50e45167e3280d3ca753096609b766f67bf56af7adb38293
test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: ac40a995ae2f69f8bc7e0748ead775d1c3854b6a628c50e9e889f286721df72d
test_ckf_tracks_example[generic-full_seeding]__performance_seeding_trees.root: 0e0676ffafdb27112fbda50d1cf627859fa745760f98073261dcf6db3f2f991e
test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: 96c04ba1772465f791f8582e10b1741d3d5c8deb95bab8de36656642e5f83a45
test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: 273432afb39a1f9b93ce4efbf1f038c9b2b1a96aae7c858447405f923132f687
test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: 3575fdef14664866447ecf84b682305228181ec19365d834c661a9b40ed5ac75
test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: 4f1504ff608d99f7327c53eab7a1668b65c8f7a600da16b72f75705ea3e32931
test_ckf_tracks_example[generic-truth_estimated]__performance_seeding.root: 1facb05c066221f6361b61f015cdf0918e94d9f3fce2269ec7b6a4dffeb2bc7e
test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: 68453d1de3ee7df324119d11dec4544f258bd139939a220ce1756399c833cc4c
test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: 74c86d8b88874d936250dad90aa7a650cb6f4085c12583381923d31baca7c8a2
test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: c97adc23d57bc89c0368aba60092943b960bbb2f5305f534c29e84767e663daf
test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: f3556901aee3cafa3c9a47296995a30b2d603347328c3f97c7e495d642f004c3
test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: 62057fca054ed932488f30369946916c2b072c91601c5400db8b3830b3994a8d
test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: df8bf2f6f06f85515b6eb9697cbe0c18c35f6d17f29ca0c235f29c017b77a3ac
test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 040a0587cf69be2c522ea57f8c29c10820d84e173c9f2399b164f317d74d6308
test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 292287ef5a062315ef6b229b699c8b6271049a6b8fd690fe14278f0e460f6ce3
test_ckf_tracks_example[odd-full_seeding]__performance_seeding_trees.root: 43c58577aafe07645e5660c4f43904efadf91d8cda45c5c04c248bbe0f59814f
test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: af7029d6c430cf835f4e41a69fc85fbf094d39b587a2c8d49b6e199e042ab192
test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 1a8e3cea942bf6e19db31254e4102d71a7c955e51248493b0da3bc881939debd
test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: dfeeea49e75fa60bbc909e5f7ef90de52731e8de777cec80e7de1f58f6d932b3
test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 59e0c04b059e45267db997875da0117efd8c699ad3f0b447f56150d048b6b604
test_ckf_tracks_example[odd-truth_estimated]__performance_seeding.root: 1a36b7017e59f1c08602ef3c2cb0483c51df248f112e3780c66594110719c575
test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: 2ec0661cd604c5e3b867a857c9aa2005e682ed95296d852e5f52a353c200b0cc
test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: 27e3418fc0c0297b7c26b825e9c6eb876182d30bd4a3a7a8e118ce08eecf3268
test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: c5103afef6ab1f44b3654332d350f9c75dba519e431a125f1534d4e27df1f7d2
test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: 4324236869bcc4b9a9c246dde9f4d9891959dd5771be872cf48473484d484746
test_vertex_fitting_reading[Truth-False-100]__performance_vertexing.root: 76ef6084d758dfdfc0151ddec2170e12d73394424e3dac4ffe46f0f339ec8293
test_vertex_fitting_reading[Iterative-False-100]__performance_vertexing.root: 60372210c830a04f95ceb78c6c68a9b0de217746ff59e8e73053750c837b57eb
test_vertex_fitting_reading[Iterative-True-100]__performance_vertexing.root: e34f217d524a5051dbb04a811d3407df3ebe2cc4bb7f54f6bda0847dbd7b52c3
Expand Down

0 comments on commit b400a1b

Please sign in to comment.