Skip to content

Commit

Permalink
Generalize ConvolutionCache::fx_prod
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Oct 4, 2024
1 parent 59d52a9 commit bf02084
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 87 deletions.
75 changes: 28 additions & 47 deletions pineappl/src/convolutions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,55 +211,36 @@ impl<'a> ConvolutionCache<'a> {
Ok(())
}

/// Return the PDF (multiplied with `x`) for the first initial state.
pub fn xfx1(&mut self, pdg_id: i32, ix1: usize, imu2: usize) -> f64 {
let ix1 = self.ix[0][ix1];
let x = self.x_grid[ix1];
if let Some((idx, cc)) = self.perm[0] {
let imuf2 = self.imuf2[imu2];
let muf2 = self.muf2_grid[imuf2];
let pid = if cc {
pids::charge_conjugate_pdg_pid(pdg_id)
} else {
pdg_id
};
let xfx = &mut self.xfx[idx];
let xfx_cache = &mut self.xfx_cache[idx];
*xfx_cache
.entry((pid, ix1, imuf2))
.or_insert_with(|| xfx(pid, x, muf2))
} else {
x
}
}

/// Return the PDF (multiplied with `x`) for the second initial state.
pub fn xfx2(&mut self, pdg_id: i32, ix2: usize, imu2: usize) -> f64 {
let ix2 = self.ix[1][ix2];
let x = self.x_grid[ix2];
if let Some((idx, cc)) = self.perm[1] {
let imuf2 = self.imuf2[imu2];
let muf2 = self.muf2_grid[imuf2];
let pid = if cc {
pids::charge_conjugate_pdg_pid(pdg_id)
} else {
pdg_id
};
let xfx = &mut self.xfx[idx];
let xfx_cache = &mut self.xfx_cache[idx];
*xfx_cache
.entry((pid, ix2, imuf2))
.or_insert_with(|| xfx(pid, x, muf2))
} else {
x
}
}

/// TODO
pub fn fx_prod(&mut self, pdg_ids: &[i32], indices: &[usize]) -> f64 {
self.xfx1(pdg_ids[0], indices[1], indices[0])
* self.xfx2(pdg_ids[1], indices[2], indices[0])
/ (self.x_grid[self.ix[0][indices[1]]] * self.x_grid[self.ix[1][indices[2]]])
// TODO: here we assume that
// - indices[0] is the (squared) factorization scale,
// - indices[1] is x1 and
// - indices[2] is x2.
// Lift this restriction!
self.perm
.iter()
.zip(pdg_ids)
.enumerate()
.filter_map(|(index, (perm, &pdg_id))| {
perm.map(|(idx, cc)| {
let ix = self.ix[index][indices[index + 1]];
let imuf2 = self.imuf2[indices[0]];
let muf2 = self.muf2_grid[imuf2];
let pid = if cc {
pids::charge_conjugate_pdg_pid(pdg_id)
} else {
pdg_id
};
let xfx = &mut self.xfx[idx];
let xfx_cache = &mut self.xfx_cache[idx];
*xfx_cache.entry((pid, ix, imuf2)).or_insert_with(|| {
let x = self.x_grid[ix];
xfx(pid, x, muf2) / x
})
})
})
.product()
}

/// Return the strong coupling for the renormalization scale set with [`LumiCache::set_grids`],
Expand Down
8 changes: 3 additions & 5 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,13 @@ impl Grid {

for (idx, value) in subgrid.indexed_iter() {
assert_eq!(idx.len(), 3);
let x1 = node_values[1][idx[1]];
let x2 = node_values[2][idx[2]];
let mut lumi = 0.0;

for entry in channel.entry() {
debug_assert_eq!(entry.0.len(), 2);
let xfx1 = convolution_cache.xfx1(entry.0[0], idx[1], idx[0]);
let xfx2 = convolution_cache.xfx2(entry.0[1], idx[2], idx[0]);
lumi += xfx1 * xfx2 * entry.1 / (x1 * x2);
// TODO: we assume `idx` to be ordered as scale, x1, x2
let fx_prod = convolution_cache.fx_prod(&entry.0, &idx);
lumi += fx_prod * entry.1;
}

let alphas = convolution_cache.alphas(idx[0]);
Expand Down
26 changes: 13 additions & 13 deletions pineappl_cli/tests/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,37 @@ const LHCB_WP_7TEV_V2_STR: &str = "b Grid FkTable
-+--------------------+--------------------+----------------------
0 7.8752126798068639e2 7.8731064380928558e2 -2.6745204220435248e-4
1 7.1872113080347663e2 7.1853123147848032e2 -2.6421836906898033e-4
2 6.2322357391848550e2 6.2306009928459093e2 -2.6230495882362259e-4
3 5.0216762988872915e2 5.0203737363369049e2 -2.5938799573266280e-4
4 3.7314505699003126e2 3.7305089832847733e2 -2.5233795755852384e-4
2 6.2322357391848550e2 6.2306009928459105e2 -2.6230495882340055e-4
3 5.0216762988872927e2 5.0203737363369049e2 -2.5938799573288485e-4
4 3.7314505699003132e2 3.7305089832847727e2 -2.5233795755885691e-4
5 2.5302044227292129e2 2.5295968261889854e2 -2.4013733229188983e-4
6 1.1971045984774410e2 1.1968525412249538e2 -2.1055574659711862e-4
7 2.9272102213930090e1 2.9268443366651141e1 -1.2499434622803562e-4
6 1.1971045984774410e2 1.1968525412249534e2 -2.1055574659745169e-4
7 2.9272102213930090e1 2.9268443366651130e1 -1.2499434622836869e-4
";

const LHCB_WP_7TEV_V2_XIR2_STR: &str = "b Grid FkTable rel. diff
-+--------------------+--------------------+----------------------
0 7.7634833292737017e2 7.7614037816519419e2 -2.6786270203205120e-4
1 7.0866199875124983e2 7.0847444839781781e2 -2.6465417048249229e-4
2 6.1427556024981789e2 6.1411417374531106e2 -2.6272655946324441e-4
3 4.9482819982783724e2 4.9469964081143053e2 -2.5980535557890150e-4
1 7.0866199875124983e2 7.0847444839781758e2 -2.6465417048282536e-4
2 6.1427556024981789e2 6.1411417374531095e2 -2.6272655946346646e-4
3 4.9482819982783735e2 4.9469964081143053e2 -2.5980535557912354e-4
4 3.6756257449354945e2 3.6746967569489709e2 -2.5274281196974169e-4
5 2.4912642701834142e2 2.4906651029915440e2 -2.4050727939273209e-4
6 1.1776254040032327e2 1.1773772039493414e2 -2.1076316207813139e-4
7 2.8749891297668260e1 2.8746299479656258e1 -1.2493327278395583e-4
7 2.8749891297668267e1 2.8746299479656273e1 -1.2493327278373378e-4
";

const LHCB_WP_7TEV_V2_XIF_2_STR: &str =
"b Grid FkTable rel. diff
-+--------------------+--------------------+----------------------
0 8.0902449713533758e2 8.0880109089579207e2 -2.7614273774967391e-4
1 7.3869242569893402e2 7.3849113100483919e2 -2.7250136469769703e-4
0 8.0902449713533770e2 8.0880109089579207e2 -2.7614273774978493e-4
1 7.3869242569893413e2 7.3849113100483896e2 -2.7250136469814112e-4
2 6.4102495904778243e2 6.4085178025871448e2 -2.7015919836448354e-4
3 5.1668563837653949e2 5.1654786167667771e2 -2.6665478896348294e-4
4 3.8405066991124284e2 3.8395127677619655e2 -2.5880213949180941e-4
5 2.6047697125229388e2 2.6041295913273854e2 -2.4574963094659008e-4
5 2.6047697125229377e2 2.6041295913273854e2 -2.4574963094614599e-4
6 1.2324364745022301e2 1.2321715784184289e2 -2.1493690691698486e-4
7 3.0134629982656573e1 3.0130872371345841e1 -1.2469412476256991e-4
7 3.0134629982656573e1 3.0130872371345848e1 -1.2469412476234787e-4
";

const LHCB_WP_7TEV_V2_XIF_2_ERROR_STR: &str = "Error: failed to evolve grid: no operator for muf2 = 25825.775616000003 found in [6456.443904000001]
Expand Down
14 changes: 7 additions & 7 deletions pineappl_cli/tests/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ b APPLgrid PineAPPL rel. diff
1 2.3289219e1 2.3289219e1 -1.9984014e-15
2 3.7442697e1 3.7442697e1 -2.1094237e-15
3 5.0087316e1 5.0087316e1 -3.1086245e-15
4 6.0873237e1 6.0873237e1 -2.8865799e-15
5 6.8944378e1 6.8944378e1 -3.8857806e-15
4 6.0873237e1 6.0873237e1 -2.5535130e-15
5 6.8944378e1 6.8944378e1 -3.5527137e-15
6 7.4277783e1 7.4277783e1 -2.8865799e-15
7 7.6356931e1 7.6356931e1 -3.7747583e-15
8 7.5009607e1 7.5009607e1 -1.5543122e-15
9 7.0045787e1 7.0045787e1 -1.2212453e-15
7 7.6356931e1 7.6356931e1 -3.3306691e-15
8 7.5009607e1 7.5009607e1 -1.8873791e-15
9 7.0045787e1 7.0045787e1 -7.7715612e-16
10 6.0009803e1 6.0009803e1 -7.7715612e-16
11 4.6770515e1 4.6770515e1 4.4408921e-16
11 4.6770515e1 4.6770515e1 2.2204460e-16
12 3.3569217e1 3.3569217e1 1.5543122e-15
13 2.1820341e1 2.1820341e1 1.3322676e-15
13 2.1820341e1 2.1820341e1 1.1102230e-15
14 1.2542026e1 1.2542026e1 2.2204460e-16
15 6.0879666e0 6.0879666e0 -1.3322676e-15
16 1.5789361e0 1.5789361e0 -1.5543122e-15
Expand Down
14 changes: 7 additions & 7 deletions pineappl_cli/tests/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Options:
#[cfg(feature = "fastnlo")]
const IMPORT_FIX_GRID_STR: &str = "b PineAPPL fastNLO rel. diff
-+------------+------------+--------------
0 2.9158424e-4 2.9158424e-4 -2.7755576e-15
0 2.9158424e-4 2.9158424e-4 -2.5535130e-15
1 2.4657895e-4 2.4657895e-4 -2.6645353e-15
";

Expand Down Expand Up @@ -251,13 +251,13 @@ const IMPORT_APPLGRID_STR: &str = "b PineAPPL APPLgrid rel. diff
const IMPORT_NEW_APPLGRID_STR: &str = "b PineAPPL APPLgrid rel. diff
--+-----------+-----------+--------------
0 6.2634897e2 6.2634897e2 1.5543122e-15
1 6.2847078e2 6.2847078e2 0.0000000e0
2 6.3163323e2 6.3163323e2 2.2204460e-16
1 6.2847078e2 6.2847078e2 -2.2204460e-16
2 6.3163323e2 6.3163323e2 0.0000000e0
3 6.3586556e2 6.3586556e2 2.2204460e-16
4 6.4139163e2 6.4139163e2 1.7763568e-15
5 6.4848088e2 6.4848088e2 -2.4424907e-15
6 6.5354150e2 6.5354150e2 -3.4416914e-15
7 6.5377566e2 6.5377566e2 -1.4432899e-15
5 6.4848088e2 6.4848088e2 -2.3314684e-15
6 6.5354150e2 6.5354150e2 -3.6637360e-15
7 6.5377566e2 6.5377566e2 -1.5543122e-15
8 6.5094729e2 6.5094729e2 1.7763568e-15
9 6.3588760e2 6.3588760e2 2.2204460e-15
10 5.9810718e2 5.9810718e2 2.2204460e-15
Expand All @@ -275,7 +275,7 @@ const IMPORT_DIS_APPLGRID_STR: &str = "b PineAPPL APPLgrid rel. diff
-+------------+------------+--------------
0 9.3514881e-2 9.3514881e-2 -3.3306691e-16
1 3.9993061e-2 3.9993061e-2 2.2204460e-16
2 1.3593440e-2 1.3593440e-2 -2.2204460e-16
2 1.3593440e-2 1.3593440e-2 0.0000000e0
3 2.0825199e-3 2.0825199e-3 -4.4408921e-16
";

Expand Down
16 changes: 8 additions & 8 deletions pineappl_cli/tests/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ const ROTATE_PID_BASIS_NO_DIFF_STR: &str = "b x1 O(as^0 a^2)

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
1 2.25 2.5 5.9601236e2 5.9601236e2 -7.772e-16 -6.5623495e0 -6.5623495e0 -2.220e-16 1.0083341e2 1.0083341e2 -5.551e-16
2 2.5 2.75 5.1561247e2 5.1561247e2 -8.882e-16 -5.2348261e0 -5.2348261e0 -6.661e-16 8.9874343e1 8.9874343e1 -1.221e-15
3 2.75 3 4.1534629e2 4.1534629e2 -4.441e-16 -3.7590420e0 -3.7590420e0 -5.551e-16 7.3935106e1 7.3935106e1 -1.554e-15
4 3 3.25 3.0812719e2 3.0812719e2 -3.331e-16 -2.5871885e0 -2.5871885e0 -5.551e-16 5.6414554e1 5.6414554e1 -2.220e-16
5 3.25 3.5 2.0807482e2 2.0807482e2 -6.661e-16 -1.6762487e0 -1.6762487e0 -1.110e-16 3.9468336e1 3.9468336e1 -6.661e-16
6 3.5 4 9.6856769e1 9.6856769e1 -3.331e-16 -8.1027456e-1 -8.1027456e-1 -1.110e-16 1.9822014e1 1.9822014e1 -1.110e-15
7 4 4.5 2.2383492e1 2.2383492e1 -3.331e-16 -2.2022770e-1 -2.2022770e-1 -5.551e-16 5.3540011e0 5.3540011e0 0.000e0
0 2 2.25 6.5070305e2 6.5070305e2 -5.551e-16 -7.8692484e0 -7.8692484e0 -4.441e-16 1.1175729e2 1.1175729e2 -1.221e-15
1 2.25 2.5 5.9601236e2 5.9601236e2 -7.772e-16 -6.5623495e0 -6.5623495e0 -4.441e-16 1.0083341e2 1.0083341e2 0.000e0
2 2.5 2.75 5.1561247e2 5.1561247e2 -8.882e-16 -5.2348261e0 -5.2348261e0 -8.882e-16 8.9874343e1 8.9874343e1 -1.221e-15
3 2.75 3 4.1534629e2 4.1534629e2 -4.441e-16 -3.7590420e0 -3.7590420e0 -6.661e-16 7.3935106e1 7.3935106e1 -1.554e-15
4 3 3.25 3.0812719e2 3.0812719e2 -5.551e-16 -2.5871885e0 -2.5871885e0 -5.551e-16 5.6414554e1 5.6414554e1 0.000e0
5 3.25 3.5 2.0807482e2 2.0807482e2 -5.551e-16 -1.6762487e0 -1.6762487e0 -2.220e-16 3.9468336e1 3.9468336e1 -6.661e-16
6 3.5 4 9.6856769e1 9.6856769e1 -4.441e-16 -8.1027456e-1 -8.1027456e-1 -4.441e-16 1.9822014e1 1.9822014e1 -1.110e-15
7 4 4.5 2.2383492e1 2.2383492e1 -6.661e-16 -2.2022770e-1 -2.2022770e-1 -5.551e-16 5.3540011e0 5.3540011e0 -6.661e-16
";

const ROTATE_PID_BASIS_READ_CHANNELS_STR: &str = " c entry
Expand Down

0 comments on commit bf02084

Please sign in to comment.