diff --git a/examples/cpp/Makefile b/examples/cpp/Makefile index 22e7758f..0b5ff595 100644 --- a/examples/cpp/Makefile +++ b/examples/cpp/Makefile @@ -3,13 +3,14 @@ CXXFLAGS = -std=c++11 -O3 -Wall -Wextra PINEAPPL_DEPS != pkg-config --cflags --libs pineappl_capi LHAPDF_DEPS != pkg-config --cflags --libs lhapdf -all: convolute-grid display-channels fill-custom-grid fill-grid +all: convolute-grid display-channels display-orders fill-custom-grid fill-grid -test-examples: convolute-grid display-channels fill-custom-grid fill-grid +test-examples: convolute-grid display-channels display-orders fill-custom-grid fill-grid ./fill-grid ./fill-custom-grid ./convolute-grid ./display-channels + ./display-orders convolute-grid: convolute-grid.cpp $(CXX) $(CXXFLAGS) $< $(LHAPDF_DEPS) $(PINEAPPL_DEPS) -o $@ @@ -17,6 +18,9 @@ convolute-grid: convolute-grid.cpp display-channels: display-channels.cpp $(CXX) $(CXXFLAGS) $< $(PINEAPPL_DEPS) -o $@ +display-orders: display-orders.cpp + $(CXX) $(CXXFLAGS) $< $(PINEAPPL_DEPS) -o $@ + fill-custom-grid: fill-grid.cpp $(CXX) $(CXXFLAGS) $< -DUSE_CUSTOM_GRID_PARAMETERS $(PINEAPPL_DEPS) -o $@ @@ -26,4 +30,4 @@ fill-grid: fill-grid.cpp PHONY: clean clean: - rm -f convolute-grid display-channels fill-custom-grid fill-grid + rm -f convolute-grid display-channels display-orders fill-custom-grid fill-grid diff --git a/examples/cpp/display-orders.cpp b/examples/cpp/display-orders.cpp new file mode 100644 index 00000000..a02be72c --- /dev/null +++ b/examples/cpp/display-orders.cpp @@ -0,0 +1,52 @@ +#include + +#include +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + std::string filename = "drell-yan-rap-ll.pineappl.lz4"; + + switch (argc) { + case 2: + filename = argv[1]; + case 1: + break; + + default: + std::cout << "Usage: " << argv[0] << " [grid]\n"; + } + + // read the grid from a file + auto* grid = pineappl_grid_read(filename.c_str()); + + // how many perturbative orders does this grid contain? + std::size_t orders = pineappl_grid_order_count(grid); + + std::vector order_params(4 * orders); + + // read out all exponents of the perturbative orders in the grid + pineappl_grid_order_params(grid, order_params.data()); + + for (std::size_t order = 0; order != orders; ++order) { + std::cout << std::setw(4) << order << ' '; + + // exponent of the strong coupling + std::uint32_t exp_as = order_params.at(4 * order + 0); + // exponent of the electromagnetic/electroweak coupling + std::uint32_t exp_al = order_params.at(4 * order + 1); + // exponent of the renormalization log + std::uint32_t exp_lr = order_params.at(4 * order + 2); + // exponent of the factorization log + std::uint32_t exp_lf = order_params.at(4 * order + 3); + + std::cout << "O(as^" << exp_as << " a^" << exp_al << " lr^" << exp_lr << " lf^" << exp_lf + << ")\n"; + } + + // release memory + pineappl_grid_delete(grid); +}