madflow package

Module contents

madflow

Submodules

Phasespace module

PhaseSpace generation routines

The output momenta has always the structure (E, px, py, pz) When a complete set of momenta is output the structure is (n_events, n_particles, n_dim)

madflow.phasespace.rambo(xrand, n_particles, sqrts, masses=None, check_physical=False)

Implementation of the RAMBO phase space generator in TensorFlow RAMBO: RA(NDOM) M(OMENTA) B(EAUTIFULLY) O(RGANIZED) # a democratic multi-particle phase space generator # based on Comput. Phys. Commun. 40 (1986) 359-373

madflow.phasespace.ramboflow(xrand, nparticles, com_sqrts, masses=None)

Takes as input an array of nevent x ndim random points and outputs an array of momenta (nevents x nparticles x 4) in the C.O.M.

The two first particles are the two incoming particles which are always massless. The masses of the outgoing particles is given by the list masses if not given all outgoing particles are taken as massless

Parameters
  • xrand (tensor (nevents, (nparticles-2)*4+2)) – random numbers to generate momenta

  • nparticles (int) – number of external particles

  • com_sqrts (float) – center of mass energy

  • masses (lust (nparticles-2)) – masses of the outgoing particles

Returns

  • final_p (tensor (nevents, nparticles, 4)) – phase space point for all particles for all events (E, px, py, pz)

  • wgt (tensor (nevents)) – weight of the phase space points

  • x1 (tensor (nevents)) – momentum fraction of parton 1

  • x2 (tensor (nevents)) – momentum fraction of parton 2

class madflow.phasespace.PhaseSpaceGenerator(nparticles, com_sqrts, masses=None, com_output=True, algorithm='ramboflow')

Bases: object

Phase space generator class able to not only generate momenta but also apply cuts

Parameters
  • nparticles (int) – number of external particles

  • com_sqrts (float) – com energy

  • masses (list(float)) – mass of the outgoing particles

  • algorithm (str) – algoirhtm to be used (by default ramboflow)

  • com_output (bool) – whether the output should be on the com frame (default, true) or the lb frame (false)

clear_cuts()

Clear all cuts, if not running on eager mode, we need to regenerate call

static mt2(ps_point)

Transverse mass squared of the given ps point (nevents, 4)

static mt(ps_point)

Transverse mass of the given ps point

static pt(ps_point)

Compute the pt of the ps point (nevents, [:], 4)

register_cut(variable, particle=None, min_val=None, max_val=None)

Register the cut for the given variable for the given particle (if needed) The variables must be done as a string and be a valid method of this class the min and max values are the values between which the variable must be found

Warning

at this point the user is trusted to use the argument ‘particle’ whenever the variable applies to

The cut functions will return a tensor of the idx of the accepted events and a tensor of booleans

Parameters
  • variable (str) – name of the variable to which the cut applies

  • particle (int) – particle index to which the cut applies

  • min_val (float) – minimum accepted value of the variable

  • max_val (float) – maximum accepted value of the variable

Utilities module

Utilities and wrappers for quickstarting integration

The main utility in this module is one_matrix_integration which is a wrapper to a full Monte Carlo integration of a given matrix element generated with madgraph.

For the example below the matrix element generated is g g > t t~

>>> from madflow.utilities import one_matrix_integration
>>> from pdfflow import mkPDF
>>> pdf = mkPDF("NNPDF31_nnlo_as_0118/0")
>>> one_matrix_integration(matrix, model_params, pdf=pdf, flavours=(0,), out_masses=[173.0, 173.0])
[INFO]  > Final results: 103.439 +/- 0.1147
madflow.utilities.generate_initial_states(matrices)

Reads a list of matrices and outputs a list of tuples of initial states each element in the list will be a tuple ([flavours hadron 1, flavours hadron 2]) for each matrix

madflow.utilities.one_matrix_integration(matrix, model_params, sqrts=7000.0, n_events=100000, n_iter=5, q=91.46, pdf=None, flavours=None, out_masses=None)

Receives a matrix element from Madgraph

Wavefunctions module

Wave functions

madflow.wavefunctions_flow.sign(x, y)

Fortran’s sign transfer function

madflow.wavefunctions_flow.signvec(x, y)

Fortran’s sign transfer function

madflow.wavefunctions_flow.sxxxxx(p, nss)

Defines a scalar wavefunction. Input momenta have shape (num events, 4).

Parameters
  • p (tf.Tensor, scalar boson four-momenta of shape=(None,4)) –

  • nss (tf.Tensor, final|initial state of shape=(), values=(+1|-1)) –

Returns

phi

Return type

tf.Tensor, scalar wavefunction of shape=(3,None)

madflow.wavefunctions_flow.ixxxxx(p, fmass, nhel, nsf)

Defines an inflow fermion wavefunction. Input momenta have shape (num events, 4).

Parameters
  • p (tf.Tensor, fermion four-momenta of shape=(None,4)) –

  • fmass (tf.Tensor, fermion mass of shape=()) –

  • nhel (tf.Tensor, fermion helicity of shape=()) –

  • nsf (tf.Tensor, particle|anti-particle of shape=(), values=(+1|-1)) –

Returns

|fi>

Return type

tf.Tensor, fermion wavefunction of shape=(6,None)

madflow.wavefunctions_flow.oxxxxx(p, fmass, nhel, nsf)

Defines an outgoing fermion wavefunction. Input momenta have shape (num events, 4).

Parameters
  • p (tf.Tensor, fermion four-momenta of shape=(None,4)) –

  • fmass (tf.Tensor, fermion mass of shape=()) –

  • nhel (tf.Tensor, fermion helicity of shape=()) –

  • nsf (tf.Tensor, particle|anti-particle of shape=(), values=(+1|-1)) –

Returns

<fo|

Return type

tf.Tensor, fermion wavefunction of shape=(6,None)

madflow.wavefunctions_flow.vxxxxx(p, vmass, nhel, nsv)

Defines a vector wavefunction. nhel=4 is for checking BRST. Input momenta have shape (num events, 4).

Parameters
  • p (tf.Tensor, vector boson four-momenta of shape=(None,4)) –

  • vmass (tf.Tensor, boson mass of shape=()) –

  • nhel (tf.Tensor, boson helicity of shape=(), 0 is forbidden if vmass=0.0) –

  • nsv (tf.Tensor, final|initial state of shape=(), values=(+1|-1)) –

Returns

epsilon^{mu(v)}

Return type

tf.Tensor, vector wavefunction of shape=(6,None)

Parameters module

Utilities and functions to deal with the parameters of the model

class madflow.parameters.Model(constants, functions)

Bases: object

This class is instantiated with knowledge about all couplings and parameters in the process of interest and provides an interface to compute them in a per-phase space basis

Parameters
  • constants (tuple(DTYPE)) – tuple with all constants of the model

  • functions (tuple(functions)) – tuple with all parameters of the model which depend on g_s

property frozen

Whether the model is frozen for a given value of alpha_s or not

freeze_alpha_s(alpha_s)

The model can be frozen to a specific value of alpha_s such that all phase space points are evaluated at that value :param alpha_s: :type alpha_s: float

unfreeze()

Remove the frozen status

get_masses()

Get the masses that entered the model as constants

parse_parameter(parameter_name)

Parse a (constant) parameter given its string name

evaluate(alpha_s=None)

Evaluate alpha_s, if the model is frozen returns the frozen values

LHE writer module