Skip to content

breaking: DRAFT Multi-parameter functional shifts#824

Draft
luketpickering wants to merge 5 commits into
developfrom
feature/FunctionalMultiParameter
Draft

breaking: DRAFT Multi-parameter functional shifts#824
luketpickering wants to merge 5 commits into
developfrom
feature/FunctionalMultiParameter

Conversation

@luketpickering
Copy link
Copy Markdown
Contributor

@luketpickering luketpickering commented Mar 7, 2026

Pull request description

Attempts to design new Functional Shift interface. Currently, but could probably be made not breaking.

Changes or fixes

n.b. Removes PrepFunctionalParameters which is maybe used by some experiments. Easy to add back in.

Key design change is that functional shifts can now be functions of multiple parameters and operate on experiment class event types, rather than taking event indexes. The experiment class event vector is now passed as the first parameter.

The hope was to remove any capturing lambdas from the tight event loop, this implementation doesn't achieve that yet.

Examples

  RegisterIndividualFunctionalParameter(
      DUNEMCEvents, "MyParameter", [](double const *par, EventInfo &ev) {
        std::cout << "I'm here with " << (*par) << std::endl;
        ev.varied_reco.e_lep *= (1.0 + *par);
      });

  RegisterIndividualFunctionalParameter(
      DUNEMCEvents, std::vector<std::string>{"MyParameter", "MyOtherParameter"},
      [](std::vector<double const *> const &pars, EventInfo &ev) {
        std::cout << "I'm here with " << (*pars[0]) << " and " << (*pars[1])
                  << std::endl;
        ev.varied_reco.e_lep *= (1.0 + *pars[0] + *pars[1]);
      });

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 7, 2026

Hi @luketpickering, thank you for contributing to MaCh3! Please wait for MaCh3 developers to review your PR. If no one answers within a week, please message people from this list: https://github.com/orgs/mach3-software/teams/mach3admin . While waiting, please enjoy this

meme

Use this action on your projects. Use jokes on issues instead.

@github-actions github-actions Bot added Parameters ⚙️ Related with neutrino interactions or oscillations Samples 🗃️ labels Mar 7, 2026
@KSkwarczynski KSkwarczynski marked this pull request as draft March 23, 2026 09:34
- SampleHandler Functional functions now have a slightly nicer signature
  void(std::vector<double> const &, EventType &), This requires a vector
  of the current parameter values to be set once per reweight in FillArray,
  but makes the interface less clunky.
@luketpickering
Copy link
Copy Markdown
Contributor Author

Slight improvement to the proposed sampleHandler interface shown below:

  RegisterIndividualFunctionalParameter(
      DUNEMCEvents, "MyParameter", [](double const &par, EventInfo &ev) {
        std::cout << "I'm here with " << par << std::endl;
        ev.varied_reco.e_lep *= (1.0 + par);
      });

  RegisterIndividualFunctionalParameter(
      DUNEMCEvents, std::vector<std::string>{"MyParameter", "MyOtherParameter"},
      [](std::vector<double> const &pars, EventInfo &ev) {
        std::cout << "I'm here with " << pars[0] << " and " << pars[1]
                  << std::endl;
        ev.varied_reco.e_lep *= (1.0 + pars[0] + pars[1]);
      });

Now the relevant parameter values are fetched and cached before the event loop, this allows us to pass a vector of parameter values instead of a vector of pointers to parameter values which makes usage cleaner and some patterns more flexible.

@luketpickering luketpickering force-pushed the feature/FunctionalMultiParameter branch from 79f390b to df14f3d Compare March 26, 2026 16:55
@KSkwarczynski KSkwarczynski added this to the v2.6 milestone Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Parameters ⚙️ Related with neutrino interactions or oscillations Samples 🗃️

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants