feat: Add a tool for writing B-fields to disk in CSV format
This PR adds a new example tool, CsvBFieldWriter, that dumps a B-field to disk in CSV format. The tool supports both grid-based and non-grid-based vector fields, it supports Cartesian and symmetrical cylindrical coordinates, and it supports user-specified ranges and bin counts.
Comes with free Python bindings.
Codecov Report
Merging #1470 (3535486) into main (b032bd2) will increase coverage by
0.07%. The diff coverage isn/a.
:exclamation: Current head 3535486 differs from pull request most recent head c9d82cc. Consider uploading reports for the commit c9d82cc to get more accurate results
@@ Coverage Diff @@
## main #1470 +/- ##
==========================================
+ Coverage 48.46% 48.54% +0.07%
==========================================
Files 384 381 -3
Lines 21071 20785 -286
Branches 9702 9536 -166
==========================================
- Hits 10213 10090 -123
+ Misses 4130 4112 -18
+ Partials 6728 6583 -145
| Impacted Files | Coverage Δ | |
|---|---|---|
| Core/src/Surfaces/RectangleBounds.cpp | 33.33% <0.00%> (-53.34%) |
:arrow_down: |
| Core/include/Acts/Surfaces/Surface.hpp | 33.33% <0.00%> (-33.34%) |
:arrow_down: |
| Core/src/Definitions/Common.cpp | 0.00% <0.00%> (-32.00%) |
:arrow_down: |
| Core/src/EventData/VectorMultiTrajectory.cpp | 66.85% <0.00%> (-10.35%) |
:arrow_down: |
| Core/src/Utilities/Logger.cpp | 30.43% <0.00%> (-8.70%) |
:arrow_down: |
| Core/include/Acts/EventData/MeasurementHelpers.hpp | 80.00% <0.00%> (-5.72%) |
:arrow_down: |
| ...e/include/Acts/EventData/VectorMultiTrajectory.hpp | 52.89% <0.00%> (-5.62%) |
:arrow_down: |
| Core/include/Acts/EventData/MultiTrajectory.ipp | 64.36% <0.00%> (-2.74%) |
:arrow_down: |
| Core/include/Acts/Propagator/ConstrainedStep.hpp | 70.21% <0.00%> (-2.13%) |
:arrow_down: |
| Core/include/Acts/Propagator/Navigator.hpp | 54.76% <0.00%> (-0.89%) |
:arrow_down: |
| ... and 35 more |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Is this good to go? There are still conversations unresolved.
I think we're waiting for some comments from @timadye.
Okay, unless Tim has any comments on the outstanding issue I think this is good to go from my side.
Sorry, I was away. I'll take a look today.
Are you planning to include a CSV reading tool? Apart from providing another good format, that would be useful to test this by writing and reading back.
I see there's a Examples/Detectors/MagneticField/src/FieldMapTextIo.cpp, but that looks like it is space-separated values.
Does this have a different interface compared to Examples/Io/Root/include/ActsExamples/Io/Root/RootBFieldWriter.hpp? It looks like this has the CsvBFieldWriter::CoordinateType coded as a template parameter, rather than an enum Config::gridType. That could be an improvement, but maybe needs considering. If it is better, we might consider changing RootBFieldWriter at a later stage. If so, do we need a more general BFieldWriter::CoordinateType or whatever?
Does this difference follow through to the Python API? It would also be nice to have a Python example and/or test to be sure it works.
Sorry for all the comments.
Hi Tim, I do have some changes in the pipeline to the Python B-field writing examples, but I opted to keep them separate from this PR for the time being. I like the idea of having a CSV reader, and I can work on implementing one.
Regarding the coordinate type enum, I agree that it might be useful to merge them, but there is also something to be said for embedding the capabilities of each writer into the class itself.
@timadye @stephenswat can you advise if we can merge this?
I still had one issue outstanding, here. I hope @stephenswat can check that.
The definitive check would be to read the ATLAS B-field, write with this PR, and check the files have the same binning. If you are not able to do that, I can give it a go.
I have incorporated Tim's patches, and marked him appropriately as a co-author of the commits.
this conflicts now with https://github.com/acts-project/acts/pull/1510
happy to re-approve after the conflict is resolved
I have incorporated Tim's patches, and marked him appropriately as a co-author of the commits.
Thanks @stephenswat! This looks good to me.
I guess you will make the other changes in a separate PR, namely:
- harmonize the
runXyzGrid()methods with theRootBFieldWriterand others. - replace my ugly
dynamic_castwith a static test, eg.if constexpr.
We discussed this in the Tuesday dev meeting and were happy to go ahead with this PR as-is. I could still test the output is correct on the ATLAS B-field. Should I do that now, or wait for you to resolve the conflict with #1510?
Hi @stephenswat - can you resolve the conflict here? Then we should be able to get this in.
Conflict resolved.
Let me test this now, and then I hope we can merge this sucker.
:bar_chart: Physics performance monitoring for c9d82cc820cff7db87e25417b829afd60b88addb
:red_square: ERROR The result has missing elements! This is likely a physmon job failure
Full report CKF: :x: seeded, :x: truth smeared, :x: truth estimated IVF: :x: seeded, :x: truth smeared, :x: truth estimated :x: Ambiguity resolution :x: Truth tracking
Vertexing :x:
:x: Vertexing vs. mu
:x: IVF seeded
:x: IVF truth_smeared
:x: IVF truth_estimated
CKF :x:
:x: CKF seeded
:x: CKF truth_smeared
:x: CKF truth_estimated
Ambiguity resolution :x:
:x: seeded
Truth tracking :x:
:x: Truth tracking