Skip to content

Commit 23c4bf7

Browse files
Fix C++ OOP interface and example
1 parent d76fa8b commit 23c4bf7

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

examples/object-oriented-cpp/dyaa.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <cstddef>
66
#include <cstdint>
77
#include <cstdio>
8-
#include <memory>
98
#include <random>
109
#include <vector>
1110

@@ -108,9 +107,10 @@ int main() {
108107
// Name of the PDF sets to be used for the convolutions
109108
std::string pdfset1 = "NNPDF31_nlo_as_0118_luxqed";
110109
std::string pdfset2 = "MSHT20qed_nnlo";
110+
const std::size_t nb_convolutions = 2;
111111

112112
// --- create a new `Channels` function for the $\gamma\gamma$ initial state
113-
PineAPPL::Channels channels;
113+
PineAPPL::Channels channels(nb_convolutions);
114114
PineAPPL::SubChannelEntry subchannels;
115115
subchannels.entry.push_back({{22, 22}, 1.0});
116116
PineAPPL::ChannelsEntry channels_entry;
@@ -150,7 +150,7 @@ int main() {
150150
pineappl_map scales_mapping = PINEAPPL_MAP_APPL_GRID_H0; // Mapping method
151151
pineappl_map moment_mapping = PINEAPPL_MAP_APPL_GRID_F2;
152152
pineappl_interp_meth interpolation_meth = PINEAPPL_INTERP_METH_LAGRANGE;
153-
std::vector<pineappl_interp_tuples> interpolations = {
153+
std::vector<pineappl_interp> interpolations = {
154154
{1e2, 1e8, 40, 3, scales_reweight, scales_mapping,
155155
interpolation_meth}, // Interpolation fo `scales`
156156
{2e-7, 1.0, 50, 3, moment_reweight, moment_mapping,

pineappl_capi/include/PineAPPL.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct Channels {
4141
pineappl_channels *raw;
4242

4343
/** @brief Constructor. */
44-
Channels() : raw(pineappl_channels_new()) {}
44+
Channels(const std::size_t convolutions) : raw(pineappl_channels_new(convolutions)) {}
4545
Channels(const Channels &) = delete;
4646
Channels(Channels &&) = delete;
4747

@@ -62,9 +62,6 @@ struct Channels {
6262
const std::size_t combinations = c.channels_entry.size();
6363
if (combinations == 0) return;
6464

65-
const std::size_t nb_convolutions =
66-
c.channels_entry[0].entry[0].first.size();
67-
6865
std::vector<std::int32_t> pids;
6966
std::vector<double> weights;
7067
for (const SubChannelEntry &s : c.channels_entry) {
@@ -75,8 +72,7 @@ struct Channels {
7572
weights.push_back(m.second);
7673
}
7774
}
78-
pineappl_channels_add(this->raw, combinations, nb_convolutions, pids.data(),
79-
weights.data());
75+
pineappl_channels_add(this->raw, combinations, pids.data(), weights.data());
8076
}
8177

8278
/**
@@ -154,12 +150,15 @@ struct Grid {
154150
* @param bin_limits bin_limits
155151
* @param mu_scales indexes representing the scales
156152
*/
157-
Grid(std::vector<Order> &orders, const Channels &channels,
158-
pineappl_pid_basis pid_basis, std::vector<int32_t> pids,
153+
Grid(std::vector<Order> &orders,
154+
const Channels &channels,
155+
pineappl_pid_basis pid_basis,
156+
std::vector<int32_t> pids,
159157
std::vector<pineappl_conv_type> &convolution_types,
160158
std::vector<pineappl_kinematics> &kinematics,
161-
std::vector<pineappl_interp_tuples> &interp,
162-
std::vector<double> &bin_limits, std::vector<std::size_t> &mu_scales)
159+
std::vector<pineappl_interp> &interp,
160+
std::vector<double> &bin_limits,
161+
std::vector<std::size_t> &mu_scales)
163162
: Grid(nullptr) {
164163
const std::size_t n_orders = orders.size();
165164
const std::size_t n_bins = bin_limits.size() - 1;
@@ -186,9 +185,9 @@ struct Grid {
186185
}
187186

188187
this->raw = pineappl_grid_new2(
189-
pid_basis, channels.raw, n_orders, raw_orders.data(), n_bins,
190-
bin_limits.data(), n_convs, convolution_types.data(), pids.data(),
191-
kinematics.data(), interp.data(), mu_scales.data());
188+
n_bins, bin_limits.data(), n_orders, raw_orders.data(), channels.raw,
189+
pid_basis, convolution_types.data(), pids.data(), interp.size(),
190+
interp.data(), kinematics.data(), mu_scales.data());
192191
}
193192

194193
/**

0 commit comments

Comments
 (0)