Skip to content

Commit

Permalink
Remove Mu2 struct
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Oct 30, 2024
1 parent 2f79ef5 commit ada5ef5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 57 deletions.
11 changes: 0 additions & 11 deletions pineappl/src/subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ pub enum SubgridEnum {
ImportSubgridV1,
}

/// Structure denoting renormalization and factorization scale values.
#[derive(Debug, Deserialize, Clone, PartialEq, PartialOrd, Serialize)]
pub struct Mu2 {
/// The (squared) renormalization scale value.
pub ren: f64,
/// The (squared) factorization scale value.
pub fac: f64,
/// The (squared) fragmentation scale value.
pub frg: f64,
}

/// Size-related statistics for a subgrid.
#[derive(Debug, Eq, PartialEq)]
pub struct Stats {
Expand Down
17 changes: 9 additions & 8 deletions pineappl/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::import_subgrid::ImportSubgridV1;
use super::interpolation::{Interp, InterpMeth, Map, ReweightMeth};
use super::packed_array::PackedArray;
use super::pids::PidBasis;
use super::subgrid::Mu2;
use float_cmp::assert_approx_eq;
use pineappl_v0::grid::Grid as GridV0;
use std::io::BufRead;
use std::iter;
Expand Down Expand Up @@ -117,17 +117,18 @@ pub fn read_uncompressed_v0(mut reader: impl BufRead) -> Result<Grid, GridError>

for (new_subgrid, old_subgrid) in result.subgrids_mut().iter_mut().zip(grid.subgrids().iter()) {
if !old_subgrid.is_empty() {
let mu2_grid: Vec<_> = old_subgrid
let scale_node_values: Vec<_> = old_subgrid
.mu2_grid()
.iter()
.map(|mu2v0| Mu2 {
ren: mu2v0.ren,
fac: mu2v0.fac,
frg: -1.0,
.map(|mu2v0| {
// TODO: implement importing flexible-scale grids
assert_approx_eq!(f64, mu2v0.ren, mu2v0.fac, ulps = 4);

mu2v0.fac
})
.collect();

let mut dim = vec![mu2_grid.len()];
let mut dim = vec![scale_node_values.len()];
if convolutions[0].is_some() {
dim.push(old_subgrid.x1_grid().len());
}
Expand All @@ -150,7 +151,7 @@ pub fn read_uncompressed_v0(mut reader: impl BufRead) -> Result<Grid, GridError>
}
}

let mut node_values = vec![mu2_grid.iter().map(|&Mu2 { ren, .. }| ren).collect()];
let mut node_values = vec![scale_node_values];
if convolutions[0].is_some() {
node_values.push(old_subgrid.x1_grid().into_owned());
}
Expand Down
29 changes: 6 additions & 23 deletions pineappl_cli/src/import/applgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use pineappl::import_subgrid::ImportSubgridV1;
use pineappl::interpolation::{Interp, InterpMeth, Map, ReweightMeth};
use pineappl::packed_array::PackedArray;
use pineappl::pids::PidBasis;
use pineappl::subgrid::Mu2;
use pineappl_applgrid::ffi::{self, grid};
use std::f64::consts::TAU;
use std::pin::Pin;
Expand Down Expand Up @@ -182,16 +181,7 @@ pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u8) -> Result<Grid> {
let igrid = unsafe { &*igrid };
let reweight = ffi::igrid_m_reweight(igrid);

let mu2_values: Vec<_> = (0..igrid.Ntau())
.map(|i| {
let q2 = igrid.getQ2(i);
Mu2 {
ren: q2,
fac: q2,
frg: -1.0,
}
})
.collect();
let scale_values: Vec<_> = (0..igrid.Ntau()).map(|i| igrid.getQ2(i)).collect();
let x1_values: Vec<_> = (0..igrid.Ny1())
.map(|i| igrid.getx1(i).clamp(0.0, 1.0))
.collect();
Expand Down Expand Up @@ -223,12 +213,12 @@ pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u8) -> Result<Grid> {
let matrix = unsafe { &*matrix };

let mut array = PackedArray::new(if dis {
vec![mu2_values.len(), x1_values.len()]
vec![scale_values.len(), x1_values.len()]
} else {
vec![mu2_values.len(), x1_values.len(), x2_values.len()]
vec![scale_values.len(), x1_values.len(), x2_values.len()]
});

for itau in 0..mu2_values.len() {
for itau in 0..scale_values.len() {
for ix1 in 0..x1_values.len() {
for ix2 in 0..x2_values.len() {
let value = ffi::sparse_matrix_get(
Expand All @@ -255,16 +245,9 @@ pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u8) -> Result<Grid> {
ImportSubgridV1::new(
array,
if dis {
vec![
mu2_values.iter().map(|&Mu2 { ren, .. }| ren).collect(),
x1_values.clone(),
]
vec![scale_values.clone(), x1_values.clone()]
} else {
vec![
mu2_values.iter().map(|&Mu2 { ren, .. }| ren).collect(),
x1_values.clone(),
x2_values.clone(),
]
vec![scale_values.clone(), x1_values.clone(), x2_values.clone()]
},
)
.into();
Expand Down
18 changes: 3 additions & 15 deletions pineappl_cli/src/import/fastnlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use pineappl::import_subgrid::ImportSubgridV1;
use pineappl::interpolation::{Interp, InterpMeth, Map, ReweightMeth};
use pineappl::packed_array::PackedArray;
use pineappl::pids::PidBasis;
use pineappl::subgrid::Mu2;
use pineappl_fastnlo::ffi::{
self, fastNLOCoeffAddBase, fastNLOCoeffAddFix, fastNLOCoeffAddFlex, fastNLOLHAPDF,
fastNLOPDFLinearCombinations, EScaleFunctionalForm,
Expand Down Expand Up @@ -212,17 +211,10 @@ fn convert_coeff_add_fix(
}

let q_values = ffi::GetScaleNodes(table, obs, j);
let mu2_values: Vec<_> = q_values
.iter()
.map(|q| Mu2 {
ren: q * q,
fac: q * q,
frg: -1.0,
})
.collect();
let scale_values: Vec<_> = q_values.into_iter().map(|q| q * q).collect();

let mut array =
PackedArray::new(vec![mu2_values.len(), x1_values.len(), x2_values.len()]);
PackedArray::new(vec![scale_values.len(), x1_values.len(), x2_values.len()]);

// TODO: figure out what the general case is supposed to be
assert_eq!(j, 0);
Expand Down Expand Up @@ -278,11 +270,7 @@ fn convert_coeff_add_fix(
[[0, obs.try_into().unwrap(), subproc.try_into().unwrap()]] =
ImportSubgridV1::new(
array,
vec![
mu2_values.iter().map(|&Mu2 { ren, .. }| ren).collect(),
x1_values.clone(),
x2_values.clone(),
],
vec![scale_values.clone(), x1_values.clone(), x2_values.clone()],
)
.into();
}
Expand Down

0 comments on commit ada5ef5

Please sign in to comment.