Skip to content

Commit

Permalink
Improve C++ examples
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Nov 4, 2023
1 parent 8d10793 commit 6efd750
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/cpp/display-channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ int main(int argc, char* argv[]) {
std::vector<double> factors(combinations);
std::vector<int> pids(2 * combinations);

// read out the channel with index given by `channel`, writing the particle identifiers into
// `pids` and the corresponding factors into `factors`
pineappl_lumi_entry(channels, channel, pids.data(), factors.data());

for (std::size_t combination = 0; combination != combinations; ++combination) {
Expand All @@ -49,6 +51,7 @@ int main(int argc, char* argv[]) {
std::cout << " + ";
}

// print factor and particle ids
std::cout << factor << " x (" << std::setw(3) << pida << ',' << std::setw(4) << pidb
<< ")";
}
Expand Down
8 changes: 6 additions & 2 deletions examples/cpp/fill-grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int main() {
// instance), this isn't a limitation.

// we bin the rapidity of the final-state lepton pair from 0 to 2.4 in steps of 0.1
double bins[] = {
std::vector<double> bins = {
0.0,
0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2,
1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4
Expand Down Expand Up @@ -203,7 +203,11 @@ int main() {
pineappl_keyval_set_string(keyval, "subgrid_type", "LagrangeSubgrid");
#endif

auto* grid = pineappl_grid_new(channels, orders.size() / 4, orders.data(), 24, bins, keyval);
// 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_new(channels, orders.size() / 4, orders.data(), bins.size() - 1,
bins.data(), keyval);

// now we no longer need `keyval` and `lumi`
pineappl_keyval_delete(keyval);
Expand Down

0 comments on commit 6efd750

Please sign in to comment.