Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in Grid::convolute_eko #182

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 34 additions & 40 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,46 +1531,6 @@ impl Grid {
})
.collect();

// the x1 and x2 grid values are the same across all non-zero subgrids
let first_non_zero_grid = self
.subgrids
.iter()
.find(|subgrid| !subgrid.is_empty())
.unwrap_or_else(|| unreachable!());
// source x1/x2 grid might differ and be differently sorted than the operator
let x1_grid = if has_pdf1 {
first_non_zero_grid
.x1_grid()
.iter()
.map(|x| {
eko_info
.grid_axes
.x_grid
.iter()
.position(|xi| approx_eq!(f64, *xi, *x, ulps = 64))
.unwrap_or_else(|| unreachable!())
})
.collect()
} else {
Vec::new()
};
let x2_grid = if has_pdf2 {
first_non_zero_grid
.x2_grid()
.iter()
.map(|x| {
eko_info
.grid_axes
.x_grid
.iter()
.position(|xi| approx_eq!(f64, *xi, *x, ulps = 64))
.unwrap_or_else(|| unreachable!())
})
.collect()
} else {
Vec::new()
};

// iterate over all bins, which are mapped one-to-one from the target to the source grid
for bin in 0..self.bin_info().bins() {
// iterate over the source grid luminosities
Expand Down Expand Up @@ -1619,6 +1579,40 @@ impl Grid {

let src_subgrid = &self.subgrids[[order, bin, src_lumi]];

// source x1/x2 grid might differ and be differently sorted than the operator
let x1_grid = if has_pdf1 {
src_subgrid
.x1_grid()
.iter()
.map(|x| {
eko_info
.grid_axes
.x_grid
.iter()
.position(|xi| approx_eq!(f64, *xi, *x, ulps = 64))
.unwrap_or_else(|| unreachable!())
})
.collect()
} else {
Vec::new()
};
let x2_grid = if has_pdf2 {
src_subgrid
.x2_grid()
.iter()
.map(|x| {
eko_info
.grid_axes
.x_grid
.iter()
.position(|xi| approx_eq!(f64, *xi, *x, ulps = 64))
.unwrap_or_else(|| unreachable!())
})
.collect()
} else {
Vec::new()
};

for ((iq2, ix1, ix2), &value) in src_subgrid.iter() {
let scale = src_subgrid.mu2_grid()[iq2].fac;
let src_iq2 = src_array_q2_grid
Expand Down