Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/CommonParam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ Or changing the name of this parameter set

<param_set name="Lepton">
<param type="bool" name="ApplyCoulombCorrection"> false </param>
<!-- Q^2 threshold for em scattering events, in GeV^2 (was hardcoded as
static const double kMinQ2Limit in src/Framework/Utils/KineUtils.h) -->
<param type="double" name="EM-MinQ2Limit"> 0.02 </param>

</param_set>

Expand Down
25 changes: 25 additions & 0 deletions src/Framework/Utils/KineUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sstream>

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)
Expand Down
7 changes: 6 additions & 1 deletion src/Framework/Utils/KineUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down