Skip to content

Commit

Permalink
Test old method Grid::evolve
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Mar 3, 2024
1 parent c6d9e76 commit 0292ac8
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
57 changes: 51 additions & 6 deletions pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,10 @@ fn evolve_grid(
orders: &[(u32, u32)],
xir: f64,
xif: f64,
use_old_evolve: bool,
) -> Result<FkTable> {
use eko::EkoSlices;
use pineappl::evolution::AlphasTable;

let alphas_table = AlphasTable::from_grid(grid, xir, &|q2| pdf.alphas_q2(q2));
use pineappl::evolution::{AlphasTable, OperatorInfo};

let order_mask: Vec<_> = grid
.orders()
Expand All @@ -455,12 +454,48 @@ fn evolve_grid(
.collect();

let mut eko_slices = EkoSlices::new(eko)?;
let alphas_table = AlphasTable::from_grid(grid, xir, &|q2| pdf.alphas_q2(q2));

Ok(grid.evolve_with_slice_iter(&mut eko_slices, &order_mask, (xir, xif), &alphas_table)?)
if use_old_evolve {
if let EkoSlices::V0 {
fac1,
info,
operator,
} = eko_slices
{
let op_info = OperatorInfo {
fac0: info.fac0,
pids0: info.pids0.clone(),
x0: info.x0.clone(),
fac1: fac1.clone(),
pids1: info.pids1.clone(),
x1: info.x1.clone(),
ren1: alphas_table.ren1,
alphas: alphas_table.alphas,
xir,
xif,
lumi_id_types: info.lumi_id_types,
};

Ok(grid.evolve(operator.view(), &op_info, &order_mask)?)
} else {
unimplemented!();
}
} else {
Ok(grid.evolve_with_slice_iter(&mut eko_slices, &order_mask, (xir, xif), &alphas_table)?)
}
}

#[cfg(not(feature = "evolve"))]
fn evolve_grid(_: &Grid, _: &Path, _: &Pdf, _: &[(u32, u32)], _: f64, _: f64) -> Result<FkTable> {
fn evolve_grid(
_: &Grid,
_: &Path,
_: &Pdf,
_: &[(u32, u32)],
_: f64,
_: f64,
_: bool,
) -> Result<FkTable> {
Err(anyhow!(
"you need to install `pineappl` with feature `evolve`"
))
Expand Down Expand Up @@ -505,6 +540,8 @@ pub struct Opts {
/// Rescale the factorization scale with this factor.
#[arg(default_value_t = 1.0, long)]
xif: f64,
#[arg(hide = true, long)]
use_old_evolve: bool,
}

impl Subcommand for Opts {
Expand All @@ -524,7 +561,15 @@ impl Subcommand for Opts {
cfg.force_positive,
);

let fk_table = evolve_grid(&grid, &self.eko, &pdf, &self.orders, self.xir, self.xif)?;
let fk_table = evolve_grid(
&grid,
&self.eko,
&pdf,
&self.orders,
self.xir,
self.xif,
self.use_old_evolve,
)?;
let evolved_results = helpers::convolute_scales(
fk_table.grid(),
&mut pdf,
Expand Down
21 changes: 21 additions & 0 deletions pineappl_cli/tests/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,27 @@ fn lhcb_wp_7tev() {
.stdout(LHCB_WP_7TEV_OPTIMIZED_STR);
}

#[test]
fn lhcb_wp_7tev_use_old_evolve() {
let output = NamedTempFile::new("fktable1c.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"--silence-lhapdf",
"evolve",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
"../test-data/LHCB_WP_7TEV.tar",
output.path().to_str().unwrap(),
"NNPDF40_nlo_as_01180",
"--orders=a2,as1a2",
"--use-old-evolve",
])
.assert()
.success()
.stdout(LHCB_WP_7TEV_STR);
}

#[test]
fn lhcb_wp_7tev_v2() {
let input = NamedTempFile::new("optimized.pineappl.lz4").unwrap();
Expand Down

0 comments on commit 0292ac8

Please sign in to comment.