diff --git a/pineappl/src/grid.rs b/pineappl/src/grid.rs index b9cfc6f6..c0b7b77f 100644 --- a/pineappl/src/grid.rs +++ b/pineappl/src/grid.rs @@ -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 @@ -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