Skip to content

Commit b2bf81b

Browse files
Fix bug in order masking
1 parent 47f7044 commit b2bf81b

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

examples/cpp/evolve-grid.cpp

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ int main() {
5050
// TODO: How to get a Grid that can be evolved??
5151
std::string filename = "LHCB_WP_7TEV_opt.pineappl.lz4";
5252

53+
// disable LHAPDF banners to guarantee deterministic output
54+
LHAPDF::setVerbosity(0);
55+
std::string pdfset = "NNPDF31_nlo_as_0118_luxqed";
56+
auto pdf = std::unique_ptr<LHAPDF::PDF>(LHAPDF::mkPDF(pdfset, 0));
57+
58+
auto xfx = [](int32_t id, double x, double q2, void* pdf) {
59+
return static_cast <LHAPDF::PDF*> (pdf)->xfxQ2(id, x, q2);
60+
};
61+
auto alphas = [](double q2, void* pdf) {
62+
return static_cast <LHAPDF::PDF*> (pdf)->alphasQ2(q2);
63+
};
64+
65+
std::vector<LHAPDF::PDF*> pdfs = {pdf.get(), pdf.get()};
66+
void** pdf_states = reinterpret_cast<void**>(pdfs.data());
67+
5368
// read the grid from a file
5469
auto* grid = pineappl_grid_read(filename.c_str());
5570

@@ -71,8 +86,8 @@ int main() {
7186

7287
// Get the shape of the evolve info objects
7388
std::vector<std::size_t> evinfo_shape(5);
74-
std::vector<uint8_t> apply_order = {3, 0};
75-
pineappl_grid_evolve_info_shape(grid, apply_order.data(), evinfo_shape.data());
89+
std::vector<uint8_t> max_orders = {3, 2};
90+
pineappl_grid_evolve_info_shape(grid, max_orders.data(), evinfo_shape.data());
7691

7792
// Get the values of the evolve info parameters. These contain, for example, the
7893
// information on the `x`-grid and `PID` used to interpolate the Grid.
@@ -82,7 +97,7 @@ int main() {
8297
std::vector<int> pids1(evinfo_shape[2]);
8398
std::vector<double> x1(evinfo_shape[3]);
8499
std::vector<double> ren1(evinfo_shape[4]);
85-
pineappl_grid_evolve_info(grid, apply_order.data(), fac1.data(),
100+
pineappl_grid_evolve_info(grid, max_orders.data(), fac1.data(),
86101
frg1.data(), pids1.data(), x1.data(), ren1.data());
87102

88103
// ------------------ Construct the Operator Info ------------------
@@ -114,32 +129,22 @@ int main() {
114129
}
115130
}
116131

117-
// Construct the values of alphas
118-
std::vector<double> alphas_table(ren1.size(), 0.118);
132+
// Construct the values of alphas table
133+
std::vector<double> alphas_table;
134+
for (double q2 : ren1) {
135+
double alpha = alphas(q2, pdf.get());
136+
alphas_table.push_back(alpha);
137+
}
138+
119139
std::vector<double> xi = {1.0, 1.0, 1.0};
120140
std::vector<std::size_t> tensor_shape = {pids1.size(), x1.size(), pids1.size(), x1.size()};
121141

122142
pineappl_fk_table* fktable = pineappl_grid_evolve(grid, opinfo_slices.data(),
123-
apply_order.data(), op_slices.data(), x1.data(),
143+
max_orders.data(), op_slices.data(), x1.data(),
124144
x1.data(), pids1.data(), pids1.data(),
125145
tensor_shape.data(), xi.data(), ren1.data(), alphas_table.data());
126146

127147
// ------------------ Compare Grid & FK after convolution ------------------
128-
// disable LHAPDF banners to guarantee deterministic output
129-
LHAPDF::setVerbosity(0);
130-
std::string pdfset = "NNPDF31_nlo_as_0118_luxqed";
131-
auto pdf = std::unique_ptr<LHAPDF::PDF>(LHAPDF::mkPDF(pdfset, 0));
132-
133-
auto xfx = [](int32_t id, double x, double q2, void* pdf) {
134-
return static_cast <LHAPDF::PDF*> (pdf)->xfxQ2(id, x, q2);
135-
};
136-
auto alphas = [](double q2, void* pdf) {
137-
return static_cast <LHAPDF::PDF*> (pdf)->alphasQ2(q2);
138-
};
139-
140-
std::vector<LHAPDF::PDF*> pdfs = {pdf.get(), pdf.get()};
141-
void** pdf_states = reinterpret_cast<void**>(pdfs.data());
142-
143148
// how many bins does this grid have?
144149
std::size_t bins = pineappl_grid_bin_count(grid);
145150

@@ -175,7 +180,7 @@ int main() {
175180
// Print the data
176181
std::cout << std::scientific << std::setprecision(6);
177182
for (size_t i = 0; i < dxsec_grid.size(); ++i) {
178-
double reldiff = std::abs(dxsec_grid[i] - dxsec_fktable[i]) / (std::abs(dxsec_grid[i]));
183+
double reldiff = (dxsec_fktable[i] - dxsec_grid[i]) / dxsec_grid[i];
179184
std::cout << std::setw(idx_width) << i
180185
<< std::setw(num_width) << dxsec_grid[i]
181186
<< std::setw(num_width) << dxsec_fktable[i]

examples/cpp/output

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ idx left right dsig/dx dx
174174
23 40626 (16, 12, 26) (5442.31, 0.265114, 0.00287387) -7.04493e-11
175175
Bin Grid FkTable reldiff
176176
---- ------------- ------------- -------------
177-
0 7.545911e+02 7.603251e+02 7.598823e-03
178-
1 6.902834e+02 6.949192e+02 6.715820e-03
179-
2 6.002520e+02 6.037697e+02 5.860343e-03
180-
3 4.855224e+02 4.878688e+02 4.832807e-03
181-
4 3.619546e+02 3.634639e+02 4.169948e-03
182-
5 2.458669e+02 2.467891e+02 3.750676e-03
183-
6 1.158685e+02 1.163001e+02 3.724532e-03
184-
7 2.751727e+01 2.763520e+01 4.285840e-03
177+
0 7.545911e+02 7.545911e+02 -3.762829e-08
178+
1 6.902834e+02 6.902834e+02 -3.537025e-08
179+
2 6.002520e+02 6.002520e+02 -3.293028e-08
180+
3 4.855224e+02 4.855223e+02 -3.037598e-08
181+
4 3.619546e+02 3.619545e+02 -2.782860e-08
182+
5 2.458669e+02 2.458669e+02 -2.526536e-08
183+
6 1.158685e+02 1.158685e+02 -2.182740e-08
184+
7 2.751727e+01 2.751727e+01 -1.732084e-08
185185
idx p-p c#0 l#0 p-p~ c#0 l# p-d c#0 l#0 p-d dx
186186
--- ------------ ----------- ------------- ------------ ------
187187
0 5.263109e-01 5.263109e-01 5.263109e-01 5.263109e-01 0.1

0 commit comments

Comments
 (0)