Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/actions/cache-test-data/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
uses: actions/cache@v4
with:
path: test-data
key: test-data-v21
key: test-data-v23
- name: Download test data if cache miss
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- added a new `V3` metadata reader to the `pineappl evolve` CLI for EKOs
generated with `v0.15.0` or higher
- C API: added new functions `pineappl_grid_evolve_info_shape`,
`pineappl_grid_evolve_info`, and `pineappl_grid_evolve` to evolve grids
- C API: added `pineappl_fktable_optimize` to optimize FK Table-like objects
given an optimization assumption

## [1.0.0] - 10/06/2025

PineAPPL 1.0 is a major rewrite from the previous version, allowing grids to
Expand Down
2 changes: 2 additions & 0 deletions maintainer/download-test-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ files=(
'https://data.nnpdf.science/pineappl/test-data/STAR_WMWP_510GEV_WM-AL-POL_UnpolPDF.tar'
'https://data.nnpdf.science/pineappl/test-data/ZEUS_2JET_319GEV_374PB-1_DIF_ETQ2_BIN6.pineappl.lz4'
'https://data.nnpdf.science/pineappl/test-data/ZEUS_2JET_319GEV_374PB-1_DIF_ETQ2_BIN6.tar'
'https://data.nnpdf.science/pineappl/test-data/LHCB_WP_8TEV.pineappl.lz4'
'https://data.nnpdf.science/pineappl/test-data/LHCB_WP_8TEV.tar'
'https://ploughshare.web.cern.ch/ploughshare/db/applfast/applfast-atlas-dijets-fnlo-arxiv-1312.3524/grids/applfast-atlas-dijets-fnlo-arxiv-1312.3524-xsec000.tab.gz'
'https://ploughshare.web.cern.ch/ploughshare/db/applfast/applfast-h1-dijets-appl-arxiv-0010054/grids/applfast-h1-dijets-appl-arxiv-0010054-xsec000.appl'
'https://ploughshare.web.cern.ch/ploughshare/db/applfast/applfast-h1-incjets-fnlo-arxiv-0706.3722/grids/applfast-h1-incjets-fnlo-arxiv-0706.3722-xsec000.tab.gz'
Expand Down
60 changes: 59 additions & 1 deletion pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mod eko {
V0(MetadataV0),
V1(MetadataV1),
V2(MetadataV2),
V3(MetadataV3), // v0.15 - v????
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually: this would hopefully correspond to __data_version__ = 3, rather then the API version v0.15, so in the end I think it is a good name 😇

}

const BASES_V1_DEFAULT_PIDS: [i32; 14] = [22, -6, -5, -4, -3, -2, -1, 21, 1, 2, 3, 4, 5, 6];
Expand All @@ -86,6 +87,12 @@ mod eko {
configs: OperatorConfigsV1,
}

#[derive(Deserialize)]
struct OperatorV2 {
init: Vec<f64>,
configs: OperatorConfigsV1,
}

#[derive(Deserialize)]
struct OperatorInfoV1 {
scale: f64,
Expand All @@ -105,13 +112,18 @@ mod eko {
bases: BasesV1,
}

#[derive(Deserialize)]
struct MetadataV3 {
xgrid: Vec<f64>,
}

pub enum EkoSlices {
V0 {
fac1: Vec<f64>,
info: OperatorSliceInfo,
operator: Array5<f64>,
},
// V1 is a special case of V2
// V1 and V3 are special cases of V2
V2 {
fac1: HashMap<OsString, f64>,
info: OperatorSliceInfo,
Expand Down Expand Up @@ -142,6 +154,7 @@ mod eko {
Metadata::V0(v0) => Self::with_v0(v0, eko_path),
Metadata::V1(v1) => Self::with_v1(v1, eko_path),
Metadata::V2(v2) => Self::with_v2(v2, eko_path),
Metadata::V3(v3) => Self::with_v3(v3, eko_path),
}
}

Expand Down Expand Up @@ -325,6 +338,51 @@ mod eko {
})
}

fn with_v3(metadata: MetadataV3, eko_path: &Path) -> Result<Self> {
let mut fac1 = HashMap::new();
let mut operator: Option<OperatorV2> = None;

for entry in Archive::new(File::open(eko_path)?).entries_with_seek()? {
let entry = entry?;
let path = entry.path()?;

if path.starts_with("./operators")
&& (path.extension().is_some_and(|ext| ext == "yaml"))
{
let Some(file_stem) = path.file_stem().map(ToOwned::to_owned) else {
continue;
};

let op_info: OperatorInfoV1 = serde_yaml::from_reader(entry)?;
fac1.insert(file_stem, op_info.scale);
} else if path.as_os_str() == "./operator.yaml" {
operator = Some(serde_yaml::from_reader(entry)?);
}
}

let operator =
operator.ok_or_else(|| anyhow!("no file 'operator.yaml' in EKO archive found"))?;

Ok(Self::V2 {
fac1,
info: OperatorSliceInfo {
// NOTE: Since v0.15, EKOs are always in the flavour basis
pid_basis: PidBasis::Pdg,
fac0: operator.init[0] * operator.init[0],
pids0: BASES_V1_DEFAULT_PIDS.to_vec(),
x0: metadata.xgrid.clone(),
fac1: 0.0,
pids1: BASES_V1_DEFAULT_PIDS.to_vec(),
x1: metadata.xgrid,
conv_type: ConvType::new(
operator.configs.polarized,
operator.configs.time_like,
),
},
archive: Archive::new(File::open(eko_path)?),
})
}

pub fn iter_mut(&mut self) -> EkoSlicesIter {
match self {
Self::V0 {
Expand Down
30 changes: 30 additions & 0 deletions pineappl_cli/tests/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ const ZEUS_2JET_STR: &str = "b Grid FkTable rel. diff
2 3.6247796e-3 3.6162230e-3 -2.3605729e-3
";

const LHCB_WP_8TEV_STR: &str = "b Grid FkTable rel. diff
-+-----------+-----------+-------------
0 8.8660824e2 8.8745467e2 9.5468156e-4
1 8.3324869e2 8.3388816e2 7.6744152e-4
2 7.4379285e2 7.4420759e2 5.5761143e-4
3 6.2114832e2 6.2135970e2 3.4030039e-4
4 4.8212545e2 4.8218796e2 1.2966015e-4
5 3.4357834e2 3.4355392e2 -7.1080989e-5
6 1.7271792e2 1.7266488e2 -3.0707061e-4
7 4.6738298e1 4.6715819e1 -4.8096830e-4
";

#[test]
fn help() {
Command::cargo_bin("pineappl")
Expand Down Expand Up @@ -461,3 +473,21 @@ fn zeus_2jet() {
.success()
.stdout(ZEUS_2JET_STR);
}

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

Command::cargo_bin("pineappl")
.unwrap()
.args([
"evolve",
"../test-data/LHCB_WP_8TEV.pineappl.lz4",
"../test-data/LHCB_WP_8TEV.tar",
output.path().to_str().unwrap(),
"NNPDF40_nnlo_as_01180",
])
.assert()
.success()
.stdout(LHCB_WP_8TEV_STR);
}