Skip to content

Fix CAPI #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/cpp/advanced-filling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ int main() {
// Construct the channel object based on the nb of convolutions
std::size_t nb_convolutions = 2;
std::size_t nb_channels = 2;
auto* channels = pineappl_channels_new();
auto* channels = pineappl_channels_new(nb_convolutions);
int32_t pids[] = { 2, -2, 4, -4 };
double factors[] = { 1.0, 1.0 };
pineappl_channels_add(channels, nb_channels, nb_convolutions, pids, factors);
pineappl_channels_add(channels, nb_channels, pids, factors);

std::size_t channel_count = 1;

Expand Down Expand Up @@ -56,7 +56,7 @@ int main() {
pineappl_map scales_mapping = PINEAPPL_MAP_APPL_GRID_H0; // Mapping method
pineappl_map moment_mapping = PINEAPPL_MAP_APPL_GRID_F2;
pineappl_interp_meth interpolation_meth = PINEAPPL_INTERP_METH_LAGRANGE;
pineappl_interp_tuples interpolations[3] = {
pineappl_interp interpolations[3] = {
{ 1e2, 1e8, 40, 3, scales_reweight, scales_mapping, interpolation_meth }, // Interpolation fo `scales`
{ 2e-7, 1.0, 50, 3, moment_reweight, moment_mapping, interpolation_meth }, // Interpolation fo `x1`
{ 2e-7, 1.0, 50, 3, moment_reweight, moment_mapping, interpolation_meth }, // Interpolation fo `x2`
Expand All @@ -71,8 +71,8 @@ int main() {
// create a new grid with the previously defined channels, 3 perturbative orders defined by the
// exponents in `orders`, 24 bins given as the 25 limits in `bins` and potential extra
// parameters in `keyval`.
auto* grid = pineappl_grid_new2(pid_basis, channels, orders.size() / 5, orders.data(), bins.size() - 1,
bins.data(), nb_convolutions, convolution_types, pdg_ids, kinematics, interpolations, mu_scales);
auto* grid = pineappl_grid_new2(bins.size() - 1, bins.data(), orders.size() / 5, orders.data(),
channels, pid_basis, convolution_types, pdg_ids, 3, interpolations, kinematics, mu_scales);

// now we no longer need `channels`
pineappl_channels_delete(channels);
Expand Down
17 changes: 7 additions & 10 deletions examples/cpp/fill-grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,8 @@ int main() {
// ---
// Create all channels

// this object will contain all channels (initial states) that we define
auto* channels = pineappl_channels_new();

// Specify the dimension of the channel, ie the number of convolutions required
std::size_t nb_convolutions = 2;
// this object will contain all channels (for two initial states) that we define
auto* channels = pineappl_channels_new(2);

// photon-photon initial state, where `22` is the photon (PDG MC ids)
int32_t pids1[] = { 22, 22 };
Expand All @@ -128,7 +125,7 @@ int main() {
double factors1[] = { 1.0 };

// define the channel #0
pineappl_channels_add(channels, 1, nb_convolutions, pids1, factors1);
pineappl_channels_add(channels, 1, pids1, factors1);

// create another channel, which we won't fill, however

Expand All @@ -143,7 +140,7 @@ int main() {
// can also pass `nullptr`

// define the channel #1
pineappl_channels_add(channels, 3, nb_convolutions, pids2, nullptr);
pineappl_channels_add(channels, 3, pids2, nullptr);

// ---
// Specify the perturbative orders that will be filled into the grid
Expand Down Expand Up @@ -201,7 +198,7 @@ int main() {
pineappl_map scales_mapping = PINEAPPL_MAP_APPL_GRID_H0; // Mapping method
pineappl_map moment_mapping = PINEAPPL_MAP_APPL_GRID_F2;
pineappl_interp_meth interpolation_meth = PINEAPPL_INTERP_METH_LAGRANGE;
pineappl_interp_tuples interpolations[3] = {
pineappl_interp interpolations[3] = {
{ 1e2, 1e8, 40, 3, scales_reweight, scales_mapping, interpolation_meth }, // Interpolation fo `scales`
{ 2e-7, 1.0, 50, 3, moment_reweight, moment_mapping, interpolation_meth }, // Interpolation fo `x1`
{ 2e-7, 1.0, 50, 3, moment_reweight, moment_mapping, interpolation_meth }, // Interpolation fo `x2`
Expand All @@ -216,8 +213,8 @@ int main() {
// create a new grid with the previously defined channels, 3 perturbative orders defined by the
// exponents in `orders`, 24 bins given as the 25 limits in `bins` and potential extra
// parameters in `keyval`.
auto* grid = pineappl_grid_new2(pid_basis, channels, orders.size() / 5, orders.data(), bins.size() - 1,
bins.data(), nb_convolutions, convolution_types, pdg_ids, kinematics, interpolations, mu_scales);
auto* grid = pineappl_grid_new2(bins.size() - 1, bins.data(), orders.size() / 5, orders.data(),
channels, pid_basis, convolution_types, pdg_ids, 3, interpolations, kinematics, mu_scales);

// now we no longer need `keyval` and `channels`
pineappl_channels_delete(channels);
Expand Down
2 changes: 1 addition & 1 deletion pineappl_capi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ rename_variants = "ScreamingSnakeCase"
"ReweightMeth" = "pineappl_reweight_meth"
"Map" = "pineappl_map"
"InterpMeth" = "pineappl_interp_meth"
"InterpTuples" = "pineappl_interp_tuples"
"Interp" = "pineappl_interp"
"KeyVal" = "pineappl_keyval"
"SubGrid" = "pineappl_subgrid"
"GridOptFlags" = "pineappl_gof"
Expand Down
Loading
Loading