Skip to content

Commit

Permalink
Add preliminary code for fastNLO exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Sep 26, 2024
1 parent 6f98239 commit 0a3d1b6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
49 changes: 48 additions & 1 deletion pineappl_cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use std::process::ExitCode;
#[cfg(feature = "applgrid")]
mod applgrid;

#[cfg(feature = "fastnlo")]
mod fastnlo;

#[cfg(feature = "applgrid")]
fn convert_into_applgrid(
output: &Path,
Expand Down Expand Up @@ -42,6 +45,36 @@ fn convert_into_applgrid(
))
}

#[cfg(feature = "fastnlo")]
fn convert_into_fastnlo(
output: &Path,
grid: &Grid,
conv_funs: &mut [Pdf],
_: usize,
discard_non_matching_scales: bool,
) -> Result<(&'static str, Vec<f64>, usize, Vec<bool>)> {
// TODO: check also scale-varied results

let (mut fastnlo, order_mask) =
fastnlo::convert_into_fastnlo(grid, output, discard_non_matching_scales)?;
let results = fastnlo::convolve_fastnlo(fastnlo.pin_mut(), conv_funs);

Ok(("fastNLO", results, 1, order_mask))
}

#[cfg(not(feature = "fastnlo"))]
fn convert_into_fastnlo(
_: &Path,
_: &Grid,
_: &mut [Pdf],
_: usize,
_: bool,
) -> Result<(&'static str, Vec<f64>, usize, Vec<bool>)> {
Err(anyhow!(
"you need to install `pineappl` with feature `fastnlo`"
))
}

fn convert_into_grid(
output: &Path,
grid: &Grid,
Expand All @@ -58,13 +91,27 @@ fn convert_into_grid(
scales,
discard_non_matching_scales,
);
} else if extension == "tab"
|| (extension == "gz"
&& output
.with_extension("")
.extension()
.map_or(false, |ext| ext == "tab"))
{
return convert_into_fastnlo(
output,
grid,
conv_funs,
scales,
discard_non_matching_scales,
);
}
}

Err(anyhow!("could not detect file format"))
}

/// Converts PineAPPL grids to APPLgrid files.
/// Converts PineAPPL grids to APPLgrid or fastNLO files.
#[derive(Parser)]
pub struct Opts {
/// Path to the input grid.
Expand Down
2 changes: 1 addition & 1 deletion pineappl_fastnlo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() {
.file("src/fastnlo.cpp")
.include(fnlo_include_path.trim())
.includes(lhapdf_include_paths)
.std("c++11") // apparently not supported by MSVC, but fastNLO probably can't be compiled on Windows
.std("c++17") // apparently not supported by MSVC, but fastNLO probably can't be compiled on Windows
.compile("fnlo-bridge");

println!("cargo:rerun-if-changed=src/lib.rs");
Expand Down

0 comments on commit 0a3d1b6

Please sign in to comment.