From 67be87d32c1881d54ffc83cfe601afe9d02759a2 Mon Sep 17 00:00:00 2001 From: Benjamin Huth <37871400+benjaminhuth@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:41:39 +0200 Subject: [PATCH] refactor: Remove GSF meta cache (#2448) The meta cache is a remainder of an older version and not necessary in the current implementation. No changes in the `tracksummary_gsf.root` as expected. Difference in `trackstates_gsf.root` hashes should come from the pathlength entries, which is accumulated different now. --- .../Acts/TrackFitting/detail/GsfActor.hpp | 60 +++++-------------- Examples/Python/tests/root_file_hashes.txt | 4 +- 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/Core/include/Acts/TrackFitting/detail/GsfActor.hpp b/Core/include/Acts/TrackFitting/detail/GsfActor.hpp index 00e945d41c5..47a44be4192 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfActor.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfActor.hpp @@ -69,32 +69,13 @@ struct GsfActor { /// Enforce default construction GsfActor() = default; - /// Stores meta information about the components - struct MetaCache { - /// Where to find the parent component in the MultiTrajectory - MultiTrajectoryTraits::IndexType parentIndex = 0; - - /// Other quantities TODO are they really needed here? seems they are - /// reinitialized to Identity etc. - BoundMatrix jacobian; - BoundToFreeMatrix jacToGlobal; - FreeMatrix jacTransport; - FreeVector derivative; - - /// We need to preserve the path length - ActsScalar pathLength = 0; - }; - /// Stores parameters of a gaussian component - struct ParameterCache { + struct ComponentCache { ActsScalar weight = 0; - BoundVector boundPars; - BoundSquareMatrix boundCov; + BoundVector boundPars = BoundVector::Zero(); + BoundSquareMatrix boundCov = BoundSquareMatrix::Identity(); }; - /// Broadcast Cache Type - using ComponentCache = std::tuple; - /// Broadcast the result_type using result_type = GsfResult; @@ -349,19 +330,11 @@ struct GsfActor { for (auto [idx, cmp] : zip(tmpStates.tips, cmps)) { auto proxy = tmpStates.traj.getTrackState(idx); - MetaCache mcache; - mcache.parentIndex = idx; - mcache.jacobian = cmp.jacobian(); - mcache.jacToGlobal = cmp.jacToGlobal(); - mcache.jacTransport = cmp.jacTransport(); - mcache.derivative = cmp.derivative(); - mcache.pathLength = cmp.pathAccumulated(); - BoundTrackParameters bound(proxy.referenceSurface().getSharedPtr(), proxy.filtered(), proxy.filteredCovariance()); applyBetheHeitler(state, navigator, bound, tmpStates.weights.at(idx), - mcache, componentCache); + componentCache); } } @@ -369,7 +342,7 @@ struct GsfActor { void applyBetheHeitler(const propagator_state_t& state, const navigator_t& navigator, const BoundTrackParameters& old_bound, - const double old_weight, const MetaCache& metaCache, + const double old_weight, std::vector& componentCaches) const { const auto& surface = *navigator.currentSurface(state.navigation); const auto p_prev = old_bound.absoluteMomentum(); @@ -443,8 +416,7 @@ struct GsfActor { "new cov not finite"); // Set the remaining things and push to vector - componentCaches.push_back( - {ParameterCache{new_weight, new_pars, new_cov}, metaCache}); + componentCaches.push_back({new_weight, new_pars, new_cov}); } } @@ -455,7 +427,7 @@ struct GsfActor { const auto final_cmp_number = std::min( static_cast(stepper.maxComponents), m_cfg.maxComponents); - auto proj = [](auto& a) -> decltype(auto) { return std::get<0>(a); }; + auto proj = [](auto& a) -> decltype(auto) { return a; }; // We must differ between surface types, since there can be different // local coordinates @@ -469,7 +441,7 @@ struct GsfActor { /// TODO This function does not expect normalized components, but this /// could be redundant work... void removeLowWeightComponents(std::vector& cmps) const { - auto proj = [](auto& cmp) -> double& { return std::get<0>(cmp).weight; }; + auto proj = [](auto& cmp) -> double& { return cmp.weight; }; detail::normalizeWeights(cmps, proj); @@ -482,7 +454,7 @@ struct GsfActor { cmps = {*std::max_element( cmps.begin(), cmps.end(), [&](auto& a, auto& b) { return proj(a) < proj(b); })}; - std::get<0>(cmps.front()).weight = 1.0; + cmps.front().weight = 1.0; } else { cmps.erase(new_end, cmps.end()); detail::normalizeWeights(cmps, proj); @@ -531,9 +503,7 @@ struct GsfActor { stepper.clearComponents(state.stepping); // Finally loop over components - for (const auto& [pcache, meta] : componentCache) { - const auto& [weight, pars, cov] = pcache; - + for (const auto& [weight, pars, cov] : componentCache) { // Add the component to the stepper BoundTrackParameters bound(surface.getSharedPtr(), pars, cov); @@ -546,12 +516,10 @@ struct GsfActor { auto& cmp = *res; cmp.jacToGlobal() = surface.boundToFreeJacobian(state.geoContext, pars); - cmp.pathAccumulated() = meta.pathLength; - - // TODO check if they are not anyways reset to identity or zero - cmp.jacobian() = meta.jacobian; - cmp.derivative() = meta.derivative; - cmp.jacTransport() = meta.jacTransport; + cmp.pathAccumulated() = state.stepping.pathAccumulated; + cmp.jacobian() = Acts::BoundMatrix::Identity(); + cmp.derivative() = Acts::FreeVector::Zero(); + cmp.jacTransport() = Acts::FreeMatrix::Identity(); } } diff --git a/Examples/Python/tests/root_file_hashes.txt b/Examples/Python/tests/root_file_hashes.txt index 1c65e8f73d5..bcb00bb210b 100644 --- a/Examples/Python/tests/root_file_hashes.txt +++ b/Examples/Python/tests/root_file_hashes.txt @@ -34,9 +34,9 @@ test_truth_tracking_kalman[odd-0.0]__performance_track_finder.root: 39aec6316cce test_truth_tracking_kalman[odd-1000.0]__trackstates_fitter.root: a2069150737e39724829d76cc91de737be2f444ed08429ddefc7038032442af3 test_truth_tracking_kalman[odd-1000.0]__tracksummary_fitter.root: 94184e78b1f283eba74190c87fefe1123df0c9927d57ea32d2e2a3a927c126df test_truth_tracking_kalman[odd-1000.0]__performance_track_finder.root: 39aec6316cceb90e314e16b02947faa691c18f57c3a851a25e547a8fc05a4593 -test_truth_tracking_gsf[generic]__trackstates_gsf.root: 8249d82ebafe9b471cc51400b04ab3bf290ea10540109de7692bd590f52956b8 +test_truth_tracking_gsf[generic]__trackstates_gsf.root: 5213bc01f5d44afd2686ab1a3775db010278c6f758e55eb78280c4750408b11c test_truth_tracking_gsf[generic]__tracksummary_gsf.root: 4fe7e3e369d2c00244454422259a292c356f2d07d9340896a434b42ef05e55c8 -test_truth_tracking_gsf[odd]__trackstates_gsf.root: a90adb31d19dedea9677864699a955cbae9787b0d55cc5eec5ab8610f0e48074 +test_truth_tracking_gsf[odd]__trackstates_gsf.root: d85edebb449fb0945033ca6d29a04d293bf546be26e27bc22f987895568285db test_truth_tracking_gsf[odd]__tracksummary_gsf.root: 14efdb194a6fa6e69587055b6f9818b4c5491235a8b8e96175f07814a3cbde97 test_particle_gun__particles.root: 8549ba6e20338004ab8ba299fc65e1ee5071985b46df8f77f887cb6fef56a8ec test_material_mapping__material-map_tracks.root: 4e1c866038f0c06b099aa74fd01c3d875f07b89f54898f90debd9b558d8e4025