feat: add wrapper for musun-gs generator#42
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #42 +/- ##
==========================================
- Coverage 85.09% 80.81% -4.29%
==========================================
Files 11 12 +1
Lines 879 1032 +153
==========================================
+ Hits 748 834 +86
- Misses 131 198 +67 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new musun-gs atmospheric muon generator wrapper to revertex, including a CLI entrypoint, documentation, and tests to validate parsing and LH5 output.
Changes:
- Introduce
revertex.generators.musun_gsto run musun-gs via container, parse ASCII output, and writevtx/kin+vtx/posLH5 groups. - Add
revertex musun-gsCLI subcommand with geometry and container options. - Add unit + CLI-style integration tests and a new documentation page.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/revertex/generators/musun_gs.py |
New generator wrapper: runtime detection, container execution, output parsing, LH5 writing. |
src/revertex/cli.py |
Adds the musun-gs subcommand wiring into the CLI. |
tests/test_musun_gs.py |
Adds parser unit tests and a CLI integration test with container execution mocked. |
docs/source/musun_gs.md |
New user documentation for musun-gs generator usage and output format. |
docs/source/index.md |
Adds musun-gs doc page to the docs toctree. |
.gitignore |
Starts ignoring .python-version (appears unrelated to this PR’s stated scope). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Another point to note would be that musun generates both vertex and kinematic information. Since remage input assumes these to be separate, one would have to add them in separate input tables, which can cause potential iteration instabilities [link]. I was wondering if, in your opinion, there is interest in having an additional input option that is a combination of the two to avoid the iteration mismatch? |
I can have a look how ugly the code would get in that case |
|
The author replied that he would like to keep track of code usage himself. As a result, he does not want us to make the source code of musun-gs public in any form. I will go ahead and prepare a LEGEND internal private repository containing the corresponding Dockerfile next week. |
|
see also #43 |
I would take this as an argument, to try to switch to mute in the long term? As i think we want to keep as much of legend open-source as possible |
|
I think this is a strong motivation to prioritise transitioning to some other software in the medium term, if possible, and stop using MUSUN. It's quite sad to hear that the author explicitly wants to keep such a shared resource private, we should strongly advocate for 100% open source software as a principle |
1b1e86c to
0b57649
Compare
|
Private MUSUN-gs repository implemented [link]. It contains the original source code, as well as an adjusted version that makes it easier to modify the sampling surface and the number of sampled muons. It also contains instructions for installing the container locally. As far as I understand, we could also "publish" a Docker image on GitHub that is available only to members via GitHub Packages. Does anyone have experience with this? Would it be preferred over users building the image by themselves? |
|
sorry but i just realised MUSUN is relatively just few lines of code? let's just ask claude to rewrite in python or C++? |
|
are the MUSUN calculations/formulas published anywhere? |
|
The generator is based on the output PDFs from MUSIC [link], an MC tool transporting muons sampled from the Gaisser formula through the overburden. These PDFs, contained in the MUSUN source code, were generated by the author, and we do not have access to MUSIC. We also only have the PDFs for LNGS, thats why the restriction. |
|
ok so it's not just the code that is closed source, we can also not reproduce any result with published material. still i think we should simplify the problem by reimplementing MUSUN (and keep it private)... |
|
even when we have a new generator for muons upcoming? (see #41) |
df4d8d5 to
c6aca82
Compare
Adds a new generator module `musun_gs` that runs the musun-gs Fortran code inside a Docker/Shifter container and converts its output to the remage LH5 vtx format (vtx/kin + vtx/pos). Key points: - Configurable sampling cuboid geometry (dx/dy/dz in cm, centred at origin) - Chunks generation in batches of 1e6 muons, multiplying seed by 7 each chunk (same convention as other revertex generators) - Converts GEANT3 particle IDs (10/11) to PDG (-13/13) - Converts musun energies (GeV) to keV and computes relativistic momenta - Converts musun positions (cm) to mm for vtx/pos output - Auto-detects Docker or Shifter runtime; checks image availability - Exposes new `musun-gs-kin` CLI subcommand feat: implement musun-gs generator and update CLI commands parent d5dfd6f author Neuberger <moritz.neuberger@tum.de> 1782221829 +0200 committer Neuberger <moritz.neuberger@tum.de> 1782222847 +0200 feat: adjusted to the live version of the musun-gs repository Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> style: pre-commit fixes fix: fixes style: pre-commit fixes fix: docs fix: for shifter use docs: update musun-gs installation instructions for Shifter usage fix: docs
c6aca82 to
c07a112
Compare
|
The PR is feature complete and ready for review. |
01484e2 to
4f6f754
Compare
|
can you squash your commits again, please? |
…ions for the docs Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> fix: rate test updated fix: issues in the documentation fix: images in docs... fix: more image fixes come on implementing fixes
ebedad0 to
33ebe8c
Compare
|
Ready for merge Id say |
Co-authored-by: Manuel Huber <ManuelHu@users.noreply.github.com>
To sample muons underground at LNGS, musun has been the primary choice as a generator for many years, including for the LEGEND experiment. To automate its on-the-fly generation in simflow, it is of interest to write a wrapper for it. Similar to the implementation of the SaG4n wrapper, the executable is stored in a docker container whose output is then turned into LH5 files.
I am still preparing the docker container, but since the software does not have a clear license and is only available via direct communication with the author, I would suggest we have the docker files as a private repository in legend-exp. I will contact the author to see if he agrees to make it public.
I plan to have a slightly adjusted version of musun in the container to allow for adjustments to the sampler (n_muons, seed, sampling surface dimensions). The output from the docker is, however, identical to the original. In addition, I plan to have the flux normalization extracted via a manual call to the revertex generator from the CLI.