Skip to content

mg7 launch: translate madevent run_card names in "set" (cuts, beams, PDFs, scale codes) - #247

Open
oliviermattelaer wants to merge 4 commits into
mainfrom
claude/gifted-gagarin-2d3d24
Open

oliviermattelaer wants to merge 4 commits into
mainfrom
claude/gifted-gagarin-2d3d24

Conversation

@oliviermattelaer

@oliviermattelaer oliviermattelaer commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Targets main (it was stacked on #223, merged 2026-10-10). Three commits plus a merge of main.

Summary

At the mg7 launch question, madevent run_card.dat names that the run_card.dat -> run_card.toml conversion (RunCardMG7.from_LO) already handles were lost. They printed WARNING: invalid set command ... and the run went on with the mg7 default; seen on main 44b8e19, where a p p > e+ e- run integrated with no m_ll cut. Two of them aborted a scripted launch outright. This PR translates them the way from_LO does.

Commit 1: cut names (set mmll 200, set ptj 30, set etaj -1, set ihtmin 100, ...)

  • New RunCardMG7.set_lo_cut writes the [cuts] entry from_LO uses. It writes only to [cuts], never [histograms], which shares the key syntax (e.g. sqrt_s.min).
  • A minimum <= 0 or a negative maximum removes the bound, as in from_LO (shared _lo_cut_is_active).
  • A cut on a _LO_CUT_GROUPS group (parton, alllepton) also adds that group, or the launch fails with KeyError: 'parton'.

Commit 2: beam, PDF and scale settings

  • set dynamical_scale_choice 3 / set sde_strategy 2: these used to abort a launch script with InvalidCardEdition ("Please report this bug"). The integer codes and the madevent et/shat/ckkw names now become the mg7 names. Codes with no mg7 equivalent (0 = user-defined, -1 = CKKW) warn and keep the current value. HT and HT/n stay with the generic editor, as before.
  • Values translated as in the conversion:
    • ebeam1, ebeam2 (and the set ebeam shortcut, with energy units) → beam.e_cm
    • lpp1, lpp2 (and set lpp) → beam.leptonic
    • pdlabel, pdlabel1, pdlabel2, lhaid → beam.pdf
    • fixed_fac_scale(1/2) → beam.fixed_fact_scale
    • maxjetflavor → the jet group
    • the per-pdg cuts {pdg: value} → a pdg<N> group plus its cut. mxx_only_part_antipart picks pair_mass or sfos_pair_mass, whichever of the two is set first.
  • One value for both beams: mg7 has one energy, one PDF and one lepton flag for both beams, so the per-beam settings of one question are combined. ebeam1 and ebeam2 give e_cm = 2 sqrt(E1 E2); lpp1 and lpp2 give beam.leptonic. What still differs per beam is reported once, when the question closes (MG7Selector.check_card_consistency), so set ebeam1 X followed by set ebeam2 X stays quiet.
  • Docs: the "Coming from MadEvent" docs page lists what is translated.

Commit 3: per-pdg cuts in the run_card.dat conversion

  • A run_card.dat is read with string pdg keys (pt_min_pdg = {6: 100} gives {'6': 100.0}), but from_LO (from Document the mg7 run card (run_card.toml) #223) only took integer keys. So the per-pdg cuts of a real card were dropped without a report. Document the mg7 run card (run_card.toml) #223's test set the dicts with integer keys directly, which hid it.
  • _lo_pdg_dict turns the keys into integers (keeping default) before from_LO reads them. New test test_from_LO_pdg_cuts_read_from_a_run_card writes and rereads a real run_card.dat; without the fix it fails with KeyError: 'pdg6-pt'.

Interplay with #154 (one energy and one PDF per beam)

#154 routes ebeam*, lpp*, pdlabel* and lhaid to its per-beam keys through RunCardMG7.set_lo_beam_param (lo_beam_params). Whichever PR merges second should make set_lo_param hand those names to set_lo_beam_param and drop the "one value for both beams" warnings for them. fixed_fac_scale, maxjetflavor, the per-pdg cuts and the integer codes stay here.

Testing

  • After merging main (df50882): test_banner.py 85 tests OK, test_mg7_launch.py 93 OK (none skipped, madspace rebuilt), tests/unit_tests/madspin 665 OK. A fresh p p > e+ e- launch with set mmll 200, dynamical_scale_choice 3, sde_strategy 2, ebeam 6800, pt_min_pdg {11: 30} applies them all and gives 1.528 pb.
  • Before the merge: tests/unit_tests/various/test_banner.py: 83 tests OK. New: test_set_lo_cut, test_set_lo_cut_composite, test_set_lo_param_value_translation, test_set_lo_param_beams_combine, test_set_lo_param_pdg_cuts, and test_set_lo_param_matches_from_LO (set lands where from_LO puts the same values).
  • tests/unit_tests/interface/test_mg7_launch.py: 92 tests OK, none skipped (madspace built from this branch). The new tests stub the generic editor and assert it is never reached for these names, and that mg7 values (transverse_mass, denominators, HT/4) still are.
  • tests/unit_tests/madspin: 665 tests OK.
  • All 224 run_card.dat parameters were run through the real launch question one by one, before and after this change.
  • End to end with bin/madgraph:
launch script result
p p > e+ e-, set mmll 200, set mmllmax 1000 1.455(14) pb
same with mmll 0 / mmllmax -1 (cut removed) 891.9 pb
p p > e+ e- j, mmll 60 226.3 pb
same plus ihtmin 100, ptllmin 50 13.88 pb
script with dynamical_scale_choice 3 and 0, sde_strategy 2, ebeam 6800, maxjetflavor 4, lpp1/2 1, fixed_fac_scale F, pt_min_pdg {11: 30}, ebeam1 7000, ebeam2 4000 no abort, no "invalid set command"; card has e_cm = 10583, denominators, the 4-flavour jet group and pdg11-pt.min = 30; one asymmetric-beam warning after the question; 503.0 pb
  • No Sphinx locally: the edited .rst page was checked with docutils (no warnings).

MG7Selector.do_set translated the madevent scalar names (_LO_SCALAR_MAP)
but not the cut names, so "set mmll 200" in a launch script printed
"invalid set command" and the run went ahead without the cut.

Cut names in RunCardMG7._LO_CUT_MAP now go through the new
RunCardMG7.set_lo_cut, which writes the [cuts] entry that from_LO uses
(never [histograms], which shares the key syntax). A minimum <= 0 or a
negative maximum removes the bound, as in from_LO, which now shares the
rule through _lo_cut_is_active. A cut on a _LO_CUT_GROUPS group (ihtmin,
ptllmin, mmnl) also adds that group to [multiparticles] when the card
lacks it; without it the launch fails with KeyError: 'parton'.

Checked end to end: p p > e+ e- with set mmll 200 / mmllmax 1000 gives
1.455 pb (891.9 pb once both are reset to 0 / -1); p p > e+ e- j with
mmll 60 goes from 226.3 pb to 13.88 pb with ihtmin 100 and ptllmin 50.
@oliviermattelaer
oliviermattelaer force-pushed the claude/gifted-gagarin-2d3d24 branch from f798323 to 3f4b065 Compare October 9, 2026 14:09
Base automatically changed from feat-run-card-docs to main October 10, 2026 10:13
At the mg7 launch question, settings that the run_card.dat conversion
(from_LO) handles were still lost:
- "set ebeam1 6500", "set ebeam 6800", "set lpp1 0", "set pdlabel ...",
  "set lhaid ...", "set fixed_fac_scale ...", "set maxjetflavor 5" and the
  per-pdg cuts ("set pt_min_pdg {6: 100}") printed "invalid set command"
  and the run went on with the mg7 default;
- "set dynamical_scale_choice 3" and "set sde_strategy 2" (madevent's
  integer codes) went to the mg7 key of the same name, which only takes
  names, and aborted a scripted launch with InvalidCardEdition.

RunCardMG7.set_lo_param now translates them as from_LO does: the integer
codes and the et/shat/ckkw shortcuts to the mg7 names (HT and HT/n stay
with the generic editor), maxjetflavor to the jet group, the {pdg: value}
cuts to a pdg<N> group plus its cut (mxx_only_part_antipart choosing
pair_mass or sfos_pair_mass, in either order), pdlabel/lhaid to beam.pdf
through the same tables. Values with no mg7 equivalent warn and keep the
current setting instead of aborting.

mg7 has one energy, one PDF and one lepton flag for both beams, so the
per-beam settings of one launch question are combined: ebeam1 and ebeam2
give e_cm = 2 sqrt(E1 E2), lpp1 and lpp2 give beam.leptonic. What still
differs per beam is reported once, when the question closes
(MG7Selector.check_card_consistency), so "set ebeam1 X" followed by
"set ebeam2 X" stays quiet. PR #154 (one energy and one PDF per beam)
routes the beam names to its per-beam keys through set_lo_beam_param;
whichever merges second hands them over to it.

from_LO now builds the jet and pdg groups with the same helpers.
@oliviermattelaer oliviermattelaer changed the title mg7 launch: translate madevent cut names in "set" (set mmll 200, ...) mg7 launch: translate madevent run_card names in "set" (cuts, beams, PDFs, scale codes) Oct 10, 2026
A run_card.dat is read with string pdg keys (pt_min_pdg = {6: 100}
gives {'6': 100.0}), but from_LO only took integer keys, so the per-pdg
cuts (pt/e/eta_min/max_pdg, mxx_min_pdg with mxx_only_part_antipart) of
a real card were dropped without a report. The existing test set the
dicts with integer keys directly, which hid it.

_lo_pdg_dict turns the keys into integers (keeping 'default') before
from_LO reads them.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant