Skip to content

Commit 43b1619

Browse files
Fix bug in example
1 parent 869ec70 commit 43b1619

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

examples/cpp/evolve-grid.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
#include <pineappl_capi.h>
12
#include <cstdint>
23
#include <cstdlib>
3-
#include <pineappl_capi.h>
4-
54
#include <cassert>
65
#include <cstddef>
7-
#include <iostream>
86
#include <string>
97
#include <algorithm>
108
#include <vector>
@@ -27,14 +25,15 @@ std::vector<double> generate_fake_ekos(
2725
std::vector<double> ops(flat_len);
2826

2927
for (std::size_t i = 0; i != flat_len; i++) {
30-
ops.push_back(distrib(gen));
28+
ops[i] = distrib(gen);
3129
}
3230

3331
return ops;
3432
}
3533

3634
int main() {
37-
std::string filename = "advanced-filling.pineappl.lz4";
35+
// TODO: How to get a Grid that can be evolved??
36+
std::string filename = "LHCB_WP_7TEV_opt.pineappl.lz4";
3837

3938
// read the grid from a file
4039
auto* grid = pineappl_grid_read(filename.c_str());
@@ -45,7 +44,8 @@ int main() {
4544
// Get the number of convolutions
4645
std::size_t n_convs = pineappl_grid_convolutions_len(grid);
4746

48-
// Fill the vector of unique convolution types
47+
// Fill the vector of unique convolution types. If the EKOs required for the Grid
48+
// are the same, then it suffices to only pass ONE single EKO.
4949
std::vector<pineappl_conv_type> conv_types;
5050
for (std::size_t i = 0; i != n_convs; i++) {
5151
pineappl_conv_type conv = pineappl_grid_conv_type(grid, i);
@@ -73,20 +73,14 @@ int main() {
7373
// ------------------ Construct the Operator Info ------------------
7474
// The Operator Info is a vector with length `N_conv * N_Q2_slices` whose
7575
// elements are `OperatorInfo` objects.
76-
std::vector<OperatorInfo> opinfo_slices(conv_types.size() * fac1.size());
77-
std::vector<std::size_t> tensor_shape = {pids1.size(), x1.size(), pids1.size(), x1.size()};
76+
std::vector<pineappl_operator_info> opinfo_slices(conv_types.size() * fac1.size());
7877
for (std::size_t i = 0; i != conv_types.size(); i++) {
7978
for (std::size_t j = 0; j != fac1.size(); j++) {
80-
OperatorInfo opinfo = {
79+
pineappl_operator_info opinfo = {
8180
FAC0, // fac0
8281
fac1[j], // fac1
83-
x1.data(), // x0
84-
x1.data(), // x1
85-
pids1.data(), // pids0
86-
pids1.data(), // pids1
8782
pid_basis,
8883
conv_types[i],
89-
tensor_shape.data()
9084
};
9185
opinfo_slices[i * fac1.size() + j] = opinfo;
9286
}
@@ -104,15 +98,18 @@ int main() {
10498
}
10599
}
106100
}
107-
std::cout << "Arrived Here!" << "\n";
108101

109102
// Construct the values of alphas
110103
std::vector<double> alphas_table(ren1.size(), 0.118);
111104
std::vector<double> xi = {1.0, 1.0, 1.0};
105+
std::vector<std::size_t> tensor_shape = {pids1.size(), x1.size(), pids1.size(), x1.size()};
106+
107+
pineappl_fk_table* fktable = pineappl_grid_evolve(grid, opinfo_slices.data(), order_mask.data(),
108+
op_slices.data(), x1.data(), x1.data(), pids1.data(), pids1.data(),
109+
tensor_shape.data(), xi.data(), ren1.data(), alphas_table.data());
112110

113-
pineappl_grid_evolve(grid, opinfo_slices.data(), order_mask.data(),
114-
op_slices.data(), xi.data(), ren1.data(), alphas_table.data());
115-
std::cout << "Where does the double free happen!" << "\n";
111+
pineappl_fktable_write(fktable, "evolved-grid.pineappl.lz4");
116112

117113
pineappl_grid_delete(grid);
114+
pineappl_fk_table_delete(fktable);
118115
}

0 commit comments

Comments
 (0)