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/misc paper updates #69

Merged
merged 46 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f209952
Remove hard dependence on DarkNews. Update some of the paper figures …
nickkamp1 Mar 28, 2024
329f39c
Allow for multiple cross section and decay interactions for primary/s…
nickkamp1 Apr 12, 2024
bb296fe
cleanup changes that should be ported to the main branch before publi…
nickkamp1 Apr 25, 2024
23d5ee2
rename to TreeWeighter
nickkamp1 May 3, 2024
cd1dee8
add HyperK
nickkamp1 May 3, 2024
cc10e52
rename LIController and LIDarkNews to SIREN_*
nickkamp1 May 5, 2024
7fb85a6
Updates to notebooks, new misc paper plots notebook, add one pybindin…
nickkamp1 May 5, 2024
43de644
Sketch serialization stuff
austinschneider May 6, 2024
b31fccb
Merge branch 'dev/misc_paper_updates' of https://github.com/Harvard-N…
nickkamp1 May 6, 2024
9c3195f
Fix compiler errors in DarkNewsCrossSection and DarkNewsDecay pybindi…
nickkamp1 May 8, 2024
c2501e8
some changes to remove pybinding-related import errors for the intera…
nickkamp1 May 8, 2024
41b09a0
changes to serialization for pybind11 trampoline classes. works and h…
nickkamp1 May 13, 2024
16c927d
attempts to implement serialization of injector. in progress...
nickkamp1 May 14, 2024
2fc8307
Serialization of injector works!!!!!
nickkamp1 May 15, 2024
bd1c811
changes to make (de)serialization of injector object work for the DIS…
nickkamp1 May 16, 2024
7570ed1
bug fixes
nickkamp1 May 16, 2024
5eb976c
Add functionality to serialize a vector of interaction trees. Update …
nickkamp1 May 16, 2024
2e84d2e
Move trampoline classes into pybindings
austinschneider May 28, 2024
f8f9b87
Get serialization working for the DarkNews examples
nickkamp1 May 28, 2024
8a1f33c
Spacing
austinschneider May 29, 2024
0112aca
Python is handled elsewhere in top-level cmake and this line is depre…
austinschneider May 29, 2024
fef94eb
Try new runner strategy
austinschneider May 29, 2024
ae777f8
Don't need windows...
austinschneider May 29, 2024
69e4f86
Split up jobs
austinschneider May 29, 2024
63b86dd
Merge branch 'dev/misc_paper_updates' of https://github.com/Harvard-N…
nickkamp1 May 29, 2024
c287be3
Add serialization test
nickkamp1 May 30, 2024
acfea5f
Try linking pybind11 to distributions library
nickkamp1 May 30, 2024
2316e93
Get serialization building and running without errors
austinschneider Jun 2, 2024
fea68fe
Inheritance based trampoline is not used
austinschneider Jun 2, 2024
c4b29f7
Use registration macro and remove cereal polymorphic registration to …
austinschneider Jun 2, 2024
56e8818
Remove comment
austinschneider Jun 2, 2024
b60806b
Remove include
austinschneider Jun 2, 2024
294fa2a
Fix up serialization for pyCrossSection
austinschneider Jun 2, 2024
cea3e15
Fix up serialization for pyDecay
austinschneider Jun 2, 2024
aa554b4
Comment and include not needed
austinschneider Jun 2, 2024
a7d166e
Remove template class for trampolines
austinschneider Jun 2, 2024
428abdc
Rename macro for pybind11 cereal methods
austinschneider Jun 2, 2024
23da9a0
Custom target for tests when using cibuildwheel
austinschneider Jun 2, 2024
e7446d1
Conditional on cibuildwheel
austinschneider Jun 2, 2024
5d2be5a
Split up linux into more runners
austinschneider Jun 3, 2024
dd6ed07
Specify all archs
austinschneider Jun 3, 2024
9db0637
Only run on PR. Split up macos build by python version
austinschneider Jun 3, 2024
e86995f
Merge artifacts
austinschneider Jun 3, 2024
d3adae2
add comment, fix dipole portal MB example
nickkamp1 Jun 3, 2024
aff88b0
remove serialization test
nickkamp1 Jun 3, 2024
4092b47
Rename TreeWeighter -> Weighter, get rid of original Weighter class
nickkamp1 Jun 3, 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
67 changes: 40 additions & 27 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,73 @@ name: Build
on: [pull_request]

jobs:
build_wheels_linux:
build_wheels_macos:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
arch: [x86_64, i686, aarch64, ppc64le, s390x]
# macos-13 is an intel runner, macos-14 is apple silicon
os: [macos-13, macos-14]
py: [cp38, cp39, cp311, cp312]

steps:
- name: Checkout SIREN
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
python-version: '3.9' # update once build dependencies are available
platforms: all

- name: Build wheels
uses: pypa/[email protected]

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
uses: pypa/[email protected]
env:
# configure cibuildwheel to build native archs ('auto'), and some
# emulated ones
CIBW_BUILD: ${{ matrix.py }}-*
CIBW_ARCHS_LINUX: auto

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_wheels_macos:

build_wheels_linux:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11]
# arch: [x86_64, arm64]
arch: [x86_64]
os: [ubuntu-latest]
py: [cp38, cp39, cp311, cp312]
image: [manylinux, musllinux]
arch: [x86_64, i686, aarch64, ppc64le, s390x]

steps:
- name: Checkout SIREN
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
python-version: '3.9' # update once build dependencies are available
platforms: all

- name: Build wheels
uses: pypa/[email protected]

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
uses: pypa/[email protected]
env:
# configure cibuildwheel to build native archs ('auto'), and some
# emulated ones
CIBW_BUILD: ${{ matrix.py }}-${{ matrix.image }}_${{ matrix.arch }}
CIBW_ARCHS: all

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
merge:
runs-on: ubuntu-latest
needs: [build_wheels_macos, build_wheels_linux]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
delete-merged: true
20 changes: 17 additions & 3 deletions projects/dataclasses/private/InteractionTree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std::shared_ptr<InteractionTreeDatum> InteractionTree::add_entry(std::shared_ptr
datum->parent = parent;
parent->daughters.push_back(datum);
}
tree.insert(datum);
tree.push_back(datum);
return datum;
}

Expand All @@ -34,7 +34,7 @@ std::shared_ptr<InteractionTreeDatum> InteractionTree::add_entry(InteractionTree
_datum->parent = parent;
parent->daughters.push_back(_datum);
}
tree.insert(_datum);
tree.push_back(_datum);
return _datum;
}

Expand All @@ -45,9 +45,23 @@ std::shared_ptr<InteractionTreeDatum> InteractionTree::add_entry(InteractionReco
datum->parent = parent;
parent->daughters.push_back(datum);
}
tree.insert(datum);
tree.push_back(datum);
return datum;
}

void SaveInteractionTrees(std::vector<std::shared_ptr<InteractionTree>>& trees, std::string const & filename) {
std::ofstream os(filename+".siren_events", std::ios::binary);
::cereal::BinaryOutputArchive archive(os);
archive(trees);
}

std::vector<std::shared_ptr<InteractionTree>> LoadInteractionTrees(std::string const & filename) {
std::ifstream is(filename+".siren_events", std::ios::binary);
::cereal::BinaryInputArchive archive(is);
std::vector<std::shared_ptr<InteractionTree>> trees;
archive(trees);
return trees;
}

} // namespace dataclasses
} // namespace siren
3 changes: 3 additions & 0 deletions projects/dataclasses/private/pybindings/dataclasses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,7 @@ PYBIND11_MODULE(dataclasses,m) {
.def("add_entry",static_cast<std::shared_ptr<InteractionTreeDatum> (InteractionTree::*)(InteractionTreeDatum&,std::shared_ptr<InteractionTreeDatum>)>(&InteractionTree::add_entry))
.def("add_entry",static_cast<std::shared_ptr<InteractionTreeDatum> (InteractionTree::*)(InteractionRecord&,std::shared_ptr<InteractionTreeDatum>)>(&InteractionTree::add_entry));

m.def("SaveInteractionTrees",&SaveInteractionTrees);
m.def("LoadInteractionTrees",&LoadInteractionTrees,pybind11::return_value_policy::reference);

}
6 changes: 3 additions & 3 deletions projects/dataclasses/private/test/InteractionTree_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ std::shared_ptr<InteractionTreeDatum> InteractionTree::add_entry(std::shared_ptr
datum->parent = parent;
parent->daughters.push_back(datum);
}
tree.insert(datum);
tree.push_back(datum);
return datum;
}

Expand All @@ -53,7 +53,7 @@ std::shared_ptr<InteractionTreeDatum> InteractionTree::add_entry(InteractionTree
_datum->parent = parent;
parent->daughters.push_back(_datum);
}
tree.insert(_datum);
tree.push_back(_datum);
return _datum;
}

Expand All @@ -64,7 +64,7 @@ std::shared_ptr<InteractionTreeDatum> InteractionTree::add_entry(InteractionReco
datum->parent = parent;
parent->daughters.push_back(datum);
}
tree.insert(datum);
tree.push_back(datum);
return datum;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <cereal/archives/json.hpp>
#include <cereal/archives/binary.hpp>
#include <cereal/types/vector.hpp>
#include <cereal/types/map.hpp>
#include <cereal/types/array.hpp>
#include <cereal/types/polymorphic.hpp>
#include <cereal/types/base_class.hpp>
Expand Down
10 changes: 9 additions & 1 deletion projects/dataclasses/public/SIREN/dataclasses/InteractionTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cstdint> // for uint32_t
#include <stddef.h> // for NULL
#include <stdexcept> // for runtime_error
#include <fstream> // for if/ofstream

#include <cereal/cereal.hpp>
#include <cereal/archives/json.hpp>
Expand All @@ -24,6 +25,7 @@ namespace siren {
namespace dataclasses {

struct InteractionTreeDatum {
InteractionTreeDatum() {}
InteractionTreeDatum(dataclasses::InteractionRecord& record) : record(record) {}
dataclasses::InteractionRecord record;
std::shared_ptr<dataclasses::InteractionTreeDatum> parent = NULL;
Expand All @@ -42,7 +44,7 @@ struct InteractionTreeDatum {
};

struct InteractionTree {
std::set<std::shared_ptr<dataclasses::InteractionTreeDatum>> tree;
std::vector<std::shared_ptr<dataclasses::InteractionTreeDatum>> tree;
std::shared_ptr<InteractionTreeDatum> add_entry(std::shared_ptr<dataclasses::InteractionTreeDatum> datum,
std::shared_ptr<dataclasses::InteractionTreeDatum> parent = NULL);
std::shared_ptr<InteractionTreeDatum> add_entry(dataclasses::InteractionTreeDatum& datum,
Expand All @@ -59,8 +61,14 @@ struct InteractionTree {
};
};

void SaveInteractionTrees(std::vector<std::shared_ptr<InteractionTree>>& trees, std::string const & filename);
std::vector<std::shared_ptr<InteractionTree>> LoadInteractionTrees(std::string const & filename);

} // namespace dataclasses
} // namespace siren

CEREAL_CLASS_VERSION(siren::dataclasses::InteractionTreeDatum, 0);
CEREAL_CLASS_VERSION(siren::dataclasses::InteractionTree, 0);

#endif // SIREN_InteractionTree_H

1 change: 1 addition & 0 deletions projects/dataclasses/public/SIREN/dataclasses/ParticleID.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdint> // for uint32_t
#include <ostream> // for ostream
#include <stdexcept> // for runtime_error
#include <sstream>

#include <cereal/cereal.hpp>
#include <cereal/archives/json.hpp>
Expand Down
1 change: 1 addition & 0 deletions projects/detector/public/SIREN/detector/MaterialModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class MaterialModel {
archive(cereal::make_nvp("MaterialNames", material_names_));
archive(cereal::make_nvp("MaterialIDs", material_ids_));
archive(cereal::make_nvp("MaterialComponents", material_components_));
archive(cereal::make_nvp("MaterialComponentsByID", material_components_by_id_));
archive(cereal::make_nvp("MaterialRadiationLength", material_radiation_length_));
archive(cereal::make_nvp("ComponentRadiationLength", component_radiation_length_));
} else {
Expand Down
1 change: 1 addition & 0 deletions projects/distributions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ target_include_directories(SIREN_distributions PUBLIC
target_link_libraries(SIREN_distributions
PRIVATE
$<BUILD_INTERFACE:rk_static>
pybind11::embed
PUBLIC
photospline
SIREN_serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ bool TabulatedFluxDistribution::equal(WeightableDistribution const & other) cons
return false;
else
return
std::tie(energyMin, energyMax, fluxTableFilename)
std::tie(energyMin, energyMax, fluxTable)
==
std::tie(x->energyMin, x->energyMax, x->fluxTableFilename);
std::tie(x->energyMin, x->energyMax, x->fluxTable);
}

bool TabulatedFluxDistribution::less(WeightableDistribution const & other) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ friend cereal::access;
archive(::cereal::make_nvp("EnergyMax", energyMax));
archive(::cereal::make_nvp("FluxTable", fluxTable));
archive(cereal::virtual_base_class<PrimaryEnergyDistribution>(this));
bounds_set = true;
ComputeIntegral();
ComputeCDF();
} else {
throw std::runtime_error("TabulatedFluxDistribution only supports version <= 0!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ friend cereal::access;
} // namespace siren

CEREAL_CLASS_VERSION(siren::distributions::DepthFunction, 0);
CEREAL_REGISTER_TYPE(siren::distributions::DepthFunction);

#endif // SIREN_DepthFunction_H
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,28 @@ friend cereal::access;
template<typename Archive>
void save(Archive & archive, std::uint32_t const version) const {
if(version == 0) {
} else {
archive(::cereal::make_nvp("MuAlpha", mu_alpha));
archive(::cereal::make_nvp("MuBeta", mu_beta));
archive(::cereal::make_nvp("TauAlpha", tau_alpha));
archive(::cereal::make_nvp("TauBeta", tau_beta));
archive(::cereal::make_nvp("Scale", scale));
archive(::cereal::make_nvp("MaxDepth", max_depth));
archive(::cereal::make_nvp("TauPrimaries", tau_primaries));
} else {
throw std::runtime_error("LeptonDepthFunction only supports version <= 0!");
}
}
template<typename Archive>
void load(Archive & archive, std::uint32_t const version) {
if(version == 0) {
} else {
archive(::cereal::make_nvp("MuAlpha", mu_alpha));
archive(::cereal::make_nvp("MuBeta", mu_beta));
archive(::cereal::make_nvp("TauAlpha", tau_alpha));
archive(::cereal::make_nvp("TauBeta", tau_beta));
archive(::cereal::make_nvp("Scale", scale));
archive(::cereal::make_nvp("MaxDepth", max_depth));
archive(::cereal::make_nvp("TauPrimaries", tau_primaries));
} else {
throw std::runtime_error("LeptonDepthFunction only supports version <= 0!");
}
}
Expand All @@ -83,6 +83,7 @@ friend cereal::access;
} // namespace siren

CEREAL_CLASS_VERSION(siren::distributions::LeptonDepthFunction, 0);
CEREAL_REGISTER_TYPE(siren::distributions::LeptonDepthFunction);
CEREAL_REGISTER_POLYMORPHIC_RELATION(siren::distributions::DepthFunction, siren::distributions::LeptonDepthFunction);

#endif // SIREN_LeptonDepthFunction_H
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <cereal/types/polymorphic.hpp>
#include <cereal/types/base_class.hpp>
#include <cereal/types/utility.hpp>
#include <cereal/types/memory.hpp>

#include "SIREN/dataclasses/InteractionTree.h"
#include "SIREN/distributions/secondary/vertex/SecondaryVertexPositionDistribution.h"
Expand Down Expand Up @@ -55,6 +56,7 @@ friend cereal::access;
void save(Archive & archive, std::uint32_t const version) const {
if(version == 0) {
archive(::cereal::make_nvp("MaxLength", max_length));
archive(::cereal::make_nvp("FidVol", fiducial_volume));
archive(cereal::virtual_base_class<SecondaryVertexPositionDistribution>(this));
} else {
throw std::runtime_error("SecondaryBoundedVertexDistribution only supports version <= 0!");
Expand All @@ -64,8 +66,10 @@ friend cereal::access;
static void load_and_construct(Archive & archive, cereal::construct<SecondaryBoundedVertexDistribution> & construct, std::uint32_t const version) {
if(version == 0) {
double max_length;
std::shared_ptr<siren::geometry::Geometry> fiducial_volume;
archive(::cereal::make_nvp("MaxLength", max_length));
construct(max_length);
archive(::cereal::make_nvp("FidVol", fiducial_volume));
construct(fiducial_volume,max_length);
archive(cereal::virtual_base_class<SecondaryVertexPositionDistribution>(construct.ptr()));
} else {
throw std::runtime_error("SecondaryBoundedVertexDistribution only supports version <= 0!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <cereal/types/polymorphic.hpp>
#include <cereal/types/base_class.hpp>
#include <cereal/types/utility.hpp>
#include <cereal/types/memory.hpp>

#include "SIREN/dataclasses/InteractionTree.h"
#include "SIREN/distributions/secondary/vertex/SecondaryVertexPositionDistribution.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cereal/types/polymorphic.hpp>
#include <cereal/types/base_class.hpp>
#include <cereal/types/utility.hpp>
#include <cereal/types/memory.hpp>

#include "SIREN/dataclasses/InteractionTree.h" // for InteractionT...
#include "SIREN/distributions/Distributions.h" // for WeightableDi...
Expand Down
11 changes: 5 additions & 6 deletions projects/injection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ LIST (APPEND injection_SOURCES
${PROJECT_SOURCE_DIR}/projects/injection/private/Process.cxx
${PROJECT_SOURCE_DIR}/projects/injection/private/Injector.cxx
${PROJECT_SOURCE_DIR}/projects/injection/private/WeightingUtils.cxx
${PROJECT_SOURCE_DIR}/projects/injection/private/TreeWeighter.cxx
${PROJECT_SOURCE_DIR}/projects/injection/private/Weighter.cxx
#${PROJECT_SOURCE_DIR}/projects/injection/private/ColumnDepthSIREN.cxx
#${PROJECT_SOURCE_DIR}/projects/injection/private/CylinderVolumeSIREN.cxx
#${PROJECT_SOURCE_DIR}/projects/injection/private/DecayRangeSIREN.cxx
#${PROJECT_SOURCE_DIR}/projects/injection/private/RangedSIREN.cxx
)
add_library(SIREN_injection OBJECT ${injection_SOURCES})
set_property(TARGET SIREN_injection PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand All @@ -21,6 +16,7 @@ target_include_directories(SIREN_injection PUBLIC
target_link_libraries(SIREN_injection
PRIVATE
$<BUILD_INTERFACE:rk_static>
pybind11::embed
PUBLIC
photospline
SIREN_serialization
Expand All @@ -41,10 +37,13 @@ install(DIRECTORY "${PROJECT_SOURCE_DIR}/projects/injection/public/"
)

#package_add_test(UnitTest_Injector ${PROJECT_SOURCE_DIR}/projects/injection/private/test/Injector_TEST.cxx)
if(NOT ${CIBUILDWHEEL})
package_add_test(UnitTest_CCM_HNL ${PROJECT_SOURCE_DIR}/projects/injection/private/test/CCM_HNL_TEST.cxx)
target_link_libraries(UnitTest_CCM_HNL pybind11::embed)
endif()

pybind11_add_module(injection ${PROJECT_SOURCE_DIR}/projects/injection/private/pybindings/injection.cxx)
target_link_libraries(injection PRIVATE SIREN photospline)
target_link_libraries(injection PRIVATE SIREN photospline pybind11::embed)
if(DEFINED SKBUILD)
set_target_properties(injection PROPERTIES
BUILD_WITH_INSTALL_RPATH FALSE
Expand Down
Loading