diff --git a/config/CommonParam.xml b/config/CommonParam.xml index 2d24e8e06..9929c5415 100644 --- a/config/CommonParam.xml +++ b/config/CommonParam.xml @@ -267,6 +267,9 @@ Or changing the name of this parameter set false + + 0.02 diff --git a/src/Framework/Utils/KineUtils.cxx b/src/Framework/Utils/KineUtils.cxx index 38ad3fa9b..c42ff5b8f 100644 --- a/src/Framework/Utils/KineUtils.cxx +++ b/src/Framework/Utils/KineUtils.cxx @@ -26,12 +26,37 @@ #include "Framework/Utils/KineUtils.h" #include "Framework/Numerical/MathUtils.h" #include "Framework/Interaction/InteractionException.h" +#include "Framework/Algorithm/AlgConfigPool.h" +#include "Framework/Registry/Registry.h" #include using namespace genie; using namespace genie::constants; +//____________________________________________________________________________ +// Runtime-configurable EM Q^2 threshold. The value is read once from +// CommonParam.xml [Lepton] / "EM-MinQ2Limit" and cached for the lifetime of the +// program; it falls back to 0.02 GeV^2 (the historical hardcoded value) if the +// registry is unavailable. The read is lazy (first use), so AlgConfigPool is +// guaranteed initialised by the time any EM kinematics runs. +genie::utils::kinematics::electromagnetic::EMMinQ2LimitProxy::operator double() const +{ + static const double value = []() -> double { + AlgConfigPool * pool = AlgConfigPool::Instance(); + Registry * r = pool ? pool->CommonList("Param", "Lepton") : nullptr; + const double v = r ? r->GetDoubleDef("EM-MinQ2Limit", 0.02) : 0.02; + LOG("KineLimits", pNOTICE) + << "EM-MinQ2Limit = " << v << " GeV^2 (CommonParam.xml [Lepton] registry " + << (r ? "found" : "missing, using fallback") << ")"; + return v; + }(); + return value; +} + +const genie::utils::kinematics::electromagnetic::EMMinQ2LimitProxy +genie::utils::kinematics::electromagnetic::kMinQ2Limit; + //____________________________________________________________________________ double genie::utils::kinematics::PhaseSpaceVolume( const Interaction * const in, KinePhaseSpace_t ps) diff --git a/src/Framework/Utils/KineUtils.h b/src/Framework/Utils/KineUtils.h index 74c400e80..d4a5ccc69 100644 --- a/src/Framework/Utils/KineUtils.h +++ b/src/Framework/Utils/KineUtils.h @@ -111,7 +111,12 @@ namespace kinematics Range1D_t InelYLim (double El, double ml, double M); Range1D_t InelYLim_X (double El, double ml, double M, double x); - static const double kMinQ2Limit = 0.02; // GeV^2 // Q2 threshold relevant for em scattering events + // Configurable Q^2 threshold for em scattering events (GeV^2). + // Reads "EM-MinQ2Limit" from CommonParam.xml [Lepton] on first use; falls + // back to 0.02 (the historical hardcoded value) if absent. Implicitly + // converts to double so all existing call sites compile unchanged. + struct EMMinQ2LimitProxy { operator double() const; }; + extern const EMMinQ2LimitProxy kMinQ2Limit; } } // kinematics namespace