Skip to content

Commit

Permalink
pre-commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoore24-24 committed Jul 6, 2023
1 parent 1dda268 commit 17e3163
Show file tree
Hide file tree
Showing 7 changed files with 421 additions and 124 deletions.
2 changes: 1 addition & 1 deletion src/_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ PYBIND11_MODULE(_ext, m) {
[](const output_wrapper ow, const int n_jets = 1, double beta = 0, double symmetry_cut = 0.1,
std::string symmetry_measure = "scalar_z", double R0 = 0.8, std::string recursion_choice = "larger_pt",
/*const FunctionOfPseudoJet<PseudoJet> * subtractor = 0,*/ double mu_cut = std::numeric_limits<double>::infinity()){

auto css = ow.cse;
std::vector<double> consts_groomed_px;
std::vector<double> consts_groomed_py;
Expand Down
26 changes: 20 additions & 6 deletions src/fastjet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,17 @@ def exclusive_jets_constituents(self, njets: int = 10) -> ak.Array:
"""

raise AssertionError()

def exclusive_jets_softdrop_grooming(
self, njets: int = 1, beta: int = 0, symmetry_cut: float = 0.1, symmetry_measure="scalar_z", R0: float = 0.8, recursion_choice="larger_pt",
#subtractor: int = 0,
mu_cut: float = float('inf'),
self,
njets: int = 1,
beta: int = 0,
symmetry_cut: float = 0.1,
symmetry_measure="scalar_z",
R0: float = 0.8,
recursion_choice="larger_pt",
# subtractor: int = 0,
mu_cut: float = float("inf"),
) -> ak.Array:
"""Performs softdrop pruning on jets.
Args:
Expand All @@ -385,11 +391,19 @@ def exclusive_jets_softdrop_grooming(
recursion_choice: Which recursion choice to use, found in RecursiveSymmetryCutBase.hh
subtractor: an optional pointer to a pileup subtractor (ignored if zero)
Returns:
Returns an array of values from the jet after it has been groomed by softdrop."""
Returns an array of values from the jet after it has been groomed by softdrop.
"""
raise AssertionError()

def exclusive_jets_energy_correlator(
self, njets: int = 1, beta: int = 1, npoint: int = 0, angles: int = -1, alpha=0, func="generalized", normalized=True,
self,
njets: int = 1,
beta: int = 1,
npoint: int = 0,
angles: int = -1,
alpha=0,
func="generalized",
normalized=True,
) -> ak.Array:
"""Returns the energy correlator of each exclusive jet.
Expand Down
86 changes: 61 additions & 25 deletions src/fastjet/_generalevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,53 +438,89 @@ def exclusive_jets_constituent_index(self, njets):
)
res = ak.Array(self._replace_multi())
return res

def exclusive_jets_softdrop_grooming(
self, njets=1, beta = 0.0, symmetry_cut = 0.1, symmetry_measure = "scalar_z", R0 = 0.8, recursion_choice = "larger_pt",
#subtractor = 0,
mu_cut = float('inf'),
self,
njets=1,
beta=0.0,
symmetry_cut=0.1,
symmetry_measure="scalar_z",
R0=0.8,
recursion_choice="larger_pt",
# subtractor = 0,
mu_cut=float("inf"),
):
if njets <= 0:
raise ValueError("Njets cannot be <= 0")

self._out = []
self._input_flag = 0
for i in range(len(self._clusterable_level)):
np_results = self._results[i].to_numpy_softdrop_grooming(
njets, beta, symmetry_cut, symmetry_measure, R0, recursion_choice, #subtractor,
mu_cut,
)
njets,
beta,
symmetry_cut,
symmetry_measure,
R0,
recursion_choice, # subtractor,
mu_cut,
)

px = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[0])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
py = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[1])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
pz = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[2])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
E = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[3])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
px = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[0])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
py = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[1])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
pz = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[2])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
E = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[3])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
jetpt = ak.Array(ak.contents.NumpyArray(np_results[5]))
jeteta = ak.Array(ak.contents.NumpyArray(np_results[6]))
jetphi = ak.Array(ak.contents.NumpyArray(np_results[7]))
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]))

self._out.append(ak.zip({
"constituents":
ak.zip(
{"px": px, "py": py, "pz": pz, "E": E}, depth_limit=2),
"msoftdrop": jetmass,
"ptsoftdrop": jetpt,
"etasoftdrop": jeteta,
"phisoftdrop": jetphi,
"Esoftdrop": jetE,
"pzsoftdrop": jetpz,},
depth_limit=1
self._out.append(
ak.zip(
{
"constituents": ak.zip(
{"px": px, "py": py, "pz": pz, "E": E}, depth_limit=2
),
"msoftdrop": jetmass,
"ptsoftdrop": jetpt,
"etasoftdrop": jeteta,
"phisoftdrop": jetphi,
"Esoftdrop": jetE,
"pzsoftdrop": jetpz,
},
depth_limit=1,
)
)
res = ak.Array(self._replace_multi())
return res


def exclusive_jets_energy_correlator(
self, njets=1, n_point=0, angles: int = -1, beta=1, alpha=0, func="generalized", normalized=True,
self,
njets=1,
n_point=0,
angles: int = -1,
beta=1,
alpha=0,
func="generalized",
normalized=True,
):
if njets <= 0:
raise ValueError("Njets cannot be <= 0")
Expand Down
86 changes: 64 additions & 22 deletions src/fastjet/_multievent.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,52 +214,94 @@ def exclusive_jets_constituent_index(self, njets):
)
out = ak.Array(ak.contents.ListOffsetArray(ak.index.Index64(off), out.layout))
return out

def exclusive_jets_softdrop_grooming(
self, njets=1, beta = 0.0, symmetry_cut = 0.1, symmetry_measure = "scalar_z", R0 = 0.8, recursion_choice = "larger_pt",
#subtractor = 0,
mu_cut = float('inf'),
self,
njets=1,
beta=0.0,
symmetry_cut=0.1,
symmetry_measure="scalar_z",
R0=0.8,
recursion_choice="larger_pt",
# subtractor = 0,
mu_cut=float("inf"),
):
if njets <= 0:
raise ValueError("Njets cannot be <= 0")
np_results = self._results.to_numpy_softdrop_grooming(
njets, beta, symmetry_cut, symmetry_measure, R0, recursion_choice, #subtractor,
njets,
beta,
symmetry_cut,
symmetry_measure,
R0,
recursion_choice, # subtractor,
mu_cut,
)

px = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[0])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
py = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[1])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
pz = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[2])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
E = ak.unflatten(ak.Array(ak.contents.NumpyArray(np_results[3])), ak.Array(ak.contents.NumpyArray(np_results[4])), highlevel=False)
px = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[0])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
py = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[1])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
pz = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[2])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
E = ak.unflatten(
ak.Array(ak.contents.NumpyArray(np_results[3])),
ak.Array(ak.contents.NumpyArray(np_results[4])),
highlevel=False,
)
jetpt = ak.Array(ak.contents.NumpyArray(np_results[5]))
jeteta = ak.Array(ak.contents.NumpyArray(np_results[6]))
jetphi = ak.Array(ak.contents.NumpyArray(np_results[7]))
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]))

out = ak.zip({
"constituents":
ak.zip(
{"px": px, "py": py, "pz": pz, "E": E}, depth_limit=2),
"msoftdrop": jetmass,
"ptsoftdrop": jetpt,
"etasoftdrop": jeteta,
"phisoftdrop": jetphi,
"Esoftdrop": jetE,
"pzsoftdrop": jetpz,},
depth_limit=1
out = ak.zip(
{
"constituents": ak.zip(
{"px": px, "py": py, "pz": pz, "E": E}, depth_limit=2
),
"msoftdrop": jetmass,
"ptsoftdrop": jetpt,
"etasoftdrop": jeteta,
"phisoftdrop": jetphi,
"Esoftdrop": jetE,
"pzsoftdrop": jetpz,
},
depth_limit=1,
)

return out

def exclusive_jets_energy_correlator(
self, njets=1, beta=1, npoint=0, angles=-1, alpha=0, func="generalized", normalized=True,
self,
njets=1,
beta=1,
npoint=0,
angles=-1,
alpha=0,
func="generalized",
normalized=True,
):
if njets <= 0:
raise ValueError("Njets cannot be <= 0")
np_results = self._results.to_numpy_energy_correlators(
njets, beta, npoint, angles, alpha, func, normalized,
njets,
beta,
npoint,
angles,
alpha,
func,
normalized,
)
out = ak.Array(ak.contents.NumpyArray(np_results))
return out
Expand Down
73 changes: 55 additions & 18 deletions src/fastjet/_pyjet.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,46 @@ def exclusive_jets_constituent_index(self, njets=10):

def exclusive_jets_constituents(self, njets=10):
return self._internalrep.exclusive_jets_constituents(njets)

def exclusive_jets_softdrop_grooming(
self, njets=1, beta = 0.0, symmetry_cut = 0.1, symmetry_measure = "scalar_z", R0 = 0.8, recursion_choice = "larger_pt",
#subtractor = 0,
mu_cut = float('inf'),
self,
njets=1,
beta=0.0,
symmetry_cut=0.1,
symmetry_measure="scalar_z",
R0=0.8,
recursion_choice="larger_pt",
# subtractor = 0,
mu_cut=float("inf"),
):
return self._internalrep.exclusive_jets_softdrop_grooming(
njets, beta, symmetry_cut, symmetry_measure, R0, recursion_choice, #subtractor,
njets,
beta,
symmetry_cut,
symmetry_measure,
R0,
recursion_choice, # subtractor,
mu_cut,
)

def exclusive_jets_energy_correlator(
self, njets=1, beta=1, npoint=0, angles=-1, alpha=0, func="generalized", normalized=True
self,
njets=1,
beta=1,
npoint=0,
angles=-1,
alpha=0,
func="generalized",
normalized=True,
):
return self._internalrep.exclusive_jets_energy_correlator(
njets, beta, npoint, angles, alpha, func, normalized,
njets,
beta,
npoint,
angles,
alpha,
func,
normalized,
)

def exclusive_jets_lund_declusterings(self, njets=10):
Expand Down Expand Up @@ -445,25 +469,38 @@ def exclusive_jets_constituents(self, njets=10):
return _dak_dispatch(self, "exclusive_jets_constituents", njets=njets)

def exclusive_jets_softdrop_grooming(
self, njets=1, beta = 0.0, symmetry_cut = 0.1, symmetry_measure = "scalar_z", R0 = 0.8, recursion_choice = "larger_pt",
#subtractor = 0,
mu_cut = float('inf'),
self,
njets=1,
beta=0.0,
symmetry_cut=0.1,
symmetry_measure="scalar_z",
R0=0.8,
recursion_choice="larger_pt",
# subtractor = 0,
mu_cut=float("inf"),
):
return _dak_dispatch(
self,
"exclusive_jets_softdrop_grooming",
njets=njets,
beta=beta,
symmetry_cut=symmetry_cut,
symmetry_measure=symmetry_measure,
R0=R0,
recursion_choice=recursion_choice,
#subtractor=subtractor,
njets=njets,
beta=beta,
symmetry_cut=symmetry_cut,
symmetry_measure=symmetry_measure,
R0=R0,
recursion_choice=recursion_choice,
# subtractor=subtractor,
mu_cut=mu_cut,
)

def exclusive_jets_energy_correlator(
self, njets=1, beta=1, npoint=0, angles=-1, alpha=0, func="generalized", normalized=False,
self,
njets=1,
beta=1,
npoint=0,
angles=-1,
alpha=0,
func="generalized",
normalized=False,
):
return _dak_dispatch(
self,
Expand Down
Loading

0 comments on commit 17e3163

Please sign in to comment.