Skip to content

Commit

Permalink
Merge pull request #99 from NESTCollaboration/gr_updateBindings
Browse files Browse the repository at this point in the history
update bindings and sync with NEST v2.3.12beta
  • Loading branch information
grischbieter authored Jan 19, 2023
2 parents 2063884 + 890928c commit 0be624f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
18 changes: 18 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ History

Patch releases mean (the Z number in X.Y.Z version) that the underlying physics has not changed. Changes to the NEST version will always trigger a minor or major release. If this library changes such that end users have to change their code, this may also trigger a minor or major release.

2.0.1 (2023-01-18)
-----------------
Updated python bindings to sync with NEST v2.3.12
* GetYields has been updated to allow for the beta ER model parameters to be user-controllable parameters
** Introduced the new default vector `ERYieldsParam` for use with GetYields

* Default parameter vectors have been moved from NESTcalc declarations to globally available vectors from NEST.hh

2.0.0 (2022-09-08)
-----------------
Update to nestpy internals, adding in basic LArNEST bindings
* The copy/paste method for the NEST bindings have been replaced with adding NEST and other modules (such as gcem and pybind11) as git submodules which are downloaded at compile time. LXe notebooks and python scripts have been moved to tutorials/arxiv, and new notebooks will be placed in the tutorials folder as they are created in the future. LAr functionality through LArNEST has been added and will be expanded upon in future releases.

* Suggestions/issues/errors should be added as github issues.

* Users may have to do before installing:
** `pip uninstall nestpy`


1.5.5 (2022-07-08)
-----------------
Expand Down
2 changes: 1 addition & 1 deletion lib/nest
27 changes: 21 additions & 6 deletions src/nestpy/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ PYBIND11_MODULE(nestpy, m)
.def("get_sPEeff", &VDetector::get_sPEeff)
.def("get_P_dphe", &VDetector::get_P_dphe)

.def("get_noiseBaseline", &VDetector::get_noiseBaseline)
.def("get_noiseLinear", &VDetector::get_noiseLinear)
.def("get_noiseQuadratic", &VDetector::get_noiseQuadratic)
.def("get_coinWind", &VDetector::get_coinWind)
.def("get_coinLevel", &VDetector::get_coinLevel)
.def("get_numPMTs", &VDetector::get_numPMTs)
Expand All @@ -136,11 +139,14 @@ PYBIND11_MODULE(nestpy, m)
.def("get_dt_min", &VDetector::get_dt_min)
.def("get_dt_max", &VDetector::get_dt_max)
.def("get_radius", &VDetector::get_radius)
.def("get_radmax", &VDetector::get_radmax)
.def("get_TopDrift", &VDetector::get_TopDrift)
.def("get_anode", &VDetector::get_anode)
.def("get_cathode", &VDetector::get_cathode)
.def("get_gate", &VDetector::get_gate)

.def("get_molarMass", &VDetector::get_molarMass )

.def("get_PosResExp", &VDetector::get_PosResExp)
.def("get_PosResBase", &VDetector::get_PosResBase)

Expand All @@ -150,6 +156,9 @@ PYBIND11_MODULE(nestpy, m)
.def("set_sPEeff", &VDetector::set_sPEeff)
.def("set_P_dphe", &VDetector::set_P_dphe)

.def("set_noiseBaseline", &VDetector::set_noiseBaseline)
.def("set_noiseLinear", &VDetector::set_noiseLinear)
.def("set_noiseQuadratic", &VDetector::set_noiseQuadratic)
.def("set_coinWind", &VDetector::set_coinWind)
.def("set_coinLevel", &VDetector::set_coinLevel)
.def("set_numPMTs", &VDetector::set_numPMTs)
Expand All @@ -169,11 +178,14 @@ PYBIND11_MODULE(nestpy, m)
.def("set_dt_min", &VDetector::set_dt_min)
.def("set_dt_max", &VDetector::set_dt_max)
.def("set_radius", &VDetector::set_radius)
.def("set_radmax", &VDetector::set_radmax)
.def("set_TopDrift", &VDetector::set_TopDrift)
.def("set_anode", &VDetector::set_anode)
.def("set_cathode", &VDetector::set_cathode)
.def("set_gate", &VDetector::set_gate)

.def("set_molarMarr", &VDetector::set_molarMass)

.def("set_PosResExp", &VDetector::set_PosResExp)
.def("set_PosResBase", &VDetector::set_PosResBase)

Expand Down Expand Up @@ -274,8 +286,9 @@ PYBIND11_MODULE(nestpy, m)
py::class_<NEST::NESTcalc, std::unique_ptr<NEST::NESTcalc, py::nodelete>>(m, "NESTcalc")
//.def(py::init<>())
.def(py::init<VDetector*>())
.def_readonly_static("default_NRYieldsParam", &NESTcalc::default_NRYieldsParam)
.def_readonly_static("default_NRERWidthsParam", &NESTcalc::default_NRERWidthsParam)
.def_readonly_static("default_NRYieldsParam", &default_NRYieldsParam)
.def_readonly_static("default_NRERWidthsParam", &default_NRERWidthsParam)
.def_readonly_static("default_ERYieldsParam", &default_ERYieldsParam)
// .def_static("BinomFluct", &NEST::NESTcalc::BinomFluct)
.def("FullCalculation", &NEST::NESTcalc::FullCalculation,
"Perform the full yield calculation with smearings")
Expand Down Expand Up @@ -306,12 +319,13 @@ PYBIND11_MODULE(nestpy, m)
py::arg("A") = 131.293,
py::arg("Z") = 54,
py::arg("nuisance_parameters") = std::vector<double>({ 11., 1.1, 0.0480, -0.0533, 12.6, 0.3, 2., 0.3, 2., 0.5, 1., 1.}),
py::arg("ERYieldsParam") = std::vector<double>({-1.,-1.,-1.,-1.,-1.,-1.,-1.,-1.,-1.,-1.}),
py::arg("oldModelER") = false
)
.def("GetQuanta", &NEST::NESTcalc::GetQuanta,
py::arg("yields"),
py::arg("density") = 2.9,
py::arg("free_parameters") = std::vector<double>({0.4,0.4,0.04,0.5,0.19,2.25, 0.0015, 0.05, 0.205, 0.45, -0.2}),
py::arg("free_parameters") = std::vector<double>({0.4,0.4,0.04,0.5,0.19,2.25,1.,0.046452,0.205,0.45,-0.2}),
py::arg("oldModelER") = false,
py::arg("SkewnessER") = -999.
)
Expand Down Expand Up @@ -346,8 +360,9 @@ PYBIND11_MODULE(nestpy, m)
m.def("execNEST", &execNEST);
m.def("GetEnergyRes", &GetEnergyRes);
m.def("GetBand", &GetBand);
m.def("default_nr_yields_params", []() { return NEST::NESTcalc::default_NRYieldsParam; });
m.def("default_nrer_widths_params", []() { return NEST::NESTcalc::default_NRERWidthsParam; });
m.def("default_nr_yields_params", []() { return default_NRYieldsParam; });
m.def("default_nrer_widths_params", []() { return default_NRERWidthsParam; });
m.def("default_er_yields_params", []() { return default_ERYieldsParam; });

//-----------------------------------------------------------------------
// LAr NEST bindings
Expand Down Expand Up @@ -581,4 +596,4 @@ PYBIND11_MODULE(nestpy, m)
.def("legacy_get_recombination_probability", &NEST::LArNEST::LegacyGetRecombinationProbability)
.def("legacy_get_let", &NEST::LArNEST::LegacyGetLinearEnergyTransfer);

}
}
6 changes: 5 additions & 1 deletion tests/core_nest_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def setUpClass(cls):

cls.nuisance = cls.nestcalc.default_NRYieldsParam
cls.free = cls.nestcalc.default_NRERWidthsParam
cls.er_params = cls.nestcalc.default_ERYieldsParam

def test_interaction_type_constructor(self):
for i in range(5):
Expand All @@ -83,6 +84,7 @@ def test_nestcalc_full_calculation(self):
result = self.nestcalc.FullCalculation(self.it, 1., 2., 3., 4, 5,
self.nuisance,
self.free,
self.er_params,
False)
assert isinstance(result, nestpy.NESTresult)

Expand Down Expand Up @@ -136,7 +138,7 @@ def test_nest_calc_get_detector(self):

def test_equality(self):
# Will call a test for the nearlyEqual function to ensure it still works.
self.nestcalc.GetYields(nestpy.INTERACTION_TYPE(0), 100., 2.9, 100., 0., 54, nestpy.default_nr_yields_params(), False)
self.nestcalc.GetYields(nestpy.INTERACTION_TYPE(0), 100., 2.9, 100., 0., 54, nestpy.default_nr_yields_params(), nestpy.default_er_yields_params(), False)


class TestSpectraWIMPTest(unittest.TestCase):
Expand All @@ -160,10 +162,12 @@ def setUpClass(cls):
cls.nestcalc = nestpy.NESTcalc(cls.detector)
cls.nuisance = cls.nestcalc.default_NRYieldsParam
cls.free = cls.nestcalc.default_NRERWidthsParam
cls.er_params = cls.nestcalc.default_ERYieldsParam
cls.result = cls.nestcalc.FullCalculation(
cls.it, 10., 3., 100., 131, 56,
cls.nuisance,
cls.free,
cls.er_params,
True)

cls.position = [2,3,4]
Expand Down

0 comments on commit 0be624f

Please sign in to comment.