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

`pineappl read --lumi` panics on empty grid #253

Closed felixhekhorn closed 6 months ago

felixhekhorn commented 6 months ago

I don't think it is me using the CLI not correctly (though I'm not 100% sure), but a bug:

First, I tried with the version I already had (0.6.1) and I got this:

$ pineappl write --optimize MaunaKea.pineappl.lz4 MaunaKea-opt.pineappl.lz4 
$ pineappl read MaunaKea.pineappl.lz4 --lumis
l    entry        entry        entry        entry        entry        entry        entry        entry        entry        entry        entry        entry
-+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------
0 1 × (21, 21)                                                                                                                                   
1 2 × ( 1, -1) 2 × ( 2, -2) 2 × ( 3, -3)                                                                                                         
2 2 × (21, -3) 2 × (21, -2) 2 × (21, -1) 2 × (21,  1) 2 × (21,  2) 2 × (21,  3)                                                                  
3 1 × (-3, -3) 1 × (-2, -2) 1 × (-1, -1) 1 × ( 1,  1) 1 × ( 2,  2) 1 × ( 3,  3)                                                                  
4 1 × (-3,  1) 1 × (-3,  2) 1 × (-2,  1) 1 × (-2,  3) 1 × (-1,  2) 1 × (-1,  3) 1 × ( 1, -3) 1 × ( 1, -2) 1 × ( 2, -3) 1 × ( 2, -1) 1 × ( 3, -2) 1 × ( 3, -1)
5 1 × (-3, -2) 1 × (-3, -1) 1 × (-2, -3) 1 × (-2, -1) 1 × (-1, -3) 1 × (-1, -2) 1 × ( 1,  2) 1 × ( 1,  3) 1 × ( 2,  1) 1 × ( 2,  3) 1 × ( 3,  1) 1 × ( 3,  2)
$ pineappl read MaunaKea-opt.pineappl.lz4 --lumis
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/pineappl_cli-0.6.1/src/read.rs:113:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

then I though maybe it was fixed upstream and updated (to 0.6.3), but the result is the same:

$ pineappl write --optimize MaunaKea.pineappl.lz4 MaunaKea-opt2.pineappl.lz4 
$ pineappl read MaunaKea-opt2.pineappl.lz4 --lumis
thread 'main' panicked at /home/felix/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pineappl_cli-0.6.3/src/read.rs:114:18:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

also orders are completely scraped

$ pineappl read MaunaKea-opt2.pineappl.lz4 --orders
o order
-+-----
$ pineappl read MaunaKea.pineappl.lz4 --orders
o       order
-+-----------------
0 O(as^2)
1 O(as^3)
2 O(as^3 lr^1)
3 O(as^3 lf^1)
4 O(as^4)
5 O(as^4 lr^1)
6 O(as^4 lf^1)
7 O(as^4 lr^2)
8 O(as^4 lr^1 lf^1)
9 O(as^4 lf^2)

PS: funnily enough convolute does not panic, but yields instead

$ pineappl --silence-lhapdf convolute MaunaKea.pineappl.lz4 NNPDF40_nnlo_as_01180 
b x1     diff    
  []      []     
-+-+-+-----------
0 0 1 0.0000000e0
felixhekhorn commented 6 months ago

I forgot a crucial piece of information: in my code the number of active flavours is an input variable and with $n_f=5$ pineappl works just fine (but it fails with $n_f=3,4$)

felixhekhorn commented 6 months ago

just in case you want to have a look: lumi creation is here and after that the code just uses the lumi index here to fill the grid here ... the thing is quite mysterious ..

cschwan commented 6 months ago

This bug is fixed in commit 6ab90a8efb9486187ee41e4bee60107dff18e49b, but the real problem is that the grid you sent me is empty.

felixhekhorn commented 6 months ago

you're right, it was my fault: I missed a

    kv.set_double("q2_min", this->m2 * 0.99);
    kv.set_double("q2_max", this->m2 * 1.01);
    kv.set_double("q2_bins", 1);

in the grid creation ... because when this->grid->fill is called with a scale which is outside the preset boundaries it will just do nothing - maybe you want to raise at least a warning?

in any case nothing to do with optimize

cschwan commented 6 months ago

in the grid creation ... because when this->grid->fill is called with a scale which is outside the preset boundaries it will just do nothing - maybe you want to raise at least a warning?

I'm not quite sure how to best do this, but, yes, we should do this. I remember that other Issues also stemmed from silently discarding events that are outside the interpolation region. I've opened a new Issue for this: https://github.com/NNPDF/pineappl/issues/254.