Skip to content

Make the EM Q2 threshold (kMinQ2Limit) configurable via CommonParam#502

Open
LiangLiu212 wants to merge 1 commit into
GENIE-MC:masterfrom
LiangLiu212:dev/em-minq2-tunable
Open

Make the EM Q2 threshold (kMinQ2Limit) configurable via CommonParam#502
LiangLiu212 wants to merge 1 commit into
GENIE-MC:masterfrom
LiangLiu212:dev/em-minq2-tunable

Conversation

@LiangLiu212

Copy link
Copy Markdown
Contributor

Motivation

The minimum Q2 for electromagnetic scattering events is a hardcoded constant in src/Framework/Utils/KineUtils.h:

static const double kMinQ2Limit = 0.02;  // GeV^2

Any study that needs a different EM low-Q2 boundary (e.g. electron-scattering validation work where the generation threshold must be varied) currently requires patching and rebuilding GENIE.

Change

Replace the constant with a small proxy object that reads EM-MinQ2Limit from CommonParam.xml [Lepton] lazily on first use and caches it for the lifetime of the program:

  • KineUtils.hkMinQ2Limit becomes extern const EMMinQ2LimitProxy, a struct with operator double(), so every existing call site compiles and behaves unchanged.
  • KineUtils.cxx — the proxy implementation: one read of CommonParam[Lepton]/EM-MinQ2Limit via AlgConfigPool (lazy, so the pool is guaranteed initialised), cached in a function-local static, logged once at pNOTICE for provenance.
  • CommonParam.xml — adds EM-MinQ2Limit to the [Lepton] param set with the historical default 0.02.

Backwards compatibility

Default behaviour is identical: if the parameter (or the registry) is absent the proxy falls back to the historical 0.02 GeV^2, and the shipped CommonParam.xml sets exactly that value. No call-site changes anywhere in the codebase.

Validation

An equivalent patch has been exercised in our local electron-scattering builds: tunes overriding EM-MinQ2Limit between 0.02 and ~1.2 GeV^2 via per-tune CommonParam.xml overlays show the expected generation-level Q2 cut in both gmkspl splines and gevgen event samples (e- on C12, O(10M)-event productions), while builds without an override reproduce the previous hardcoded behaviour.

🤖 Generated with Claude Code

The minimum Q2 for electromagnetic scattering events was a hardcoded
constant (static const double kMinQ2Limit = 0.02 GeV^2) in KineUtils.h,
so studies of the EM low-Q2 region required rebuilding GENIE.

Replace the constant with an EMMinQ2LimitProxy that lazily reads
"EM-MinQ2Limit" from CommonParam.xml [Lepton] on first use and caches
it for the lifetime of the program. The proxy converts implicitly to
double, so every existing call site compiles unchanged, and it falls
back to the historical 0.02 GeV^2 if the parameter or registry is
absent -- default behaviour is identical. The chosen value is logged
once at pNOTICE for provenance.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LiangLiu212 LiangLiu212 requested review from nusense and sjgardiner June 9, 2026 22:30
@LiangLiu212

Copy link
Copy Markdown
Contributor Author

I currently work on (e, e'p) analysis. I create this PR via claude code just with prompt.

Although I open this PR, I do not intend to include it in the v3.8 release.

@jtenavidal

jtenavidal commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This work is already ongoing in #492 and was presented last week at the GENIE core meeting. It had a lot of discussion and feedback. Pablo is already working on it.

We discussed the implementation at the GENIE meeting with specific input needs from e4nu. I would recommend avoiding duplication of efforts.

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