Skip to content

Setting the SecondNucleonEmitter at run-time and enabling SRC in CC-QEL interactions#506

Open
CarlosNeutrino wants to merge 10 commits into
GENIE-MC:masterfrom
CarlosNeutrino:cmorales/SRC_fix_AR23
Open

Setting the SecondNucleonEmitter at run-time and enabling SRC in CC-QEL interactions#506
CarlosNeutrino wants to merge 10 commits into
GENIE-MC:masterfrom
CarlosNeutrino:cmorales/SRC_fix_AR23

Conversation

@CarlosNeutrino

Copy link
Copy Markdown

Description

This Pull Request changes the way the SecondNucleonEmitter for SRC is configured. It adds the SecondNucleonEmitter in CC-QEL events (not configured before, as QELEventGenerator does not use FermiMover):

  • Before this changes, the SecondNucleonEmitter was only read from the config/ files independently from the NuclearModel.
  • The SecondNucleonEmitter depends strongly on the NuclearModel, and the code was using incompatible SecondNucleonEmitter algorithms for the specified global NuclearModel.
  • StringUtils.h → used for Split
  • Now, the SecondNucleonEmitter is configured at run-time depending on the global NuclearModel. In specific, the new code:
    • config/FermiMover.xml and config/QELEventGenerator.xml include two new strings ("NuclearModels" and "SecondNucleonEmitters") that read the NuclearModel along with the corresponding SecondNucleonEmitter
    • FermiMover.cxx and QELEventGenerator.cxx LoadConfig() reads the strings and sets the correct SecondNucleonEmitter.
    • The globally configured NuclearModel is read from the GlobalParameterList.

Development

  • A future improvement is to create a standalone module that runs SecondEmitter independently, so we do not duplicate the code in FermiMover and QELEventGenerator

Notes for reviewers

  • I tried to read the NuclearModel from EventGeneratorListAssembler but there was not any simpler way of doing it (neither did I manage to make it work) John Plows and I agreed to go ahead with GlobalParameterList
  • I have tested that the code compiles and it runs.

@CarlosNeutrino
CarlosNeutrino marked this pull request as ready for review July 7, 2026 14:28
Copilot AI review requested due to automatic review settings July 7, 2026 14:28
@CarlosNeutrino
CarlosNeutrino marked this pull request as draft July 7, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request makes the SRC SecondNucleonEmitter selection depend on the globally configured NuclearModel at runtime (instead of being fixed purely by per-algorithm XML), and enables SecondNucleonEmitter handling in CC-QEL event generation.

Changes:

  • Add runtime mapping logic in FermiMover and QELEventGenerator to choose a SecondNucleonEmissionI implementation based on the global NuclearModel.
  • Extend config/FermiMover.xml and config/QELEventGenerator.xml with NuclearModels / SecondNucleonEmitters string lists to define the mapping.
  • Invoke SecondNucleonEmissionI::ProcessEventRecord() in QELEventGenerator before creating the remnant nucleus so the remnant accounts for a possible second nucleon.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Physics/QuasiElastic/EventGen/QELEventGenerator.h Adds SecondNucleonEmitter state and mapping container.
src/Physics/QuasiElastic/EventGen/QELEventGenerator.cxx Selects SecondNucleonEmitter at runtime from global NuclearModel and applies it during event record processing.
src/Physics/NuclearState/FermiMover.h Adds mapping container for NuclearModel → SecondNucleonEmitter.
src/Physics/NuclearState/FermiMover.cxx Selects SecondNucleonEmitter at runtime from global NuclearModel (replacing fixed sub-alg selection).
config/QELEventGenerator.xml Adds NuclearModel/SecondNucleonEmitter mapping strings for QEL generator config.
config/FermiMover.xml Adds NuclearModel/SecondNucleonEmitter mapping strings for FermiMover config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Physics/QuasiElastic/EventGen/QELEventGenerator.h
Comment thread src/Physics/QuasiElastic/EventGen/QELEventGenerator.h Outdated
Comment thread src/Physics/QuasiElastic/EventGen/QELEventGenerator.cxx Outdated
Comment thread src/Physics/NuclearState/FermiMover.h Outdated
Comment thread src/Physics/NuclearState/FermiMover.cxx
@CarlosNeutrino CarlosNeutrino changed the title Setting the SecondNucleonEmitter at run-time Setting the SecondNucleonEmitter at run-time and enabling SRC in CC-QEL interactions Jul 7, 2026
@CarlosNeutrino
CarlosNeutrino marked this pull request as ready for review July 7, 2026 15:28
@CarlosNeutrino
CarlosNeutrino marked this pull request as draft July 7, 2026 15:28
@CarlosNeutrino
CarlosNeutrino force-pushed the cmorales/SRC_fix_AR23 branch from 8028184 to b760f0d Compare July 7, 2026 16:00
@CarlosNeutrino
CarlosNeutrino marked this pull request as ready for review July 8, 2026 09:15
Comment thread config/FermiMover.xml
<param_set name="Default">
<param type="bool" name="KeepHitNuclOnMassShell"> false </param>
<param type="alg" name="SecondNucleonEmitter"> genie::SpectralFunction2p2h/Default </param>
<param type="bool" name="KeepHitNuclOnMassShell"> false </param>

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.

Extra indentation... Not the end of the world but worth pointing out.

Comment thread config/FermiMover.xml

<!-- Possible SecondNucleonEmitters for every different NuclearModel -->
<param type="string" name="NuclearModels">genie::LocalFGM;genie::FGMBodekRitchie;genie::EffectiveSF</param>
<param type="string" name="SecondNucleonEmitters">genie::SRCNuclearRecoil/Default;genie::SRCNuclearRecoil/Default;genie::SpectralFunction2p2h/Default</param>

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.

Just to point out some GENIE functionality here: you can use <param type="vec-string" name="SecondNuclearEmitters" delim=";"> and access the values as a std::vector using Algorithm::GetParamVect - see config/QELEventGeneratorSM.xml and src/Physics/QuasiElastic/EventGen/QELEventGeneratorSM.cxx::LoadConfig()

@kjplows kjplows left a comment

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.

Overall looks good, thank you @CarlosNeutrino ! Requesting changes for the following:

  1. GetParamVect and vec-string where possible
  2. We should discuss making the silent continue statement on second-nucleon-emission load a proper Exception.

assert(fSecondEmitter);
// Build nuclear-model algorithm name -> SecondNucleonEmitter algorithm,
std::string nucl_model_names_str, fermi_mover_algids_str;
this->GetParam("NuclearModels", nucl_model_names_str);

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.

See comment on the config about loading these directly into std::vector<std::string> 🙂
(also saves you from including StringUtils.h)

const SecondNucleonEmissionI * emitter =
dynamic_cast<const SecondNucleonEmissionI *>(alg);
if (!emitter) {
LOG("FermiMover", pWARN)

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 argue making this an exception, rather than a silent continue. If this statement triggers it's either a misconfiguration or a bad runtime load, both should trigger warnings and interrupt execution. Happy to defer to @sjgardiner or @nusense on this.

this->GetParam("NuclearModels", nucl_model_names_str);
this->GetParam("SecondNucleonEmitters", fermi_mover_algids_str);

std::vector<std::string> nucl_model_names = genie::utils::str::Split(nucl_model_names_str, ";");

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.

Same comment as above, you can avoid this with GetParamVect

LOG("QELEvent", pWARN)
<< "No SecondNucleonEmitter for nuclear model "
<< nucl_model_name << " -- SRC recoil disabled";
}

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.

(This is not so much directed at this PR but applies anyway) - not a huge fan of duplicating code, but given QELEventGenerator contains duplicate code anyway, this is at least consistent. Maintenance caveat: any PRs targeting SecondNucleonEmitter have to be done in two locations in code.

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.

3 participants