Skip to content

Relax the Geant4 field epsilons outside the muon spectrometer and support local field parameters - #15852

Open
sawenzel wants to merge 2 commits into
AliceO2Group:devfrom
sawenzel:g4-field-params
Open

sawenzel wants to merge 2 commits into
AliceO2Group:devfrom
sawenzel:g4-field-params

Conversation

@sawenzel

@sawenzel sawenzel commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

This PR takes a look at the Geant4 field integration parameters with the goal to achieve faster CPU while maintaining the current physics output.

The PR relaxes the minimum epsilon of the Geant4 field integration, keeps the tight value in the muon spectrometer through local fields, and adds the O2 support that local field parameters need. It reduces the transport CPU time in pp by 10%, while the tracking accuracy stays unchanged.

The current tight settings in g4config.in go back to the ALIROOT-7121 Geant4 validation of 2018. There, deltaIntersection and both epsilons were tightened together to remove a 1/pT bias of the TrackRef refit. With Geant4 11.2 the bias is still present at the default deltaIntersection, but only deltaIntersection controls it. The epsilons do not affect it. Geant4 uses for each step ε = deltaOneStep / L, clamped to [ε_min, ε_max] (G4PropagatorInField::ComputeStep), so ε_max governs short steps and ε_min governs long steps. The long steps in the air of the muon spectrometer need the tight ε_min; nothing else does.

Field-integration parameters

The bias was measured as in ALIROOT-7121. Single 100 GeV tracks were simulated in a uniform 0.5 T field, and the ITS and TPC TrackRefs were refitted with a circle. At deltaIntersection = 1e-3 mm (Geant4 default), the ITS+TPC 1/pT is shifted by −0.3% for μ± and by −0.68% for charged geantinos. At 1e-5 mm the shift is compatible with zero, and it is identical for every ε_max in {1e-5, 1e-4, 1e-3}.

1/pT bias vs deltaIntersection

In the barrel, the epsilons have no measurable effect. Geantinos between 0.3 and 100 GeV were compared track by track with an ultra-tight uncached reference in the real field map, and with the exact helix in a uniform field. With the settings of this PR, and even with ε_min = ε_max = 1e-3, all TrackRef positions agree with the current ones (median deviation from the exact helix 0.02–0.16 µm in the ITS). Full-physics μ± at 1, 10 and 100 GeV give results identical to the current settings.

In the muon arm, the bias was measured as its counterpart there: the displacement at the last MCH station along the dipole deflection, relative to that deflection, which corresponds to the relative momentum shift. A relaxed ε_min moves the positions by about 45 µm (median, against 6–9 µm now) and shifts the momentum scale by up to −120 ppm. The volumes YOUT1, DDIP and YOUT2 therefore keep the tight epsilons as local fields. With ε_min = 1e-4 elsewhere, the median momentum-scale shift is below 35 ppm and its rms about 100 ppm (currently 45 ppm), negligible against the momentum resolution of the muon spectrometer. Relaxing ε_max alone changes nothing, neither in accuracy nor in CPU time.

Muon-arm momentum-scale shift per configuration

Local field parameters

Geant4 VMC builds a local field only for a TGeo volume that carries a field. O2 attaches the field only globally, so the per-volume parameters created with /mcDet/createMagFieldParameters had no effect. The Geant4 run configuration is moved from FastSim to Detectors/gconfig as o2::g4config::G4RunConfiguration; fast simulation now provides its parts through two factory functions, with unchanged behaviour. The new G4LocalFieldConstruction attaches the global field to every volume that has its own parameter directory /mcMagField/<vol>/ and switches on local fields in Geant4 VMC. The configuration therefore lives entirely in g4config.in, and the step does nothing when no volume has local parameters.

Geant4 VMC forces a local field onto all daughters of a volume, which would switch the field on inside zero-field media. A volume whose subtree contains a medium with ifield = 0 is therefore refused with a warning. Local fields are built only with TGeo navigation; with G4.navmode=kG4 a warning is issued, and the global field applies everywhere.

Where the field is evaluated

In pp, 74% of all evaluations of o2::field::MagneticField::Field occur on the A side at z = 4–8.5 m and small radius, in the fringe field of the solenoid, where no detector needs tracking precision. About 20% occur in the central barrel and 3% in the muon arm. The relaxed ε_min removes 26% of all evaluations, mostly on the A side.

Field evaluations in (z, r)

Performance and validation

configuration CPU s/event
current 6.8–6.9
this PR 6.1–6.2

The timings come from pp at 13.6 TeV (512 events, -j 32, EPYC 7552), with the runs alternated with the baseline on an otherwise idle node. For the physics check, 3000 pp events per configuration were simulated in a uniform field with two seeds, and compared event by event against the current settings. A null configuration, which changes only the random sequence, sets the scale for the fluctuations. The hit counts in all detectors and the TrackRef 1/pT refit of charged primaries stay within that spread. The change was tested as an overlay of libO2FastSim and libO2G4Setup on MC-prod-2026-v12-1; pp events are reproducible run to run with local fields.

Hits per event vs current settings

TrackRef 1/pT refit in pp

Further gains are followed up separately: the DormandPrince745 stepper and ε_min = 1e-3 would bring −15%, but they displace a small fraction of muon-arm tracks that cross the edge of the dipole field map, which drops from 7 kG to zero at a polar angle of 9.7°.

Overall, the field-integration settings now keep only the tightening that the ALIROOT-7121 bias requires, plus a tight ε_min where the muon arm needs it, and O2 can set field parameters per volume.

https://its.cern.ch/jira/browse/O2-7198
https://alice.its.cern.ch/jira/browse/ALIROOT-7121

Assisted by Claude Code.

sawenzel and others added 2 commits September 25, 2026 17:10
This moves the O2 Geant4 VMC run configuration out of FastSim, so that other features can extend it.

- G4RunConfiguration is now o2::g4config::G4RunConfiguration in Detectors/gconfig, built into G4Setup.
- FastSim provides the fast simulation and its regions through createFastSimulation() and createFastSimRegionConstruction().
- The behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This relaxes the Geant4 field-integration epsilons, keeps them tight as local fields in the muon spectrometer, and adds the support for local field parameters.

- The tight epsilons from ALIROOT-7121 do not affect the 1/pT bias; only deltaIntersection does, and it stays at 1e-5 mm.
- minimumEpsilon controls the long steps; relaxing it to 1e-4 moves nothing in the barrel, but it would move MCH positions, so YOUT1, DDIP and YOUT2 keep the tight values.
- G4LocalFieldConstruction attaches the global field to every volume given its own parameters with /mcDet/createMagFieldParameters, so that the /mcMagField/<vol>/ settings take effect.
- A volume whose subtree contains zero-field media is refused, since Geant4 VMC forces a local field onto all daughters.
- This saves about 10% of the transport CPU time in pp.

https://its.cern.ch/jira/browse/O2-7198
https://alice.its.cern.ch/jira/browse/ALIROOT-7121

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sawenzel
sawenzel requested a review from a team as a code owner September 25, 2026 15:10
@shahor02

Copy link
Copy Markdown
Collaborator

@sawenzel to be sure: the last plot on relative pT bias shows a purely circular fit w/o e-loss correction?

@sawenzel

Copy link
Copy Markdown
Collaborator Author

@sawenzel to be sure: the last plot on relative pT bias shows a purely circular fit w/o e-loss correction?

@shahor02 : Yes, it is a purely geometric circle fit of the TrackRef positions in the transverse plane (uniform 5 kG field, no e-loss or MS correction, no vertex constraint), compared with the radius from the generated pT at the vertex.

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

Development

Successfully merging this pull request may close these issues.

2 participants