Skip to content

Commit

Permalink
Fix import of NPDFDim = 2 fastNLO tables
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Oct 18, 2024
1 parent 82b67a8 commit 213e68a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions maintainer/generate-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl
wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl/test-data/E906nlo_bin_00.tar'
wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl/test-data/FK_ATLASTTBARTOT13TEV.dat'
wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl/test-data/FK_POSXDQ.dat'
wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl/test-data/LHC8-Mtt-HT4-173_3-bin1.tab.gz'
wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl/test-data/LHCBWZMU7TEV_PI_part1.appl'
wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl/test-data/LHCB_DY_8TEV.pineappl.lz4'
wget --no-verbose --no-clobber -P test-data 'https://data.nnpdf.science/pineappl/test-data/LHCB_DY_8TEV.tar'
Expand Down
13 changes: 12 additions & 1 deletion pineappl_cli/src/import/fastnlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use pineappl_fastnlo::ffi::{
fastNLOPDFLinearCombinations, EScaleFunctionalForm,
};
use std::f64::consts::TAU;
use std::mem;

fn pid_to_pdg_id(pid: i32) -> i32 {
match pid {
Expand Down Expand Up @@ -130,6 +131,8 @@ fn convert_coeff_add_fix(

let total_scalenodes: usize = table.GetTotalScalenodes().try_into().unwrap();

let npdfdim = table.GetNPDFDim();

for obs in 0..table_as_add_base.GetNObsBin() {
let x1_values = ffi::GetXNodes1(table_as_add_base, obs);

Expand Down Expand Up @@ -178,13 +181,21 @@ fn convert_coeff_add_fix(
table.GetSigmaTilde(obs, j, mu2_slice.try_into().unwrap(), ix, subproc);

if value != 0.0 {
if npdfdim == 2 {
mem::swap(&mut ix1, &mut ix2);
}

array[[mu2_slice, ix2, ix1]] =
value / factor * x1_values[ix1] * x2_values[ix2];

if npdfdim == 2 {
mem::swap(&mut ix1, &mut ix2);
}
}

ix1 += 1;

match table.GetNPDFDim() {
match npdfdim {
2 => {
if ix1 == x1_values.len() {
ix1 = 0;
Expand Down
28 changes: 28 additions & 0 deletions pineappl_cli/tests/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ const IMPORT_DOUBLE_HADRONIC_FASTNLO_STR: &str =
20 2.0326950e-2 2.0326950e-2 6.6613381e-15 1.3211654e-14
";

#[cfg(feature = "fastnlo")]
const IMPORT_NPDFDIM_2_TABLE_STR: &str = "0 1.0824021e0 1.0824021e0 1.4654944e-14
1 1.0680553e0 1.0680553e0 -1.4432899e-15
2 6.4959982e-1 6.4959982e-1 4.4408921e-15
3 3.3033872e-1 3.3033872e-1 2.0872193e-14
4 1.3360159e-1 1.3360159e-1 -2.3092639e-14
5 3.2728146e-2 3.2728146e-2 -5.7731597e-15
6 3.8508907e-3 3.8508907e-3 2.2870594e-14
";

#[test]
fn help() {
Command::cargo_bin("pineappl")
Expand Down Expand Up @@ -1268,3 +1278,21 @@ fn import_double_hadronic_fastnlo() {
IMPORT_DOUBLE_HADRONIC_FASTNLO_STR,
));
}

#[test]
#[cfg(feature = "fastnlo")]
fn import_npdfdim_2_table() {
let output = NamedTempFile::new("converted10.pineappl.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"import",
"../test-data/LHC8-Mtt-HT4-173_3-bin1.tab.gz",
output.path().to_str().unwrap(),
"NNPDF31_nlo_as_0118_luxqed",
])
.assert()
.success()
.stdout(predicates::str::ends_with(IMPORT_NPDFDIM_2_TABLE_STR));
}

0 comments on commit 213e68a

Please sign in to comment.