Skip to content

Commit

Permalink
modify the call to generate_block to make it compatible with eko 0.13.5
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Jun 16, 2023
1 parent d63bda0 commit 10dd7e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ requirements:
- sphinxcontrib-bibtex
- curio >=1.0
- pineappl >=0.5.8
- eko >=0.13.4,<0.14
- eko >=0.13.5,<0.14
- banana-hep >=0.6.8
- fiatlux

Expand Down
23 changes: 3 additions & 20 deletions n3fit/src/evolven3fit_new/eko_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def construct_eko_cards(
legacy_class = runcards.Legacy(theory, {})
theory_card = legacy_class.new_theory

# construct operator card
# Generate the q2grid, if q_fin and q_points are None, use `nf0` to select a default
q2_grid = utils.generate_q2grid(
mu0,
q_fin,
Expand All @@ -99,6 +99,8 @@ def construct_eko_cards(
},
theory["nf0"],
)

# construct operator card
op_card = default_op_card
masses = np.array([theory["mc"], theory["mb"], theory["mt"]]) ** 2
thresholds_ratios = np.array([thresholds["c"], thresholds["b"], thresholds["t"]]) ** 2
Expand Down Expand Up @@ -144,22 +146,3 @@ def construct_eko_cards(

op_card = runcards.OperatorCard.from_dict(op_card)
return theory_card, op_card


def split_evolgrid(evolgrid):
"""Split the evolgrid in blocks according to the number of flavors."""
evolgrid_index_list = []
evolgrid.sort()
starting_nf = evolgrid[0][1]
for evo_point in evolgrid:
current_nf = evo_point[1]
if current_nf != starting_nf:
evolgrid_index_list.append(evolgrid.index(evo_point))
starting_nf = current_nf
start_index = 0
evolgrid_list = []
for index in evolgrid_index_list:
evolgrid_list.append(evolgrid[start_index:index])
start_index = index
evolgrid_list.append(evolgrid[start_index:])
return evolgrid_list
21 changes: 15 additions & 6 deletions n3fit/src/evolven3fit_new/evolve.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections import defaultdict
import logging
import pathlib
import sys
Expand Down Expand Up @@ -178,19 +179,27 @@ def evolve_exportgrid(exportgrid, eko, x_grid, qed):
# generate block to dump
targetgrid = eko.bases.targetgrid.tolist()

def ev_pdf(pid, x, Q2):
return x * evolved_pdf[Q2]["pdfs"][pid][targetgrid.index(x)]
# Finally separate by nf block (and order per nf/q)
by_nf = defaultdict(list)
for q, nf in sorted(eko.evolgrid, key=lambda ep: ep[1]):
by_nf[nf].append(q)
q2block_per_nf = {nf: sorted(qs) for nf, qs in by_nf.items()}

evolgrid_list = eko_utils.split_evolgrid(eko.evolgrid)
blocks = []
for evgrid in evolgrid_list:
for nf, q2grid in q2block_per_nf.items():

def pdf_xq2(pid, x, Q2):
x_idx = targetgrid.index(x)
return x * evolved_pdf[(Q2, nf)]["pdfs"][pid][x_idx]

block = genpdf.generate_block(
ev_pdf,
pdf_xq2,
xgrid=targetgrid,
evolgrid=evgrid,
sorted_q2grid=q2grid,
pids=basis_rotation.flavor_basis_pids,
)
blocks.append(block)

return blocks


Expand Down

0 comments on commit 10dd7e2

Please sign in to comment.