Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/HNL_DIS #83

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8ab0ff8
add all HNL splines
nickkamp1 Jun 5, 2024
12ee85e
initial suite of changes to re-implement the dipole DIS from spline c…
nickkamp1 Jun 6, 2024
054db56
fix runtime errors on HNL generation related to particle types
nickkamp1 Jun 15, 2024
da6a16c
Rename some classes, flush out the two body decay class
nickkamp1 Jun 25, 2024
d3f6c40
fix build errors, add 3 nu decay
nickkamp1 Jun 27, 2024
9b74316
Add pybinding constants, fix bug in charged pseudoscalr decays
nickkamp1 Jul 15, 2024
1bf85f7
Add crundec
nickkamp1 Jul 22, 2024
1f6f28f
build crundec
nickkamp1 Jul 22, 2024
b7644e0
changes to facilitate hadronic and W/Z HNL decays
nickkamp1 Jul 23, 2024
429238c
build fixes
nickkamp1 Jul 24, 2024
edebab7
fixes to hadronic decay width, need to update the meson calculation
nickkamp1 Jul 25, 2024
e0ac150
treat hadron decays properly w/ meson calculation
nickkamp1 Jul 25, 2024
031150a
loop corrections
nickkamp1 Jul 29, 2024
65fba94
first attempt at external list primary injector
nickkamp1 Jul 29, 2024
af425d8
build fixes to PrimaryExternalDistribution
nickkamp1 Jul 31, 2024
b12805a
add lake geneva detector geometry
nickkamp1 Jul 31, 2024
bf13077
introduce primary bounded and physical vertex distributions to sample…
nickkamp1 Aug 1, 2024
d3ece63
changes to fix runtime errors
nickkamp1 Aug 1, 2024
2299eba
add fiducial volume to LG and enable querying of detector sectors by …
nickkamp1 Aug 3, 2024
1a41eec
fix kinematic issues in DIS, including rounding errors
nickkamp1 Aug 3, 2024
46a4879
ability to save interaction probabilities for each process
nickkamp1 Aug 4, 2024
8fb7574
add ability to save interaction parameters to output file
nickkamp1 Aug 5, 2024
670b419
many changes in DIS implementation + albrecht's lake geneva detector
nickkamp1 Aug 6, 2024
1b2b66a
more complex logic for adding darknews interactions, fix some errors …
nickkamp1 Aug 7, 2024
6048f27
add get mass function, define lake and surface geneva detector separa…
nickkamp1 Aug 11, 2024
a07adce
first step at EW decay
nickkamp1 Aug 22, 2024
ad14be3
more EW decay logic, add prototype surface detector
nickkamp1 Aug 23, 2024
8d6e85f
Bump version
austinschneider Jun 5, 2024
0e65d08
Just cp310
austinschneider Jun 5, 2024
8f854df
Add all supported python versions. Remove less common architectures
austinschneider Jun 5, 2024
e4766c7
Patch broken DarkNews ModelContainer
austinschneider Jun 5, 2024
1a3cc9f
Bump version to 0.0.3
austinschneider Jun 5, 2024
4bcbe36
SIREN ND280+ MODULE ADDITION (#73)
mingshauliu Aug 14, 2024
bb8ef40
fix hadron decay rate calculation to properly match literature
nickkamp1 Sep 4, 2024
cc6b360
Merge branch 'dev/HNL_DIS' of https://github.com/Harvard-Neutrino/SIR…
nickkamp1 Sep 4, 2024
e661208
add km3net-orca
nickkamp1 Sep 10, 2024
c0a6387
Merge branch 'dev/HNL_DIS' of github.com:Harvard-Neutrino/SIREN into …
nickkamp1 Sep 10, 2024
706ea38
_util bug fixes and KM3Net renaming
nickkamp1 Sep 11, 2024
ec5bf66
detector changes, functionality to save initial position of interacti…
nickkamp1 Sep 16, 2024
ba2e243
make a ton of nc cross section splines
nickkamp1 Sep 16, 2024
4908b7f
total decay width for EW decay
nickkamp1 Sep 17, 2024
bb8eb67
implement sampling for secondary decay
nickkamp1 Sep 23, 2024
7cb6f75
fix build warnings, add more dipole hnl splines
nickkamp1 Sep 23, 2024
d73b33c
update geneva surface detectors
nickkamp1 Oct 2, 2024
8894000
Allow underscores in model names
nickkamp1 Oct 3, 2024
8344d23
Fix SINE detectors, make UNDINE detectors
nickkamp1 Oct 4, 2024
88255a6
update geneva detector specs
nickkamp1 Oct 17, 2024
ba5a267
include an explicit W^2 kinematic bound in DIS xs class
nickkamp1 Oct 23, 2024
f4e12cf
Start implementing 2D flux table for atmospheric fluxes
nickkamp1 Nov 4, 2024
80a2e0b
fixing build and runtime errors on 2D flux distribution
nickkamp1 Nov 5, 2024
3095d66
fix log integration
nickkamp1 Nov 6, 2024
5f2de22
fix issues with 2D tabular integral calculation, sampling errors with…
nickkamp1 Nov 13, 2024
134affe
getting HNLs to work for SINE and UNDINE
nickkamp1 Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [macos-13, macos-14]
py: [cp38, cp39, cp311, cp312]
py: [cp38, cp39, cp310, cp311, cp312]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -40,9 +40,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
py: [cp38, cp39, cp311, cp312]
py: [cp38, cp39, cp310, cp311, cp312]
image: [manylinux, musllinux]
arch: [x86_64, i686, aarch64, ppc64le, s390x]
arch: [x86_64, aarch64]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ include(pybind11)

# load project dependencies
include(rk)
include(crundec3)
include(cereal)
include(delabella)
include(CFITSIO)
Expand Down
1 change: 1 addition & 0 deletions cmake/Packages/crundec3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/crundec3 EXCLUDE_FROM_ALL)
16 changes: 15 additions & 1 deletion projects/dataclasses/private/InteractionRecord.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ void PrimaryDistributionRecord::SetHelicity(double helicity) {
this->helicity = helicity;
}

void PrimaryDistributionRecord::SetInteractionParameters(std::map<std::string, double> const & parameters) {
interaction_parameters = parameters;
}

void PrimaryDistributionRecord::SetInteractionParameter(std::string const & name, double value) {
interaction_parameters[name] = value;
}

void PrimaryDistributionRecord::UpdateMass() const {
if(mass_set)
return;
Expand Down Expand Up @@ -334,6 +342,9 @@ void PrimaryDistributionRecord::Finalize(InteractionRecord & record) const {
record.primary_mass = GetMass();
record.primary_momentum = GetFourMomentum();
record.primary_helicity = GetHelicity();
for (auto x : interaction_parameters) {
record.interaction_parameters[x.first] = x.second;
}
}

/////////////////////////////////////////
Expand Down Expand Up @@ -680,7 +691,10 @@ void CrossSectionDistributionRecord::Finalize(InteractionRecord & record) const
record.target_mass = target_mass;
record.target_helicity = target_helicity;

record.interaction_parameters = interaction_parameters;
//record.interaction_parameters = interaction_parameters;
for (auto x : interaction_parameters) {
record.interaction_parameters[x.first] = x.second;
}

record.secondary_ids.resize(secondary_particles.size());
record.secondary_masses.resize(secondary_particles.size());
Expand Down
1 change: 1 addition & 0 deletions projects/dataclasses/private/pybindings/dataclasses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ PYBIND11_MODULE(dataclasses,m) {
.def(init<>())
.def("__str__", [](InteractionRecord const & r) { std::stringstream ss; ss << r; return ss.str(); })
.def_readwrite("signature",&InteractionRecord::signature)
.def_readwrite("primary_initial_position",&InteractionRecord::primary_initial_position)
.def_readwrite("primary_mass",&InteractionRecord::primary_mass)
.def_readwrite("primary_momentum",&InteractionRecord::primary_momentum)
.def_readwrite("primary_helicity",&InteractionRecord::primary_helicity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class PrimaryDistributionRecord {
mutable std::array<double, 3> initial_position;
mutable std::array<double, 3> interaction_vertex;
mutable double helicity = 0;
std::map<std::string, double> interaction_parameters;
public:
friend std::ostream& ::operator<<(std::ostream& os, PrimaryDistributionRecord const& record);

Expand Down Expand Up @@ -104,6 +105,8 @@ class PrimaryDistributionRecord {
void SetInitialPosition(std::array<double, 3> initial_position);
void SetInteractionVertex(std::array<double, 3> interaction_vertex);
void SetHelicity(double helicity);
void SetInteractionParameters(std::map<std::string, double> const & parameters);
void SetInteractionParameter(std::string const & name, double value);

void UpdateMass() const;
void UpdateEnergy() const;
Expand Down
22 changes: 19 additions & 3 deletions projects/dataclasses/public/SIREN/dataclasses/ParticleTypes.def
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
X(unknown, 0)
X(d,1)
X(dBar,-1)
X(u,2)
X(uBar,-2)
X(s,3)
X(sBar,-3)
X(c,4)
X(cBar,-4)
X(b,5)
X(bBar,-5)
X(t,6)
X(tBar,-6)
X(Gamma, 22)
X(EPlus, -11)
X(EMinus, 11)
Expand All @@ -13,8 +25,9 @@ X(RhoMinus, -213)
X(K0_Long, 130)
X(KPlus, 321)
X(KMinus, -321)
X(KStarPlus, 9000311)
X(KStarMinus, -9000311)
X(KPrime0, 9000311)
X(KPrimePlus, 9000321)
X(KPrimeMinus, -9000321)
X(Neutron, 2112)
X(PPlus, 2212)
X(PMinus, -2212)
Expand Down Expand Up @@ -43,7 +56,7 @@ X(DMinus, -411)
X(D0, 421)
X(D0Bar, -421)
X(DsPlus, 431)
X(DsMinusBar, -431)
X(DsMinus, -431)
X(LambdacPlus, 4122)
X(WPlus, 24)
X(WMinus, -24)
Expand Down Expand Up @@ -167,8 +180,11 @@ X(Nu1, 5911)
X(Nu2, 5912)
X(Nu3, 5913)
X(N4, 5914)
X(N4Bar, -5914)
X(N5, 5915)
X(N5Bar, -5915)
X(N6, 5916)
X(N6Bar, -5916)
X(ZPrime, 5921)
X(HPrime, 5901)
X(PhiPrime, 5902)
Expand Down
62 changes: 47 additions & 15 deletions projects/detector/private/DetectorModel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ namespace {
void string_to_lower(std::string & data) {
std::transform(data.begin(), data.end(), data.begin(), [](unsigned char c){ return std::tolower(c); });
}
double estimateDotError(const std::array<double, 3>& p0, const std::array<double, 3>& p1, const std::array<double, 3>& int_dir) {
constexpr double epsilon = std::numeric_limits<double>::epsilon();

double dot_product = 0.0;
double error_sum = 0.0;

for (int i = 0; i < 3; ++i) {
double diff = p1[i] - p0[i];
double prod = int_dir[i] * diff;
dot_product += prod;
error_sum += std::fabs(int_dir[i] * diff);
}

// Estimated error of the expression
double error_estimate = epsilon * error_sum;

return error_estimate;
}

template <class InIt>
typename std::iterator_traits<InIt>::value_type accumulate(InIt begin, InIt end) {
Expand Down Expand Up @@ -244,6 +262,14 @@ DetectorSector DetectorModel::GetSector(int heirarchy) const {
return sectors_[index];
}

DetectorSector DetectorModel::GetSector(std::string name) const {
for (auto sector : sectors_) {
if (sector.name==name) return sector;
}
std::cout << "Sector " << name << " not found, returning empty sector\n";
return DetectorSector();
}

void DetectorModel::ClearSectors() {
sectors_.clear();
sector_map_.clear();
Expand Down Expand Up @@ -688,6 +714,11 @@ double DetectorModel::GetInteractionDensity(Geometry::IntersectionList const & i
} else {
direction.normalize();
}
// If we have only decays, avoid the sector loop
// total_decay_length is in m
if(targets.empty()) {
return 1.0 / total_decay_length;
}
double dot = direction * intersections.direction;
assert(std::abs(1.0 - std::abs(dot)) < 1e-6);
double offset = (intersections.position - p0) * direction;
Expand All @@ -698,11 +729,6 @@ double DetectorModel::GetInteractionDensity(Geometry::IntersectionList const & i
dot = 1;
}

// If we have only decays, avoid the sector loop
// total_decay_length is in m
if(targets.empty()) {
return 1.0 / total_decay_length;
}

double interaction_density = std::numeric_limits<double>::quiet_NaN();

Expand Down Expand Up @@ -983,11 +1009,22 @@ double DetectorModel::GetInteractionDepthInCGS(Geometry::IntersectionList const
}
Vector3D direction = p1 - p0;
double distance = direction.magnitude();
// this dot error turned out to be much smaller than 1e-6 for event that failed the assertion below
// double dot_error = estimateDotError(std::array<double, 3>(p0.get()),
// std::array<double, 3>(p1.get()),
// std::array<double, 3>(intersections.direction));

// If we have only decays, avoid the sector loop
if(targets.empty()) {
return distance/total_decay_length; // m / m --> dimensionless
}
if(distance == 0.0) {
return 0.0;
}
direction.normalize();

// TODO: a better numerical precision check when the traversed distance is very small
// this functionally only happens for decays right now, so we just check for decays at the top
double dot = intersections.direction * direction;
assert(std::abs(1.0 - std::abs(dot)) < 1e-6);
double offset = (intersections.position - p0) * direction;
Expand All @@ -998,11 +1035,6 @@ double DetectorModel::GetInteractionDepthInCGS(Geometry::IntersectionList const
dot = 1;
}

// If we have only decays, avoid the sector loop
if(targets.empty()) {
return distance/total_decay_length; // m / m --> dimensionless
}

std::vector<double> interaction_depths(targets.size(), 0.0);

std::function<bool(std::vector<Geometry::Intersection>::const_iterator, std::vector<Geometry::Intersection>::const_iterator, double)> callback =
Expand Down Expand Up @@ -1331,6 +1363,11 @@ double DetectorModel::DistanceForInteractionDepthFromPoint(Geometry::Intersectio
interaction_depth *= -1;
direction = -direction;
}
// If we have only decays, avoid the sector loop
// decay length in m
if(targets.empty()) {
return interaction_depth * total_decay_length;
}

double dot = intersections.direction * direction;
assert(std::abs(1.0 - std::abs(dot)) < 1e-6);
Expand All @@ -1342,11 +1379,6 @@ double DetectorModel::DistanceForInteractionDepthFromPoint(Geometry::Intersectio
dot = 1;
}

// If we have only decays, avoid the sector loop
// decay length in m
if(targets.empty()) {
return interaction_depth * total_decay_length;
}

// Recast decay length to cm for density integral
double total_decay_length_cm = total_decay_length / siren::utilities::Constants::cm;
Expand Down
9 changes: 8 additions & 1 deletion projects/detector/private/pybindings/DetectorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,14 @@ void register_DetectorModel(pybind11::module_ & m) {
.def_property("DetectorOrigin", &DetectorModel::GetDetectorOrigin, &DetectorModel::SetDetectorOrigin)
.def_property("DetectorRotation", &DetectorModel::GetDetectorRotation, &DetectorModel::SetDetectorRotation)
.def("AddSector", &DetectorModel::AddSector)
.def("GetSector", &DetectorModel::GetSector)
.def("GetSector", (
DetectorSector (DetectorModel::*)(
int) const
)(&DetectorModel::GetSector))
.def("GetSector", (
DetectorSector (DetectorModel::*)(
std::string) const
)(&DetectorModel::GetSector))
.def("ClearSectors", &DetectorModel::ClearSectors)
.def("GetIntersections", (
siren::geometry::Geometry::IntersectionList (DetectorModel::*)(
Expand Down
1 change: 1 addition & 0 deletions projects/detector/public/SIREN/detector/DetectorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ friend siren::detector::Path;

void AddSector(DetectorSector sector);
DetectorSector GetSector(int level) const;
DetectorSector GetSector(std::string name) const;

void ClearSectors();

Expand Down
7 changes: 7 additions & 0 deletions projects/distributions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
LIST (APPEND distributions_SOURCES
${PROJECT_SOURCE_DIR}/projects/distributions/private/Distributions.cxx

${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/PrimaryExternalDistribution.cxx

${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/direction/PrimaryDirectionDistribution.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/direction/IsotropicDirection.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/direction/FixedDirection.cxx
Expand All @@ -14,6 +16,9 @@ LIST (APPEND distributions_SOURCES
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/energy/PowerLaw.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/energy/Monoenergetic.cxx

${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/energy_direction/PrimaryEnergyDirectionDistribution.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/energy_direction/Tabulated2DFluxDistribution.cxx

${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/helicity/PrimaryNeutrinoHelicityDistribution.cxx

${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/mass/PrimaryMass.cxx
Expand All @@ -29,6 +34,8 @@ LIST (APPEND distributions_SOURCES
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/vertex/OrientedCylinderPositionDistribution.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/vertex/CylinderVolumePositionDistribution.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/vertex/ColumnDepthPositionDistribution.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/vertex/PrimaryPhysicalVertexDistribution.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/primary/vertex/PrimaryBoundedVertexDistribution.cxx

${PROJECT_SOURCE_DIR}/projects/distributions/private/secondary/vertex/SecondaryVertexPositionDistribution.cxx
${PROJECT_SOURCE_DIR}/projects/distributions/private/secondary/vertex/SecondaryPhysicalVertexDistribution.cxx
Expand Down
Loading
Loading