Crate pineappl_capi

source ·
Expand description

The C-language interface for PineAPPL.

The PineAPPL Application Programming Interface for the C language (CAPI) defines types and functions that allow PineAPPL to be used without having to write Rust code, and instead offering

  • C or C++, or
  • Fortran as programming languages. Fortran is supported using the iso_c_binding module to wrap CAPI’s functions (see the Fortran example in the repository).

Note that the CAPI only defines a subset of functionality available in the Rust module, which is extended on an as-needed basis. If you happen to miss a function please open a new issue on the github page.

§Using and linking the CAPI

To use PineAPPL’s CAPI you must include its header pineappl_capi.h. To successfully build your program, you should rely on pkgconf or pkg-conf, as follows:

pkg-config --cflags pineappl_capi
pkg-config --libs pineappl_capi

This will read PineAPPL’s .pc file and print the neccessary CFLAGS (--cflags) and linker flags (--libs). This procedure is supported by many build systems, such as

§Strings and other types

Strings used in this library are have the Rust type *const c_char or *mut c_char and correspond to the C types const char* and char*, respectively. The strings are assumed to be encoded using UTF-8, which Rust uses internally.

All other built-in types in Rust (f64, usize, i32, u32, …) correspond to types in C as defined by the translation tables of cbindgen. If in doubt, consult the generated header pineappl_capi.h.

Structs§

  • Key-value storage for passing optional information during grid creation with pineappl_grid_new.
  • Type for defining a luminosity function.

Functions§

  • Returns the number of bins in grid.
  • Returns the number of dimensions of the bins this grid has.
  • Write the left limits for the specified dimension into left.
  • Write the right limits for the specified dimension into right.
  • Stores the bin sizes of grid in bin_sizes.
  • Returns a cloned object of grid.
  • Convolutes the specified grid with the PDF xfx, which is the PDF for a hadron with the PDG id pdg_id, and strong coupling alphas. These functions must evaluate the PDFs for the given x and q2 for the parton with the given PDG id, pdg_id, and return the result. Note that the value must be the PDF multiplied with its argument x. The value of the pointer state provided to these functions is the same one given to this function. The parameter order_mask must be as long as there are perturbative orders contained in grid and is used to selectively disable (false) or enable (true) individual orders. If order_mask is set to NULL, all orders are active. The parameter lumi_mask can be used similarly, but must be as long as the luminosity function grid was created with has entries, or NULL to enable all luminosities. The values xi_ren and xi_fac can be used to vary the renormalization and factorization from its central value, which corresponds to 1.0. After convolution of the grid with the PDFs the differential cross section for each bin is written into results.
  • Convolutes the specified grid with the PDFs xfx1 and xfx2, which are the PDFs of hadrons with PDG ids pdg_id1 and pdg_id2, respectively, and strong coupling alphas. These functions must evaluate the PDFs for the given x and q2 for the parton with the given PDG id, pdg_id, and return the result. Note that the value must be the PDF multiplied with its argument x. The value of the pointer state provided to these functions is the same one given to this function. The parameter order_mask must be as long as there are perturbative orders contained in grid and is used to selectively disable (false) or enable (true) individual orders. If order_mask is set to NULL, all orders are active. The parameter lumi_mask can be used similarly, but must be as long as the luminosity function grid was created with has entries, or NULL to enable all luminosities. The values xi_ren and xi_fac can be used to vary the renormalization and factorization from its central value, which corresponds to 1.0. After convolution of the grid with the PDFs the differential cross section for each bin is written into results.
  • Try to deduplicate channels of grid by detecting pairs of them that contain the same subgrids. The numerical equality is tested using a tolerance of ulps, given in units of least precision.
  • Delete a grid previously created with pineappl_grid_new.
  • Fill grid for the given momentum fractions x1 and x2, at the scale q2 for the given value of the order, observable, and lumi with weight.
  • Fill grid for the given momentum fractions x1 and x2, at the scale q2 for the given value of the order and observable with weights. The parameter of weight must contain a result for entry of the luminosity function the grid was created with.
  • Fill grid with as many points as indicated by size.
  • Return the value for key stored in grid. If key isn’t found, NULL will be returned. After usage the string must be deallocated using pineappl_string_delete.
  • Return the luminosity function of grid.
  • Merges other into grid and subsequently deletes other.
  • Merges the bins of corresponding to the indices from the half-open interval [from, to] into a single bin.
  • Creates a new and empty grid. The creation requires four different sets of parameters:
  • Optimizes the grid representation for space efficiency.
  • Optimizes the grid representation for space efficiency. The parameter flags determines which optimizations are applied, see GridOptFlags.
  • Return the number of orders in grid.
  • Write the order parameters of grid into order_params.
  • Read a PineAPPL grid from a file with name filename.
  • Scale all grids in grid by factor.
  • Scales each subgrid by a bin-dependent factor given in factors. If a bin does not have a corresponding entry in factors it is not rescaled. If factors has more entries than there are bins the superfluous entries do not have an effect.
  • Scales each subgrid by a factor which is the product of the given values alphas, alpha, logxir, and logxif, each raised to the corresponding powers for each subgrid. In addition, every subgrid is scaled by a factor global independently of its order.
  • Sets an internal key-value pair for the grid.
  • Sets a remapper for the grid. This can be used to ‘upgrade’ one-dimensional bin limits to N-dimensional ones. The new bin limits must be given in the form of tuples giving the left and right limits, and a tuple for each dimension.
  • Splits the grid such that the luminosity function contains only a single combination per channel.
  • Write grid to a file with name filename. If filename ends in .lz4 the grid is automatically LZ4 compressed.
  • Get the boolean-valued parameter with name key stored in key_vals.
  • Delete the previously created object pointed to by key_vals.
  • Get the double-valued parameter with name key stored in key_vals.
  • Get the string-valued parameter with name key stored in key_vals.
  • Return a pointer to newly-created pineappl_keyval object.
  • Set the double-valued parameter with name key to value in key_vals.
  • Set the double-valued parameter with name key to value in key_vals.
  • Set the int-valued parameter with name key to value in key_vals.
  • Set the string-valued parameter with name key to value in key_vals.
  • Get the int-valued parameter with name key stored in key_vals.
  • Adds a linear combination of initial states to the luminosity function lumi.
  • Returns the number of combinations of the luminosity function lumi for the specified entry.
  • Returns the number of channel for the luminosity function lumi.
  • Delete luminosity function previously created with pineappl_lumi_new.
  • Read out the channel with index entry of the luminosity function lumi. The PDG ids and factors will be copied into pdg_ids and factors.
  • Creates a new luminosity function and returns a pointer to it. If no longer needed, the object should be deleted using pineappl_lumi_delete.
  • Deletes a string previously allocated by pineappl_grid_key_value. If string is a NULL pointer this function does nothing.