acts icon indicating copy to clipboard operation
acts copied to clipboard

feat: Add a tool for writing B-fields to disk in CSV format

Open stephenswat opened this issue 3 years ago • 11 comments

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.

stephenswat avatar Aug 26 '22 16:08 stephenswat

Codecov Report

Merging #1470 (3535486) into main (b032bd2) will increase coverage by 0.07%. The diff coverage is n/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

codecov[bot] avatar Aug 26 '22 17:08 codecov[bot]

Is this good to go? There are still conversations unresolved.

asalzburger avatar Aug 29 '22 12:08 asalzburger

I think we're waiting for some comments from @timadye.

stephenswat avatar Aug 29 '22 13:08 stephenswat

Okay, unless Tim has any comments on the outstanding issue I think this is good to go from my side.

stephenswat avatar Sep 01 '22 08:09 stephenswat

Sorry, I was away. I'll take a look today.

timadye avatar Sep 01 '22 08:09 timadye

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.

timadye avatar Sep 01 '22 15:09 timadye

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.

timadye avatar Sep 01 '22 16:09 timadye

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.

stephenswat avatar Sep 02 '22 08:09 stephenswat

@timadye @stephenswat can you advise if we can merge this?

paulgessinger avatar Oct 03 '22 08:10 paulgessinger

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.

timadye avatar Oct 03 '22 09:10 timadye

I have incorporated Tim's patches, and marked him appropriately as a co-author of the commits.

stephenswat avatar Oct 17 '22 12:10 stephenswat

this conflicts now with https://github.com/acts-project/acts/pull/1510

happy to re-approve after the conflict is resolved

andiwand avatar Oct 27 '22 09:10 andiwand

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:

  1. harmonize the runXyzGrid() methods with the RootBFieldWriter and others.
  2. replace my ugly dynamic_cast with 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?

timadye avatar Oct 27 '22 11:10 timadye

Hi @stephenswat - can you resolve the conflict here? Then we should be able to get this in.

asalzburger avatar Nov 08 '22 14:11 asalzburger

Conflict resolved.

stephenswat avatar Nov 09 '22 12:11 stephenswat

Let me test this now, and then I hope we can merge this sucker.

timadye avatar Nov 09 '22 12:11 timadye

: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

github-actions[bot] avatar Nov 09 '22 12:11 github-actions[bot]