Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Write correct tracks to file for refitting, prevent FPE #3999

Merged
merged 19 commits into from
Jan 30, 2025

Conversation

benjaminhuth
Copy link
Member

@benjaminhuth benjaminhuth commented Dec 19, 2024

Unfortunately, there where the KF tracks written to files so far.

--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

  • Use a conventional commits prefix: quick summary
    • We mostly use feat, fix, refactor, docs, chore and build types.
  • A milestone will be assigned by one of the maintainers

Summary by CodeRabbit

  • New Features

    • Enhanced track refitting functionality for GSF and Kalman filter algorithms.
    • Updated track summary and performance tracking for refitted tracks.
  • Bug Fixes

    • Corrected input track and particle matching references in track processing scripts.
  • Tests

    • Updated test file hash values to reflect changes in track refitting output.
  • Chores

    • Improved error handling in the calculation of fitted track parameters.

Copy link

coderabbitai bot commented Dec 19, 2024

Walkthrough

In the realm of track refitting, significant changes have emerged. Two Python scripts, truth_tracking_gsf_refitting.py and truth_tracking_kalman_refitting.py, have been modified to update input and output track parameters. The modifications ensure proper routing of refitted tracks through writers and algorithms, with minimal alterations to the underlying logic. Correspondingly, the root_file_hashes.txt has been updated to reflect these changes in test file contents.

Changes

File Change Summary
Examples/Scripts/Python/truth_tracking_gsf_refitting.py - Added initialVarInflation parameter
- Updated input/output track parameters for writers and algorithms
Examples/Scripts/Python/truth_tracking_kalman_refitting.py - Updated input track and particle matching parameters for writers
Examples/Python/tests/root_file_hashes.txt - Updated hash values for GSF and Kalman refitting test files

Possibly related PRs

Suggested Labels

automerge, Track Fitting

Suggested Reviewers

  • paulgessinger
  • andiwand

Poem

Tracks dancing through space and time,
Refitted paths, a quantum climb.
Parameters shift, yet purpose clear,
In code's embrace, precision draws near. 🚀✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4be50b and 630c22c.

📒 Files selected for processing (1)
  • Examples/Io/Root/src/RootTrackSummaryWriter.cpp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: merge-sentinel
  • GitHub Check: macos
🔇 Additional comments (2)
Examples/Io/Root/src/RootTrackSummaryWriter.cpp (2)

411-412: Wise handling of negative variance values, I see!

Handle negative covariance values correctly, you now do. Return NaN for invalid variance, you shall. Implemented well, the suggestion from past review is.


411-412: Clean and elegant, the lambda function is!

Encapsulate covariance access in a lambda function, you did. Good practice this is, for readability and maintenance it brings.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added this to the next milestone Dec 19, 2024
@github-actions github-actions bot added the Component - Examples Affects the Examples module label Dec 19, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32d4bc1 and 30d4564.

📒 Files selected for processing (1)
  • Examples/Scripts/Python/truth_tracking_gsf_refitting.py (2 hunks)
🔇 Additional comments (2)
Examples/Scripts/Python/truth_tracking_gsf_refitting.py (2)

79-82: Correct, this change is! Using GSF refit tracks instead of original tracks, we now are.

Wisdom in this modification I sense. Properly aligned with the GSF refitting output, the RootTrackSummaryWriter now is.


Line range hint 1-120: Verify the flow of tracks through the Force, we must.

Through the sequence of operations, track flow we must validate. From KF tracks to GSF refit tracks, the path leads.

✅ Verification successful

Verified, the flow of tracks is. Consistent, the Force remains.

Through the codebase, a clear path I see:

  • From "kf_tracks" to "gsf_refit_tracks" the transformation flows
  • Proper track-particle matching maintained through "refit_track_particle_matching"
  • Only in performance writer, "track_particle_matching" used as intended

Hmm, yes. In balance, the Force is. No disturbance in the tracking flow I sense.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistent usage of track references across the codebase

# Search for track reference patterns to ensure consistency
echo "=== Searching for track reference patterns ==="
rg -A 2 "inputTracks\s*=\s*['\"](?:kf_tracks|gsf_refit_tracks)['\"]"

# Search for track-particle matching patterns
echo "=== Searching for track-particle matching patterns ==="
rg -A 2 "TrackParticleMatching\s*=\s*['\"](?:track_particle_matching|refit_track_particle_matching)['\"]"

Length of output: 9852

Examples/Scripts/Python/truth_tracking_gsf_refitting.py Outdated Show resolved Hide resolved
andiwand
andiwand previously approved these changes Dec 19, 2024
Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

This will most likely require a ref update

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
Examples/Algorithms/TrackFitting/include/ActsExamples/TrackFitting/RefittingAlgorithm.hpp (1)

36-37: Approve this change, I do. Yet documentation, it needs.

Wise addition of initialVarInflation parameter, this is. But document its purpose and the meaning of each element in the array, we must.

Add documentation like this, you should:

    /// Inflate initial covariance.
+   /// @note Array elements correspond to [d0, z0, phi, theta, q/p, t] parameters
    std::array<double, 6> initialVarInflation = {1., 1., 1., 1., 1., 1.};
Examples/Python/src/TrackFitting.cpp (1)

43-45: Consider documentation updates, you should.

When Python bindings change, documentation in both realms - C++ and Python - update we must. For future Padawans, clear guidance provide.

Consider:

  • Adding Python docstring examples
  • Updating C++ documentation with parameter description
  • Including usage examples in README
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52ed96f and abd3155.

📒 Files selected for processing (5)
  • Examples/Algorithms/TrackFitting/include/ActsExamples/TrackFitting/RefittingAlgorithm.hpp (1 hunks)
  • Examples/Algorithms/TrackFitting/src/RefittingAlgorithm.cpp (1 hunks)
  • Examples/Python/src/TrackFitting.cpp (1 hunks)
  • Examples/Scripts/Python/truth_tracking_gsf_refitting.py (3 hunks)
  • Examples/Scripts/Python/truth_tracking_kalman_refitting.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Examples/Scripts/Python/truth_tracking_gsf_refitting.py
🔇 Additional comments (3)
Examples/Scripts/Python/truth_tracking_kalman_refitting.py (1)

44-44: Large inflation values, concerning they are. Verify their necessity, we must.

Setting all covariance inflation factors to 100.0, a significant impact on track fitting accuracy it may have. Consider different values for different parameters, you should.

Examples/Algorithms/TrackFitting/src/RefittingAlgorithm.cpp (1)

83-91: Placement of covariance inflation, correct it is.

Good structure maintained, error handling preserved. Approve this part of implementation, I do.

Examples/Python/src/TrackFitting.cpp (1)

44-44: Approve this change, I do. Yet verify its impact, we must.

Hmmmm. Wise addition of initialVarInflation parameter, this is. With the PR's objective of fixing GSF refitting output, aligns well it does.

Run this verification script, we shall:

✅ Verification successful

Verified the change is, proper usage found it has.

Found evidence in the codebase, I have:

  • In truth_tracking_gsf_refitting.py and truth_tracking_kalman_refitting.py, properly used the parameter is, with value [100.0] * 6
  • In RefittingAlgorithm.hpp, default values defined correctly they are: {1., 1., 1., 1., 1., 1.}
  • In RefittingAlgorithm.cpp, implementation handles the parameter appropriately it does

Matches the PR's objective of fixing GSF refitting output, this change does. Working as intended, the parameter is.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage patterns of initialVarInflation in Python scripts
# and related configuration files

# Search for Python scripts using RefittingAlgorithm
echo "=== Python usage patterns ==="
rg -A 5 "RefittingAlgorithm.*initialVarInflation" --type py

# Search for any documentation or configuration mentioning this parameter
echo "=== Documentation and configuration ==="
rg "initialVarInflation" --type md --type txt

Length of output: 265


Script:

#!/bin/bash
# Search for RefittingAlgorithm usage patterns more broadly
echo "=== RefittingAlgorithm usage patterns ==="
rg -A 10 "RefittingAlgorithm" --type py

# Search for initialVarInflation in C++ files
echo "=== C++ implementation details ==="
rg -A 5 "initialVarInflation" --type cpp

# Look for the algorithm declaration pattern
echo "=== Algorithm declaration patterns ==="
ast-grep --pattern 'ACTS_PYTHON_DECLARE_ALGORITHM($$$)'

Length of output: 31849

Copy link

github-actions bot commented Dec 19, 2024

📊: Physics performance monitoring for b1f1341

Full contents

physmon summary

@github-actions github-actions bot added Infrastructure Changes to build tools, continous integration, ... Changes Performance labels Dec 19, 2024
andiwand
andiwand previously approved these changes Dec 20, 2024
@paulgessinger
Copy link
Member

@andiwand @benjaminhuth the physmon failure is real, there's a new FPE in the KF refitting job:

 0# 0x00007F5235AF33A4 in /usr/lib/x86_64-linux-gnu/libm.so.6
 1# ActsExamples::RootTrackSummaryWriter::writeT(ActsExamples::AlgorithmContext const&, Acts::TrackContainer<Acts::ConstVectorTrackContainer, Acts::ConstVectorMultiTrajectory, std::shared_ptr> const&) at /builds/acts/ci-bridge/src/Examples/Io/Root/src/RootTrackSummaryWriter.cpp:412
 2# ActsExamples::Sequencer::run()::{lambda()#1}::operator()() const::{lambda(tbb::detail::d1::blocked_range<unsigned long> const&)#1}::operator()(tbb::detail::d1::blocked_range<unsigned long> const&) const at /builds/acts/ci-bridge/src/Examples/Framework/src/Framework/Sequencer.cpp:502
 3# tbb::detail::d1::start_for<tbb::detail::d1::blocked_range<unsigned long>, ActsExamples::Sequencer::run()::{lambda()#1}::operator()() const::{lambda(tbb::detail::d1::blocked_range<unsigned long> const&)#1}, tbb::detail::d1::auto_partitioner const>::execute(tbb::detail::d1::execution_data&) at /builds/acts/ci-bridge/dependencies/include/oneapi/tbb/parallel_for.h:170
 4# tbb::detail::r1::thread_dispatcher::process(rml::job&) at /home/runner/work/ci-dependencies/ci-dependencies/build/tbb/src/tbb/src/tbb/thread_dispatcher.cpp:183
 5# tbb::detail::r1::rml::private_worker::thread_routine(void*) at /home/runner/work/ci-dependencies/ci-dependencies/build/tbb/src/tbb/src/tbb/private_server.cpp:221
 6# 0x00007F5235968A94 in /usr/lib/x86_64-linux-gnu/libc.so.6
 7# __clone in /usr/lib/x86_64-linux-gnu/libc.so.6

08:04:30    ResPlotTool    WARNING   Fitted track parameter :phi has negative covariance = -1.0983e-08

Negatice covariance value?

@benjaminhuth
Copy link
Member Author

Puh... Seems to me like a 2025 problem :D

@github-actions github-actions bot added the Stale label Jan 19, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
Tests/UnitTests/Core/Propagator/DirectNavigatorTests.cpp (5)

197-202: Clean and purposeful, this struct is! Yet documentation, it lacks.

A brief comment explaining the purpose of NavigationBreakAborter, helpful would be.

+/// Struct to abort navigation when a break condition is met in the navigator
 struct NavigationBreakAborter {

212-213: Remove commented code, we must! Clarity, it brings.

The commented logger configuration, distracting it is.

-  Propagator<StraightLineStepper, DirectNavigator> prop(std::move(stepper), std::move(
-                                                                                dnav) /*, Acts::getDefaultLogger("DirectNavigatorTest", Acts::Logging::VERBOSE)*/);
+  Propagator<StraightLineStepper, DirectNavigator> prop(std::move(stepper), 
+                                                       std::move(dnav));

229-232: Magic numbers in the parameters, I sense! Named constants, we should use.

More meaningful, the test parameters should be.

+  constexpr auto kDefaultMomentum = 1.0_GeV;
+  constexpr auto kDefaultTime = 0.0_ns;
   BoundTrackParameters startParameters = BoundTrackParameters(
       startSurface->getSharedPtr(),
-      {0.0_mm, 0.0_mm, 0.0_rad, 0.0_rad, 1.0 / 1.0_GeV, 0.0_ns}, std::nullopt,
+      {0.0_mm, 0.0_mm, 0.0_rad, 0.0_rad, 1.0 / kDefaultMomentum, kDefaultTime}, std::nullopt,
       ParticleHypothesis::muon());

258-267: Magic numbers in surface creation, troubling they are! Constants, we need.

More readable and maintainable, the test setup should be.

+  constexpr int kNumSurfaces = 10;
+  constexpr double kSurfaceSpacing = 100.0_mm;
   std::vector<std::shared_ptr<const Acts::Surface>> surfaces;
-  for (int i = 0; i < 10; i++) {
+  for (int i = 0; i < kNumSurfaces; i++) {
     Transform3 transform = Transform3::Identity();
-    transform.translate(Vector3{0.0_mm, 0.0_mm, i * 100.0_mm});
+    transform.translate(Vector3{0.0_mm, 0.0_mm, i * kSurfaceSpacing});

263-266: GeometryId creation, more explicit it should be!

A helper function for GeometryId creation, clearer intent would show.

+    auto createGeometryId = [](int index) {
+      return Acts::GeometryIdentifier()
+          .setVolume(1)
+          .setLayer(1)
+          .setSensitive(index + 1);
+    };
-    surface->assignGeometryId(
-        Acts::GeometryIdentifier().setVolume(1).setLayer(1).setSensitive(i +
-                                                                         1));
+    surface->assignGeometryId(createGeometryId(i));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a4c92f and 5bf11c7.

📒 Files selected for processing (2)
  • Core/include/Acts/Propagator/DirectNavigator.hpp (2 hunks)
  • Tests/UnitTests/Core/Propagator/DirectNavigatorTests.cpp (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Core/include/Acts/Propagator/DirectNavigator.hpp
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: merge-sentinel
  • GitHub Check: unused_files
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: missing_includes
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: macos
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, g++)
  • GitHub Check: linux_ubuntu
  • GitHub Check: build_debug
🔇 Additional comments (1)
Tests/UnitTests/Core/Propagator/DirectNavigatorTests.cpp (1)

25-25: Hmmmm, good this include addition is!

For the new test cases, necessary this StraightLineStepper include is.

kodiakhq bot pushed a commit that referenced this pull request Jan 28, 2025
Pulled out of #3999 

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

## Release Notes

- **New Features**
  - Enhanced navigation initialization for direct navigator.
  - Added more comprehensive testing for navigation scenarios.

- **Tests**
  - Introduced new test case for forward and backward surface navigation.
  - Added navigation break abort logic for more robust testing.

- **Improvements**
  - Streamlined surface index determination method.
  - Improved logging for navigation direction.
  - Updated hash values for test files related to refitting and tracking.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@github-actions github-actions bot removed the Component - Core Affects the Core module label Jan 28, 2025
andiwand
andiwand previously approved these changes Jan 29, 2025
andiwand
andiwand previously approved these changes Jan 29, 2025
@benjaminhuth benjaminhuth changed the title fix: Write correct tracks to file for refitting, mask FPE fix: Write correct tracks to file for refitting, prevent FPE Jan 29, 2025
Copy link

@kodiakhq kodiakhq bot merged commit 8d100b2 into acts-project:main Jan 30, 2025
42 checks passed
@acts-project-service acts-project-service added the Fails Athena tests This PR causes a failure in the Athena tests label Jan 30, 2025
paulgessinger pushed a commit to paulgessinger/acts that referenced this pull request Jan 30, 2025
…oject#3999)

Unfortunately, there where the KF tracks written to files so far.
@paulgessinger paulgessinger modified the milestones: next, v39.0.0 Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes Performance Component - Examples Affects the Examples module Fails Athena tests This PR causes a failure in the Athena tests fpe Floating point exception Infrastructure Changes to build tools, continous integration, ...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants