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

feat: adding groomed jet radius and momentum balance variables for softdrop groomed jet #312

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion src/_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,8 @@ PYBIND11_MODULE(_ext, m) {
std::vector<double> jet_groomed_m;
std::vector<double> jet_groomed_E;
std::vector<double> jet_groomed_pz;
std::vector<double> jet_groomed_delta_R;
std::vector<double> jet_groomed_symmetry;

fastjet::contrib::RecursiveSymmetryCutBase::SymmetryMeasure sym_meas = fastjet::contrib::RecursiveSymmetryCutBase::SymmetryMeasure::scalar_z;
if (symmetry_measure == "scalar_z") {
Expand Down Expand Up @@ -1703,6 +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());

auto sd_struct = soft.structure_of<fastjet::contrib::SoftDrop>();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewfeickert and @rkansal47 I would like to hear suggestions on solving this failed test (https://github.com/scikit-hep/fastjet/actions/runs/10819914062/job/30018826074?pr=312#step:7:135). The RuntimeError std::bad_cast is coming from this specific line calling the dynamic casting in (https://github.com/alisw/fastjet/blob/master/fastjet/include/fastjet/PseudoJet.hh#L1126). The error thrown is happening on MacOS only. I can replicate this error on my own Mac but calling the same function in C++ only script with the same fastjet-contrib version did not give such an error. So I suspect this is related to pybind or how we compile the code. I am unfamiliar with both and would like to hear suggestions for things to try from any experts on this project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to ask (in addition to @rkansal47) other people that have touched the C++: @jpivarski @jmduarte @chrispap95 @lgray @aryan26roy

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());
Expand All @@ -1723,6 +1730,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,
Expand All @@ -1735,7 +1744,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.
Expand Down
4 changes: 4 additions & 0 deletions src/fastjet/_generalevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -504,6 +506,8 @@ def exclusive_jets_softdrop_grooming(
"phisoftdrop": jetphi,
"Esoftdrop": jetE,
"pzsoftdrop": jetpz,
"deltaRsoftdrop": jetdeltaR,
"symmetrysoftdrop": jetsymmetry,
},
depth_limit=1,
)
Expand Down
4 changes: 4 additions & 0 deletions src/fastjet/_multievent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -276,6 +278,8 @@ def exclusive_jets_softdrop_grooming(
"phisoftdrop": jetphi,
"Esoftdrop": jetE,
"pzsoftdrop": jetpz,
"deltaRsoftdrop": jetdeltaR,
"symmetrysoftdrop": jetsymmetry,
},
depth_limit=1,
)
Expand Down
4 changes: 4 additions & 0 deletions src/fastjet/_singleevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -260,6 +262,8 @@ def exclusive_jets_softdrop_grooming(
"phisoftdrop": jetphi,
"Esoftdrop": jetE,
"pzsoftdrop": jetpz,
"deltaRsoftdrop": jetdeltaR,
"symmetrysoftdrop": jetsymmetry,
},
depth_limit=1,
)
Expand Down
28 changes: 28 additions & 0 deletions tests/test_002-exclusive_jets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]),
Expand Down Expand Up @@ -352,6 +366,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]),
Expand Down Expand Up @@ -393,6 +409,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]),
Expand Down
18 changes: 18 additions & 0 deletions tests/test_008-dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +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]
),
"ptsoftdrop": ak.Array([142.88274528437645, 142.88274528437645]),
"etasoftdrop": ak.Array([2.726117171791057, 2.726117171791057]),
"phisoftdrop": ak.Array([1.1012644074821902, 1.1012644074821902]),
Expand Down Expand Up @@ -220,6 +226,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]),
Expand Down
Loading