Skip to content

Implement external generator for Monopoles - #2557

Open
jackal1-66 wants to merge 1 commit into
AliceO2Group:masterfrom
jackal1-66:monopoleGen
Open

jackal1-66 wants to merge 1 commit into
AliceO2Group:masterfrom
jackal1-66:monopoleGen

Conversation

@jackal1-66

@jackal1-66 jackal1-66 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds a configurable external generator for magnetic monopoles to O2DPG, so that monopole
samples can be produced from a highly configurable JSON configuration. A new BSM folder is also created to contain the future generators of the newly created PAG.
Two production modes are available at the moment, selected by "mode":

  • schwinger — a monopole/antimonopole pair, back-to-back in the pair rest frame, as produced
    by the Schwinger mechanism in the field of an ultraperipheral heavy-ion collision. The default
    spectrum is Maxwell–Jüttner, dN/dp ∝ p² exp(-√(p²+m²)/T) with T = 18.37 GeV, obtained from an
    unbinned maximum-likelihood fit to the reference PbPb HepMC samples. @igor Ostrovskiy if you could check this specific part it would be highly appreciated. The temperature was fitted from your data, but if you have a specific value I can just set it there.
  • single — independent single monopoles, charge sign fixed or random.

The idea is that in the future people could add more simulation modes by using the same external generator.
Every quantity — mass, magnetic charge, multiplicity, momentum, direction, azimuth, vertex, recoil —
is a value spec: a fixed number, a weighted list, or a draw from uniform, loguniform, gaus,
exp, powerlaw, poisson, thermal or an arbitrary formula (any TFormula), with optional
truncation, "integer": true and "sampleOnce": true. Non-analytic shapes are drawn from a
tabulated inverse CDF built once at startup. The momentum magnitude can be given as p, pt,
ekin or etot and the direction as eta, y, theta or costheta. Unknown JSON keys will cause an error during execution, so that the users do not lose time generating with an unwanted configuration.
The transported monopole mass and magnetic charge are transport settings (G4.monopoleMass,
G4.monopoleMagneticCharge) and are read in a different process than the generator, so
it cannot set them. They have to be given on the command line or, as in the ini file here,
in a [G4] section. The generator reads them back and refuses to start when they disagree with its
own configuration (transport.onMismatch: fatal by default, warn, ignore). When the JSON
leaves the mass or the charge open and the transport key was given explicitly, the transport value
is adopted, so a mass scan is one JSON file plus a varying G4.monopoleMass.
I validated the full development using both standalone o2-sim and O2DPG workflows, running multiple pass with various configurations.

@jackal1-66
jackal1-66 requested a review from sawenzel as a code owner November 18, 2026 14:38
@github-actions

Copy link
Copy Markdown

REQUEST FOR PRODUCTION RELEASES:
To request your PR to be included in production software, please add the corresponding labels called "async-" to your PR. Add the labels directly (if you have the permissions) or add a comment of the form (note that labels are separated by a ",")

+async-label <label1>, <label2>, !<label3> ...

This will add <label1> and <label2> and removes <label3>.

The following labels are available
async-2023-pbpb-apass4
async-2023-pp-apass4
async-2024-pp-apass1
async-2022-pp-apass7
async-2024-pp-cpass0
async-2024-PbPb-apass1
async-2024-ppRef-apass1
async-2024-PbPb-apass2
async-2023-PbPb-apass5

@sawenzel

Copy link
Copy Markdown
Contributor

Thanks for this nice and very complete generator. I tested it with O2sim v20261123 on an EL9 machine: the CI-style runs (o2-sim-dpl-eventgen and o2-sim --noGeant), a full Geant4 run with PIPE, ITS and TPC, and a direct sampling of the Schwinger spectrum. The monopole physics gets attached, hits are produced, and the sampled momenta agree with the analytic Maxwell-Juettner shape (mean p 82.41 vs 82.46 GeV, KS probability 0.89). A wrong G4.monopoleMass is caught as intended.

However, there are a few things that I would recommend fixing before merging:

  • The Config-check job fails because the usage comment on line 50 of GeneratorMonopoles.C contains $O2DPG_ROOT. Writing $O2DPG_MC_CONFIG_ROOT there fixes it.
  • Unknown keys are only rejected at the object level, not inside a value specification. For instance, "p": {"dist": "thermal", "temperatur": 40} is accepted and runs silently with the default T = 18.37 GeV. MonoValue::parse should check the allowed keys per dist as well.
  • drawMomentum silently skips draws that are kinematically impossible (for instance etot < m cosh(y)), which changes the configured distributions without any message. With monopoles_showcase.json, the rapidity is configured as a Gaussian with sigma 1.5, but the generated one has an RMS of 0.66 and |y| < 2.34. Counting the rejections and warning (or failing) when the acceptance becomes small would make this visible.
  • MonopolesTransportKeys() aborts in plain ROOT when the JSON leaves the mass or the charge open, which is the mass-scan use case. finaliseConfig still queries G4Params and the parameter provenance in the report mode, and outside o2-sim this ends in Assertion 'enumtype != nullptr' failed in ConfigurableParamHelper.cxx. Skipping the transport lookups when only printing the keys should solve this.

Two smaller points:

  • The showcase config uses onMismatch: "warn", so when combined with the ini file it runs with a generator charge of 3 and a transport charge of 1 without stopping. Since people will copy this file, I would prefer fatal there.
  • The note printed by MonopolesTransportKeys() says that mass and charge are not fixed even when only one of them varies.

Note that this is the only O2DPG ini that compiles its macro with ACLiC, which costs about 30 s per job. I confirmed that cling fails without the +, but the failure comes from O2's own dictionary payload for PrimaryGeneratorParam and TMCProcess. Fixing this on the O2 side, to avoid ACLiC, could be considered a follow-up. What do you think?

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.

2 participants