Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
31cc779
pdf input to a Vec of strings
t7phy Jun 9, 2024
2392652
Merge remote-tracking branch 'origin/master' into ts050624
t7phy Jun 9, 2024
5efc0f1
Undo changes from commit 31cc779
cschwan Jun 10, 2024
0ec7393
Prepare CLI for multiple convolution functions
cschwan Jun 10, 2024
9556a50
Add struct `ConvFun` and use it in `channels`
cschwan Jun 10, 2024
98de0ba
add two conv funcs support in convolve_scales
t7phy Jun 10, 2024
ed4cbc2
Make `helpers::convolve_scales` a bit more generic
cschwan Jun 11, 2024
5148a6c
Fix bug from commit ed4cbc2
cschwan Jun 11, 2024
f69ad05
add flag to choose the pdfset from which alphas is taken
t7phy Jun 12, 2024
cc01da9
add flag to choose the pdfset from which alphas is taken
t7phy Jun 12, 2024
f47b808
allow users to choose the conv_func for alphas
t7phy Jun 13, 2024
044c774
Use zero-based indexing for `use_alphas_from` parameter
cschwan Jun 13, 2024
be221cd
Use new struct `ConvFun` in most subcommands
cschwan Jun 15, 2024
cfcf027
Migrate `analyze` subcommand to use `ConvFun`
cschwan Jun 17, 2024
a507af8
Replace `ConvFun` with `ConvFuns`
cschwan Jun 17, 2024
1436618
Migrate subcommand `convolve` to `ConvFuns`
cschwan Jun 17, 2024
699851c
Remove switch `--pdf-with-scale-cov` from `uncert` subcommand
cschwan Jun 17, 2024
5f8e576
Migrate `uncert` to use `ConvFun`
cschwan Jun 18, 2024
0020bde
Fix main test
cschwan Jun 19, 2024
ab9bd08
Add `members` variable to `ConvFuns`
cschwan Jun 21, 2024
4ff0319
Add new helper function `create_conv_funs_for_set` and use it in `unc…
cschwan Jun 21, 2024
a29639b
Migrate `pull` subcommand to use `ConvFuns`
cschwan Jun 21, 2024
da7b948
Change help text of `--pull-from` in `pull`
cschwan Jun 21, 2024
8e0b172
Try to fix compilation error in CI
cschwan Jun 21, 2024
da1137f
Merge branch 'master' into ts050624
cschwan Jun 27, 2024
a981f7e
Add missing units for PDF uncertainties
cschwan Jun 27, 2024
1d4af96
Migrate parts of `plot` to `ConvFuns`
cschwan Jun 27, 2024
c59f38e
Remove obsolete helper functions
cschwan Jun 27, 2024
ddbf227
Migrate the remaining parts of `plot` to `ConvFuns`
cschwan Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- added `PidBasis::charge_conjugate` and `PidBasis::guess`
- added `Grid::set_pid_basis` method
- added `Grid::subgrids` and `Grid::subgrids_mut` methods
- added new switch `conv_fun_uncert_from` to subcommand `plot` to allow
choosing with convolution function uncertainty should be plotted

### Changed

Expand All @@ -39,6 +41,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- changed member `lumi_id_types` of `OperatorInfo` and `OperatorSliceInfo` to
`pid_basis`, which is now of type `PidBasis`
- renamed module `pineappl::lumi` to `pineappl::convolutions`
- renamed switch `--pdf` to `--conv-fun` in the subcommand `uncert`. This
switch now optionally accepts a list of indices, which determines the
corresponding convolution function (PDF/FF), for which the uncertainty should
calculated
- renamed `no_pdf_unc` to `no_conv_fun_unc` in subcommand `plot`

### Removed

Expand All @@ -54,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- removed `TryFromGridError::MetadataMissing`
- removed `Grid::subgrid` and `Grid::set_subgrid` methods; these functions have
been replaced with `Grid::subgrids` and `Grid::subgrids_mut`
- removed the switch `--pdf-with-scale-cov` from `pineappl uncert`

## [0.7.4] - 23/05/2024

Expand Down
13 changes: 6 additions & 7 deletions pineappl_cli/src/analyze.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::helpers::{self, ConvoluteMode};
use super::helpers::{self, ConvFuns, ConvoluteMode};
use super::{GlobalConfiguration, Subcommand};
use anyhow::Result;
use clap::builder::TypedValueParser;
Expand Down Expand Up @@ -39,9 +39,8 @@ pub struct CkfOpts {
/// Path to the input grid.
#[arg(value_hint = ValueHint::FilePath)]
input: PathBuf,
/// LHAPDF id or name of the PDF set.
#[arg(value_parser = helpers::parse_pdfset)]
pdfset: String,
/// LHAPDF ID(s) or name(s) of the PDF(s)/FF(s).
conv_funs: ConvFuns,
/// Order defining the K factors.
#[arg(value_parser = helpers::parse_order)]
order: (u32, u32),
Expand All @@ -65,7 +64,7 @@ pub struct CkfOpts {
impl Subcommand for CkfOpts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
let grid = helpers::read_grid(&self.input)?;
let mut pdf = helpers::create_pdf(&self.pdfset)?;
let mut conv_funs = helpers::create_conv_funs(&self.conv_funs)?;

let orders_den = if self.orders_den.is_empty() {
grid.orders()
Expand All @@ -87,7 +86,7 @@ impl Subcommand for CkfOpts {
lumi_mask[lumi] = true;
helpers::convolve(
&grid,
&mut pdf,
&mut conv_funs,
&[self.order],
&[],
&lumi_mask,
Expand All @@ -103,7 +102,7 @@ impl Subcommand for CkfOpts {
lumi_mask[lumi] = true;
helpers::convolve(
&grid,
&mut pdf,
&mut conv_funs,
&orders_den,
&[],
&lumi_mask,
Expand Down
11 changes: 5 additions & 6 deletions pineappl_cli/src/channels.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::helpers::{self, ConvoluteMode};
use super::helpers::{self, ConvFuns, ConvoluteMode};
use super::{GlobalConfiguration, Subcommand};
use anyhow::Result;
use clap::builder::TypedValueParser;
Expand All @@ -14,9 +14,8 @@ pub struct Opts {
/// Path to the input grid.
#[arg(value_hint = ValueHint::FilePath)]
input: PathBuf,
/// LHAPDF id or name of the PDF set.
#[arg(value_parser = helpers::parse_pdfset)]
pdfset: String,
/// LHAPDF ID(s) or name(s) of the PDF(s)/FF(s).
conv_funs: ConvFuns,
/// Show absolute numbers of each contribution.
#[arg(long, short)]
absolute: bool,
Expand Down Expand Up @@ -65,7 +64,7 @@ pub struct Opts {
impl Subcommand for Opts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
let grid = helpers::read_grid(&self.input)?;
let mut pdf = helpers::create_pdf(&self.pdfset)?;
let mut conv_funs = helpers::create_conv_funs(&self.conv_funs)?;

let mut channels: Vec<_> = self.channels.iter().cloned().flatten().collect();
channels.sort_unstable();
Expand Down Expand Up @@ -93,7 +92,7 @@ impl Subcommand for Opts {
channel_mask[channel] = true;
helpers::convolve(
&grid,
&mut pdf,
&mut conv_funs,
&self.orders,
&[],
&channel_mask,
Expand Down
20 changes: 10 additions & 10 deletions pineappl_cli/src/convolve.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::helpers::{self, ConvoluteMode};
use super::helpers::{self, ConvFuns, ConvoluteMode};
use super::{GlobalConfiguration, Subcommand};
use anyhow::Result;
use clap::{Parser, ValueHint};
Expand All @@ -15,8 +15,8 @@ pub struct Opts {
#[arg(value_hint = ValueHint::FilePath)]
input: PathBuf,
/// LHAPDF id(s) or name of the PDF set(s).
#[arg(required = true, value_parser = helpers::parse_pdfset)]
pdfsets: Vec<String>,
#[arg(required = true)]
conv_funs: Vec<ConvFuns>,
/// Selects a subset of bins.
#[arg(
long,
Expand Down Expand Up @@ -49,12 +49,12 @@ pub struct Opts {
impl Subcommand for Opts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
let grid = helpers::read_grid(&self.input)?;
let mut pdf = helpers::create_pdf(&self.pdfsets[0])?;
let mut conv_funs_0 = helpers::create_conv_funs(&self.conv_funs[0])?;
let bins: Vec<_> = self.bins.iter().cloned().flatten().collect();

let results = helpers::convolve(
&grid,
&mut pdf,
&mut conv_funs_0,
&self.orders,
&bins,
&[],
Expand All @@ -77,13 +77,13 @@ impl Subcommand for Opts {
);
let bin_count = limits.len();

let other_results: Vec<_> = self.pdfsets[1..]
let other_results: Vec<_> = self.conv_funs[1..]
.iter()
.flat_map(|pdfset| {
let mut pdf = helpers::create_pdf(pdfset).unwrap();
.flat_map(|conv_funs| {
let mut conv_funs = helpers::create_conv_funs(conv_funs).unwrap();
helpers::convolve(
&grid,
&mut pdf,
&mut conv_funs,
&self.orders,
&bins,
&[],
Expand All @@ -108,7 +108,7 @@ impl Subcommand for Opts {
}
title.add_cell(cell!(c->format!("{y_label}\n[{y_unit}]")));

for other in self.pdfsets[1..].iter().map(|pdf| helpers::pdf_label(pdf)) {
for other in self.conv_funs[1..].iter().map(|conv_funs| &conv_funs.label) {
let mut cell = cell!(c->format!("{other}\n[{y_unit}] [%]"));
cell.set_hspan(2);
title.add_cell(cell);
Expand Down
17 changes: 8 additions & 9 deletions pineappl_cli/src/diff.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::helpers::{self, ConvoluteMode};
use super::helpers::{self, ConvFuns, ConvoluteMode};
use super::{GlobalConfiguration, Subcommand};
use anyhow::{bail, Result};
use clap::{Parser, ValueHint};
Expand All @@ -16,9 +16,8 @@ pub struct Opts {
/// Path to the second grid.
#[arg(value_hint = ValueHint::FilePath)]
input2: PathBuf,
/// LHAPDF id or name of the PDF set.
#[arg(value_parser = helpers::parse_pdfset)]
pdfset: String,
/// LHAPDF ID(s) or name(s) of the PDF(s)/FF(s).
conv_funs: ConvFuns,
/// Ignore differences in the orders and sum them.
#[arg(long)]
ignore_orders: bool,
Expand Down Expand Up @@ -127,7 +126,7 @@ impl Subcommand for Opts {
bail!("channels differ");
}

let mut pdf = helpers::create_pdf(&self.pdfset)?;
let mut conv_funs = helpers::create_conv_funs(&self.conv_funs)?;

let mut table = helpers::create_table();
let mut title = Row::empty();
Expand All @@ -149,7 +148,7 @@ impl Subcommand for Opts {

let results1 = helpers::convolve(
&grid1,
&mut pdf,
&mut conv_funs,
&orders1,
&[],
&[],
Expand All @@ -159,7 +158,7 @@ impl Subcommand for Opts {
);
let results2 = helpers::convolve(
&grid2,
&mut pdf,
&mut conv_funs,
&orders2,
&[],
&[],
Expand Down Expand Up @@ -205,7 +204,7 @@ impl Subcommand for Opts {
.map(|&order| {
helpers::convolve(
&grid1,
&mut pdf,
&mut conv_funs,
&[order],
&[],
&[],
Expand All @@ -220,7 +219,7 @@ impl Subcommand for Opts {
.map(|&order| {
helpers::convolve(
&grid2,
&mut pdf,
&mut conv_funs,
&[order],
&[],
&[],
Expand Down
19 changes: 9 additions & 10 deletions pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::helpers::{self, ConvoluteMode};
use super::helpers::{self, ConvFuns, ConvoluteMode};
use super::{GlobalConfiguration, Subcommand};
use anyhow::{anyhow, Result};
use clap::{Parser, ValueHint};
Expand Down Expand Up @@ -425,7 +425,7 @@ mod eko {
fn evolve_grid(
grid: &Grid,
eko: &Path,
pdf: &Pdf,
use_alphas_from: &Pdf,
orders: &[(u32, u32)],
xir: f64,
xif: f64,
Expand All @@ -446,7 +446,7 @@ fn evolve_grid(
.collect();

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

if use_old_evolve {
if let EkoSlices::V0 {
Expand Down Expand Up @@ -506,9 +506,8 @@ pub struct Opts {
/// Path to the converted grid.
#[arg(value_hint = ValueHint::FilePath)]
output: PathBuf,
/// LHAPDF id or name of the PDF set to check the converted grid with.
#[arg(value_parser = helpers::parse_pdfset)]
pdfset: String,
/// LHAPDF ID(s) or name of the PDF(s)/FF(s).
conv_funs: ConvFuns,
/// Relative threshold between the table and the converted grid when comparison fails.
#[arg(default_value = "1e-3", long)]
accuracy: f64,
Expand Down Expand Up @@ -542,10 +541,10 @@ impl Subcommand for Opts {
use prettytable::row;

let grid = helpers::read_grid(&self.input)?;
let mut pdf = helpers::create_pdf(&self.pdfset)?;
let mut conv_funs = helpers::create_conv_funs(&self.conv_funs)?;
let results = helpers::convolve_scales(
&grid,
&mut pdf,
&mut conv_funs,
&self.orders,
&[],
&[],
Expand All @@ -557,15 +556,15 @@ impl Subcommand for Opts {
let fk_table = evolve_grid(
&grid,
&self.eko,
&pdf,
&conv_funs[cfg.use_alphas_from],
&self.orders,
self.xir,
self.xif,
self.use_old_evolve,
)?;
let evolved_results = helpers::convolve_scales(
fk_table.grid(),
&mut pdf,
&mut conv_funs,
&[],
&[],
&[],
Expand Down
29 changes: 17 additions & 12 deletions pineappl_cli/src/export.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::helpers::{self, ConvoluteMode};
use super::helpers::{self, ConvFuns, ConvoluteMode};
use super::{GlobalConfiguration, Subcommand};
use anyhow::{anyhow, Result};
use clap::builder::{PossibleValuesParser, TypedValueParser};
Expand All @@ -16,15 +16,15 @@ mod applgrid;
fn convert_into_applgrid(
output: &Path,
grid: &Grid,
pdf: &mut Pdf,
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 applgrid, order_mask) =
applgrid::convert_into_applgrid(grid, output, discard_non_matching_scales)?;
let results = applgrid::convolve_applgrid(applgrid.pin_mut(), pdf);
let results = applgrid::convolve_applgrid(applgrid.pin_mut(), conv_funs);

Ok(("APPLgrid", results, 1, order_mask))
}
Expand All @@ -33,7 +33,7 @@ fn convert_into_applgrid(
fn convert_into_applgrid(
_: &Path,
_: &Grid,
_: &mut Pdf,
_: &mut [Pdf],
_: usize,
_: bool,
) -> Result<(&'static str, Vec<f64>, usize, Vec<bool>)> {
Expand All @@ -45,13 +45,19 @@ fn convert_into_applgrid(
fn convert_into_grid(
output: &Path,
grid: &Grid,
pdf: &mut Pdf,
conv_funs: &mut [Pdf],
scales: usize,
discard_non_matching_scales: bool,
) -> Result<(&'static str, Vec<f64>, usize, Vec<bool>)> {
if let Some(extension) = output.extension() {
if extension == "appl" || extension == "root" {
return convert_into_applgrid(output, grid, pdf, scales, discard_non_matching_scales);
return convert_into_applgrid(
output,
grid,
conv_funs,
scales,
discard_non_matching_scales,
);
}
}

Expand All @@ -67,9 +73,8 @@ pub struct Opts {
/// Path to the converted grid.
#[arg(value_hint = ValueHint::FilePath)]
output: PathBuf,
/// LHAPDF id or name of the PDF set to check the converted grid with.
#[arg(value_parser = helpers::parse_pdfset)]
pdfset: String,
/// LHAPDF ID(s) or name of the PDF(s)/FF(s) to check the converted grid with.
conv_funs: ConvFuns,
/// Relative threshold between the table and the converted grid when comparison fails.
#[arg(default_value = "1e-10", long)]
accuracy: f64,
Expand Down Expand Up @@ -97,13 +102,13 @@ impl Subcommand for Opts {
use prettytable::{cell, row};

let grid = helpers::read_grid(&self.input)?;
let mut pdf = helpers::create_pdf(&self.pdfset)?;
let mut conv_funs = helpers::create_conv_funs(&self.conv_funs)?;

// TODO: figure out `member` from `self.pdfset`
let (grid_type, results, scale_variations, order_mask) = convert_into_grid(
&self.output,
&grid,
&mut pdf,
&mut conv_funs,
self.scales,
self.discard_non_matching_scales,
)?;
Expand Down Expand Up @@ -148,7 +153,7 @@ impl Subcommand for Opts {
} else {
let reference_results = helpers::convolve(
&grid,
&mut pdf,
&mut conv_funs,
&orders,
&[],
&[],
Expand Down
Loading