Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polarised proton fits #1979

Merged
merged 97 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
3eedbb7
start porting changes required for polarised fits
Radonirinaunimi Mar 4, 2024
3008640
undo accidental changes in modules
Radonirinaunimi Mar 4, 2024
8bb220a
undo further changes
Radonirinaunimi Mar 4, 2024
358bac6
fix computation of unpol bound and positivity operations
Radonirinaunimi Mar 5, 2024
83d06a0
add template runcard for polarised fits
Radonirinaunimi Mar 5, 2024
b8ccf4f
update template card
Radonirinaunimi Mar 5, 2024
84c6ace
made some fixes (related to multi-replicas) from CR
Radonirinaunimi Mar 6, 2024
71da9af
adopt new way of doing convolutions
Radonirinaunimi Mar 6, 2024
90e6638
make new convolution work
Radonirinaunimi Mar 6, 2024
d32ec09
revert back positional argument for the time being
Radonirinaunimi Mar 6, 2024
615fc2e
add polarized comparefits report
Radonirinaunimi Mar 6, 2024
67f5aae
clean up a bit POS convolution
Radonirinaunimi Mar 6, 2024
eaff52a
simplify sum rules in polarized reports
Radonirinaunimi Mar 6, 2024
de87db8
remove unrelated changes to POS metadata
Radonirinaunimi Mar 7, 2024
d5b337b
change default ranges in PDF plots of reports
Radonirinaunimi Mar 7, 2024
2abd122
add option to plot correlated uncertainties of partial integrated distr.
Radonirinaunimi Mar 7, 2024
18dcdad
add correlated spin moment plots to report
Radonirinaunimi Mar 7, 2024
1b6beb3
update the way in which unpol bound is parsed
Radonirinaunimi Mar 7, 2024
dd5cd53
update the runcard accordingly
Radonirinaunimi Mar 7, 2024
16c8041
deprecate old evolven3fit with new one
Radonirinaunimi Mar 7, 2024
a9981ac
revert the default behavior of pol.md
Radonirinaunimi Mar 7, 2024
9b5e312
remove deprecated checks
Radonirinaunimi Mar 7, 2024
518ff5e
start adding the regression test
Radonirinaunimi Mar 7, 2024
2e4da99
add documentation for running polarized fits
Radonirinaunimi Mar 8, 2024
97f1742
reflect changes from hyperopt parallel
Radonirinaunimi Mar 8, 2024
35e4c91
propagate is_polarized attr from pineparser
Radonirinaunimi Mar 8, 2024
4f57d19
deactivate regression for the time being
Radonirinaunimi Mar 8, 2024
71ff771
fix issues when checking polarised key from FKs
Radonirinaunimi Mar 8, 2024
938ebac
fix tests by extending _fake_FKTableData
Radonirinaunimi Mar 8, 2024
c26e112
Merge branch 'master' into nnpdfpol
Radonirinaunimi Mar 9, 2024
c286bf0
improve plotting of partial correlated moments
Radonirinaunimi Mar 9, 2024
3ac781a
change paradigm in enforcing polarised positivity boundary conditions
Radonirinaunimi Mar 9, 2024
87eaa6d
update runcard accordingly
Radonirinaunimi Mar 9, 2024
db80734
remove previous occurences of pos_bound
Radonirinaunimi Mar 9, 2024
76440c4
fixed tiny typos
Radonirinaunimi Mar 10, 2024
00346a4
fix parameters in test_layers
Radonirinaunimi Mar 10, 2024
d57c56c
fixed report when including positivity boundary plots
Radonirinaunimi Mar 11, 2024
c41c956
fixed scale when plotting Positivity Boundary conditions
Radonirinaunimi Mar 11, 2024
c0125ed
add check to unpolarized BC at vp-setupfit level
Radonirinaunimi Mar 11, 2024
1b660a8
fix tiny typo in the documentation
Radonirinaunimi Mar 11, 2024
13f6aa4
re-activate polarized regression test
Radonirinaunimi Mar 11, 2024
1eb11df
Apply suggestions from code review
Radonirinaunimi Mar 13, 2024
db17740
offload computations of POS BC to vp.convolution
Radonirinaunimi Mar 13, 2024
b575ea1
add tests for operations
Radonirinaunimi Mar 13, 2024
043e974
rename and completely order operations
Radonirinaunimi Mar 13, 2024
636ae79
fixed test_backend accordingly
Radonirinaunimi Mar 13, 2024
0955010
pass only one list into the observable computation
Radonirinaunimi Mar 13, 2024
10466fa
quite some refactors
Radonirinaunimi Mar 13, 2024
173c3ec
remove fitbasis from test
Radonirinaunimi Mar 13, 2024
9030a38
fixes some namings here and there
Radonirinaunimi Mar 14, 2024
82cefa3
simplifies further checks for BC computations
Radonirinaunimi Mar 14, 2024
1de5a3c
fixes again test due to renaming
Radonirinaunimi Mar 14, 2024
a28b133
minor corrections in the docstrings
Radonirinaunimi Mar 14, 2024
0c00cb0
significantly improve the polarized plottings
Radonirinaunimi Mar 14, 2024
0c15938
fixes paging in report
Radonirinaunimi Mar 14, 2024
50800f3
Merge branch 'master' into nnpdfpol
Radonirinaunimi Mar 15, 2024
e6fbdbb
further modifications to plotting
Radonirinaunimi Mar 17, 2024
90404fe
fixed major bug in POS Boundary Condition
Radonirinaunimi Mar 19, 2024
6ee6e1b
fixed issues that also affects the unpolarized POS
Radonirinaunimi Mar 24, 2024
2e744aa
rename function to be more generic
Radonirinaunimi Mar 26, 2024
fa96f1d
fix conflicts in operations
Radonirinaunimi Mar 27, 2024
0b083dc
Merge branch 'master' into nnpdfpol
Radonirinaunimi Mar 28, 2024
405e965
Merge branch 'master' into nnpdfpol
Radonirinaunimi Mar 28, 2024
4fddd50
fix example runcard to use updated names
Radonirinaunimi Mar 28, 2024
c3c97ed
remove completely pseudodata POS trials for polarized data
Radonirinaunimi Mar 29, 2024
3d20c17
remove the strict need for RELU in LM
Radonirinaunimi Apr 1, 2024
3392c4c
various tiny fixes on documentations
Radonirinaunimi Apr 1, 2024
8d1455d
fix dataset namings in regression
Radonirinaunimi Apr 2, 2024
f6b106c
Merge branch 'master' into nnpdfpol
Radonirinaunimi Apr 2, 2024
84a8ed0
final minor fixes in plottings
Radonirinaunimi Apr 2, 2024
2b0d8ca
Automatically regenerated regressions from PR 1979, branch nnpdfpol.
Apr 2, 2024
66ce7d8
add tests to test_fit
Radonirinaunimi Apr 2, 2024
82743d8
Fix regression fit test for polarized
Radonirinaunimi Apr 3, 2024
6321f08
Merge branch 'master' into nnpdfpol
Radonirinaunimi Apr 4, 2024
0e9c39f
go through the documentation one last time
Radonirinaunimi Apr 4, 2024
2f51e40
fix rng seed for TSR sum rules
Radonirinaunimi Apr 4, 2024
6bd4088
fix weights names in regression tests
Radonirinaunimi Apr 15, 2024
9ef946d
remove unwanted folder
Radonirinaunimi Apr 15, 2024
77b6f25
regenerate files from virtual machine
Radonirinaunimi Apr 15, 2024
8966b14
push forgotten commit
Radonirinaunimi Apr 15, 2024
412f8f8
various adjustments
Radonirinaunimi Apr 15, 2024
b29956f
use nnseed as the sr seed for TSR ; update weights, use double-preci…
scarlehoff Apr 16, 2024
47a077f
add test for sum_rules=TSR
scarlehoff Apr 16, 2024
f064628
Automatically regenerated regressions from PR 2053, branch regenerate…
Apr 16, 2024
992784b
Merge pull request #2053 from NNPDF/regenerate_test_pol
Radonirinaunimi Apr 16, 2024
aeb2a96
Merge branch 'master' into nnpdfpol
Radonirinaunimi Apr 16, 2024
29dd4fc
Apply suggestions from code review
Radonirinaunimi Apr 17, 2024
88a7b25
fix plotting of boundary conditions
Radonirinaunimi Apr 17, 2024
53fa696
address most/all of the review comments
Radonirinaunimi Apr 17, 2024
6edffdb
this does seem to do the joob
Radonirinaunimi Apr 17, 2024
9a8a9dd
Merge branch 'master' into nnpdfpol
Radonirinaunimi Apr 18, 2024
817f63a
update reference for fitbot
scarlehoff Apr 18, 2024
50ecdf4
improve sum rule module
Radonirinaunimi Apr 18, 2024
6fc3388
fix central sum rules
Radonirinaunimi Apr 18, 2024
f06b519
combine limits at more lower levels
Radonirinaunimi Apr 18, 2024
c5f1e30
Merge pull request #2057 from NNPDF/improve-sumrules
Radonirinaunimi Apr 18, 2024
abe5d46
merged changes from master
Radonirinaunimi Apr 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions n3fit/runcards/examples/nnpdfpol20_dis_nnlo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
############################################################
# Configuration file for N3FIT
############################################################
description: NNPDFpol2.0 NNLO DIS fit with ID822 (W2min=4)

############################################################
dataset_inputs:
# -------------- Superseeded by COMPASS15 ---------------------
# - {dataset: COMPASS_NC_17GEV_MUP_G1, frac: 0.60, cfac: [NRM]}
# - {dataset: COMPASS_NC_25GEV_MUD_G1, frac: 0.60, cfac: [NRM]}
# -------------------------------------------------------------
- {dataset: COMPASS15_NC_17GEV_MUP_G1, frac: 0.60, cfac: [NRM]}
- {dataset: COMPASS15_NC_25GEV_MUD_G1, frac: 0.60, cfac: [NRM]}
- {dataset: E142_NC_58GEV_EN_G1, frac: 0.60, cfac: [NRM]}
- {dataset: E143_NC_4GEV_EP_G1, frac: 0.60, cfac: [NRM]}
- {dataset: E143_NC_8GEV_ED_G1, frac: 0.60, cfac: [NRM]}
- {dataset: E154_NC_9GEV_EN_G1, frac: 0.60, cfac: [NRM]}
- {dataset: E155_NC_9GEV_EN_G1F1RATIO, frac: 0.60}
- {dataset: E155_NC_9GEV_EP_G1F1RATIO, frac: 0.60}
- {dataset: EMC_NC_16GEV_MUP_G1, frac: 0.60, cfac: [NRM]}
- {dataset: HERMES_NC_7GEV_ED_G1, frac: 0.60, cfac: [NRM]}
- {dataset: HERMES_NC_7GEV_EP_G1, frac: 0.60, cfac: [NRM]}
# ------------- Same as P+N due to Isospin --------------------
# - {dataset: HERMES_NC_7GEV_EN_G1, frac: 0.60, cfac: [NRM]}
# -------------------------------------------------------------
- {dataset: HERMES97_NC_7GEV_EN_G1, frac: 0.60, cfac: [NRM]}
- {dataset: JLABE06_NC_3GEV_EN_G1F1RATIO, frac: 0.60}
- {dataset: JLABEG1B_NC_3GEV_EP_G1F1RATIO, frac: 0.60}
- {dataset: JLABEG1B_NC_4GEV_ED_G1F1RATIO, frac: 0.60}
- {dataset: JLABE97_NC_3GEV_EN_G1, frac: 0.60, cfac: [NRM]}
- {dataset: JLABE99_NC_3GEV_EN_G1F1RATIO, frac: 0.60}
- {dataset: JLABEG1DVCS_NC_5GEV_ED_G1F1RATIO, frac: 0.60}
- {dataset: JLABEG1DVCS_NC_3GEV_EP_G1F1RATIO, frac: 0.60}
- {dataset: SMC_NC_24GEV_MUD_G1, frac: 0.60, cfac: [NRM]}
- {dataset: SMC_NC_17GEV_MUP_G1, frac: 0.60, cfac: [NRM]}
- {dataset: SMCSX_NC_24GEV_MUD_G1F1RATIO, frac: 0.60}
- {dataset: SMCSX_NC_17GEV_MUP_G1F1RATIO, frac: 0.60}

############################################################
datacuts:
t0pdfset: NNPDFpol10_100 # PDF set to generate t0 covmat
q2min: 1.00 # Q2 minimum
w2min: 4.00 # W2 minimum

unpolpdf: NNPDF40_nnlo_pch_as_01180

############################################################
theory:
theoryid: 822

############################################################
trvlseed: 14613416
nnseed: 1865683875
mcseed: 746898422
save: false
genrep: true

parameters:
nodes_per_layer: [25, 20, 4]
activation_per_layer: [tanh, tanh, linear]
initializer: glorot_normal
optimizer:
clipnorm: 6.073e-6
learning_rate: 2.621e-3
optimizer_name: Nadam
epochs: 20000
positivity:
initial: 1
multiplier:
threshold: 1e-7
integrability:
initial: 1
multiplier:
threshold: 1e-2
stopping_patience: 0.1
layer_type: dense
dropout: 0.0
threshold_chi2: 3.5

fitting:
fitbasis: EVOL_POL
sum_rules: TSR
basis:
- {fl: sng, trainable: false, smallx: [1.094, 1.118], largex: [1.46, 3.003]}
- {fl: g, trainable: false, smallx: [0.8189, 1.844], largex: [2.591, 5.697]}
- {fl: t3, trainable: false, smallx: [-0.4401, 0.9163], largex: [1.773, 3.333]}
- {fl: t8, trainable: false, smallx: [0.5852, 0.8537], largex: [1.533, 3.436]}

###########################################################
positivity:
posdatasets:
- {dataset: NNPDF_POS_5GEV_XDELTAG, maxlambda: 1e8}
- {dataset: NNPDF_POS_5GEV_XDELTADQ, maxlambda: 1e8}
- {dataset: NNPDF_POS_5GEV_XDELTASQ, maxlambda: 1e8}
- {dataset: NNPDF_POS_5GEV_XDELTAUQ, maxlambda: 1e8}

############################################################
integrability:
integdatasets:
- {dataset: NNPDF_INTEG_1GEV_XDELTAG, maxlambda: 1e2}
- {dataset: NNPDF_INTEG_1GEV_XDELTASIGMA, maxlambda: 1e2}

############################################################
debug: false
maxcores: 4
15 changes: 15 additions & 0 deletions n3fit/src/n3fit/backends/keras_backend/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,21 @@ def pow(tensor, power):
return tf.pow(tensor, power)


@tf.function
def absolute(tensor):
"""
Compute the absolute value of a tensor
"""
return K.abs(tensor)


def multiply_minusone(tensor):
Radonirinaunimi marked this conversation as resolved.
Show resolved Hide resolved
"""
Multiply the elements of a given tensor by (-1)
"""
return keras_Lambda(lambda x: -1 * x)(tensor)


@tf.function(reduce_retracing=True)
def op_log(o_tensor, **kwargs):
"""
Expand Down
14 changes: 10 additions & 4 deletions n3fit/src/n3fit/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import numbers
import os

import numpy as np

from n3fit.hyper_optimization import penalties as penalties_module
from n3fit.hyper_optimization import rewards as rewards_module
from reportengine.checks import CheckError, make_argcheck
from validphys.core import PDF
from validphys.pdfbases import check_basis

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -71,6 +68,15 @@ def check_stopping(parameters):
raise CheckError(f"Needs to run at least 1 epoch, got: {epochs}")


@make_argcheck
def check_polarised(fitbasis, fitting):
"""Checks that if the polarised basis is used, then the necessary entries
are specified correctly.
"""
if "POL" in fitbasis and fitting.get("sum_rules") != "TSR":
raise CheckError("'sum_rules' needs to be 'TSR' for polarised fits.")


def check_basis_with_layers(basis, parameters):
"""Check that the last layer matches the number of flavours defined in the runcard"""
number_of_flavours = len(basis)
Expand Down Expand Up @@ -334,7 +340,7 @@ def check_sumrules(sum_rules):
"""Checks that the chosen option for the sum rules are sensible"""
if isinstance(sum_rules, bool):
return
accepted_options = ["ALL", "MSR", "VSR", "ALLBUTCSR"]
accepted_options = ["ALL", "MSR", "VSR", "TSR", "ALLBUTCSR"]
if sum_rules.upper() in accepted_options:
return
raise CheckError(f"The only accepted options for the sum rules are: {accepted_options}")
Expand Down
24 changes: 16 additions & 8 deletions n3fit/src/n3fit/layers/DIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

from .observable import Observable

POS_POLSD_IDEX = [0, 2] # Polarised POS Datasets
POS_UNPOL_IDEX = [1, 3] # Unpolarised POS Datasets


class DIS(Observable):
"""
Expand Down Expand Up @@ -64,16 +67,21 @@ def call(self, pdf):
raise ValueError("DIS layer call with a dataset that needs more than one xgrid?")

results = []
# Separate the two possible paths this layer can take
if self.many_masks:
for mask, fktable in zip(self.all_masks, self.fktables):
for idx, fktable in enumerate(self.fktables):
mask = self.all_masks[idx] if self.many_masks else self.all_masks[0]
if self.is_polarised_pos() and idx in POS_UNPOL_IDEX:
# Convolute the FK tables with the pre-computed Unpolarised PDFs
pdf_masked = op.boolean_mask(self.computed_pdfs[idx], mask, axis=3)
else:
pdf_masked = op.boolean_mask(pdf, mask, axis=3)

if self.is_polarised_pos() and idx in POS_POLSD_IDEX:
# Compute the absolute value of `x \Delta f(x)` and multiply with (-1)
res = op.tensor_product(pdf_masked, fktable, axes=[(2, 3), (2, 1)])
results.append(res)
else:
pdf_masked = op.boolean_mask(pdf, self.all_masks[0], axis=3)
for fktable in self.fktables:
res = op.multiply_minusone(op.absolute(res))
else:
res = op.tensor_product(pdf_masked, fktable, axes=[(2, 3), (2, 1)])
results.append(res)

results.append(res)

return self.operation(results)
2 changes: 1 addition & 1 deletion n3fit/src/n3fit/layers/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class LossPositivity(LossLagrange):
True
"""

def __init__(self, alpha=1e-7, **kwargs):
def __init__(self, alpha=0.0, **kwargs):
self.alpha = alpha
super().__init__(**kwargs)

Expand Down
70 changes: 63 additions & 7 deletions n3fit/src/n3fit/layers/msr_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@
from n3fit.backends import MetaLayer
from n3fit.backends import operations as op

IDX = {'photon': 0, 'sigma': 1, 'g': 2, 'v': 3, 'v3': 4, 'v8': 5, 'v15': 6, 'v24': 7, 'v35': 8}
IDX = {
'photon': 0,
'sigma': 1,
'g': 2,
'v': 3,
'v3': 4,
'v8': 5,
'v15': 6,
'v24': 7,
'v35': 8,
't3': 9,
't8': 10,
't15': 11,
't24': 12,
't35': 13,
}
MSR_COMPONENTS = ['g']
MSR_DENOMINATORS = {'g': 'g'}
# The VSR normalization factor of component f is given by
Expand All @@ -20,12 +35,42 @@
VSR_CONSTANTS = {'v': 3.0, 'v35': 3.0, 'v24': 3.0, 'v3': 1.0, 'v8': 3.0, 'v15': 3.0}
VSR_DENOMINATORS = {'v': 'v', 'v35': 'v', 'v24': 'v', 'v3': 'v3', 'v8': 'v8', 'v15': 'v15'}

CSR_COMPONENTS = ['v','v35','v24']
CSR_COMPONENTS = ['v', 'v35', 'v24']
CSR_DENOMINATORS = {'v': 'v', 'v35': 'v', 'v24': 'v'}
NOV15_COMPONENTS = ['v3', 'v8']
NOV15_CONSTANTS = {'v3': 1.0, 'v8': 3.0}
NOV15_DENOMINATORS = {'v3': 'v3', 'v8': 'v8'}

# The following lays out the SR for Polarised PDFs
TSR_COMPONENTS = ['t3', 't8']
TSR_DENOMINATORS = {'t3': 't3', 't8': 't8'}
# Sum Rules defined as in PDG 2023
TSR_CONSTANTS = {'t3': 1.2756, 't8': 0.5850}
TSR_CONSTANTS_UNC = {'t3': 0.0013, 't8': 0.025}


def sample_tsr(v: dict, e: dict, t: list, nr: int) -> list:
"""
Sample the Triplets sum rules according to the PDG uncertainties.

Parameters
----------
v: dict
dictionary that maps the triplet component to its PDG value
e: dict
dictionary that maps the triplet component to its denominator
t: list
list of triplet component for which SR should be applied
nr: int
number of replicas that are fitter simultaneously

Returns
-------
list:
list of sum rule values sampled according to a normal distribution
"""
return [[np.random.normal(v[c], e[c]) for _ in range(nr)] for c in t]


class MSR_Normalization(MetaLayer):
"""
Expand All @@ -34,7 +79,8 @@ class MSR_Normalization(MetaLayer):

_msr_enabled = False
_vsr_enabled = False
_csr_enabled = False
_tsr_enabled = False
_csr_enabled = False

def __init__(self, mode: str = "ALL", replicas: int = 1, **kwargs):
if mode == True or mode.upper() == "ALL":
Expand All @@ -44,7 +90,8 @@ def __init__(self, mode: str = "ALL", replicas: int = 1, **kwargs):
self._msr_enabled = True
elif mode.upper() == "VSR":
self._vsr_enabled = True

elif mode.upper() == "TSR":
self._tsr_enabled = True
elif mode.upper() == "ALLBUTCSR":
self._msr_enabled = True
self._csr_enabled = True
Expand All @@ -63,6 +110,13 @@ def __init__(self, mode: str = "ALL", replicas: int = 1, **kwargs):
self.vsr_factors = op.numpy_to_tensor(
[np.repeat(VSR_CONSTANTS[c], replicas) for c in VSR_COMPONENTS]
)
if self._tsr_enabled:
self.divisor_indices += [IDX[TSR_DENOMINATORS[c]] for c in TSR_COMPONENTS]
indices += [IDX[c] for c in TSR_COMPONENTS]
self.tsr_factors = op.numpy_to_tensor(
sample_tsr(TSR_CONSTANTS, TSR_CONSTANTS_UNC, TSR_COMPONENTS, replicas)
)

if self._csr_enabled:
# modified vsr for V, V24, V35
indices += [IDX[c] for c in CSR_COMPONENTS]
Expand Down Expand Up @@ -114,11 +168,13 @@ def call(self, pdf_integrated, photon_integral):
]
if self._vsr_enabled:
numerators += [self.vsr_factors]
if self._tsr_enabled:
numerators += [self.tsr_factors]
if self._csr_enabled:
numerators += len(CSR_COMPONENTS)*[op.batchit(4.0 - 1./3. * y[IDX['v15']], batch_dimension=0)]
numerators += len(CSR_COMPONENTS) * [
op.batchit(4.0 - 1.0 / 3.0 * y[IDX['v15']], batch_dimension=0)
]
numerators += [self.vsr_factors]



numerators = op.concatenate(numerators, axis=0)
divisors = op.gather(y, self.divisor_indices, axis=0)
Expand Down
30 changes: 29 additions & 1 deletion n3fit/src/n3fit/layers/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,27 @@ class Observable(MetaLayer, ABC):
number of flavours in the pdf (default:14)
"""

def __init__(self, fktable_data, fktable_arr, operation_name, nfl=14, **kwargs):
def __init__(
self,
fktable_data,
fktable_arr,
dataset_name,
fitbasis,
extern_lhapdf,
operation_name,
n_replicas=1,
nfl=14,
**kwargs
):
super(MetaLayer, self).__init__(**kwargs)

self.dataset_name = dataset_name
self.nfl = nfl
self.fitbasis = fitbasis
self.fktable_data = fktable_data
self.nfks = len(fktable_data)

self.computed_pdfs = []
basis = []
xgrids = []
self.fktables = []
Expand All @@ -51,6 +67,12 @@ def __init__(self, fktable_data, fktable_arr, operation_name, nfl=14, **kwargs):
basis.append(fkdata.luminosity_mapping)
self.fktables.append(op.numpy_to_tensor(fk))

if self.is_polarised_pos():
resx = extern_lhapdf(fkdata.xgrid.tolist())
mult_resx = np.repeat([resx], n_replicas, axis=0)
resx = np.expand_dims(mult_resx, axis=0)
self.computed_pdfs.append(op.numpy_to_tensor(resx))

# check how many xgrids this dataset needs
if is_unique(xgrids):
self.splitting = None
Expand All @@ -71,6 +93,12 @@ def __init__(self, fktable_data, fktable_arr, operation_name, nfl=14, **kwargs):
def compute_output_shape(self, input_shape):
return (self.output_dim, None)

def is_polarised_pos(self):
if "POL" in self.fitbasis and "_POS_" in self.dataset_name:
Radonirinaunimi marked this conversation as resolved.
Show resolved Hide resolved
# Polarised POS contains at least 2 FK tables
return self.nfks >= 2
Radonirinaunimi marked this conversation as resolved.
Show resolved Hide resolved
return False

# Overridables
@abstractmethod
def gen_mask(self, basis):
Expand Down
Loading