CustomFunction

class CustomFunction : public madspace::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.

Public Types

enum CustomFunctionType

What the custom function computes.

Values:

enumerator cut

Acceptance factor, 0 rejects the event.

enumerator scale

Renormalization and factorization scales.

enumerator bias

Event bias.

Public Functions

CustomFunction(std::size_t function_index, CustomFunctionType type, std::size_t particle_count, const nested_vector2<me_int_t> &pdg_id_options = {})
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.

inline CustomFunction(const MatrixElementApi &function_api, CustomFunctionType type, std::size_t particle_count, const nested_vector2<me_int_t> &pdg_id_options = {})

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.

inline std::size_t function_index() const

Index of the loaded library in the context.

inline CustomFunctionType type() const

What the function computes.

inline bool dynamic_pdg_ids() const

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