Skip to content

Commit

Permalink
Test --rotate-pid-basis more thoroughly
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed May 3, 2024
1 parent 87e906c commit ce37a11
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 16 deletions.
1 change: 1 addition & 0 deletions pineappl_cli/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl Subcommand for Opts {
bail!("number of bins differ");
}

// TODO: use approximate comparison
if !self.ignore_lumis && (grid1.lumi() != grid2.lumi()) {
bail!("luminosities differ");
}
Expand Down
105 changes: 89 additions & 16 deletions pineappl_cli/tests/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ const MULTIPLE_ARGUMENTS_STR: &str = "b etal dsig/detal
5 4 4.5 2.9004607e1
";

const ROTATE_PID_BASIS_NO_DIFF_STR: &str = "b x1 O(as^0 a^2) O(as^0 a^3) O(as^1 a^2)
-+----+----+-----------+-----------+-------+-------------+-------------+-------+-----------+-----------+-------
0 2 2.25 6.5070305e2 6.5070305e2 0.000e0 -7.8692484e0 -7.8692484e0 0.000e0 1.1175729e2 1.1175729e2 0.000e0
1 2.25 2.5 5.9601236e2 5.9601236e2 0.000e0 -6.5623495e0 -6.5623495e0 0.000e0 1.0083341e2 1.0083341e2 0.000e0
2 2.5 2.75 5.1561247e2 5.1561247e2 0.000e0 -5.2348261e0 -5.2348261e0 0.000e0 8.9874343e1 8.9874343e1 0.000e0
3 2.75 3 4.1534629e2 4.1534629e2 0.000e0 -3.7590420e0 -3.7590420e0 0.000e0 7.3935106e1 7.3935106e1 0.000e0
4 3 3.25 3.0812719e2 3.0812719e2 0.000e0 -2.5871885e0 -2.5871885e0 0.000e0 5.6414554e1 5.6414554e1 0.000e0
5 3.25 3.5 2.0807482e2 2.0807482e2 0.000e0 -1.6762487e0 -1.6762487e0 0.000e0 3.9468336e1 3.9468336e1 0.000e0
6 3.5 4 9.6856769e1 9.6856769e1 0.000e0 -8.1027456e-1 -8.1027456e-1 0.000e0 1.9822014e1 1.9822014e1 0.000e0
7 4 4.5 2.2383492e1 2.2383492e1 0.000e0 -2.2022770e-1 -2.2022770e-1 0.000e0 5.3540011e0 5.3540011e0 0.000e0
";

const ROTATE_PID_BASIS_DIFF_STR: &str = "b x1 O(as^0 a^2) O(as^0 a^3) O(as^1 a^2)
-+----+----+-----------+-----------+----------+-------------+-------------+----------+-----------+-----------+----------
0 2 2.25 6.5070305e2 6.5070305e2 -2.220e-16 -7.8692484e0 -7.8692484e0 -4.441e-16 1.1175729e2 1.1175729e2 -1.221e-15
Expand Down Expand Up @@ -913,15 +925,41 @@ fn rewrite_channels() {

#[test]
fn rotate_pid_basis() {
let output = NamedTempFile::new("evolution-basis.pineappl.lz4").unwrap();
let pdg_to_pdg = NamedTempFile::new("pdg-to-pdg.pineappl.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"write",
"--rotate-pid-basis=PDG",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
pdg_to_pdg.path().to_str().unwrap(),
])
.assert()
.success()
.stdout("");

Command::cargo_bin("pineappl")
.unwrap()
.args([
"diff",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
pdg_to_pdg.path().to_str().unwrap(),
"NNPDF31_nlo_as_0118_luxqed",
])
.assert()
.success()
.stdout(ROTATE_PID_BASIS_NO_DIFF_STR);

let pdg_to_evol = NamedTempFile::new("pdg-to-evol.pineappl.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"write",
"--rotate-pid-basis=EVOL",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
output.path().to_str().unwrap(),
pdg_to_evol.path().to_str().unwrap(),
])
.assert()
.success()
Expand All @@ -932,46 +970,53 @@ fn rotate_pid_basis() {
.args([
"diff",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
output.path().to_str().unwrap(),
pdg_to_evol.path().to_str().unwrap(),
"NNPDF31_nlo_as_0118_luxqed",
"--ignore-lumis",
])
.assert()
.success()
.stdout(ROTATE_PID_BASIS_DIFF_STR);

let output2 = NamedTempFile::new("evolution-basis.pineappl.lz4").unwrap();
let evol_to_evol = NamedTempFile::new("evol-to-evol.pineappl.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"write",
"--rotate-pid-basis=EVOL",
"--split-lumi",
"--optimize",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
output2.path().to_str().unwrap(),
pdg_to_evol.path().to_str().unwrap(),
evol_to_evol.path().to_str().unwrap(),
])
.assert()
.success()
.stdout("");

Command::cargo_bin("pineappl")
.unwrap()
.args(["read", "--lumis", output2.path().to_str().unwrap()])
.args([
"diff",
pdg_to_evol.path().to_str().unwrap(),
evol_to_evol.path().to_str().unwrap(),
"NNPDF31_nlo_as_0118_luxqed",
])
.assert()
.success()
.stdout(ROTATE_PID_BASIS_READ_LUMIS_STR);
.stdout(ROTATE_PID_BASIS_NO_DIFF_STR);

let output3 = NamedTempFile::new("evolution-basis.pineappl.lz4").unwrap();
let evol_to_pdg = NamedTempFile::new("evol-to-pdg.pineappl.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"write",
"--rotate-pid-basis=PDG",
output2.path().to_str().unwrap(),
output3.path().to_str().unwrap(),
// fix factors that are almost '1' to exact '1's
"--rewrite-channel",
"0",
"1 * ( 2, -1) + 1 * ( 4, -3)",
pdg_to_evol.path().to_str().unwrap(),
evol_to_pdg.path().to_str().unwrap(),
])
.assert()
.success()
Expand All @@ -980,11 +1025,39 @@ fn rotate_pid_basis() {
Command::cargo_bin("pineappl")
.unwrap()
.args([
"convolve",
output3.path().to_str().unwrap(),
"diff",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
evol_to_pdg.path().to_str().unwrap(),
"NNPDF31_nlo_as_0118_luxqed",
])
.assert()
.success()
.stdout(DEFAULT_STR);
.stdout(ROTATE_PID_BASIS_NO_DIFF_STR);

let evol_to_evol_optimize = NamedTempFile::new("evol-to-evol-optimize.pineappl.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"write",
"--rotate-pid-basis=EVOL",
"--split-lumi",
"--optimize",
"../test-data/LHCB_WP_7TEV.pineappl.lz4",
evol_to_evol_optimize.path().to_str().unwrap(),
])
.assert()
.success()
.stdout("");

Command::cargo_bin("pineappl")
.unwrap()
.args([
"read",
"--lumis",
evol_to_evol_optimize.path().to_str().unwrap(),
])
.assert()
.success()
.stdout(ROTATE_PID_BASIS_READ_LUMIS_STR);
}

0 comments on commit ce37a11

Please sign in to comment.