|
6 | 6 |
|
7 | 7 | def main(filename, Q2): |
8 | 8 | # setup data |
9 | | - xgrid = np.geomspace(5e-5, 0.7, 10) |
10 | | - lepton_pid = 11 |
11 | 9 | pid = 4 |
| 10 | + xgrid = np.geomspace(5e-5, 0.7, 10) |
| 11 | + bins_length = len(xgrid) |
| 12 | + bin_limits = [float(i) for i in range(0, bins_length + 1)] |
| 13 | + |
| 14 | + # Instantiate the objecs required to construct a new Grid |
| 15 | + channels = [pineappl.boc.Channel([([pid], 1.0)])] |
| 16 | + orders = [pineappl.boc.Order(0, 0, 0, 0, 0)] |
| 17 | + convolution_types = pineappl.convolutions.ConvType(polarized=False, time_like=False) |
| 18 | + convolutions = [ |
| 19 | + pineappl.convolutions.Conv(convolution_types=convolution_types, pid=2212) |
| 20 | + ] |
| 21 | + kinematics = [pineappl.boc.Kinematics.Scale(0), pineappl.boc.Kinematics.X(0)] |
| 22 | + scale_funcs = pineappl.boc.Scales( |
| 23 | + ren=pineappl.boc.ScaleFuncForm.Scale(0), |
| 24 | + fac=pineappl.boc.ScaleFuncForm.Scale(0), |
| 25 | + frg=pineappl.boc.ScaleFuncForm.NoScale(0), |
| 26 | + ) |
| 27 | + bin_limits = pineappl.boc.BinsWithFillLimits.from_fill_limits( |
| 28 | + fill_limits=bin_limits |
| 29 | + ) |
| 30 | + interpolations = [ |
| 31 | + pineappl.interpolation.Interp( |
| 32 | + min=1e2, |
| 33 | + max=1e3, |
| 34 | + nodes=50, |
| 35 | + order=3, |
| 36 | + reweight_meth=pineappl.interpolation.ReweightingMethod.NoReweight, |
| 37 | + map=pineappl.interpolation.MappingMethod.ApplGridH0, |
| 38 | + interpolation_meth=pineappl.interpolation.InterpolationMethod.Lagrange, |
| 39 | + ), # Interpolation on the Scale |
| 40 | + pineappl.interpolation.Interp( |
| 41 | + min=1e-5, |
| 42 | + max=1, |
| 43 | + nodes=40, |
| 44 | + order=3, |
| 45 | + reweight_meth=pineappl.interpolation.ReweightingMethod.ApplGridX, |
| 46 | + map=pineappl.interpolation.MappingMethod.ApplGridF2, |
| 47 | + interpolation_meth=pineappl.interpolation.InterpolationMethod.Lagrange, |
| 48 | + ), # Interpolation on momentum fraction x |
| 49 | + ] |
| 50 | + |
| 51 | + grid = pineappl.grid.Grid( |
| 52 | + pid_basis=pineappl.pids.PidBasis.Evol, |
| 53 | + channels=channels, |
| 54 | + orders=orders, |
| 55 | + bins=bin_limits, |
| 56 | + convolutions=convolutions, |
| 57 | + interpolations=interpolations, |
| 58 | + kinematics=kinematics, |
| 59 | + scale_funcs=scale_funcs, |
| 60 | + ) |
12 | 61 |
|
13 | | - # init pineappl objects |
14 | | - lumi_entries = [pineappl.boc.Channel([(pid, lepton_pid, 1.0)])] |
15 | | - orders = [pineappl.grid.Order(0, 0, 0, 0)] |
16 | | - bins = len(xgrid) |
17 | | - # NOTE: `bin_limits` have to be `np.ndarray` |
18 | | - bin_limits = np.array([float(i) for i in range(0, bins + 1)]) |
19 | | - # subgrid params - default is just sufficient |
20 | | - params = pineappl.subgrid.SubgridParams() |
21 | | - # inti grid |
22 | | - grid = pineappl.grid.Grid(lumi_entries, orders, bin_limits, params) |
23 | 62 | limits = [] |
24 | 63 | # add each point as a bin |
25 | 64 | for bin_, x in enumerate(xgrid): |
26 | 65 | # keep DIS bins |
27 | | - limits.append((Q2, Q2)) |
28 | | - limits.append((x, x)) |
29 | | - # delta function |
30 | | - array = np.zeros(len(xgrid)) |
31 | | - array[bin_] = 1 |
32 | | - # create and set |
33 | | - subgrid = pineappl.import_only_subgrid.ImportOnlySubgridV1( |
34 | | - array[np.newaxis, :, np.newaxis], |
35 | | - np.array([Q2]), # `q2_grid` has to be `np.ndarrary` |
36 | | - np.array(xgrid), # `x_grid` has to be `np.ndarrary` |
37 | | - np.array([1.0]), # `x_grid` has to be `np.ndarrary` |
| 66 | + limits.append([(Q2, Q2), (x, x)]) |
| 67 | + # Fill the subgrid with delta functions |
| 68 | + array_subgrid = np.zeros((1, xgrid.size)) |
| 69 | + array_subgrid[0][bin_] = 1 |
| 70 | + # create and set the subgrid |
| 71 | + subgrid = pineappl.subgrid.ImportSubgridV1( |
| 72 | + array=array_subgrid, |
| 73 | + node_values=[[Q2], xgrid], |
38 | 74 | ) |
39 | 75 | grid.set_subgrid(0, bin_, 0, subgrid.into()) |
40 | 76 | # set the correct observables |
41 | | - normalizations = np.array([1.0] * bins) # `normalizations` has to be `np.ndarray` |
42 | | - remapper = pineappl.bin.BinRemapper(normalizations, limits) |
43 | | - grid.set_remapper(remapper) |
| 77 | + normalizations = [1.0] * bins_length |
| 78 | + bin_configs = pineappl.boc.BinsWithFillLimits.from_limits_and_normalizations( |
| 79 | + limits=limits, |
| 80 | + normalizations=normalizations, |
| 81 | + ) |
| 82 | + grid.set_bwfl(bin_configs) |
44 | 83 |
|
45 | 84 | # set the initial state PDF ids for the grid |
46 | | - grid.set_key_value("initial_state_1", "2212") |
47 | | - grid.set_key_value("initial_state_2", str(lepton_pid)) |
48 | | - grid.set_key_value( |
| 85 | + grid.set_metadata( |
49 | 86 | "runcard", |
50 | 87 | f"positivity constraint for quark {pid}", |
51 | 88 | ) |
|
0 commit comments