HNL 3-body decay sampling#111
Closed
austinschneider wants to merge 1 commit into
Closed
Conversation
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
ff12237 to
26c739b
Compare
542e789 to
ad12640
Compare
Contributor
There was a problem hiding this comment.
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::Constantsvia a newutilities.Constantssubmodule. - Included
Constants.hin 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; |
26c739b to
4aa1586
Compare
ad12640 to
c6019e8
Compare
4aa1586 to
770d5fc
Compare
c6019e8 to
d6563e3
Compare
770d5fc to
88fa558
Compare
d6563e3 to
fd91564
Compare
88fa558 to
73a93fd
Compare
fd91564 to
00db822
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack: PR 13 of 14
This PR is part of a 14-PR stack decomposing
dev/HNL_DISinto reviewable chunks.feat/hnl-decays-hadronic-ewfeat/hnl-3body-samplingMerge order:
feat/hnl-decays-hadronic-ewshould land before this PR.Squashed contents
Squashed diff for paths:
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
dev/HNL_DIS_clean..fitsdata files have been removed from the branch and are packaged separately.