Skip to content

Add SphereVolumePositionDistribution#103

Closed
austinschneider wants to merge 1 commit into
chore/file-reorgfrom
feat/sphere-distribution
Closed

Add SphereVolumePositionDistribution#103
austinschneider wants to merge 1 commit into
chore/file-reorgfrom
feat/sphere-distribution

Conversation

@austinschneider

Copy link
Copy Markdown
Collaborator

Stack: PR 5 of 14

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

  • Base: chore/file-reorg
  • Head: feat/sphere-distribution

Merge order: chore/file-reorg should land before this PR.

Squashed contents

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

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/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
Copilot AI review requested due to automatic review settings April 28, 2026 04:28
@austinschneider austinschneider force-pushed the feat/sphere-distribution branch from 582b384 to 52bfd20 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 a new SphereVolumePositionDistribution implementation for sampling and weighting vertex positions uniformly within a spherical volume/shell.

Changes:

  • Introduces SphereVolumePositionDistribution public 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));
@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