NNPDF / pineappl

PineAPPL is not an extension of APPLgrid
https://nnpdf.github.io/pineappl/
GNU General Public License v3.0
12 stars 3 forks source link

Factorisation scales below Q2=100 not working in the fortran interface #294

Closed giacomomagni closed 2 weeks ago

giacomomagni commented 3 weeks ago

Somehow I have a problem filling pineapple grids with the fortran interface for values of Q2 below 10**2.

For instance this example:

      program test_pine_below10
        use pineappl

        implicit none

        integer, dimension(2)   :: pdg_ids
        real*8, dimension(1) :: factors
        integer, dimension(4)    :: orders
        real*8, dimension(4) :: bins
        real*8, dimension(3) :: xs

        type (pineappl_keyval) :: key_vals
        type (pineappl_grid)     :: grid
        type (pineappl_lumi)    :: lumi

        integer :: i
        real*8               :: x1, x2, q, weight, j

        lumi = pineappl_lumi_new()
        pdg_ids = (/ 0, 0 /)
        factors = (/ 1.0D0 /)
        call pineappl_lumi_add(lumi, 1, pdg_ids, factors)

        orders = (/ 0, 2, 0, 0 /)
        bins = (/ 8D0, 9D0, 10D0, 11D0 /)

        key_vals = pineappl_keyval_new()
        grid = pineappl_grid_new(lumi, 1, orders, 3, bins, key_vals)

        call pineappl_keyval_delete(key_vals)
        call pineappl_lumi_delete(lumi)

        xs = (/ 0.1, 0.2, 0.3 /)
        do j=1,3
          x1 = xs(j)
          x2 = xs (j)
          weight = 10000D0

          q = 10.5D0
          call pineappl_grid_fill(grid, x1, x2, q**2, 0, 
     & q, 0, weight)
          q = 9.5D0
          call pineappl_grid_fill(grid, x1, x2, q**2, 0,
     & q, 0, weight)
          q = 8.5D0
          call pineappl_grid_fill(grid, x1, x2, q**2, 0,
     & q, 0, weight)
        enddo

        call pineappl_grid_write(grid, "test.pineappl.lz4")
        call pineappl_grid_delete(grid)

      end program

Produce a grid where the values of Q2 below 100 are not correctly stored:

>>> import pineappl
>>> import numpy as np
>>> gg  = pineappl.grid.Grid.read("test.pineappl.lz4")
>>> gg.evolve_info(np.array([True])).fac1
array([1.00000000e+02, 1.22426823e+02, 1.50717358e+02, 1.86606248e+02,
       2.32398443e+02, 2.91175045e+02, 3.67079962e+02, 4.65721676e+02,
       5.94740000e+02, 7.64610958e+02, 9.89797707e+02, 1.29040786e+03,
       1.69459731e+03, 2.24208265e+03, 2.98931259e+03, 4.01714130e+03,
       5.44230543e+03, 7.43473138e+03, 1.02438547e+04, 1.42389905e+04,
       1.99718069e+04, 2.82738833e+04, 4.04104823e+04, 5.83252532e+04,
       8.50334753e+04, 1.25260400e+05, 1.86488213e+05, 2.80691490e+05,
       4.27245381e+05, 6.57853743e+05, 1.02499655e+06, 1.61658126e+06,
       2.58166342e+06, 4.17616348e+06, 6.84516734e+06, 1.13730376e+07,
       1.91609100e+07, 3.27468017e+07, 5.67943528e+07, 1.00000000e+08])
>>> gg.optimize()
>>> gg.evolve_info(np.array([True])).fac1
array([110.25])

I suspect this is because of the original binning that is all above 100. Would it be possible to fix this?

EDIT: or maybe there is already a way to set this grid in the fortran interface?

cschwan commented 2 weeks ago

Hi @giacomomagni, add the following line after the creation of key_vals and before grid:

call pineappl_keyval_set_double(key_vals, "q2_min", 5.0d0) ! set the smallest value

See also the C++ example, which shows all the values you can change (here only the scale-related parameters):

https://github.com/NNPDF/pineappl/blob/756dc97a2dc71d340c860a729c2f58606a24304d/examples/cpp/fill-grid.cpp#L179-L183

giacomomagni commented 2 weeks ago

Thanks @cschwan for the prompt reply, that was exactly what we were missing! :)