CustomFunction

class madspace.CustomFunction(*args, **kwargs)

Bases: FunctionGenerator

A user-supplied function of the event momenta, loaded as a UMAMI library.

Custom cuts, scales and biases use the UMAMI interface as a generic batched function. The library is loaded like a matrix element, with Context::load_matrix_element. It receives the momenta (UMAMI_IN_MOMENTA), the particle count (UMAMI_IN_PARTICLE_COUNT) and the PDG ids of the external particles (UMAMI_IN_PDG_IDS). It returns one value per event under UMAMI_OUT_CUT or UMAMI_OUT_BIAS, or a scale returns the three values UMAMI_OUT_REN_SCALE, UMAMI_OUT_FACT_SCALE_1 and UMAMI_OUT_FACT_SCALE_2.

With a single PDG-id option the ids are constant. With several options the ids are selected per event by the flavor_index argument.

batch is the leading batch dimension.

Arguments

  • momenta – float, shape (batch, particle_count, 4) – the event momenta.

  • flavor_index – int, shape (batch,) – index into the PDG-id options. Present only with more than one option.

Returns

  • cut or bias – float, shape (batch,) – the function value.

  • ren_scale, fact_scale1, fact_scale2 – float, shape (batch,) – the scales, for a function of type scale.

Overloaded function.

  1. __init__(self: madspace._madspace_py.CustomFunction, function_index: typing.SupportsInt, type: madspace._madspace_py.CustomFunction.CustomFunctionType, particle_count: typing.SupportsInt, pdg_id_options: collections.abc.Sequence[collections.abc.Sequence[typing.SupportsInt]] = []) -> None

Parameters:
  • function_index – Index of the loaded library in the context.

  • type – What the function computes.

  • particle_count – Number of external particles.

  • pdg_id_options – PDG ids of the external particles, one list per flavor option. Empty passes zeros.

  1. __init__(self: madspace._madspace_py.CustomFunction, function_api: madspace._madspace_py.MatrixElementApi, type: madspace._madspace_py.CustomFunction.CustomFunctionType, particle_count: typing.SupportsInt, pdg_id_options: collections.abc.Sequence[collections.abc.Sequence[typing.SupportsInt]] = []) -> None

Take the index from an already-loaded library.

Parameters:
  • function_api – The loaded library.

  • type – What the function computes.

  • particle_count – Number of external particles.

  • pdg_id_options – See the other constructor.

class CustomFunctionType(*args, **kwargs)

Bases: pybind11_object

Members:

cut

scale

bias

Overloaded function.

  1. __init__(self: madspace._madspace_py.CustomFunction.CustomFunctionType, value: typing.SupportsInt) -> None

  2. __init__(self: madspace._madspace_py.CustomFunction.CustomFunctionType, name: str) -> None

bias = <CustomFunctionType.bias: 2>
cut = <CustomFunctionType.cut: 0>
CustomFunction.CustomFunctionType.name -> str
scale = <CustomFunctionType.scale: 1>
property value
bias = <CustomFunctionType.bias: 2>
cut = <CustomFunctionType.cut: 0>
dynamic_pdg_ids(self: madspace._madspace_py.CustomFunction) → bool

Whether the PDG ids are selected per event by a flavor_index argument.

function_index(self: madspace._madspace_py.CustomFunction) → int

Index of the loaded library in the context.

scale = <CustomFunctionType.scale: 1>
type(self: madspace._madspace_py.CustomFunction) → madspace._madspace_py.CustomFunction.CustomFunctionType

What the function computes.