Skip to content

HNL 3-body decay sampling#111

Closed
austinschneider wants to merge 1 commit into
feat/hnl-decays-hadronic-ewfrom
feat/hnl-3body-sampling
Closed

HNL 3-body decay sampling#111
austinschneider wants to merge 1 commit into
feat/hnl-decays-hadronic-ewfrom
feat/hnl-3body-sampling

Conversation

@austinschneider

Copy link
Copy Markdown
Collaborator

Stack: PR 13 of 14

This PR is part of a 14-PR stack decomposing dev/HNL_DIS into reviewable chunks.

  • Base: feat/hnl-decays-hadronic-ew
  • Head: feat/hnl-3body-sampling

Merge order: feat/hnl-decays-hadronic-ew should land before this PR.

Squashed contents

Squashed diff for paths:

  • projects/utilities/public/SIREN/utilities/Sampling.h
  • projects/utilities/private/pybindings/utilities.cxx

Source commits on dev/HNL_DIS_clean that contributed:
197bf14 (Nicholas Kamp): fixing build errors from the merge
5e2b658 (Nicholas Kamp): start MH sampling template
ac0ce24 (Nicholas Kamp): changes to facilitate hadronic and W/Z HNL decays
b895e21 (Nicholas Kamp): add lots of sampling code
c6f922d (Nicholas Kamp): Add pybinding constants, fix bug in charged pseudoscalr decays

Notes

  • This branch is the squashed cumulative diff of the listed source commits. Per-commit history is browsable on dev/HNL_DIS_clean.
  • Large .fits data files have been removed from the branch and are packaged separately.

Squashed diff for paths:
  - projects/utilities/public/SIREN/utilities/Sampling.h
  - projects/utilities/private/pybindings/utilities.cxx

Source commits on dev/HNL_DIS_clean that contributed:
  197bf14 (Nicholas Kamp): fixing build errors from the merge
  5e2b658 (Nicholas Kamp): start MH sampling template
  ac0ce24 (Nicholas Kamp): changes to facilitate hadronic and W/Z HNL decays
  b895e21 (Nicholas Kamp): add lots of sampling code
  c6f922d (Nicholas Kamp): Add pybinding constants, fix bug in charged pseudoscalr decays
Copilot AI review requested due to automatic review settings April 28, 2026 04:29
@austinschneider austinschneider force-pushed the feat/hnl-decays-hadronic-ew branch from ff12237 to 26c739b Compare April 28, 2026 04:34
@austinschneider austinschneider force-pushed the feat/hnl-3body-sampling branch from 542e789 to ad12640 Compare April 28, 2026 04:34

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds utilities to support HNL 3-body decay sampling by introducing a Metropolis–Hastings sampler helper and exposing physics/constants to Python via pybind11.

Changes:

  • Added a header-only Metropolis–Hastings sampling utility (Sampling.h).
  • Added pybind11 bindings for siren::utilities::Constants via a new utilities.Constants submodule.
  • Included Constants.h in the Python bindings compilation unit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
projects/utilities/public/SIREN/utilities/Sampling.h Introduces a Metropolis–Hastings sampling helper returning a sampled parameter vector.
projects/utilities/private/pybindings/utilities.cxx Adds a Constants Python submodule and binds many constants.

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

Comment on lines +36 to +37
double odds = test_llh / llh;
accept = (llh==0 || odds>1. || random->Uniform(0,1) < odds);

#include <cmath>
#include <vector>
#include <cassert>
namespace utilities {

/**
* @brief Performs a Metropolic Hasting sampling of a differential distribution
Comment on lines +15 to +19
* @brief Performs a Metropolic Hasting sampling of a differential distribution
*
*
* @param func the function to integrate
* @param tol the (absolute) tolerance on the error of the integral
* @param tol the (absolute) tolerance on the error of the integral
*/
template<typename FuncTypeProposal, typename FuncTypeLikelihood>
std::vector<double> MetropolisHasting_Sample(const FuncTypeProposal& func_proposal, const FuncTypeLikelihood& func_likelihood, std::shared_ptr<siren::utilities::SIREN_random> random, const size_t burnin = 40) {
Comment on lines +20 to +49
module Constants = m.def_submodule("Constants");
// geometry
Constants.attr("pi") = &Constants::pi;
Constants.attr("tau") = &Constants::tau;
Constants.attr("degrees") = &Constants::degrees;
// This is used since the user will enter a number in degrees, while the c trigonometric functions
// expect angles presented in radians.
Constants.attr("deg") = &Constants::deg;
Constants.attr("radian") = &Constants::radian;

// meter
Constants.attr("m") = &Constants::m;
Constants.attr("meter") = &Constants::meter;
Constants.attr("cm") = &Constants::cm;
Constants.attr("centimeter") = &Constants::centimeter;

// second is a billion to be consistent with IceCube code
Constants.attr("second") = &Constants::second;

// speed of light
Constants.attr("c") = &Constants::c;

// masses, GeV/c^2
Constants.attr("protonMass") = &Constants::protonMass;
Constants.attr("neutronMass") = &Constants::neutronMass;
Constants.attr("isoscalarMass") = &Constants::isoscalarMass;
Constants.attr("electronMass") = &Constants::electronMass;
Constants.attr("muonMass") = &Constants::muonMass;
Constants.attr("tauMass") = &Constants::tauMass;
Constants.attr("lambda0Mass") = &Constants::lambda0Mass;
Comment on lines +21 to +49
// geometry
Constants.attr("pi") = &Constants::pi;
Constants.attr("tau") = &Constants::tau;
Constants.attr("degrees") = &Constants::degrees;
// This is used since the user will enter a number in degrees, while the c trigonometric functions
// expect angles presented in radians.
Constants.attr("deg") = &Constants::deg;
Constants.attr("radian") = &Constants::radian;

// meter
Constants.attr("m") = &Constants::m;
Constants.attr("meter") = &Constants::meter;
Constants.attr("cm") = &Constants::cm;
Constants.attr("centimeter") = &Constants::centimeter;

// second is a billion to be consistent with IceCube code
Constants.attr("second") = &Constants::second;

// speed of light
Constants.attr("c") = &Constants::c;

// masses, GeV/c^2
Constants.attr("protonMass") = &Constants::protonMass;
Constants.attr("neutronMass") = &Constants::neutronMass;
Constants.attr("isoscalarMass") = &Constants::isoscalarMass;
Constants.attr("electronMass") = &Constants::electronMass;
Constants.attr("muonMass") = &Constants::muonMass;
Constants.attr("tauMass") = &Constants::tauMass;
Constants.attr("lambda0Mass") = &Constants::lambda0Mass;
@austinschneider austinschneider force-pushed the feat/hnl-decays-hadronic-ew branch from 26c739b to 4aa1586 Compare April 28, 2026 05:09
@austinschneider austinschneider force-pushed the feat/hnl-3body-sampling branch from ad12640 to c6019e8 Compare April 28, 2026 05:09
@austinschneider austinschneider force-pushed the feat/hnl-decays-hadronic-ew branch from 4aa1586 to 770d5fc Compare April 28, 2026 06:04
@austinschneider austinschneider force-pushed the feat/hnl-3body-sampling branch from c6019e8 to d6563e3 Compare April 28, 2026 06:04
@austinschneider austinschneider force-pushed the feat/hnl-decays-hadronic-ew branch from 770d5fc to 88fa558 Compare April 28, 2026 13:26
@austinschneider austinschneider force-pushed the feat/hnl-3body-sampling branch from d6563e3 to fd91564 Compare April 28, 2026 13:26
@austinschneider austinschneider force-pushed the feat/hnl-decays-hadronic-ew branch from 88fa558 to 73a93fd Compare April 28, 2026 14:36
@austinschneider austinschneider force-pushed the feat/hnl-3body-sampling branch from fd91564 to 00db822 Compare April 28, 2026 14:36
@austinschneider

Copy link
Copy Markdown
Collaborator Author

Closing to reopen from the commit author's account so they can be added as a reviewer. Branch unchanged; will be re-linked from the new PR shortly.

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