Add SphereVolumePositionDistribution#103
Closed
austinschneider wants to merge 1 commit into
Closed
Conversation
Squashed diff for paths: - projects/distributions/private/primary/vertex/SphereVolumePositionDistribution.cxx - projects/distributions/public/SIREN/distributions/primary/vertex/SphereVolumePositionDistribution.h Source commits on dev/HNL_DIS_clean that contributed: 9dae77a (Nicholas Kamp): spherical volume position distribution
3c2cad2 to
af5236c
Compare
582b384 to
52bfd20
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 a new SphereVolumePositionDistribution implementation for sampling and weighting vertex positions uniformly within a spherical volume/shell.
Changes:
- Introduces
SphereVolumePositionDistributionpublic header with cereal polymorphic serialization. - Implements sampling, probability density, bounds computation, cloning, and equivalence/ordering in a new
.cxx.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| projects/distributions/public/SIREN/distributions/primary/vertex/SphereVolumePositionDistribution.h | Declares the new distribution API and cereal serialization/registration. |
| projects/distributions/private/primary/vertex/SphereVolumePositionDistribution.cxx | Implements sphere-volume sampling, generation probability, bounds, clone, and comparisons. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+115
to
+118
| bool SphereVolumePositionDistribution::less(WeightableDistribution const & other) const { | ||
| const SphereVolumePositionDistribution* x = dynamic_cast<const SphereVolumePositionDistribution*>(&other); | ||
| return sphere < x->sphere; | ||
| } |
| double r = std::cbrt(r_cubed); | ||
|
|
||
| // Sample angles uniformly on sphere surface | ||
| double phi = rand->Uniform(0, 2 * M_PI); // azimuthal angle |
| siren::math::Vector3D pos(sphere.GlobalToLocalPosition(record.interaction_vertex)); | ||
| double r = pos.magnitude(); // Distance from sphere center | ||
|
|
||
| if(r <= sphere.GetInnerRadius() || r >= sphere.GetRadius()) { |
| @@ -0,0 +1,76 @@ | |||
| #pragma once | |||
| std::tuple<siren::math::Vector3D, siren::math::Vector3D> SamplePosition(std::shared_ptr<siren::utilities::SIREN_random> rand, std::shared_ptr<siren::detector::DetectorModel const> detector_model, std::shared_ptr<siren::interactions::InteractionCollection const> interactions, siren::dataclasses::PrimaryDistributionRecord & record) const override; | ||
| public: | ||
| virtual double GenerationProbability(std::shared_ptr<siren::detector::DetectorModel const> detector_model, std::shared_ptr<siren::interactions::InteractionCollection const> interactions, siren::dataclasses::InteractionRecord const & record) const override; | ||
| SphereVolumePositionDistribution(siren::geometry::Sphere); |
Comment on lines
+87
to
+89
| std::shared_ptr<PrimaryInjectionDistribution> SphereVolumePositionDistribution::clone() const { | ||
| return std::shared_ptr<PrimaryInjectionDistribution>(new SphereVolumePositionDistribution(*this)); | ||
| } |
| @@ -0,0 +1,125 @@ | |||
| #include "SIREN/distributions/primary/vertex/SphereVolumePositionDistribution.h" | |||
|
|
|||
| #include <array> // for array | |||
| #include <cmath> // for sqrt, cos | ||
| #include <string> // for basic_string | ||
| #include <vector> // for vector | ||
| #include <stdlib.h> // for abs |
| std::vector<siren::geometry::Geometry::Intersection> intersections = sphere.Intersections(pos, dir); | ||
| siren::detector::DetectorModel::SortIntersections(intersections); | ||
| if(intersections.size() == 0) { | ||
| return std::tuple<siren::math::Vector3D, siren::math::Vector3D>(siren::math::Vector3D(0, 0, 0), siren::math::Vector3D(0, 0, 0)); |
af5236c to
d8afcb8
Compare
52bfd20 to
4a3b65e
Compare
d8afcb8 to
2390c7f
Compare
4a3b65e to
924e07b
Compare
2390c7f to
94b2c44
Compare
924e07b to
bfd5d31
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 5 of 14
This PR is part of a 14-PR stack decomposing
dev/HNL_DISinto reviewable chunks.chore/file-reorgfeat/sphere-distributionMerge order:
chore/file-reorgshould land before this PR.Squashed contents
Squashed diff for paths:
Source commits on dev/HNL_DIS_clean that contributed:
9dae77a (Nicholas Kamp): spherical volume position distribution
Notes
dev/HNL_DIS_clean..fitsdata files have been removed from the branch and are packaged separately.