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

Polarized proton-PDF fits #1893

Closed
wants to merge 232 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
49884c1
new commondata reader
scarlehoff Feb 23, 2023
d9caf5e
improve the notebook
scarlehoff Feb 23, 2023
9742b56
remove duplicated functions
scarlehoff Feb 23, 2023
b4ca338
make theory optional
scarlehoff Feb 23, 2023
63fd7c2
remove old style data that was included with this pr
scarlehoff Mar 29, 2023
713d55e
updated reader to the new (new) format
scarlehoff Mar 29, 2023
a7d4350
some parser updates
scarlehoff Mar 30, 2023
965ec3f
update the reader: definition->definitions, add a columns of 0s when …
scarlehoff Mar 31, 2023
d59c36f
reorder in the parser
scarlehoff Mar 31, 2023
dcac7cc
handle nonstr
scarlehoff Mar 31, 2023
a29c059
applied suggestion for ValidOperation
scarlehoff Mar 31, 2023
e97c892
add check for -1 factors when they are just eigenvectors
scarlehoff Apr 3, 2023
611e6f8
fill the mid kinematic value with the average of min and max
scarlehoff Apr 28, 2023
4fe61d3
update notebook ; allow for hepdata version to be None
scarlehoff Apr 28, 2023
db49073
update notebook
scarlehoff May 2, 2023
397d341
ignore kinematic variables beyond the 3rd one
scarlehoff May 3, 2023
b3d0ea0
fix tests
scarlehoff May 3, 2023
f75fb66
minimal set of modifications so that one can actually use the new cd …
scarlehoff Sep 23, 2023
261df04
first movements towards the deprecation of the yaml database; take th…
scarlehoff Sep 23, 2023
688a49b
add a specific error for datasets without TheoryMetaData
scarlehoff Sep 25, 2023
8f934dc
update commondataparser to "fake" PlotOptions
scarlehoff Sep 28, 2023
76b4eb3
separate plotting options so that they are compatible with the old-co…
scarlehoff Oct 10, 2023
a4d8fc5
import plotoptions
scarlehoff Oct 10, 2023
adf5976
use kinematic coverage to select the kinematics
scarlehoff Oct 10, 2023
07807d4
document a bit better each class inside the parser
scarlehoff Oct 11, 2023
6b64aed
read kinematic_coverage as a list ; add a few checks
scarlehoff Oct 11, 2023
03423a8
add the transitional identity tranformation
scarlehoff Oct 20, 2023
1b6bcec
remove todo and add extra info about the self.legacy
scarlehoff Oct 20, 2023
1d05c99
use the kinematic coverage variables for the filter
scarlehoff Oct 24, 2023
786a8ad
Update validphys2/src/validphys/core.py
scarlehoff Oct 27, 2023
1ed9cef
promote the shifts flag to a first class theory flag
scarlehoff Oct 31, 2023
ef82c7c
tell the user why a given dataset could not load when the theory is m…
scarlehoff Oct 31, 2023
bb88213
beautify a bit the grouping labels
scarlehoff Oct 31, 2023
ec9f9c9
show a verbose error when not finding pineappl fktables
scarlehoff Nov 12, 2023
2361ef8
add the option for extra_labels
scarlehoff Nov 13, 2023
1b105ef
fallback until we have some more datasets merged
scarlehoff Nov 13, 2023
afc5262
swap old and new in the mapping old:new
scarlehoff Nov 14, 2023
1a16244
allow for a normalize dictionary
scarlehoff Dec 4, 2023
c0f9c35
update reader for cd with less than 3 variables
scarlehoff Dec 7, 2023
5e5e7a7
allow saving the whole kin
scarlehoff Dec 8, 2023
df27ed7
try to autoguess the total-cross section case
scarlehoff Dec 8, 2023
bbd02df
change the order of the checks
scarlehoff Dec 8, 2023
0aba3aa
start modifications for polarised PDF fits
Radonirinaunimi Dec 10, 2023
d3d7e6e
account for the uncertainties in computing TSR
Radonirinaunimi Dec 11, 2023
17df7b5
Start modifications for positivity
Radonirinaunimi Dec 11, 2023
dd7cda2
start implemeting positivity constraints
Radonirinaunimi Dec 11, 2023
ef054d3
fix wrong shape of extern_lhapdf
Radonirinaunimi Dec 11, 2023
50c18dd
simplify branchings when computing DIS obs
Radonirinaunimi Dec 11, 2023
f955f5b
make pol POS naming more restrictive
Radonirinaunimi Dec 12, 2023
780e684
fix ordering of abs and minusone
Radonirinaunimi Dec 12, 2023
da20d9c
Add more constraints
Radonirinaunimi Dec 12, 2023
6fcf395
make tests working
Radonirinaunimi Dec 12, 2023
115bd05
start making cosmetic improvements
Radonirinaunimi Dec 12, 2023
8d5bbcb
trick tests to avoid defining namespace
Radonirinaunimi Dec 12, 2023
5371188
add runcard checks for polarised fits
Radonirinaunimi Dec 13, 2023
96647ad
add use of polarised evolution in evolven3fit_new
Radonirinaunimi Dec 16, 2023
a8a4176
add option to not include positivity in comparefit-report
Radonirinaunimi Dec 17, 2023
3ba8500
replace npos comparefits to use_pol instead
Radonirinaunimi Dec 18, 2023
dfa0687
new commondata reader
scarlehoff Feb 23, 2023
be8f2c3
improve the notebook
scarlehoff Feb 23, 2023
fca2e53
remove duplicated functions
scarlehoff Feb 23, 2023
1ed85dc
make theory optional
scarlehoff Feb 23, 2023
75f4601
remove old style data that was included with this pr
scarlehoff Mar 29, 2023
79237af
updated reader to the new (new) format
scarlehoff Mar 29, 2023
28b7760
some parser updates
scarlehoff Mar 30, 2023
2b2f999
update the reader: definition->definitions, add a columns of 0s when …
scarlehoff Mar 31, 2023
0967a91
reorder in the parser
scarlehoff Mar 31, 2023
7b6a81a
handle nonstr
scarlehoff Mar 31, 2023
b2d69e9
applied suggestion for ValidOperation
scarlehoff Mar 31, 2023
28638af
add check for -1 factors when they are just eigenvectors
scarlehoff Apr 3, 2023
4b9b88e
fill the mid kinematic value with the average of min and max
scarlehoff Apr 28, 2023
da8e553
update notebook ; allow for hepdata version to be None
scarlehoff Apr 28, 2023
a77a1fa
update notebook
scarlehoff May 2, 2023
f5b60e2
ignore kinematic variables beyond the 3rd one
scarlehoff May 3, 2023
ce22fab
fix tests
scarlehoff May 3, 2023
c686af0
minimal set of modifications so that one can actually use the new cd …
scarlehoff Sep 23, 2023
efbc4da
first movements towards the deprecation of the yaml database; take th…
scarlehoff Sep 23, 2023
c11f06f
add a specific error for datasets without TheoryMetaData
scarlehoff Sep 25, 2023
9333683
update commondataparser to "fake" PlotOptions
scarlehoff Sep 28, 2023
b40ed8f
separate plotting options so that they are compatible with the old-co…
scarlehoff Oct 10, 2023
077c461
import plotoptions
scarlehoff Oct 10, 2023
ff9b40a
use kinematic coverage to select the kinematics
scarlehoff Oct 10, 2023
71d98db
document a bit better each class inside the parser
scarlehoff Oct 11, 2023
5687643
read kinematic_coverage as a list ; add a few checks
scarlehoff Oct 11, 2023
9303395
add the transitional identity tranformation
scarlehoff Oct 20, 2023
c223905
remove todo and add extra info about the self.legacy
scarlehoff Oct 20, 2023
268d8bc
use the kinematic coverage variables for the filter
scarlehoff Oct 24, 2023
23bb9ee
Update validphys2/src/validphys/core.py
scarlehoff Oct 27, 2023
49f7111
promote the shifts flag to a first class theory flag
scarlehoff Oct 31, 2023
cb62ad4
tell the user why a given dataset could not load when the theory is m…
scarlehoff Oct 31, 2023
490ffc2
beautify a bit the grouping labels
scarlehoff Oct 31, 2023
0f085a0
show a verbose error when not finding pineappl fktables
scarlehoff Nov 12, 2023
68059e7
add the option for extra_labels
scarlehoff Nov 13, 2023
99ec68e
fallback until we have some more datasets merged
scarlehoff Nov 13, 2023
e89b4ed
swap old and new in the mapping old:new
scarlehoff Nov 14, 2023
d25541c
allow for a normalize dictionary
scarlehoff Dec 4, 2023
e962537
update reader for cd with less than 3 variables
scarlehoff Dec 7, 2023
814d2c8
allow saving the whole kin
scarlehoff Dec 8, 2023
42601f2
try to autoguess the total-cross section case
scarlehoff Dec 8, 2023
5439c27
change the order of the checks
scarlehoff Dec 8, 2023
7ee6897
improve a bit report by removing unneeded details
Radonirinaunimi Dec 18, 2023
69dbbb4
fix minor details from CR
Radonirinaunimi Dec 19, 2023
196fa88
fix 1/x for polarised TSR
Radonirinaunimi Dec 20, 2023
7f184b8
merge changes from newcd reader
Radonirinaunimi Dec 21, 2023
f120388
sample TSR according to a normal distribution
Radonirinaunimi Dec 21, 2023
94be8aa
remove deprecated commits
Radonirinaunimi Dec 21, 2023
23eb61e
fix various issues when merging
Radonirinaunimi Dec 21, 2023
db89376
fall ELU back to RELU in polarised fits
Radonirinaunimi Dec 26, 2023
9abfc6b
include one-sigma in computation of unpol bounds
Radonirinaunimi Dec 27, 2023
05714e5
read Q0 value from the theory description for unpol bound
Radonirinaunimi Dec 28, 2023
0a78fa1
Impose Positivity on pairs of flavours
Radonirinaunimi Dec 29, 2023
97301f5
Move computation of unpolpdf to vp
Radonirinaunimi Jan 3, 2024
0033ed9
modify sligthly checks
Radonirinaunimi Jan 3, 2024
714be4f
make some cleaning and fix multireplicas
Radonirinaunimi Jan 4, 2024
9aeea89
apply black
Radonirinaunimi Jan 4, 2024
06a43c2
move wrap_lhapdf further to pdfbases
Radonirinaunimi Jan 8, 2024
4396527
change order of convolution to account for DGluon POS
Radonirinaunimi Jan 11, 2024
6e071ec
add template polarised run card
Radonirinaunimi Jan 19, 2024
795a5ba
new commondata reader
scarlehoff Feb 23, 2023
c70d1ef
improve the notebook
scarlehoff Feb 23, 2023
cab8b59
remove duplicated functions
scarlehoff Feb 23, 2023
0b46788
make theory optional
scarlehoff Feb 23, 2023
2a370c9
remove old style data that was included with this pr
scarlehoff Mar 29, 2023
ff0405d
updated reader to the new (new) format
scarlehoff Mar 29, 2023
b8955d1
some parser updates
scarlehoff Mar 30, 2023
09b681b
update the reader: definition->definitions, add a columns of 0s when …
scarlehoff Mar 31, 2023
903f7a0
reorder in the parser
scarlehoff Mar 31, 2023
f2c251a
handle nonstr
scarlehoff Mar 31, 2023
72490ba
applied suggestion for ValidOperation
scarlehoff Mar 31, 2023
6f7aa81
add check for -1 factors when they are just eigenvectors
scarlehoff Apr 3, 2023
19932ef
fill the mid kinematic value with the average of min and max
scarlehoff Apr 28, 2023
df06395
update notebook ; allow for hepdata version to be None
scarlehoff Apr 28, 2023
09878d7
update notebook
scarlehoff May 2, 2023
6c1340f
ignore kinematic variables beyond the 3rd one
scarlehoff May 3, 2023
73c994a
fix tests
scarlehoff May 3, 2023
2cfdcf9
minimal set of modifications so that one can actually use the new cd …
scarlehoff Sep 23, 2023
9649e48
first movements towards the deprecation of the yaml database; take th…
scarlehoff Sep 23, 2023
4ea46d4
add a specific error for datasets without TheoryMetaData
scarlehoff Sep 25, 2023
5964fad
update commondataparser to "fake" PlotOptions
scarlehoff Sep 28, 2023
341025b
separate plotting options so that they are compatible with the old-co…
scarlehoff Oct 10, 2023
56b90fd
import plotoptions
scarlehoff Oct 10, 2023
3770466
use kinematic coverage to select the kinematics
scarlehoff Oct 10, 2023
65752ac
document a bit better each class inside the parser
scarlehoff Oct 11, 2023
41416de
read kinematic_coverage as a list ; add a few checks
scarlehoff Oct 11, 2023
fee6f6a
add the transitional identity tranformation
scarlehoff Oct 20, 2023
13db7fe
remove todo and add extra info about the self.legacy
scarlehoff Oct 20, 2023
07baa3d
use the kinematic coverage variables for the filter
scarlehoff Oct 24, 2023
f14a645
Update validphys2/src/validphys/core.py
scarlehoff Oct 27, 2023
b5c5e44
promote the shifts flag to a first class theory flag
scarlehoff Oct 31, 2023
028ab1e
tell the user why a given dataset could not load when the theory is m…
scarlehoff Oct 31, 2023
c09ec77
beautify a bit the grouping labels
scarlehoff Oct 31, 2023
00b1f80
show a verbose error when not finding pineappl fktables
scarlehoff Nov 12, 2023
871ab6e
add the option for extra_labels
scarlehoff Nov 13, 2023
2c2d263
fallback until we have some more datasets merged
scarlehoff Nov 13, 2023
2df5c43
swap old and new in the mapping old:new
scarlehoff Nov 14, 2023
db81cb6
allow for a normalize dictionary
scarlehoff Dec 4, 2023
a212479
update reader for cd with less than 3 variables
scarlehoff Dec 7, 2023
68a52b1
allow saving the whole kin
scarlehoff Dec 8, 2023
f61bf23
try to autoguess the total-cross section case
scarlehoff Dec 8, 2023
82327dc
change the order of the checks
scarlehoff Dec 8, 2023
111e0da
rebased on top of current master
scarlehoff Jan 25, 2024
dc30d40
modify import
scarlehoff Jan 26, 2024
2bbaa06
change the name of the new data folder to new_commondata
scarlehoff Feb 1, 2024
cff6af4
various fixes related to the heracomb datasets ; change variants to v…
scarlehoff Feb 2, 2024
87550a5
add necessary changes to read all 4.0 datasets ported to the new format
scarlehoff Feb 6, 2024
ea06b2d
implement positivity
scarlehoff Feb 6, 2024
2537e12
try to reflect changes
Radonirinaunimi Feb 6, 2024
a373186
Merge branch 'final_reader_for_new_commondata_mk2' into polarised-fits
Radonirinaunimi Feb 6, 2024
7e2813f
new commondata reader
scarlehoff Feb 23, 2023
7f54975
improve the notebook
scarlehoff Feb 23, 2023
53381f2
remove duplicated functions
scarlehoff Feb 23, 2023
26a70e3
make theory optional
scarlehoff Feb 23, 2023
f4fb91d
remove old style data that was included with this pr
scarlehoff Mar 29, 2023
ef53143
updated reader to the new (new) format
scarlehoff Mar 29, 2023
06f266d
some parser updates
scarlehoff Mar 30, 2023
ab8d527
update the reader: definition->definitions, add a columns of 0s when …
scarlehoff Mar 31, 2023
ac9978c
reorder in the parser
scarlehoff Mar 31, 2023
fb74236
handle nonstr
scarlehoff Mar 31, 2023
f0cd316
applied suggestion for ValidOperation
scarlehoff Mar 31, 2023
f8f3473
add check for -1 factors when they are just eigenvectors
scarlehoff Apr 3, 2023
80dd48e
fill the mid kinematic value with the average of min and max
scarlehoff Apr 28, 2023
6ab82a2
update notebook ; allow for hepdata version to be None
scarlehoff Apr 28, 2023
9a63c71
update notebook
scarlehoff May 2, 2023
965f0e8
ignore kinematic variables beyond the 3rd one
scarlehoff May 3, 2023
aa84684
fix tests
scarlehoff May 3, 2023
6dadd54
minimal set of modifications so that one can actually use the new cd …
scarlehoff Sep 23, 2023
c30aa94
first movements towards the deprecation of the yaml database; take th…
scarlehoff Sep 23, 2023
1fb9537
add a specific error for datasets without TheoryMetaData
scarlehoff Sep 25, 2023
fd7ca8b
update commondataparser to "fake" PlotOptions
scarlehoff Sep 28, 2023
cd4151a
separate plotting options so that they are compatible with the old-co…
scarlehoff Oct 10, 2023
28837fc
import plotoptions
scarlehoff Oct 10, 2023
2354461
use kinematic coverage to select the kinematics
scarlehoff Oct 10, 2023
051f94b
document a bit better each class inside the parser
scarlehoff Oct 11, 2023
8b00175
read kinematic_coverage as a list ; add a few checks
scarlehoff Oct 11, 2023
26bf158
add the transitional identity tranformation
scarlehoff Oct 20, 2023
4165c9c
remove todo and add extra info about the self.legacy
scarlehoff Oct 20, 2023
27f1ba4
use the kinematic coverage variables for the filter
scarlehoff Oct 24, 2023
f419bb5
Update validphys2/src/validphys/core.py
scarlehoff Oct 27, 2023
3926e85
promote the shifts flag to a first class theory flag
scarlehoff Oct 31, 2023
4152266
tell the user why a given dataset could not load when the theory is m…
scarlehoff Oct 31, 2023
10a31bc
beautify a bit the grouping labels
scarlehoff Oct 31, 2023
54dd1e5
show a verbose error when not finding pineappl fktables
scarlehoff Nov 12, 2023
a5d2a43
add the option for extra_labels
scarlehoff Nov 13, 2023
9aad92f
fallback until we have some more datasets merged
scarlehoff Nov 13, 2023
f76a145
swap old and new in the mapping old:new
scarlehoff Nov 14, 2023
b559d14
allow for a normalize dictionary
scarlehoff Dec 4, 2023
a6ed5d3
update reader for cd with less than 3 variables
scarlehoff Dec 7, 2023
387e4b0
allow saving the whole kin
scarlehoff Dec 8, 2023
44a43e4
try to autoguess the total-cross section case
scarlehoff Dec 8, 2023
a47f498
change the order of the checks
scarlehoff Dec 8, 2023
58c5ec2
rebased on top of current master
scarlehoff Jan 25, 2024
aa9f7c2
modify import
scarlehoff Jan 26, 2024
2f272a9
change the name of the new data folder to new_commondata
scarlehoff Feb 1, 2024
d7f7eda
various fixes related to the heracomb datasets ; change variants to v…
scarlehoff Feb 2, 2024
346cd95
add necessary changes to read all 4.0 datasets ported to the new format
scarlehoff Feb 6, 2024
178eb05
implement positivity
scarlehoff Feb 6, 2024
ecc599c
now the variant can also change the theory
scarlehoff Feb 6, 2024
bf85536
allow data_central in the variants...
scarlehoff Feb 7, 2024
9f9f27f
add the possibility to read integrability datasets
scarlehoff Feb 7, 2024
11906d6
reflects updated changes
Radonirinaunimi Feb 9, 2024
b22349e
shortned annotation in line_by
Radonirinaunimi Feb 10, 2024
76f98ae
add slight modifications to template runcard
Radonirinaunimi Feb 10, 2024
3d020ed
tiny comment change
Radonirinaunimi Feb 10, 2024
7daa587
undo polarised cuts
Radonirinaunimi Feb 10, 2024
6f5641d
add sigma+t8 to report plotting bases
Radonirinaunimi Feb 14, 2024
25f7b05
undo change of scale
Radonirinaunimi Feb 14, 2024
2891731
remove luminosities from polarised report
Radonirinaunimi Feb 14, 2024
a55d973
add slightly more information regarding SR
Radonirinaunimi Feb 16, 2024
1335687
finally rename pdfs correctly
Radonirinaunimi Feb 17, 2024
bce2717
fixed labelling of evol_pol
Radonirinaunimi Feb 17, 2024
295698d
merge new reader
Radonirinaunimi Mar 4, 2024
0b70e50
remove notebook
Radonirinaunimi Mar 4, 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
89 changes: 89 additions & 0 deletions n3fit/runcards/examples/nnpdfpol20_dis_nnlo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
############################################################
# Configuration file for N3FIT
############################################################
description: NNPDFpol2.0 NNLO DIS fit

############################################################
dataset_inputs:
- {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_EN_G1, frac: 0.60, cfac: [NRM]}
- {dataset: HERMES_NC_7GEV_EP_G1, frac: 0.60, cfac: [NRM]}
- {dataset: SMC_NC_24GEV_MUD_G1, frac: 0.60, cfac: [NRM]}
- {dataset: SMC_NC_17GEV_MUP_G1, frac: 0.60, cfac: [NRM]}
- {dataset: COMPASS_NC_17GEV_MUP_G1, frac: 0.60, cfac: [NRM]}
- {dataset: COMPASS_NC_25GEV_MUD_G1, frac: 0.60, cfac: [NRM]}

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

unpolpdf: NNPDF40_nnlo_pch_as_01180

############################################################
theory:
theoryid: 800

############################################################
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_DGLUON_XFXQ, maxlambda: 1e8}
- {dataset: NNPDF_POS_DDOWN_XFXQ-SUM, maxlambda: 1e8}
- {dataset: NNPDF_POS_DSTRANGE_XFXQ-SUM, maxlambda: 1e8}
- {dataset: NNPDF_POS_DUP_XFXQ-SUM, maxlambda: 1e8}

############################################################
integrability:
integdatasets:
- {dataset: NNPDF_INTEG_DG_XFXQ, maxlambda: 1e2}
- {dataset: NNPDF_INTEG_DSIGMA_XFXQ, 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):
"""
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
62 changes: 58 additions & 4 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 @@ -26,6 +41,36 @@
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,6 +79,7 @@ class MSR_Normalization(MetaLayer):

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

def __init__(self, mode: str = "ALL", replicas: int = 1, **kwargs):
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
Radonirinaunimi marked this conversation as resolved.
Show resolved Hide resolved
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,11 @@ 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 += [self.vsr_factors]



numerators = op.concatenate(numerators, axis=0)
divisors = op.gather(y, self.divisor_indices, axis=0)
Expand Down
32 changes: 31 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,14 @@ 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))
# TODO: Ideally fetch info from Commondata Metadata
operation_name = "SMP" if self.nfks == 4 else "ADD"

# check how many xgrids this dataset needs
if is_unique(xgrids):
self.splitting = None
Expand All @@ -71,6 +95,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:
# Polarised POS contains at least 2 FK tables
return self.nfks >= 2
return False

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