Skip to content

Commit c5f4f27

Browse files
Address comments from Code Review
1 parent 52c8fb9 commit c5f4f27

5 files changed

Lines changed: 101 additions & 138 deletions

File tree

examples/cpp/evolve-grid-identity.cpp

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,21 @@ std::vector<std::size_t> unravel_index(std::size_t flat_index, const std::vector
2525
}
2626

2727
extern "C" void generate_fake_ekos(
28-
const int* pids_in,
29-
const double* x_in,
30-
const int* pids_out,
31-
const double* x_out,
28+
const int* /*pids_in*/,
29+
const double* /*x_in*/,
30+
const int* /*pids_out*/,
31+
const double* /*x_out*/,
3232
double* eko_buffer,
3333
void* params_state,
34-
pineappl_conv_type conv_type,
35-
double fac1,
34+
pineappl_conv_type /*conv_type*/,
35+
double /*fac1*/,
3636
std::size_t pids_in_len,
3737
std::size_t x_in_len,
3838
std::size_t pids_out_len,
3939
std::size_t x_out_len
4040
) {
41-
// Ignore unused variables
42-
(void) pids_in;
43-
(void) x_in;
44-
(void) pids_out;
45-
(void) x_out;
46-
(void) conv_type;
47-
(void) fac1;
48-
4941
// Check to get the μ0 of the PDF from the `params_state`
50-
const double mu0_scale = static_cast<LHAPDF::PDF*> (params_state)->q2Min();
51-
(void) mu0_scale; // Mark as unused variable
42+
const double _ = static_cast<LHAPDF::PDF*> (params_state)->q2Min();
5243

5344
std::size_t flat_len = pids_in_len * x_in_len * pids_out_len * x_out_len;
5445
// NOTE: The EKO has to have as shape: (pids_in, x_in, pids_out, x_out)
@@ -133,8 +124,12 @@ int main() {
133124

134125
// Get the shape of the evolve info objects
135126
std::vector<std::size_t> evinfo_shape(5);
136-
std::vector<uint8_t> max_orders = {2, 3};
137-
pineappl_grid_evolve_info_shape(grid, max_orders.data(), evinfo_shape.data());
127+
// NOTE: The argument of `pineappl_grid_evolve_info_shape` must follow the following orders:
128+
// - `grid`: PineAPPL Grid
129+
// - `order_mask`: array of booleans to mask the order(s) to apply the Evolution to,
130+
// `nullptr` selects all the orders
131+
// - `evinfo_shape`: placeholder to store the shape of the Evolution Operator
132+
pineappl_grid_evolve_info_shape(grid, nullptr, evinfo_shape.data());
138133

139134
// Get the values of the evolve info parameters. These contain, for example, the
140135
// information on the `x`-grid and `PID` used to interpolate the Grid.
@@ -144,7 +139,12 @@ int main() {
144139
std::vector<int> pids_in(evinfo_shape[2]);
145140
std::vector<double> x_in(evinfo_shape[3]);
146141
std::vector<double> ren1(evinfo_shape[4]);
147-
pineappl_grid_evolve_info(grid, max_orders.data(), fac1.data(),
142+
// NOTE: The argument of `pineappl_grid_evolve_info` must follow the following orders:
143+
// - `grid`: PineAPPL Grid
144+
// - `order_mask`: array of booleans to mask the order(s) to apply the Evolution to,
145+
// `nullptr` selects all the orders
146+
// The rest of the arguments are placeholders to store data
147+
pineappl_grid_evolve_info(grid, nullptr, fac1.data(),
148148
frg1.data(), pids_in.data(), x_in.data(), ren1.data());
149149

150150
// ------------------ Construct the Operator Info ------------------
@@ -183,8 +183,10 @@ int main() {
183183
// - `grid`: PineAPPL Grid
184184
// - `op_info`: operator info
185185
// - `operator`: callback that returns an evolution operator
186-
// - `max_orders`: max orders to apply the evolution
186+
// - `order_mask`: array of booleans to mask the order(s) to apply the Evolution to,
187+
// `nullptr` selects all the orders
187188
// - `params_state`: parameters that get passed to `operator`
189+
// - `nb_convolutions`: the number of convolutions/Evolution Operators required
188190
// - `x_in`: x-grid of the Grid
189191
// - `x_out`: x-grid of the FK table
190192
// - `pids_in`: PIDs basis representation of the Grid
@@ -193,10 +195,11 @@ int main() {
193195
// - `xi`: scale variation
194196
// - `ren1`: values of the renormalization scales
195197
// - `alphas_table`: values of alphas for each renormalization scales
196-
pineappl_fktable* fktable = pineappl_grid_evolve(grid, opinfo_slices.data(),
197-
generate_fake_ekos, max_orders.data(), pdf.get(), x_in.data(),
198-
x_in.data(), pids_in.data(), pids_out.data(),
199-
tensor_shape.data(), xi.data(), ren1.data(), alphas_table.data());
198+
pineappl_grid* fktable = pineappl_grid_evolve(grid, opinfo_slices.data(),
199+
generate_fake_ekos, nullptr, pdf.get(),
200+
conv_types.size(), x_in.data(), x_in.data(),
201+
pids_in.data(), pids_out.data(), tensor_shape.data(),
202+
xi.data(), ren1.data(), alphas_table.data());
200203

201204
// ------------------ Compare Grid & FK after convolution ------------------
202205
// how many bins does this grid have?
@@ -211,13 +214,15 @@ int main() {
211214

212215
// [ convolve the FK Table ]
213216
std::vector<double> dxsec_fktable(bins);
214-
pineappl_fktable_convolve(fktable, xfx, pdf_states, nullptr,
215-
nullptr, 1, nullptr, dxsec_fktable.data());
217+
auto as_one = [](double /*q2*/, void* /*pdf*/) { return 1.0; };
218+
pineappl_grid_convolve(fktable, xfx, as_one, pdf_states, nullptr,
219+
nullptr, nullptr, nullptr, 1,
220+
mu_scales.data(), dxsec_fktable.data());
216221

217222
// Print the results
218223
print_results(dxsec_grid, dxsec_fktable);
219224

220-
pineappl_fktable_write(fktable, "evolved-grid.pineappl.lz4");
225+
pineappl_fktable_write(fktable, "evolved-grid-identity.pineappl.lz4");
221226

222227
pineappl_grid_delete(grid);
223228
pineappl_fktable_delete(fktable);

examples/cpp/evolve-grid.cpp

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,21 @@ std::vector<std::size_t> unravel_index(std::size_t flat_index, const std::vector
8383
}
8484

8585
extern "C" void generate_fake_ekos(
86-
const int* pids_in,
87-
const double* x_in,
88-
const int* pids_out,
89-
const double* x_out,
86+
const int* /*pids_in*/,
87+
const double* /*x_in*/,
88+
const int* /*pids_out*/,
89+
const double* /*x_out*/,
9090
double* eko_buffer,
9191
void* params_state,
92-
pineappl_conv_type conv_type,
93-
double fac1,
94-
std::size_t pids_in_len,
95-
std::size_t x_in_len,
96-
std::size_t pids_out_len,
97-
std::size_t x_out_len
92+
pineappl_conv_type /*conv_type*/,
93+
double /*fac1*/,
94+
std::size_t /*pids_in_len*/,
95+
std::size_t /*x_in_len*/,
96+
std::size_t /*pids_out_len*/,
97+
std::size_t /*x_out_len*/
9898
) {
99-
// Ignore unused variables
100-
(void) pids_in;
101-
(void) x_in;
102-
(void) pids_out;
103-
(void) x_out;
104-
(void) conv_type;
105-
(void) pids_in_len;
106-
(void) x_in_len;
107-
(void) pids_out_len;
108-
(void) x_out_len;
109-
(void) fac1;
110-
11199
// Check to get the μ0 from the PDF
112-
const double mu0_scale = static_cast<LHAPDF::PDF*> (params_state)->q2Min();
113-
(void) mu0_scale; // Mark as unused variable
100+
const double _ = static_cast<LHAPDF::PDF*> (params_state)->q2Min();
114101

115102
std::ifstream input_file("../../test-data/EKO_LHCB_WP_7TEV.txt");
116103
double weight_value;
@@ -191,8 +178,12 @@ int main() {
191178

192179
// Get the shape of the evolve info objects
193180
std::vector<std::size_t> evinfo_shape(5);
194-
std::vector<uint8_t> max_orders = {2, 3};
195-
pineappl_grid_evolve_info_shape(grid, max_orders.data(), evinfo_shape.data());
181+
// NOTE: The argument of `pineappl_grid_evolve_info_shape` must follow the following orders:
182+
// - `grid`: PineAPPL Grid
183+
// - `order_mask`: array of booleans to mask the order(s) to apply the Evolution to,
184+
// `nullptr` selects all the orders
185+
// - `evinfo_shape`: placeholder to store the shape of the Evolution Operator
186+
pineappl_grid_evolve_info_shape(grid, nullptr, evinfo_shape.data());
196187

197188
// Get the values of the evolve info parameters. These contain, for example, the
198189
// information on the `x`-grid and `PID` used to interpolate the Grid.
@@ -202,7 +193,12 @@ int main() {
202193
std::vector<int> _pids_in(evinfo_shape[2]);
203194
std::vector<double> _x_in(evinfo_shape[3]);
204195
std::vector<double> ren1(evinfo_shape[4]);
205-
pineappl_grid_evolve_info(grid, max_orders.data(), fac1.data(),
196+
// NOTE: The argument of `pineappl_grid_evolve_info` must follow the following orders:
197+
// - `grid`: PineAPPL Grid
198+
// - `order_mask`: array of booleans to mask the order(s) to apply the Evolution to,
199+
// `nullptr` selects all the orders
200+
// The rest of the arguments are placeholders to store data
201+
pineappl_grid_evolve_info(grid, nullptr, fac1.data(),
206202
frg1.data(), _pids_in.data(), _x_in.data(), ren1.data());
207203

208204
// ------------------ Construct the Operator Info ------------------
@@ -241,8 +237,10 @@ int main() {
241237
// - `grid`: PineAPPL Grid
242238
// - `op_info`: operator info
243239
// - `operator`: callback that returns an evolution operator
244-
// - `max_orders`: max orders to apply the evolution
240+
// - `order_mask`: array of booleans to mask the order(s) to apply the Evolution to,
241+
// `nullptr` selects all the orders
245242
// - `params_state`: parameters that get passed to `operator`
243+
// - `nb_convolutions`: the number of convolutions/Evolution Operators required
246244
// - `x_in`: x-grid of the Grid
247245
// - `x_out`: x-grid of the FK table
248246
// - `pids_in`: PIDs basis representation of the Grid
@@ -251,10 +249,11 @@ int main() {
251249
// - `xi`: scale variation
252250
// - `ren1`: values of the renormalization scales
253251
// - `alphas_table`: values of alphas for each renormalization scales
254-
pineappl_fktable* fktable = pineappl_grid_evolve(grid, opinfo_slices.data(),
255-
generate_fake_ekos, max_orders.data(), pdf.get(), XGRID.data(),
256-
XGRID.data(), pids_in.data(), pids_out.data(),
257-
tensor_shape.data(), xi.data(), ren1.data(), alphas_table.data());
252+
pineappl_grid* fktable = pineappl_grid_evolve(grid, opinfo_slices.data(),
253+
generate_fake_ekos, nullptr, pdf.get(),
254+
conv_types.size(), XGRID.data(), XGRID.data(),
255+
pids_in.data(), pids_out.data(), tensor_shape.data(),
256+
xi.data(), ren1.data(), alphas_table.data());
258257

259258
// ------------------ Compare Grid & FK after convolution ------------------
260259
// how many bins does this grid have?
@@ -269,8 +268,10 @@ int main() {
269268

270269
// [ convolve the FK Table ]
271270
std::vector<double> dxsec_fktable(bins);
272-
pineappl_fktable_convolve(fktable, xfx, pdf_states, nullptr,
273-
nullptr, 1, nullptr, dxsec_fktable.data());
271+
auto as_one = [](double /*q2*/, void* /*pdf*/) { return 1.0; };
272+
pineappl_grid_convolve(fktable, xfx, as_one, pdf_states, nullptr,
273+
nullptr, nullptr, nullptr, 1,
274+
mu_scales.data(), dxsec_fktable.data());
274275

275276
// Print the results
276277
print_results(dxsec_grid, dxsec_fktable);

pineappl/src/convolutions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl GridConvCache<'_, '_> {
282282

283283
/// TODO
284284
#[repr(C)]
285-
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, Hash)]
285+
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
286286
pub enum ConvType {
287287
/// Unpolarized parton distribution function.
288288
UnpolPDF,

pineappl_capi/cbindgen.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ rename_variants = "ScreamingSnakeCase"
3838
"Channels" = "pineappl_channels"
3939
"Conv" = "pineappl_conv"
4040
"ConvType" = "pineappl_conv_type"
41-
"FkTable" = "pineappl_fktable"
4241
"Grid" = "pineappl_grid"
4342
"GridOptFlags" = "pineappl_gof"
4443
"Interp" = "pineappl_interp"

0 commit comments

Comments
 (0)