Skip to content

Commit

Permalink
Propagate configs to esf
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Nov 19, 2021
1 parent a37c157 commit 07a32df
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 65 deletions.
28 changes: 14 additions & 14 deletions src/yadism/coefficient_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def collect_ffns(esf, obs_name, nf):
# Now: F2c in FFNS3 (the true thing)
elems.extend(heavy.kernels.generate(esf, nf))
ihq = nf + 1
if ihq in esf.sf.intrinsic_range:
if ihq in esf.info.intrinsic_range:
elems.extend(intrinsic.kernels.generate(esf, ihq))
# add "missing" diagrams
if obs_name.flavor_family in ["total"]:
Expand All @@ -57,9 +57,9 @@ class Combiner:

def __init__(self, esf):
self.esf = esf
self.obs_name = esf.sf.obs_name
self.nf = esf.sf.threshold.nf(esf.Q2)
self.target = esf.sf.target
self.obs_name = esf.info.obs_name
self.nf = esf.info.threshold.nf(esf.Q2)
self.target = esf.info.target

def collect_zmvfns(self):
"""
Expand Down Expand Up @@ -105,13 +105,13 @@ def collect_fonll(self):
"""
elems = []
# above the *next* threshold use ZM-VFNS
# nl = self.esf.sf.nf_ff - 1
# nl = self.esf.info.nf_ff - 1
# if nl + 1 < self.nf:
# return self.collect_zmvfns()
nl = self.nf - 1
# below charm it is simply FFNS
if self.nf <= 3:
return self.collect_ffns()
return collect_ffns(self.esf, self.esf.info.obs_name, self.nf)

if self.obs_name.flavor in ["light", "total"]:
# FFNSlow
Expand All @@ -137,7 +137,7 @@ def collect_fonll(self):
# FFNSlow
elems.extend(heavy.kernels.generate(self.esf, nl))
# add F^d
if ihq in self.esf.sf.intrinsic_range:
if ihq in self.esf.info.intrinsic_range:
elems.extend(intrinsic.kernels.generate(self.esf, ihq))
elems.extend(
self.damp_elems(
Expand Down Expand Up @@ -180,12 +180,12 @@ def damp_elems(self, nl, elems):
elems : list(Kernel)
modified kernels
"""
if not self.esf.sf.FONLL_damping:
if not self.esf.info.FONLL_damping:
return elems
nhq = nl + 1
# TODO: replace mass with threshold?
m2hq = self.esf.sf.m2hq[nhq - 4]
power = self.esf.sf.damping_powers[nhq - 4]
m2hq = self.esf.info.m2hq[nhq - 4]
power = self.esf.info.damping_powers[nhq - 4]
if self.esf.Q2 > m2hq:
damp = np.power(1.0 - m2hq / self.esf.Q2, power)
else:
Expand Down Expand Up @@ -245,11 +245,11 @@ def collect_elems(self):
elems : list(yadism.kernels.Kernel)
all participants
"""
if self.esf.sf.scheme == "FFNS":
full = self.collect_ffns()
elif self.esf.sf.scheme == "ZM-VFNS":
if self.esf.info.scheme == "FFNS":
full = collect_ffns(self.esf, self.esf.info.obs_name, self.nf)
elif self.esf.info.scheme == "ZM-VFNS":
full = self.collect_zmvfns()
elif self.esf.sf.scheme in ["FONLL-A", "FONLL-B", "FONLL-C"]:
elif self.esf.info.scheme in ["FONLL-A", "FONLL-B", "FONLL-C"]:
full = self.collect_fonll()
else:
raise ValueError("Unknown FNS")
Expand Down
40 changes: 20 additions & 20 deletions src/yadism/coefficient_functions/fonll/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ def generate_light(esf, nl):
# rewrite the derivative term back as a sum
# and so we're back to cbar^{(nl)}
light_elems = light.kernels.generate(esf, nl)
kind = esf.sf.obs_name.kind
mu2hq = esf.sf.threshold.area_walls[ihq - 3]
kind = esf.info.obs_name.kind
mu2hq = esf.info.threshold.area_walls[ihq - 3]
L = np.log(esf.Q2 / mu2hq)
fonll_cfs = import_pc_module(kind, esf.process)

if esf.process == "CC":
light_weights = kernels.cc_weights(
esf.sf.coupling_constants, esf.Q2, kind, kernels.flavors[:nl], nl
esf.info.coupling_constants, esf.Q2, kind, kernels.flavors[:nl], nl
)
else:
light_weights = light.kernels.nc_weights(
esf.sf.coupling_constants, esf.Q2, kind, nl
esf.info.coupling_constants, esf.Q2, kind, nl
)

as_norm = 2.0
Expand Down Expand Up @@ -78,15 +78,15 @@ def generate_light_diff(esf, nl):
elems : list(yadism.kernels.Kernel)
list of elements
"""
kind = esf.sf.obs_name.kind
kind = esf.info.obs_name.kind
light_cfs = import_pc_module(kind, esf.process, "light")
if esf.process == "CC":
light_weights = kernels.cc_weights(
esf.sf.coupling_constants, esf.Q2, kind, kernels.flavors[:nl], nl + 1
esf.info.coupling_constants, esf.Q2, kind, kernels.flavors[:nl], nl + 1
)
else:
light_weights = light.kernels.nc_weights(
esf.sf.coupling_constants, esf.Q2, kind, nl + 1, skip_heavylight=True
esf.info.coupling_constants, esf.Q2, kind, nl + 1, skip_heavylight=True
)
s_w = {nl + 1: light_weights["s"][nl + 1], -(nl + 1): light_weights["s"][-(nl + 1)]}
return (kernels.Kernel(s_w, light_cfs.Singlet(esf, nl + 1)),)
Expand All @@ -108,28 +108,28 @@ def generate_heavy_diff(esf, nl):
elems : list(yadism.kernels.Kernel)
list of elements
"""
kind = esf.sf.obs_name.kind
kind = esf.info.obs_name.kind
ihq = nl + 1
# add light contributions
elems = kernels.generate_single_flavor_light(esf, nl + 1, ihq)
# add asymptotic contributions
# The matching does not necessarily happen at the quark mass
# m2hq = esf.sf.m2hq[ihq - 4]
# m2hq = esf.info.m2hq[ihq - 4]
# but will be done at the proper threshold
fonll_cfs = import_pc_module(kind, esf.process)
mu2hq = esf.sf.threshold.area_walls[ihq - 3]
mu2hq = esf.info.threshold.area_walls[ihq - 3]
asys = []
if esf.process == "CC":
wa = kernels.cc_weights(
esf.sf.coupling_constants, esf.Q2, kind, kernels.flavors[ihq - 1], nl
esf.info.coupling_constants, esf.Q2, kind, kernels.flavors[ihq - 1], nl
)
asys = [
-kernels.Kernel(wa["ns"], fonll_cfs.AsyQuark(esf, nl, mu2hq=mu2hq)),
-kernels.Kernel(wa["g"], fonll_cfs.AsyGluon(esf, nl, mu2hq=mu2hq)),
]
else:
asy_weights = heavy.kernels.nc_weights(
esf.sf.coupling_constants, esf.Q2, kind, nl
esf.info.coupling_constants, esf.Q2, kind, nl
)
if kind != "F3":
asys = [
Expand Down Expand Up @@ -166,19 +166,19 @@ def generate_heavy_intrinsic_diff(esf, nl):
elems : list(yadism.kernels.Kernel)
list of elements
"""
kind = esf.sf.obs_name.kind
kind = esf.info.obs_name.kind
cfs = import_pc_module(kind, esf.process)
ihq = nl + 1
m2hq = esf.sf.m2hq[ihq - 4]
m2hq = esf.info.m2hq[ihq - 4]
# matching scale
mu2hq = esf.sf.threshold.area_walls[ihq - 3]
mu2hq = esf.info.threshold.area_walls[ihq - 3]
# add normal terms starting from NNLO
nnlo_terms = generate_heavy_diff(esf, nl)
for k in nnlo_terms:
k.min_order = 2
if esf.process == "CC":
w = kernels.cc_weights(
esf.sf.coupling_constants, esf.Q2, kind, kernels.flavors[ihq - 1], ihq
esf.info.coupling_constants, esf.Q2, kind, kernels.flavors[ihq - 1], ihq
)
wq = {k: v for k, v in w["ns"].items() if abs(k) == ihq}
if kind == "F3":
Expand All @@ -205,8 +205,8 @@ def generate_heavy_intrinsic_diff(esf, nl):
)
# NC
if kind == "F3":
wVA = esf.sf.coupling_constants.get_weight(ihq, esf.Q2, "VA")
wAV = esf.sf.coupling_constants.get_weight(ihq, esf.Q2, "AV")
wVA = esf.info.coupling_constants.get_weight(ihq, esf.Q2, "VA")
wAV = esf.info.coupling_constants.get_weight(ihq, esf.Q2, "AV")
wp = wVA + wAV
wm = wVA - wAV
return (
Expand All @@ -221,8 +221,8 @@ def generate_heavy_intrinsic_diff(esf, nl):
*nnlo_terms,
)
# add matching terms
wVV = esf.sf.coupling_constants.get_weight(ihq, esf.Q2, "VV")
wAA = esf.sf.coupling_constants.get_weight(ihq, esf.Q2, "AA")
wVV = esf.info.coupling_constants.get_weight(ihq, esf.Q2, "VV")
wAA = esf.info.coupling_constants.get_weight(ihq, esf.Q2, "AA")
wp = wVV + wAA
wm = wVV - wAA
return (
Expand Down
14 changes: 7 additions & 7 deletions src/yadism/coefficient_functions/heavy/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def generate(esf, nf):
elems : list(yadism.kernels.Kernel)
list of elements
"""
kind = esf.sf.obs_name.kind
kind = esf.info.obs_name.kind
pcs = import_pc_module(kind, esf.process)
ihq = nf + 1
m2hq = esf.sf.m2hq[ihq - 4]
m2hq = esf.info.m2hq[ihq - 4]
if esf.process == "CC":
w = kernels.cc_weights(
esf.sf.coupling_constants, esf.Q2, kind, kernels.flavors[nf], nf
esf.info.coupling_constants, esf.Q2, kind, kernels.flavors[nf], nf
)
return (
kernels.Kernel(w["ns"], pcs.NonSinglet(esf, nf, m2hq=m2hq)),
Expand All @@ -39,7 +39,7 @@ def generate(esf, nf):
# F3 is a non-singlet quantity and hence has neither gluon nor singlet-like contributions
if kind == "F3":
return ()
weights = nc_weights(esf.sf.coupling_constants, esf.Q2, kind, nf)
weights = nc_weights(esf.info.coupling_constants, esf.Q2, kind, nf)
gVV = kernels.Kernel(weights["gVV"], pcs.GluonVV(esf, nf, m2hq=m2hq))
gAA = kernels.Kernel(weights["gAA"], pcs.GluonAA(esf, nf, m2hq=m2hq))
sVV = kernels.Kernel(weights["sVV"], pcs.SingletVV(esf, nf, m2hq=m2hq))
Expand All @@ -63,14 +63,14 @@ def generate_missing(esf, nf):
elems : list(yadism.kernels.Kernel)
list of elements
"""
kind = esf.sf.obs_name.kind
kind = esf.info.obs_name.kind
pcs = import_pc_module(kind, esf.process)
ihq = nf + 1
m2hq = esf.sf.m2hq[ihq - 4]
m2hq = esf.info.m2hq[ihq - 4]
# in CC there are no missing diagrams known yet
if esf.process == "CC":
return ()
weights = light_nc_weights(esf.sf.coupling_constants, esf.Q2, kind, nf)
weights = light_nc_weights(esf.info.coupling_constants, esf.Q2, kind, nf)
return (kernels.Kernel(weights["ns"], pcs.NonSinglet(esf, nf, m2hq=m2hq)),)


Expand Down
14 changes: 7 additions & 7 deletions src/yadism/coefficient_functions/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def generate_single_flavor_light(esf, nf, ihq):
elems : list(yadism.kernels.Kernel)
list of elements
"""
kind = esf.sf.obs_name.kind
kind = esf.info.obs_name.kind
light_cfs = import_local(
kind, esf.process, ".".join(__name__.split(".")[:-1] + ["light", ""])
)
Expand All @@ -288,10 +288,10 @@ def generate_single_flavor_light(esf, nf, ihq):
s_partons = {}
if esf.process == "CC":
w_even = cc_weights_even(
esf.sf.coupling_constants, esf.Q2, kind, flavors[ihq - 1], nf
esf.info.coupling_constants, esf.Q2, kind, flavors[ihq - 1], nf
)
w_odd = cc_weights_odd(
esf.sf.coupling_constants, esf.Q2, kind, flavors[ihq - 1], nf
esf.info.coupling_constants, esf.Q2, kind, flavors[ihq - 1], nf
)
return (
Kernel(w_even["ns"], light_cfs.NonSingletEven(esf, nf)),
Expand All @@ -303,13 +303,13 @@ def generate_single_flavor_light(esf, nf, ihq):
Kernel(w_odd["ns"], light_cfs.NonSingletOdd(esf, nf)),
)
if kind != "F3":
w = esf.sf.coupling_constants.get_weight(
w = esf.info.coupling_constants.get_weight(
ihq, esf.Q2, "VV"
) + esf.sf.coupling_constants.get_weight(ihq, esf.Q2, "AA")
) + esf.info.coupling_constants.get_weight(ihq, esf.Q2, "AA")
else:
w = esf.sf.coupling_constants.get_weight(
w = esf.info.coupling_constants.get_weight(
ihq, esf.Q2, "VA"
) + esf.sf.coupling_constants.get_weight(ihq, esf.Q2, "AV")
) + esf.info.coupling_constants.get_weight(ihq, esf.Q2, "AV")

ns_partons[ihq] = w
ns_partons[-ihq] = w if kind != "F3" else -w
Expand Down
8 changes: 4 additions & 4 deletions src/yadism/coefficient_functions/light/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ def generate(esf, nf):
elems : list(yadism.kernels.Kernel)
list of elements
"""
kind = esf.sf.obs_name.kind
kind = esf.info.obs_name.kind
pcs = import_pc_module(kind, esf.process)
if esf.process == "CC":
weights_even = kernels.cc_weights_even(
esf.sf.coupling_constants, esf.Q2, kind, kernels.flavors[:nf], nf
esf.info.coupling_constants, esf.Q2, kind, kernels.flavors[:nf], nf
)
ns_even = kernels.Kernel(weights_even["ns"], pcs.NonSingletEven(esf, nf))
g = kernels.Kernel(weights_even["g"], pcs.Gluon(esf, nf))
s = kernels.Kernel(weights_even["s"], pcs.Singlet(esf, nf))
weights_odd = kernels.cc_weights_odd(
esf.sf.coupling_constants, esf.Q2, kind, kernels.flavors[:nf], nf
esf.info.coupling_constants, esf.Q2, kind, kernels.flavors[:nf], nf
)
ns_odd = kernels.Kernel(weights_odd["ns"], pcs.NonSingletOdd(esf, nf))
return (ns_even, g, s, ns_odd)
weights = nc_weights(esf.sf.coupling_constants, esf.Q2, kind, nf)
weights = nc_weights(esf.info.coupling_constants, esf.Q2, kind, nf)
ns = kernels.Kernel(weights["ns"], pcs.NonSinglet(esf, nf))
g = kernels.Kernel(weights["g"], pcs.Gluon(esf, nf))
s = kernels.Kernel(weights["s"], pcs.Singlet(esf, nf))
Expand Down
30 changes: 21 additions & 9 deletions src/yadism/esf/esf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,37 @@ class is used to perform the convolution with the basis functions (see
"""

def __init__(self, configs, kinematics: dict):
def __init__(self, kinematics: dict, obs_name, configs):
x = kinematics["x"]
if x > 1 or x <= 0:
raise ValueError("Kinematics 'x' must be in the range (0,1]")
if kinematics["Q2"] <= 0:
raise ValueError("Kinematics 'Q2' must be in the range (0,∞)")
# check domain
if x < min(configs.managers["interpolator"].xgrid_raw):
if x < min(configs.interpolator.xgrid_raw):
raise ValueError(f"x outside xgrid - cannot convolute starting from x={x}")

self.x = x
self.Q2 = kinematics["Q2"]
self.nf = None
self.process = configs.managers["coupling_constants"].obs_config["process"]
self.process = configs.coupling_constants.obs_config["process"]
self.res = ESFResult(self.x, self.Q2, None)
self._computed = False
# select available partonic coefficient functions
self.orders = list(filter(lambda e: e <= configs.theory["pto"], range(2 + 1)))
self.configs = configs
self.info = ESFInfo(obs_name, configs)

logger.debug("Init %s", self)

def __repr__(self):
return "%s_%s(x=%f,Q2=%f)" % (self.sf.obs_name, self.process, self.x, self.Q2)
return "%s_%s(x=%f,Q2=%f)" % (self.info.obs_name, self.process, self.x, self.Q2)

@property
def zeros(self):
return np.zeros(
(
len(br.flavor_basis_pids),
len(self.configs.managers["interpolator"].xgrid),
len(self.info.configs.interpolator.xgrid),
)
)

Expand All @@ -114,9 +114,9 @@ def compute_local(self):
cfc = cf.Combiner(self)
full_orders = [(o, 0, 0, 0) for o in self.orders]
# prepare scale variations
sv_manager = self.configs.managers["sv_manager"]
sv_manager = self.info.configs.managers["sv_manager"]
if sv_manager is not None:
full_orders = sv.build_orders(self.configs.theory["pto"])
full_orders = sv.build_orders(self.info.configs.theory["pto"])
# init orders with 0
for o in full_orders:
self.res.orders[o] = [self.zeros, self.zeros]
Expand All @@ -136,7 +136,7 @@ def compute_local(self):
# compute convolution point
convolution_point = cfe.coeff.convolution_point()
val, err = conv.convolute_vector(
rsl, self.configs.managers["interpolator"], convolution_point
rsl, self.info.configs.managers["interpolator"], convolution_point
)
# add the factor x from the LHS
val, err = convolution_point * val, convolution_point * err
Expand Down Expand Up @@ -184,3 +184,15 @@ def get_result(self):
self.compute_local()

return copy.deepcopy(self.res)


class ESFInfo:
def __init__(self, obs_name, configs):
self.obs_name = obs_name
self.configs = configs

def __getattribute__(self, name):
if name in ["obs_name", "configs"]:
return super().__getattribute__(name)

return self.configs.__getattribute__(name)
Loading

0 comments on commit 07a32df

Please sign in to comment.