From a3ca0cef10361aa3be2aa99ab8cb2863f43931d8 Mon Sep 17 00:00:00 2001 From: Ka Wa Ho Date: Wed, 11 Sep 2024 17:18:40 -0400 Subject: [PATCH 1/4] adding groomed jet radius and momentum balance for softdrop groomed jet --- src/_ext.cpp | 10 +++++++++- src/fastjet/_generalevent.py | 4 ++++ src/fastjet/_multievent.py | 4 ++++ src/fastjet/_singleevent.py | 4 ++++ tests/test_002-exclusive_jets.py | 14 ++++++++++++++ tests/test_008-dask.py | 14 ++++++++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/_ext.cpp b/src/_ext.cpp index 9d190311..452d190e 100644 --- a/src/_ext.cpp +++ b/src/_ext.cpp @@ -1658,6 +1658,8 @@ PYBIND11_MODULE(_ext, m) { std::vector jet_groomed_m; std::vector jet_groomed_E; std::vector jet_groomed_pz; + std::vector jet_groomed_delta_R; + std::vector jet_groomed_symmetry; fastjet::contrib::RecursiveSymmetryCutBase::SymmetryMeasure sym_meas = fastjet::contrib::RecursiveSymmetryCutBase::SymmetryMeasure::scalar_z; if (symmetry_measure == "scalar_z") { @@ -1703,6 +1705,8 @@ PYBIND11_MODULE(_ext, m) { jet_groomed_m.push_back(soft.m()); jet_groomed_E.push_back(soft.E()); jet_groomed_pz.push_back(soft.pz()); + jet_groomed_delta_R.push_back(soft.structure_of().delta_R()); + jet_groomed_symmetry.push_back(soft.structure_of().symmetry()); for (unsigned int k = 0; k < soft.constituents().size(); k++){ consts_groomed_px.push_back(soft.constituents()[k].px()); consts_groomed_py.push_back(soft.constituents()[k].py()); @@ -1723,6 +1727,8 @@ PYBIND11_MODULE(_ext, m) { auto jet_m = py::array(jet_groomed_m.size(), jet_groomed_m.data()); auto jet_E = py::array(jet_groomed_E.size(), jet_groomed_E.data()); auto jet_pz = py::array(jet_groomed_pz.size(), jet_groomed_pz.data()); + auto jet_delta_R = py::array(jet_groomed_delta_R.size(), jet_groomed_delta_R.data()); + auto jet_symmetry = py::array(jet_groomed_symmetry.size(), jet_groomed_symmetry.data()); return std::make_tuple( consts_px, @@ -1735,7 +1741,9 @@ PYBIND11_MODULE(_ext, m) { jet_phi, jet_m, jet_E, - jet_pz + jet_pz, + jet_delta_R, + jet_symmetry ); }, R"pbdoc( Performs softdrop pruning on jets. diff --git a/src/fastjet/_generalevent.py b/src/fastjet/_generalevent.py index 3333ebff..feef6fb0 100644 --- a/src/fastjet/_generalevent.py +++ b/src/fastjet/_generalevent.py @@ -491,6 +491,8 @@ def exclusive_jets_softdrop_grooming( jetmass = ak.Array(ak.contents.NumpyArray(np_results[8])) jetE = ak.Array(ak.contents.NumpyArray(np_results[9])) jetpz = ak.Array(ak.contents.NumpyArray(np_results[10])) + jetdeltaR = ak.Array(ak.contents.NumpyArray(np_results[11])) + jetsymmetry = ak.Array(ak.contents.NumpyArray(np_results[12])) self._out.append( ak.zip( @@ -504,6 +506,8 @@ def exclusive_jets_softdrop_grooming( "phisoftdrop": jetphi, "Esoftdrop": jetE, "pzsoftdrop": jetpz, + "deltaRsoftdrop": jetdeltaR, + "symmetrysoftdrop": jetsymmetry, }, depth_limit=1, ) diff --git a/src/fastjet/_multievent.py b/src/fastjet/_multievent.py index 9358fa4e..ccce578d 100644 --- a/src/fastjet/_multievent.py +++ b/src/fastjet/_multievent.py @@ -264,6 +264,8 @@ def exclusive_jets_softdrop_grooming( jetmass = ak.Array(ak.contents.NumpyArray(np_results[8])) jetE = ak.Array(ak.contents.NumpyArray(np_results[9])) jetpz = ak.Array(ak.contents.NumpyArray(np_results[10])) + jetdeltaR = ak.Array(ak.contents.NumpyArray(np_results[11])) + jetsymmetry = ak.Array(ak.contents.NumpyArray(np_results[12])) out = ak.zip( { @@ -276,6 +278,8 @@ def exclusive_jets_softdrop_grooming( "phisoftdrop": jetphi, "Esoftdrop": jetE, "pzsoftdrop": jetpz, + "deltaRsoftdrop": jetdeltaR, + "symmetrysoftdrop": jetsymmetry, }, depth_limit=1, ) diff --git a/src/fastjet/_singleevent.py b/src/fastjet/_singleevent.py index 2c1fa77f..2fdbaa9c 100644 --- a/src/fastjet/_singleevent.py +++ b/src/fastjet/_singleevent.py @@ -248,6 +248,8 @@ def exclusive_jets_softdrop_grooming( jetmass = ak.Array(ak.contents.NumpyArray(np_results[8])) jetE = ak.Array(ak.contents.NumpyArray(np_results[9])) jetpz = ak.Array(ak.contents.NumpyArray(np_results[10])) + jetdeltaR = ak.Array(ak.contents.NumpyArray(np_results[11])) + jetsymmetry = ak.Array(ak.contents.NumpyArray(np_results[12])) out = ak.zip( { @@ -260,6 +262,8 @@ def exclusive_jets_softdrop_grooming( "phisoftdrop": jetphi, "Esoftdrop": jetE, "pzsoftdrop": jetpz, + "deltaRsoftdrop": jetdeltaR, + "symmetrysoftdrop": jetsymmetry, }, depth_limit=1, ) diff --git a/tests/test_002-exclusive_jets.py b/tests/test_002-exclusive_jets.py index b6e8376e..d5ea0382 100644 --- a/tests/test_002-exclusive_jets.py +++ b/tests/test_002-exclusive_jets.py @@ -352,6 +352,8 @@ def test_exclusive_jets_softdrop_grooming_multi(): ], ), "msoftdrop": ak.Array([488.2395243115817, 488.2395243115817]), + "deltaRsoftdrop": ak.Array([0.009873899817126915, 0.009873899817126915]), + "symmetrysoftdrop": ak.Array([0.49727522889673303, 0.49727522889673303]), "ptsoftdrop": ak.Array([142.88274528437645, 142.88274528437645]), "etasoftdrop": ak.Array([2.726117171791057, 2.726117171791057]), "phisoftdrop": ak.Array([1.1012644074821902, 1.1012644074821902]), @@ -393,6 +395,18 @@ def test_exclusive_jets_softdrop_grooming_multi(): rtol=1e-12, atol=0, ), + ak.isclose( + ak.Array([softdrop_output.deltaRsoftdrop]), + ak.Array([softdrop.deltaRsoftdrop]), + rtol=1e-12, + atol=0, + ), + ak.isclose( + ak.Array([softdrop_output.symmetrysoftdrop]), + ak.Array([softdrop.symmetrysoftdrop]), + rtol=1e-12, + atol=0, + ), ak.isclose( ak.Array([softdrop_output.ptsoftdrop]), ak.Array([softdrop.ptsoftdrop]), diff --git a/tests/test_008-dask.py b/tests/test_008-dask.py index 946b7e66..79df05ac 100644 --- a/tests/test_008-dask.py +++ b/tests/test_008-dask.py @@ -179,6 +179,8 @@ def dask_multi_test_exclusive_jets_softdrop_grooming(): {"px": 32.45, "py": 63.21, "pz": 543.14, "E": 599.56}, ], "msoftdrop": ak.Array([488.2395243115817, 488.2395243115817]), + "deltaRsoftdrop": ak.Array([0.009873899817126915, 0.009873899817126915]), + "symmetrysoftdrop": ak.Array([0.49727522889673303, 0.49727522889673303]), "ptsoftdrop": ak.Array([142.88274528437645, 142.88274528437645]), "etasoftdrop": ak.Array([2.726117171791057, 2.726117171791057]), "phisoftdrop": ak.Array([1.1012644074821902, 1.1012644074821902]), @@ -220,6 +222,18 @@ def dask_multi_test_exclusive_jets_softdrop_grooming(): rtol=1e-12, atol=0, ), + ak.isclose( + ak.Array([softdrop_output.deltaRsoftdrop]), + ak.Array([softdrop.deltaRsoftdrop]), + rtol=1e-12, + atol=0, + ), + ak.isclose( + ak.Array([softdrop_output.symmetrysoftdrop]), + ak.Array([softdrop.symmetrysoftdrop]), + rtol=1e-12, + atol=0, + ), ak.isclose( ak.Array([softdrop_output.ptsoftdrop]), ak.Array([softdrop.ptsoftdrop]), From 3e2dba73c300292909d6a3f4a6133bc24495607f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 21:24:39 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_008-dask.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_008-dask.py b/tests/test_008-dask.py index 79df05ac..d1eeada4 100644 --- a/tests/test_008-dask.py +++ b/tests/test_008-dask.py @@ -179,8 +179,12 @@ def dask_multi_test_exclusive_jets_softdrop_grooming(): {"px": 32.45, "py": 63.21, "pz": 543.14, "E": 599.56}, ], "msoftdrop": ak.Array([488.2395243115817, 488.2395243115817]), - "deltaRsoftdrop": ak.Array([0.009873899817126915, 0.009873899817126915]), - "symmetrysoftdrop": ak.Array([0.49727522889673303, 0.49727522889673303]), + "deltaRsoftdrop": ak.Array( + [0.009873899817126915, 0.009873899817126915] + ), + "symmetrysoftdrop": ak.Array( + [0.49727522889673303, 0.49727522889673303] + ), "ptsoftdrop": ak.Array([142.88274528437645, 142.88274528437645]), "etasoftdrop": ak.Array([2.726117171791057, 2.726117171791057]), "phisoftdrop": ak.Array([1.1012644074821902, 1.1012644074821902]), From 3c6588f2cdc09524a4ed270fd6fade282fa6816c Mon Sep 17 00:00:00 2001 From: Ka Wa Ho Date: Wed, 11 Sep 2024 22:23:17 -0400 Subject: [PATCH 3/4] adding to test_exclusive_jets_softdrop_grooming test --- tests/test_002-exclusive_jets.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_002-exclusive_jets.py b/tests/test_002-exclusive_jets.py index d5ea0382..cb80c90a 100644 --- a/tests/test_002-exclusive_jets.py +++ b/tests/test_002-exclusive_jets.py @@ -234,6 +234,8 @@ def test_exclusive_jets_softdrop_grooming(): {"px": 32.45, "py": 63.21, "pz": 543.14, "E": 599.56}, ], "msoftdrop": 488.2395243115817, + "deltaRsoftdrop": 0.009873899817126915, + "symmetrysoftdrop": 0.49727522889673303, "ptsoftdrop": 142.88274528437645, "etasoftdrop": 2.726117171791057, "phisoftdrop": 1.1012644074821902, @@ -275,6 +277,18 @@ def test_exclusive_jets_softdrop_grooming(): rtol=1e-12, atol=0, ), + ak.isclose( + ak.Array([softdrop_output.deltaRsoftdrop]), + ak.Array([softdrop.deltaRsoftdrop]), + rtol=1e-12, + atol=0, + ), + ak.isclose( + ak.Array([softdrop_output.symmetrysoftdrop]), + ak.Array([softdrop.symmetrysoftdrop]), + rtol=1e-12, + atol=0, + ), ak.isclose( ak.Array([softdrop_output.ptsoftdrop]), ak.Array([softdrop.ptsoftdrop]), From 643d232ce4cf3dabae4bf0096315378c435be822 Mon Sep 17 00:00:00 2001 From: Ka Wa Ho Date: Fri, 13 Sep 2024 09:59:28 -0400 Subject: [PATCH 4/4] separating problematic call --- src/_ext.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/_ext.cpp b/src/_ext.cpp index 452d190e..2b10c7e9 100644 --- a/src/_ext.cpp +++ b/src/_ext.cpp @@ -1705,8 +1705,11 @@ PYBIND11_MODULE(_ext, m) { jet_groomed_m.push_back(soft.m()); jet_groomed_E.push_back(soft.E()); jet_groomed_pz.push_back(soft.pz()); - jet_groomed_delta_R.push_back(soft.structure_of().delta_R()); - jet_groomed_symmetry.push_back(soft.structure_of().symmetry()); + + auto sd_struct = soft.structure_of(); + jet_groomed_delta_R.push_back(sd_struct.delta_R()); + jet_groomed_symmetry.push_back(sd_struct.symmetry()); + for (unsigned int k = 0; k < soft.constituents().size(); k++){ consts_groomed_px.push_back(soft.constituents()[k].px()); consts_groomed_py.push_back(soft.constituents()[k].py());