Skip to content

Add configurable Q2 minimum cuts and spline consistency metadata#492

Open
Pabce wants to merge 8 commits into
GENIE-MC:masterfrom
Pabce:command-line-q2
Open

Add configurable Q2 minimum cuts and spline consistency metadata#492
Pabce wants to merge 8 commits into
GENIE-MC:masterfrom
Pabce:command-line-q2

Conversation

@Pabce
Copy link
Copy Markdown

@Pabce Pabce commented May 21, 2026

Summary

Adds a configurable phase-space Q2 minimum cut, initially used for EM/electron interactions, with optional weak-interaction support through XML configuration or --q2-min.

Main Changes

  • Add KPhaseSpaceCuts as the central service for configurable Q2 cuts.
  • Add CommonPhaseSpaceCuts.xml configuration XML as the single source of truth for Q2 cuts, and potential future kinematic cuts in other variables.
  • Add --q2-min to gevgen and gmkspl.
  • Apply the configured cut consistently across phase-space and affected physics modules.
  • Record Q2 cut metadata in spline XML output.
  • Make gevgen reject spline files whose recorded Q2 cut is missing or inconsistent when an effective cut is active.

Validation

  • Added gtestKPhaseSpace coverage for EM defaults, weak defaults, command-line overrides, probe-aware spline metadata, and XML round-tripping.

IMPLEMENTATION_REPORT.md

Pabce and others added 7 commits January 13, 2026 23:25
Add EM-Q2-min parameter to CommonParam.xml [Kinematics] section,
allowing users to configure the minimum Q^2 threshold for EM scattering
events without recompiling. Default value is 0.02 GeV^2 (unchanged).

CRITICAL FIX: DISKinematicsGenerator was sampling (x,y) and converting
to Q^2 without checking if Q^2 >= Q2min, allowing events to leak below
the threshold. Added explicit Q^2 check in event generation loop.

Changes:
- Add EM-Q2-min parameter to 5 config files (main + 4 GEM tunes)
- Add KPhaseSpace::GetQ2MinEM() to load config value at runtime
- Update KineUtils electromagnetic functions to accept Q2min parameter
- Fix 8 physics modules that used hardcoded kMinQ2Limit constant:
  * DISKinematicsGenerator: Add Q^2 threshold check (critical bug fix)
  * RESKinematicsGenerator: Use config value in max xsec calculation
  * MECGenerator, MECUtils, SuSAv2MECPXSec, EmpiricalMECPXSec2015
  * QELEventGeneratorSuSA, SuSAv2QELPXSec

Users must regenerate cross-section splines after changing EM-Q2-min.

17 files modified. See IMPLEMENTATION_REPORT.md for details.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The explicit Q² threshold check in DISKinematicsGenerator.cxx has been
removed after testing confirmed that the implicit enforcement mechanism
works correctly. The Q²min threshold is properly enforced through the
existing kinematic validation chain:
  ValidKinematics() → IsAllowed() → Q2Lim_W() → InelQ2Lim_W()

This approach is cleaner and more consistent with how other kinematic
constraints are handled in GENIE.

Updated IMPLEMENTATION_REPORT.md to reflect this change:
- Removed the "Critical Issue" section about DISKinematicsGenerator
- Updated file count from 17 to 16 modified files
- Added note about the implicit enforcement mechanism

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add the ability to override the EM-Q2-min parameter (minimum Q^2 threshold
for electromagnetic scattering events) from the command line, without
requiring modification of CommonParam.xml.

Changes to both gevgen (gEvGen.cxx) and gmkspl (gMakeSplines.cxx):
- Parse new --em-q2-min <value> argument (value in GeV^2)
- Override the Registry value after BuildTune() loads XML configs
- Add documentation in help text and header comments
- Log the override value in job configuration output

This allows users to easily test different Q^2 thresholds without editing
XML configuration files or regenerating builds.

Usage examples:
  gevgen ... --em-q2-min 0.5
  gmkspl ... --em-q2-min 0.5
@Pabce
Copy link
Copy Markdown
Author

Pabce commented May 21, 2026

The "enable pi0 decays by default" was a local change that got into the branch by accident - but it is now reverted.

@Pabce Pabce force-pushed the command-line-q2 branch from 36d703e to a41866d Compare May 21, 2026 16:41
@Pabce Pabce force-pushed the command-line-q2 branch from a41866d to 28a9ba2 Compare May 21, 2026 16:48
@Pabce
Copy link
Copy Markdown
Author

Pabce commented May 22, 2026

Example spline generated with gmkspl -p 11 -t 1000180400 -e 8.0 -n 3 --event-generator-list EM -o gxspl_eAr40_Q2min010.xml --tune G18_10a_02_11a --q2-min 0.10.

The relevant Q2 cut information is placed as:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- generated by genie::XSecSplineList::SaveSplineList() -->

<genie_xsec_spline_list version="3.00" uselog="1">

  <genie_tune name="G18_10a_02_11a">

    <kinematics>
      <q2 min="0.1" unit="GeV^2" source="command-line --q2-min"/>
    </kinematics>
[...]

gxspl_eAr40_Q2min010.xml

@jtenavidal jtenavidal requested review from jtenavidal and nusense May 27, 2026 12:33
Comment thread src/Apps/gMakeSplines.cxx
// Q2 minimum override
gOptQ2MinSet = false;
if(parser.OptionExists("q2-min")) {
LOG("gmkspl", pINFO) << "Reading Q2 minimum cut override";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a more descriptive message like
LOG("gmkspl", pINFO) << "Overiding minimum Q2 phase-space minimum by "<< gOptQ2Min ;

Comment thread src/Apps/gMakeSplines.cxx
cross-section calculation for nuclear targets.
--q2-min
Override the minimum Q^2 phase-space cut (in GeV^2). For weak
interactions, this explicitly opts the run into the Q2 cut.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a new feature, I would specify where this is by default setup for EM interactions.
Quote the CommonPhaseSpaceCuts.xml file


ClassImp(KPhaseSpace)

namespace {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Q2l = kinematics::DarkQ2Lim_W(Ev,M,ml,W);
} else {
Q2l = is_em ? kinematics::electromagnetic::InelQ2Lim_W(Ev,ml,M,W) : kinematics::InelQ2Lim_W(Ev,M,ml,W);
Q2l = is_em ? kinematics::electromagnetic::InelQ2Lim_W(Ev,ml,M,W,0.) : kinematics::InelQ2Lim_W(Ev,M,ml,W);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this enforcing 0 for everything but em?
Doesn't it need to still be configurable?

Range1D_t Q2Lim_W_SPP_iso (void) const; ///< Q2 limits @ fixed W for resonance single pion production on isoscalar nucleon

static double GetTMaxDFR();
static double GetQ2MinEM(); ///< Deprecated; use KPhaseSpaceCuts instead.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we remove the function?

bool fHasQ2MinOverride;
double fQ2MinOverride;

struct Cleaner {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is also not the standard way to do this in GENIE. To discuss later.

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