Skip to content

Commit

Permalink
Fix dimensionality of imported DIS fastNLO tables
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Oct 10, 2024
1 parent 0a66c20 commit 1e17155
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 59 deletions.
13 changes: 2 additions & 11 deletions pineappl_cli/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ fn convert_fastnlo(
alpha: u32,
conv_funs: &ConvFuns,
member: usize,
dis_pid: i32,
scales: usize,
fnlo_mur: Option<&str>,
fnlo_muf: Option<&str>,
Expand Down Expand Up @@ -79,7 +78,7 @@ fn convert_fastnlo(
}
}

let grid = fastnlo::convert_fastnlo_table(&file, alpha, dis_pid)?;
let grid = fastnlo::convert_fastnlo_table(&file, alpha)?;
let mut reader = ffi::downcast_lhapdf_to_reader_mut(file.as_mut().unwrap());

// TODO: scale-variation log conversion is only enabled for flex grids
Expand Down Expand Up @@ -121,7 +120,6 @@ fn convert_fastnlo(
_: u32,
_: &ConvFuns,
_: usize,
_: i32,
_: usize,
_: Option<&str>,
_: Option<&str>,
Expand Down Expand Up @@ -151,7 +149,6 @@ fn convert_grid(
conv_funs: &mut [Pdf],
fun_names: &ConvFuns,
member: usize,
dis_pid: i32,
scales: usize,
fnlo_mur: Option<&str>,
fnlo_muf: Option<&str>,
Expand All @@ -164,9 +161,7 @@ fn convert_grid(
.extension()
.map_or(false, |ext| ext == "tab"))
{
return convert_fastnlo(
input, alpha, fun_names, member, dis_pid, scales, fnlo_mur, fnlo_muf,
);
return convert_fastnlo(input, alpha, fun_names, member, scales, fnlo_mur, fnlo_muf);
} else if extension == "dat" {
return convert_fktable(input);
} else if extension == "appl" || extension == "root" {
Expand Down Expand Up @@ -245,9 +240,6 @@ pub struct Opts {
/// Do not optimize converted grid.
#[arg(long)]
no_optimize: bool,
/// Particle ID for the non-hadronic initial states if it cannot be determined from the grid.
#[arg(long, default_value_t = 11)]
dis_pid: i32,
}

impl Subcommand for Opts {
Expand All @@ -263,7 +255,6 @@ impl Subcommand for Opts {
&mut conv_funs,
&self.conv_funs,
0,
self.dis_pid,
self.scales,
self.fnlo_mur.as_deref(),
self.fnlo_muf.as_deref(),
Expand Down
114 changes: 68 additions & 46 deletions pineappl_cli/src/import/fastnlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,32 @@ fn pid_to_pdg_id(pid: i32) -> i32 {
fn reconstruct_channels(
table: &fastNLOCoeffAddBase,
comb: &fastNLOPDFLinearCombinations,
dis_pid: i32,
) -> Vec<Channel> {
let dis_pid = if table.GetNPDF() == 2 { 0 } else { dis_pid };
let mut channels = Vec::new();
let npdf = table.GetNPDF();

// if there's a (non-empty) PDF coefficient vector reconstruct the channels; the advantage is
// that we preserve the order of the channels in the PineAPPL grid
for pdf_entry in 0..ffi::GetPDFCoeffSize(table) {
let mut entries = Vec::new();

for entry in ffi::GetPDFCoeff(table, pdf_entry) {
let a = pid_to_pdg_id(entry.first);
let b = if dis_pid == 0 {
pid_to_pdg_id(entry.second)
} else {
dis_pid
};
let f = 1.0;
let mut pids = vec![pid_to_pdg_id(entry.first)];

if npdf == 2 {
pids.push(pid_to_pdg_id(entry.second));
}

entries.push((vec![a, b], f));
entries.push((pids, 1.0));
}

channels.push(Channel::new(entries));
}

// if the PDF coefficient vector was empty, we must reconstruct the channels in a different way
if channels.is_empty() {
assert_eq!(npdf, 2);

let nsubproc = table.GetNSubproc().try_into().unwrap();

let mut xfx1 = [0.0; 13];
Expand Down Expand Up @@ -96,7 +95,6 @@ fn convert_coeff_add_fix(
comb: &fastNLOPDFLinearCombinations,
bins: usize,
alpha: u32,
dis_pid: i32,
) -> Grid {
let table_as_add_base = ffi::downcast_coeff_add_fix_to_base(table);

Expand All @@ -109,7 +107,7 @@ fn convert_coeff_add_fix(

let mut grid = Grid::new(
PidBasis::Pdg,
reconstruct_channels(table_as_add_base, comb, dis_pid),
reconstruct_channels(table_as_add_base, comb),
vec![Order {
alphas: table_as_add_base.GetNpow().try_into().unwrap(),
alpha,
Expand All @@ -122,37 +120,64 @@ fn convert_coeff_add_fix(
.collect(),
convolutions,
// TODO: read out interpolation parameters from fastNLO
vec![
Interp::new(
1e2,
1e8,
40,
3,
ReweightMeth::NoReweight,
Map::ApplGridH0,
InterpMeth::Lagrange,
),
Interp::new(
2e-7,
1.0,
50,
3,
ReweightMeth::ApplGridX,
Map::ApplGridF2,
InterpMeth::Lagrange,
),
Interp::new(
2e-7,
1.0,
50,
3,
ReweightMeth::ApplGridX,
Map::ApplGridF2,
InterpMeth::Lagrange,
),
],
if npdf == 2 {
vec![
Interp::new(
1e2,
1e8,
40,
3,
ReweightMeth::NoReweight,
Map::ApplGridH0,
InterpMeth::Lagrange,
),
Interp::new(
2e-7,
1.0,
50,
3,
ReweightMeth::ApplGridX,
Map::ApplGridF2,
InterpMeth::Lagrange,
),
Interp::new(
2e-7,
1.0,
50,
3,
ReweightMeth::ApplGridX,
Map::ApplGridF2,
InterpMeth::Lagrange,
),
]
} else {
vec![
Interp::new(
1e2,
1e8,
40,
3,
ReweightMeth::NoReweight,
Map::ApplGridH0,
InterpMeth::Lagrange,
),
Interp::new(
2e-7,
1.0,
50,
3,
ReweightMeth::ApplGridX,
Map::ApplGridF2,
InterpMeth::Lagrange,
),
]
},
// TODO: change kinematics for DIS
vec![Kinematics::Scale(0), Kinematics::X1, Kinematics::X2],
if npdf == 2 {
vec![Kinematics::Scale(0), Kinematics::X1, Kinematics::X2]
} else {
vec![Kinematics::Scale(0), Kinematics::X1]
},
Scales {
ren: ScaleFuncForm::Scale(0),
fac: ScaleFuncForm::Scale(0),
Expand Down Expand Up @@ -265,7 +290,6 @@ fn convert_coeff_add_flex(
_bins: usize,
_alpha: u32,
_ipub_units: i32,
_dis_pid: i32,
) -> Grid {
todo!()

Expand Down Expand Up @@ -459,7 +483,7 @@ fn convert_coeff_add_flex(
// grid
}

pub fn convert_fastnlo_table(file: &fastNLOLHAPDF, alpha: u32, dis_pid: i32) -> Result<Grid> {
pub fn convert_fastnlo_table(file: &fastNLOLHAPDF, alpha: u32) -> Result<Grid> {
let file_as_reader = ffi::downcast_lhapdf_to_reader(file);
let file_as_table = ffi::downcast_lhapdf_to_table(file);

Expand Down Expand Up @@ -500,7 +524,6 @@ pub fn convert_fastnlo_table(file: &fastNLOLHAPDF, alpha: u32, dis_pid: i32) ->
bins,
alpha,
file_as_table.GetIpublunits(),
dis_pid,
));
}
} else {
Expand All @@ -509,7 +532,6 @@ pub fn convert_fastnlo_table(file: &fastNLOLHAPDF, alpha: u32, dis_pid: i32) ->
linear_combinations,
bins,
alpha,
dis_pid,
));
}
}
Expand Down
2 changes: 0 additions & 2 deletions pineappl_cli/tests/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Options:
--digits-abs <ABS> Set the number of fractional digits shown for absolute numbers [default: 7]
--digits-rel <REL> Set the number of fractional digits shown for relative numbers [default: 7]
--no-optimize Do not optimize converted grid
--dis-pid <DIS_PID> Particle ID for the non-hadronic initial states if it cannot be determined from the grid [default: 11]
-h, --help Print help
";

Expand All @@ -45,7 +44,6 @@ Options:
--digits-abs <ABS> Set the number of fractional digits shown for absolute numbers [default: 7]
--digits-rel <REL> Set the number of fractional digits shown for relative numbers [default: 7]
--no-optimize Do not optimize converted grid
--dis-pid <DIS_PID> Particle ID for the non-hadronic initial states if it cannot be determined from the grid [default: 11]
-h, --help Print help
";

Expand Down

0 comments on commit 1e17155

Please sign in to comment.