From 7f6f54efd8411bcff0d6f50550153198a69bcf0d Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 28 Mar 2024 11:39:56 +0100 Subject: [PATCH 01/60] First minimal example --- nnpdf_data/theory.py | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 nnpdf_data/theory.py diff --git a/nnpdf_data/theory.py b/nnpdf_data/theory.py new file mode 100644 index 0000000000..807c9dcd6e --- /dev/null +++ b/nnpdf_data/theory.py @@ -0,0 +1,59 @@ +""" +This module provides an unique source and definition for all the possible parameters +that a theory card can contain. +It also implement some utilities function to manage the theory cards. +""" + +from dataclasses import dataclass + + +@dataclass(frozen=True) +class _TheoryCard: + ID: int + PTO: int + FNS: str + DAMP: int + DAMPPOWERc: None #Power of the damping factor in FONLL for the c + DAMPPOWERb: None #Power of the damping factor in FONLL for the b + IC: int + IB: int + ModEv: str + ModSV: None# + XIR: float + XIF: float + NfFF: int + #MaxNfAs: int + #MaxNfPdf: int + nfref: 5 + nf0: 3 + Q0: float + alphas: float + Qref: float #TODO: understand if we want to enforce Qref = Qedref and remove Qedref. Note that this is mandatory in eko + QED: int + alphaqed: float + Qedref: float + SxRes: int# + SxOrd: str# + HQ: str + mc: float + Qmc: float# + kcThr: float + mb: float + Qmb: float# + kbThr: float + mt: float + Qmt: float# + ktThr: float + CKM: list[float] + MZ: float + MW: float + GF: float + SIN2TW: float# + TMC: int + MP: float + Comments: str + global_nx: int# + #EScaleVar: int + FactScaleVar: None #used in yadism to allow for Fact scale var + RenScaleVar: None #used in yadism to allow for Ren scale var + n3lo_cf_variation : None \ No newline at end of file From 6e080870bc1c9d5049550327e12c165054f5f0b5 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 28 Mar 2024 14:16:14 +0100 Subject: [PATCH 02/60] Update nnpdf_data/theory.py Co-authored-by: Felix Hekhorn --- nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/theory.py b/nnpdf_data/theory.py index 807c9dcd6e..f8664942a9 100644 --- a/nnpdf_data/theory.py +++ b/nnpdf_data/theory.py @@ -8,7 +8,7 @@ @dataclass(frozen=True) -class _TheoryCard: +class TheoryCard: ID: int PTO: int FNS: str From 0f71abe4d9f5111089b53b8e3b03ba30fcf9619b Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 28 Mar 2024 14:18:30 +0100 Subject: [PATCH 03/60] Remove unused parameters --- nnpdf_data/{ => nnpdf_data}/theory.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) rename nnpdf_data/{ => nnpdf_data}/theory.py (85%) diff --git a/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py similarity index 85% rename from nnpdf_data/theory.py rename to nnpdf_data/nnpdf_data/theory.py index f8664942a9..e953c094d4 100644 --- a/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -18,12 +18,10 @@ class TheoryCard: IC: int IB: int ModEv: str - ModSV: None# + ModSV: None XIR: float XIF: float NfFF: int - #MaxNfAs: int - #MaxNfPdf: int nfref: 5 nf0: 3 Q0: float @@ -32,28 +30,24 @@ class TheoryCard: QED: int alphaqed: float Qedref: float - SxRes: int# - SxOrd: str# HQ: str mc: float - Qmc: float# + Qmc: float kcThr: float mb: float - Qmb: float# + Qmb: float kbThr: float mt: float - Qmt: float# + Qmt: float ktThr: float CKM: list[float] MZ: float MW: float GF: float - SIN2TW: float# + SIN2TW: float TMC: int MP: float Comments: str - global_nx: int# - #EScaleVar: int FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var n3lo_cf_variation : None \ No newline at end of file From 9a40b969642589b1a731933ec238c2186cfbdab0 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 28 Mar 2024 18:22:24 +0100 Subject: [PATCH 04/60] Add use_fhmruvv and remove IB --- nnpdf_data/nnpdf_data/theory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index e953c094d4..7e45b375e7 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -16,7 +16,6 @@ class TheoryCard: DAMPPOWERc: None #Power of the damping factor in FONLL for the c DAMPPOWERb: None #Power of the damping factor in FONLL for the b IC: int - IB: int ModEv: str ModSV: None XIR: float @@ -50,4 +49,5 @@ class TheoryCard: Comments: str FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var - n3lo_cf_variation : None \ No newline at end of file + n3lo_cf_variation : None + use_fhmruvv: None \ No newline at end of file From 1065a9348b1c489c3677fefb9300e535e0dd2613 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 4 Apr 2024 16:17:42 +0200 Subject: [PATCH 05/60] Remove Qedref --- nnpdf_data/nnpdf_data/theory.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 7e45b375e7..415a31d165 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -25,10 +25,9 @@ class TheoryCard: nf0: 3 Q0: float alphas: float - Qref: float #TODO: understand if we want to enforce Qref = Qedref and remove Qedref. Note that this is mandatory in eko + Qref: float QED: int alphaqed: float - Qedref: float HQ: str mc: float Qmc: float From 3a22aa6f0bc2014ca3464d4e8b00dbca0a06d3f6 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Mon, 8 Apr 2024 11:20:01 +0200 Subject: [PATCH 06/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Juan M. Cruz-Martinez --- nnpdf_data/nnpdf_data/theory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 415a31d165..419ac9d154 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -16,7 +16,8 @@ class TheoryCard: DAMPPOWERc: None #Power of the damping factor in FONLL for the c DAMPPOWERb: None #Power of the damping factor in FONLL for the b IC: int - ModEv: str + ModEv: str # EXA or TRN + IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: None XIR: float XIF: float From 90cb80fb16f08fe9fba4bff63ca07273d3741dab Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 8 Apr 2024 11:27:21 +0200 Subject: [PATCH 07/60] Address review comment --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 419ac9d154..529da0b4b2 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -18,7 +18,7 @@ class TheoryCard: IC: int ModEv: str # EXA or TRN IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: None + ModSV: str = None XIR: float XIF: float NfFF: int From 0655ba5db3e823b6ecfe67bf5b43eb8bff470de0 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 8 Apr 2024 11:29:29 +0200 Subject: [PATCH 08/60] Modify DAMPPOWERs --- nnpdf_data/nnpdf_data/theory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 529da0b4b2..31b2e4ad15 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -13,8 +13,8 @@ class TheoryCard: PTO: int FNS: str DAMP: int - DAMPPOWERc: None #Power of the damping factor in FONLL for the c - DAMPPOWERb: None #Power of the damping factor in FONLL for the b + DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c + DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b IC: int ModEv: str # EXA or TRN IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA From 6fb5b6d1a8a3fc80f415fd3c52eae3b23100ff98 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 8 Apr 2024 11:40:51 +0200 Subject: [PATCH 09/60] Add comments to parameters --- nnpdf_data/nnpdf_data/theory.py | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 31b2e4ad15..2ae135e0a3 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -9,45 +9,45 @@ @dataclass(frozen=True) class TheoryCard: - ID: int - PTO: int - FNS: str - DAMP: int + ID: int # ID number of the theory + PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) + FNS: str # Flavor number scheme (i.e. FONLL-C) + DAMP: int # Whether a damping function is applied or not for FONLL DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b - IC: int - ModEv: str # EXA or TRN + IC: int # Intrinsic charm + ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: str = None - XIR: float - XIF: float - NfFF: int - nfref: 5 - nf0: 3 - Q0: float - alphas: float - Qref: float - QED: int - alphaqed: float + ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) + XIR: float # Renormalization scale ratio + XIF: float # Factorization scale ratio + NfFF: int # Number of active flavors + nfref: 5 # Number of active flavors at Qref + nf0: 3 # Number of active flavors at the parametrization scale Q0 + Q0: float # Parametrization scale + alphas: float # Value of alpha_s at the scale Qref + Qref: float # Reference scale for alphas and alphaqed + QED: int # Whether QED effects are taken into account + alphaqed: float # Values of alpha QED at the scale Qref HQ: str - mc: float - Qmc: float - kcThr: float - mb: float - Qmb: float - kbThr: float - mt: float - Qmt: float - ktThr: float - CKM: list[float] - MZ: float - MW: float - GF: float + mc: float # Pole mass of the charm + Qmc: float # MSbar mass reference scale of the charm + kcThr: float # Threshold ratio of the charm + mb: float # Pole mass of the bottom + Qmb: float # MSbar mass reference scale of the bottom + kbThr: float # Threshold ratio of the bottom + mt: float # Pole mass of the top + Qmt: float # MSbar mass reference scale of the top + ktThr: float # Threshold ratio of the top + CKM: list[float] # CKM matrix elements + MZ: float # Mass of Z + MW: float # Mass of W + GF: float # Fermi constant SIN2TW: float - TMC: int - MP: float - Comments: str + TMC: int # Time like + MP: float # Mass of the proton + Comments: str # Comments on the theory FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var - n3lo_cf_variation : None + n3lo_cf_variation : None # Variation of the N3LO coefficient function approximation use_fhmruvv: None \ No newline at end of file From 9ccd33a46a3c1ed65333b8748908af18f2e08295 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:01:58 +0200 Subject: [PATCH 10/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 2ae135e0a3..e762490c6e 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -29,7 +29,7 @@ class TheoryCard: Qref: float # Reference scale for alphas and alphaqed QED: int # Whether QED effects are taken into account alphaqed: float # Values of alpha QED at the scale Qref - HQ: str + HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). mc: float # Pole mass of the charm Qmc: float # MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm From 0808e9a881e071bbce9e203de52769cb46439cc5 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:02:37 +0200 Subject: [PATCH 11/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index e762490c6e..06d30b9789 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -15,7 +15,7 @@ class TheoryCard: DAMP: int # Whether a damping function is applied or not for FONLL DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b - IC: int # Intrinsic charm + IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) From cb1c0cbdbc00787a75ab111d593a475a3f7357ef Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:02:48 +0200 Subject: [PATCH 12/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 06d30b9789..46501ba640 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -13,7 +13,7 @@ class TheoryCard: PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) FNS: str # Flavor number scheme (i.e. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL - DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c + DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) From 503b5c06ec796e2de291199355b01e06a620364a Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:02:59 +0200 Subject: [PATCH 13/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 46501ba640..04d17a459a 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -14,7 +14,7 @@ class TheoryCard: FNS: str # Flavor number scheme (i.e. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c - DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b + DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA From 44f39cb648ae00e2dd7d79bda2718e6b8d0694dc Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:03:09 +0200 Subject: [PATCH 14/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 04d17a459a..4ec0e29c43 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -19,7 +19,7 @@ class TheoryCard: ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) - XIR: float # Renormalization scale ratio + XIR: float # Renormalization scale over the hard scattering scale rato XIF: float # Factorization scale ratio NfFF: int # Number of active flavors nfref: 5 # Number of active flavors at Qref From 8c42f4d7cb85ce8be3e21b6b742d6f3f3f17afd3 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:03:17 +0200 Subject: [PATCH 15/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 4ec0e29c43..99a635e568 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -21,7 +21,7 @@ class TheoryCard: ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) XIR: float # Renormalization scale over the hard scattering scale rato XIF: float # Factorization scale ratio - NfFF: int # Number of active flavors + NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes nfref: 5 # Number of active flavors at Qref nf0: 3 # Number of active flavors at the parametrization scale Q0 Q0: float # Parametrization scale From ccda8f9bf13be97f3daa234fb2578650a25fa353 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:03:53 +0200 Subject: [PATCH 16/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 99a635e568..8ca02ccb45 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -27,7 +27,7 @@ class TheoryCard: Q0: float # Parametrization scale alphas: float # Value of alpha_s at the scale Qref Qref: float # Reference scale for alphas and alphaqed - QED: int # Whether QED effects are taken into account + QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed alphaqed: float # Values of alpha QED at the scale Qref HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). mc: float # Pole mass of the charm From cacfb06a0686c82410b8badc33d86c2f48205c79 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Wed, 10 Apr 2024 11:08:50 +0200 Subject: [PATCH 17/60] Address review comments --- nnpdf_data/nnpdf_data/theory.py | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 8ca02ccb45..bee4dcb551 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -19,35 +19,35 @@ class TheoryCard: ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) - XIR: float # Renormalization scale over the hard scattering scale rato - XIF: float # Factorization scale ratio + XIR: float # Renormalization scale over the hard scattering scale ratio + XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes - nfref: 5 # Number of active flavors at Qref + nfref: int # Number of active flavors at Qref nf0: 3 # Number of active flavors at the parametrization scale Q0 - Q0: float # Parametrization scale + Q0: float # [GeV] Parametrization scale alphas: float # Value of alpha_s at the scale Qref - Qref: float # Reference scale for alphas and alphaqed + Qref: float # [GeV] Reference scale for alphas and alphaqed QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed alphaqed: float # Values of alpha QED at the scale Qref HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). - mc: float # Pole mass of the charm - Qmc: float # MSbar mass reference scale of the charm + mc: float # [GeV] charm mass + Qmc: float # [GeV] MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm - mb: float # Pole mass of the bottom - Qmb: float # MSbar mass reference scale of the bottom + mb: float # # [GeV] bottom mass + Qmb: float # [GeV] MSbar mass reference scale of the bottom kbThr: float # Threshold ratio of the bottom - mt: float # Pole mass of the top - Qmt: float # MSbar mass reference scale of the top + mt: float # # [GeV] top mass + Qmt: float # [GeV] MSbar mass reference scale of the top ktThr: float # Threshold ratio of the top CKM: list[float] # CKM matrix elements - MZ: float # Mass of Z - MW: float # Mass of W + MZ: float # [GeV] Mass of Z + MW: float # [GeV] Mass of W GF: float # Fermi constant SIN2TW: float - TMC: int # Time like - MP: float # Mass of the proton + TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact + MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var - n3lo_cf_variation : None # Variation of the N3LO coefficient function approximation - use_fhmruvv: None \ No newline at end of file + n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound + use_fhmruvv: None # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file From a5ea0908f9d360967a238e2fdcb0e9d7c1c0ff83 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Wed, 10 Apr 2024 11:09:49 +0200 Subject: [PATCH 18/60] Remove Fact and Ren Scalevar' --- nnpdf_data/nnpdf_data/theory.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index bee4dcb551..7ef58a4a2b 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -47,7 +47,5 @@ class TheoryCard: TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory - FactScaleVar: None #used in yadism to allow for Fact scale var - RenScaleVar: None #used in yadism to allow for Ren scale var n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound use_fhmruvv: None # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file From c0d0ea752e8517b326b779e042d3963837f9ec43 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 11 Apr 2024 11:58:23 +0200 Subject: [PATCH 19/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Juan M. Cruz-Martinez --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 7ef58a4a2b..1ff731aa72 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -23,7 +23,7 @@ class TheoryCard: XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes nfref: int # Number of active flavors at Qref - nf0: 3 # Number of active flavors at the parametrization scale Q0 + nf0: int = 3 # Number of active flavors at the parametrization scale Q0 Q0: float # [GeV] Parametrization scale alphas: float # Value of alpha_s at the scale Qref Qref: float # [GeV] Reference scale for alphas and alphaqed From 7caa2c81861f6f855e641a2593b4bd4a21b8192a Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 11 Apr 2024 11:58:34 +0200 Subject: [PATCH 20/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Juan M. Cruz-Martinez --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 1ff731aa72..90d16027dd 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -48,4 +48,4 @@ class TheoryCard: MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound - use_fhmruvv: None # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file + use_fhmruvv: bool = False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file From 8e0652f36facade1ec72fc0013a0fc358afc3e41 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 11 Apr 2024 11:59:57 +0200 Subject: [PATCH 21/60] Put all the optional parameters at the end --- nnpdf_data/nnpdf_data/theory.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 90d16027dd..ee31c32000 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -13,17 +13,12 @@ class TheoryCard: PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) FNS: str # Flavor number scheme (i.e. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL - DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c - DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) - IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) XIR: float # Renormalization scale over the hard scattering scale ratio XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes nfref: int # Number of active flavors at Qref - nf0: int = 3 # Number of active flavors at the parametrization scale Q0 Q0: float # [GeV] Parametrization scale alphas: float # Value of alpha_s at the scale Qref Qref: float # [GeV] Reference scale for alphas and alphaqed @@ -47,5 +42,10 @@ class TheoryCard: TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory + IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA + ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) + DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c + DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound - use_fhmruvv: bool = False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file + use_fhmruvv: bool = False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. + nf0: int = 3 # Number of active flavors at the parametrization scale Q0 \ No newline at end of file From fa1920b173b5d6eee05ab2e2eb22168ad5d2629c Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 28 Mar 2024 11:39:56 +0100 Subject: [PATCH 22/60] First minimal example --- nnpdf_data/theory.py | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 nnpdf_data/theory.py diff --git a/nnpdf_data/theory.py b/nnpdf_data/theory.py new file mode 100644 index 0000000000..807c9dcd6e --- /dev/null +++ b/nnpdf_data/theory.py @@ -0,0 +1,59 @@ +""" +This module provides an unique source and definition for all the possible parameters +that a theory card can contain. +It also implement some utilities function to manage the theory cards. +""" + +from dataclasses import dataclass + + +@dataclass(frozen=True) +class _TheoryCard: + ID: int + PTO: int + FNS: str + DAMP: int + DAMPPOWERc: None #Power of the damping factor in FONLL for the c + DAMPPOWERb: None #Power of the damping factor in FONLL for the b + IC: int + IB: int + ModEv: str + ModSV: None# + XIR: float + XIF: float + NfFF: int + #MaxNfAs: int + #MaxNfPdf: int + nfref: 5 + nf0: 3 + Q0: float + alphas: float + Qref: float #TODO: understand if we want to enforce Qref = Qedref and remove Qedref. Note that this is mandatory in eko + QED: int + alphaqed: float + Qedref: float + SxRes: int# + SxOrd: str# + HQ: str + mc: float + Qmc: float# + kcThr: float + mb: float + Qmb: float# + kbThr: float + mt: float + Qmt: float# + ktThr: float + CKM: list[float] + MZ: float + MW: float + GF: float + SIN2TW: float# + TMC: int + MP: float + Comments: str + global_nx: int# + #EScaleVar: int + FactScaleVar: None #used in yadism to allow for Fact scale var + RenScaleVar: None #used in yadism to allow for Ren scale var + n3lo_cf_variation : None \ No newline at end of file From 8341ca26e936f807c2bd8981d6a09e53ce56ff70 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 28 Mar 2024 14:16:14 +0100 Subject: [PATCH 23/60] Update nnpdf_data/theory.py Co-authored-by: Felix Hekhorn --- nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/theory.py b/nnpdf_data/theory.py index 807c9dcd6e..f8664942a9 100644 --- a/nnpdf_data/theory.py +++ b/nnpdf_data/theory.py @@ -8,7 +8,7 @@ @dataclass(frozen=True) -class _TheoryCard: +class TheoryCard: ID: int PTO: int FNS: str From 230706560c0be6e623514237314a5f7e4e6c7cdf Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 28 Mar 2024 14:18:30 +0100 Subject: [PATCH 24/60] Remove unused parameters --- nnpdf_data/{ => nnpdf_data}/theory.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) rename nnpdf_data/{ => nnpdf_data}/theory.py (85%) diff --git a/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py similarity index 85% rename from nnpdf_data/theory.py rename to nnpdf_data/nnpdf_data/theory.py index f8664942a9..e953c094d4 100644 --- a/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -18,12 +18,10 @@ class TheoryCard: IC: int IB: int ModEv: str - ModSV: None# + ModSV: None XIR: float XIF: float NfFF: int - #MaxNfAs: int - #MaxNfPdf: int nfref: 5 nf0: 3 Q0: float @@ -32,28 +30,24 @@ class TheoryCard: QED: int alphaqed: float Qedref: float - SxRes: int# - SxOrd: str# HQ: str mc: float - Qmc: float# + Qmc: float kcThr: float mb: float - Qmb: float# + Qmb: float kbThr: float mt: float - Qmt: float# + Qmt: float ktThr: float CKM: list[float] MZ: float MW: float GF: float - SIN2TW: float# + SIN2TW: float TMC: int MP: float Comments: str - global_nx: int# - #EScaleVar: int FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var n3lo_cf_variation : None \ No newline at end of file From 74b91ca9f80922d78f418cbcabe00057122b2189 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 28 Mar 2024 18:22:24 +0100 Subject: [PATCH 25/60] Add use_fhmruvv and remove IB --- nnpdf_data/nnpdf_data/theory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index e953c094d4..7e45b375e7 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -16,7 +16,6 @@ class TheoryCard: DAMPPOWERc: None #Power of the damping factor in FONLL for the c DAMPPOWERb: None #Power of the damping factor in FONLL for the b IC: int - IB: int ModEv: str ModSV: None XIR: float @@ -50,4 +49,5 @@ class TheoryCard: Comments: str FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var - n3lo_cf_variation : None \ No newline at end of file + n3lo_cf_variation : None + use_fhmruvv: None \ No newline at end of file From 72d7a5cfca0c5aae3d509d39a9162caebbaeab8e Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 4 Apr 2024 16:17:42 +0200 Subject: [PATCH 26/60] Remove Qedref --- nnpdf_data/nnpdf_data/theory.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 7e45b375e7..415a31d165 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -25,10 +25,9 @@ class TheoryCard: nf0: 3 Q0: float alphas: float - Qref: float #TODO: understand if we want to enforce Qref = Qedref and remove Qedref. Note that this is mandatory in eko + Qref: float QED: int alphaqed: float - Qedref: float HQ: str mc: float Qmc: float From eadaae082db083eab2b30571c5ea8d7709f329e0 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Mon, 8 Apr 2024 11:20:01 +0200 Subject: [PATCH 27/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Juan M. Cruz-Martinez --- nnpdf_data/nnpdf_data/theory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 415a31d165..419ac9d154 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -16,7 +16,8 @@ class TheoryCard: DAMPPOWERc: None #Power of the damping factor in FONLL for the c DAMPPOWERb: None #Power of the damping factor in FONLL for the b IC: int - ModEv: str + ModEv: str # EXA or TRN + IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: None XIR: float XIF: float From 4a522a1cadce9456e5b6939a23ba7b168dfa4197 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 8 Apr 2024 11:27:21 +0200 Subject: [PATCH 28/60] Address review comment --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 419ac9d154..529da0b4b2 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -18,7 +18,7 @@ class TheoryCard: IC: int ModEv: str # EXA or TRN IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: None + ModSV: str = None XIR: float XIF: float NfFF: int From 514c9a3622a1d1689b1028c7ab7d04364137d6f0 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 8 Apr 2024 11:29:29 +0200 Subject: [PATCH 29/60] Modify DAMPPOWERs --- nnpdf_data/nnpdf_data/theory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 529da0b4b2..31b2e4ad15 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -13,8 +13,8 @@ class TheoryCard: PTO: int FNS: str DAMP: int - DAMPPOWERc: None #Power of the damping factor in FONLL for the c - DAMPPOWERb: None #Power of the damping factor in FONLL for the b + DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c + DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b IC: int ModEv: str # EXA or TRN IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA From 9904beb878a8f78a1c37f82107ec7534ea20ebaa Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 8 Apr 2024 11:40:51 +0200 Subject: [PATCH 30/60] Add comments to parameters --- nnpdf_data/nnpdf_data/theory.py | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 31b2e4ad15..2ae135e0a3 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -9,45 +9,45 @@ @dataclass(frozen=True) class TheoryCard: - ID: int - PTO: int - FNS: str - DAMP: int + ID: int # ID number of the theory + PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) + FNS: str # Flavor number scheme (i.e. FONLL-C) + DAMP: int # Whether a damping function is applied or not for FONLL DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b - IC: int - ModEv: str # EXA or TRN + IC: int # Intrinsic charm + ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: str = None - XIR: float - XIF: float - NfFF: int - nfref: 5 - nf0: 3 - Q0: float - alphas: float - Qref: float - QED: int - alphaqed: float + ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) + XIR: float # Renormalization scale ratio + XIF: float # Factorization scale ratio + NfFF: int # Number of active flavors + nfref: 5 # Number of active flavors at Qref + nf0: 3 # Number of active flavors at the parametrization scale Q0 + Q0: float # Parametrization scale + alphas: float # Value of alpha_s at the scale Qref + Qref: float # Reference scale for alphas and alphaqed + QED: int # Whether QED effects are taken into account + alphaqed: float # Values of alpha QED at the scale Qref HQ: str - mc: float - Qmc: float - kcThr: float - mb: float - Qmb: float - kbThr: float - mt: float - Qmt: float - ktThr: float - CKM: list[float] - MZ: float - MW: float - GF: float + mc: float # Pole mass of the charm + Qmc: float # MSbar mass reference scale of the charm + kcThr: float # Threshold ratio of the charm + mb: float # Pole mass of the bottom + Qmb: float # MSbar mass reference scale of the bottom + kbThr: float # Threshold ratio of the bottom + mt: float # Pole mass of the top + Qmt: float # MSbar mass reference scale of the top + ktThr: float # Threshold ratio of the top + CKM: list[float] # CKM matrix elements + MZ: float # Mass of Z + MW: float # Mass of W + GF: float # Fermi constant SIN2TW: float - TMC: int - MP: float - Comments: str + TMC: int # Time like + MP: float # Mass of the proton + Comments: str # Comments on the theory FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var - n3lo_cf_variation : None + n3lo_cf_variation : None # Variation of the N3LO coefficient function approximation use_fhmruvv: None \ No newline at end of file From 31b39a46bc9f39a8df86d0e80f6cf69f947266b6 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:01:58 +0200 Subject: [PATCH 31/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 2ae135e0a3..e762490c6e 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -29,7 +29,7 @@ class TheoryCard: Qref: float # Reference scale for alphas and alphaqed QED: int # Whether QED effects are taken into account alphaqed: float # Values of alpha QED at the scale Qref - HQ: str + HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). mc: float # Pole mass of the charm Qmc: float # MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm From da7ba205c77a83962651bc16d5acde33353b1efa Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:02:37 +0200 Subject: [PATCH 32/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index e762490c6e..06d30b9789 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -15,7 +15,7 @@ class TheoryCard: DAMP: int # Whether a damping function is applied or not for FONLL DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b - IC: int # Intrinsic charm + IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) From 6de4627b2a361c8b7afc523d98b0754ce999256d Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:02:48 +0200 Subject: [PATCH 33/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 06d30b9789..46501ba640 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -13,7 +13,7 @@ class TheoryCard: PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) FNS: str # Flavor number scheme (i.e. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL - DAMPPOWERc: int = None #Power of the damping factor in FONLL for the c + DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) From bbfa5ffc578fa6f2da79b05598dc63db594a3cde Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:02:59 +0200 Subject: [PATCH 34/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 46501ba640..04d17a459a 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -14,7 +14,7 @@ class TheoryCard: FNS: str # Flavor number scheme (i.e. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c - DAMPPOWERb: int = None #Power of the damping factor in FONLL for the b + DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA From 9a900dac74b614f45f7d194954042584f222e67e Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:03:09 +0200 Subject: [PATCH 35/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 04d17a459a..4ec0e29c43 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -19,7 +19,7 @@ class TheoryCard: ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) - XIR: float # Renormalization scale ratio + XIR: float # Renormalization scale over the hard scattering scale rato XIF: float # Factorization scale ratio NfFF: int # Number of active flavors nfref: 5 # Number of active flavors at Qref From f303c4a92f3dfb13cacc7b924d3244c5417d9bb4 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:03:17 +0200 Subject: [PATCH 36/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 4ec0e29c43..99a635e568 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -21,7 +21,7 @@ class TheoryCard: ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) XIR: float # Renormalization scale over the hard scattering scale rato XIF: float # Factorization scale ratio - NfFF: int # Number of active flavors + NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes nfref: 5 # Number of active flavors at Qref nf0: 3 # Number of active flavors at the parametrization scale Q0 Q0: float # Parametrization scale From 42ac7d19863d10b3fda7de0ed7f35c3b323f43bc Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 10 Apr 2024 11:03:53 +0200 Subject: [PATCH 37/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 99a635e568..8ca02ccb45 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -27,7 +27,7 @@ class TheoryCard: Q0: float # Parametrization scale alphas: float # Value of alpha_s at the scale Qref Qref: float # Reference scale for alphas and alphaqed - QED: int # Whether QED effects are taken into account + QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed alphaqed: float # Values of alpha QED at the scale Qref HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). mc: float # Pole mass of the charm From 5f76e79278774ad22e253c8ce8fcc1f9eed166c1 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Wed, 10 Apr 2024 11:08:50 +0200 Subject: [PATCH 38/60] Address review comments --- nnpdf_data/nnpdf_data/theory.py | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 8ca02ccb45..bee4dcb551 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -19,35 +19,35 @@ class TheoryCard: ModEv: str # DGLAP evolution solution method (EXA or TRN) IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) - XIR: float # Renormalization scale over the hard scattering scale rato - XIF: float # Factorization scale ratio + XIR: float # Renormalization scale over the hard scattering scale ratio + XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes - nfref: 5 # Number of active flavors at Qref + nfref: int # Number of active flavors at Qref nf0: 3 # Number of active flavors at the parametrization scale Q0 - Q0: float # Parametrization scale + Q0: float # [GeV] Parametrization scale alphas: float # Value of alpha_s at the scale Qref - Qref: float # Reference scale for alphas and alphaqed + Qref: float # [GeV] Reference scale for alphas and alphaqed QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed alphaqed: float # Values of alpha QED at the scale Qref HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). - mc: float # Pole mass of the charm - Qmc: float # MSbar mass reference scale of the charm + mc: float # [GeV] charm mass + Qmc: float # [GeV] MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm - mb: float # Pole mass of the bottom - Qmb: float # MSbar mass reference scale of the bottom + mb: float # # [GeV] bottom mass + Qmb: float # [GeV] MSbar mass reference scale of the bottom kbThr: float # Threshold ratio of the bottom - mt: float # Pole mass of the top - Qmt: float # MSbar mass reference scale of the top + mt: float # # [GeV] top mass + Qmt: float # [GeV] MSbar mass reference scale of the top ktThr: float # Threshold ratio of the top CKM: list[float] # CKM matrix elements - MZ: float # Mass of Z - MW: float # Mass of W + MZ: float # [GeV] Mass of Z + MW: float # [GeV] Mass of W GF: float # Fermi constant SIN2TW: float - TMC: int # Time like - MP: float # Mass of the proton + TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact + MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory FactScaleVar: None #used in yadism to allow for Fact scale var RenScaleVar: None #used in yadism to allow for Ren scale var - n3lo_cf_variation : None # Variation of the N3LO coefficient function approximation - use_fhmruvv: None \ No newline at end of file + n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound + use_fhmruvv: None # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file From 8529b534f8fda80cb65e3ce5672930915b24b80b Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Wed, 10 Apr 2024 11:09:49 +0200 Subject: [PATCH 39/60] Remove Fact and Ren Scalevar' --- nnpdf_data/nnpdf_data/theory.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index bee4dcb551..7ef58a4a2b 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -47,7 +47,5 @@ class TheoryCard: TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory - FactScaleVar: None #used in yadism to allow for Fact scale var - RenScaleVar: None #used in yadism to allow for Ren scale var n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound use_fhmruvv: None # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file From 8a9a43749e6fbe12fde2a2113dfce703eaa7e8af Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 11 Apr 2024 11:58:23 +0200 Subject: [PATCH 40/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Juan M. Cruz-Martinez --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 7ef58a4a2b..1ff731aa72 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -23,7 +23,7 @@ class TheoryCard: XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes nfref: int # Number of active flavors at Qref - nf0: 3 # Number of active flavors at the parametrization scale Q0 + nf0: int = 3 # Number of active flavors at the parametrization scale Q0 Q0: float # [GeV] Parametrization scale alphas: float # Value of alpha_s at the scale Qref Qref: float # [GeV] Reference scale for alphas and alphaqed From 20d3f74f253f836d5f9ac3cd46509619df56c194 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 11 Apr 2024 11:58:34 +0200 Subject: [PATCH 41/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Juan M. Cruz-Martinez --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 1ff731aa72..90d16027dd 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -48,4 +48,4 @@ class TheoryCard: MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound - use_fhmruvv: None # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file + use_fhmruvv: bool = False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file From 58faa655b01556b3edab912c194a12d58f82cde8 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 11 Apr 2024 11:59:57 +0200 Subject: [PATCH 42/60] Put all the optional parameters at the end --- nnpdf_data/nnpdf_data/theory.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 90d16027dd..ee31c32000 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -13,17 +13,12 @@ class TheoryCard: PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) FNS: str # Flavor number scheme (i.e. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL - DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c - DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) - IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) XIR: float # Renormalization scale over the hard scattering scale ratio XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes nfref: int # Number of active flavors at Qref - nf0: int = 3 # Number of active flavors at the parametrization scale Q0 Q0: float # [GeV] Parametrization scale alphas: float # Value of alpha_s at the scale Qref Qref: float # [GeV] Reference scale for alphas and alphaqed @@ -47,5 +42,10 @@ class TheoryCard: TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory + IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA + ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) + DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c + DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound - use_fhmruvv: bool = False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. \ No newline at end of file + use_fhmruvv: bool = False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. + nf0: int = 3 # Number of active flavors at the parametrization scale Q0 \ No newline at end of file From b689f2665397b80bc3bd7c8bdcc05c1cfd7c851a Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 12 Apr 2024 16:31:06 +0200 Subject: [PATCH 43/60] update runcard and rebase with master --- nnpdf_data/nnpdf_data/theory.py | 111 +++++++++++++++---------- nnpdf_data/nnpdf_data/theorydbutils.py | 48 +---------- nnpdf_data/nnpdf_data/utils.py | 7 +- 3 files changed, 77 insertions(+), 89 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index ee31c32000..2372b9446a 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -1,51 +1,76 @@ """ This module provides an unique source and definition for all the possible parameters -that a theory card can contain. -It also implement some utilities function to manage the theory cards. +that a theory card can contain. """ -from dataclasses import dataclass +import dataclasses +DEPRECATED_KEYS = ["MaxNfAs", "SxRes", "SxOrd" "EScaleVar", "Qedref", "global_nx"] -@dataclass(frozen=True) + +@dataclasses.dataclass(frozen=True) class TheoryCard: - ID: int # ID number of the theory - PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) - FNS: str # Flavor number scheme (i.e. FONLL-C) - DAMP: int # Whether a damping function is applied or not for FONLL - IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed - ModEv: str # DGLAP evolution solution method (EXA or TRN) - XIR: float # Renormalization scale over the hard scattering scale ratio - XIF: float # Factorization scale over the hard scattering scale ratio - NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes - nfref: int # Number of active flavors at Qref - Q0: float # [GeV] Parametrization scale - alphas: float # Value of alpha_s at the scale Qref - Qref: float # [GeV] Reference scale for alphas and alphaqed - QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed - alphaqed: float # Values of alpha QED at the scale Qref - HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). - mc: float # [GeV] charm mass - Qmc: float # [GeV] MSbar mass reference scale of the charm - kcThr: float # Threshold ratio of the charm - mb: float # # [GeV] bottom mass - Qmb: float # [GeV] MSbar mass reference scale of the bottom - kbThr: float # Threshold ratio of the bottom - mt: float # # [GeV] top mass - Qmt: float # [GeV] MSbar mass reference scale of the top - ktThr: float # Threshold ratio of the top - CKM: list[float] # CKM matrix elements - MZ: float # [GeV] Mass of Z - MW: float # [GeV] Mass of W - GF: float # Fermi constant + ID: int # ID number of the theory + PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) + FNS: str # Flavor number scheme (i.e. FONLL-C) + DAMP: int # Whether a damping function is applied or not for FONLL + IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed + ModEv: str # DGLAP evolution solution method (EXA or TRN) + XIR: float # Renormalization scale over the hard scattering scale ratio + XIF: float # Factorization scale over the hard scattering scale ratio + NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes + QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed + HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). + mc: float # [GeV] charm mass + Qmc: float # [GeV] MSbar mass reference scale of the charm + kcThr: float # Threshold ratio of the charm + mb: float # # [GeV] bottom mass + Qmb: float # [GeV] MSbar mass reference scale of the bottom + kbThr: float # Threshold ratio of the bottom + mt: float # # [GeV] top mass + Qmt: float # [GeV] MSbar mass reference scale of the top + ktThr: float # Threshold ratio of the top + CKM: list[float] # CKM matrix elements + MZ: float # [GeV] Mass of Z + MW: float # [GeV] Mass of W + GF: float # Fermi constant SIN2TW: float - TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact - MP: float # [GeV] Mass of the proton - Comments: str # Comments on the theory - IterEv: int = None # Number of iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) - DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c - DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b - n3lo_cf_variation : int = 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound - use_fhmruvv: bool = False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. - nf0: int = 3 # Number of active flavors at the parametrization scale Q0 \ No newline at end of file + TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact + MP: float # [GeV] Mass of the proton + Comments: str # Comments on the theory + MaxNfPdf: int = 5 # Used by pineko to define the thresholds + # Fit theory parameters default + nf0: int = 4 # Number of active flavors at the parametrization scale Q0 + Q0: float = 1.65 # [GeV] Parametrization scale + nfref: int = 5 # Number of active flavors at Qref + Qref: float = 91.2 # [GeV] Reference scale for alphas and alphaqed + alphas: float = 0.118 # Value of alpha_s at the scale Qref + alphaqed: float = 0.007496252 # Values of alpha QED at the scale Qref + # Evolution parameters + IterEv: int = None # iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA + ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) + DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c + DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b + # N3LO parameters + n3lo_cf_variation: list = dataclasses.field( + default_factory=lambda: 7 * [0] + ) # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound + use_fhmruvv: bool = ( + False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. + ) + ###### Keys for compatibility with old NNPDF theories, their values will be dropped inmediately after reading to avoid problems + ###### they will be set to ``None`` inmediately after loading the theory + MaxNfAs: int = None + SxRes: int = None + SxOrd: str = None + EScaleVar: int = None + Qedref: float = None + global_nx: int = None + + def __post_init__(self): + """Drop deprecated keys""" + for key in DEPRECATED_KEYS: + object.__setattr__(self, key, None) + + def asdict(self): + return dataclasses.asdict(self) diff --git a/nnpdf_data/nnpdf_data/theorydbutils.py b/nnpdf_data/nnpdf_data/theorydbutils.py index defc35577f..bc92575a22 100644 --- a/nnpdf_data/nnpdf_data/theorydbutils.py +++ b/nnpdf_data/nnpdf_data/theorydbutils.py @@ -5,58 +5,15 @@ low level utilities for querying the theory database file and representing the data as a python object. """ -from dataclasses import asdict, dataclass from functools import lru_cache from pathlib import Path import pandas as pd +from .theory import TheoryCard from .utils import parse_yaml_inp -@dataclass(frozen=True) -class _TheoryCard: - ID: int - PTO: int - FNS: str - DAMP: int - IC: int - ModEv: str - XIR: float - XIF: float - NfFF: int - MaxNfAs: int - MaxNfPdf: int - Q0: float - alphas: float - Qref: float - QED: int - alphaqed: float - Qedref: float - SxRes: int - SxOrd: str - HQ: str - mc: float - Qmc: float - kcThr: float - mb: float - Qmb: float - kbThr: float - mt: float - Qmt: float - ktThr: float - CKM: list[float] - MZ: float - MW: float - GF: float - SIN2TW: float - TMC: int - MP: float - Comments: str - global_nx: int - EScaleVar: int - - class TheoryNotFoundInDatabase(Exception): pass @@ -67,7 +24,8 @@ def parse_theory_card(theory_card): Returns the theory as a dictionary """ if theory_card.exists(): - return asdict(parse_yaml_inp(theory_card, _TheoryCard)) + tcard = parse_yaml_inp(theory_card, TheoryCard) + return tcard.asdict() raise TheoryNotFoundInDatabase(f"Theory card {theory_card} not found") diff --git a/nnpdf_data/nnpdf_data/utils.py b/nnpdf_data/nnpdf_data/utils.py index 2fe7c15c4c..0803ba34e8 100644 --- a/nnpdf_data/nnpdf_data/utils.py +++ b/nnpdf_data/nnpdf_data/utils.py @@ -3,6 +3,11 @@ import ruamel.yaml as yaml from validobj import ValidationError, parse_input +try: + Loader = yaml.CLoader +except AttributeError: + Loader = yaml.Loader + def parse_yaml_inp(input_yaml, spec): """ @@ -12,7 +17,7 @@ def parse_yaml_inp(input_yaml, spec): https://validobj.readthedocs.io/en/latest/examples.html#yaml-line-numbers """ input_yaml = pathlib.Path(input_yaml) - inp = yaml.round_trip_load(input_yaml.open("r", encoding="utf-8")) + inp = yaml.load(input_yaml.read_text(encoding="utf-8"), Loader=Loader) try: return parse_input(inp, spec) except ValidationError as e: From 60c95fc9a7a0ce93ea1b6abc094486eed6718822 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 12 Apr 2024 20:04:35 +0200 Subject: [PATCH 44/60] add parameters still requested by eko to evolven3fit ; photon module now uses qref instead of qedref --- n3fit/src/evolven3fit/eko_utils.py | 4 ++++ nnpdf_data/nnpdf_data/theory.py | 9 +++++++-- validphys2/src/validphys/photon/alpha.py | 6 +++--- validphys2/src/validphys/photon/compute.py | 8 +++----- validphys2/src/validphys/tests/photon/test_alpha.py | 6 +++--- validphys2/src/validphys/tests/photon/test_compute.py | 2 +- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/n3fit/src/evolven3fit/eko_utils.py b/n3fit/src/evolven3fit/eko_utils.py index 54aba7160d..7f47d7f5c0 100644 --- a/n3fit/src/evolven3fit/eko_utils.py +++ b/n3fit/src/evolven3fit/eko_utils.py @@ -58,6 +58,10 @@ def construct_eko_cards( if "nf0" not in theory: theory["nf0"] = find_nf(mu0, theory, thresholds) + # eko needs a value for Qedref and for max nf alphas + theory["Qedref"] = theory["Qref"] + theory["MaxNfAs"] = theory["MaxNfPdf"] + # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory legacy_class = runcards.Legacy(theory, {}) theory_card = legacy_class.new_theory diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 2372b9446a..29114b28b8 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -38,7 +38,7 @@ class TheoryCard: TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory - MaxNfPdf: int = 5 # Used by pineko to define the thresholds + MaxNfPdf: int = 5 # Used by pineko and the photon module to define the thresholds # Fit theory parameters default nf0: int = 4 # Number of active flavors at the parametrization scale Q0 Q0: float = 1.65 # [GeV] Parametrization scale @@ -68,7 +68,12 @@ class TheoryCard: global_nx: int = None def __post_init__(self): - """Drop deprecated keys""" + """Drop deprecated keys and apply some checks""" + if self.Qedref is not None and self.QED != 0: + # Check that nobody is trying to use this with a wrong Qedref! + if self.Qedref != self.Qref: + raise ValueError(f"Trying to use {self.ID} with {self.Qedref} != {self.Qref}. This is not supported!") + for key in DEPRECATED_KEYS: object.__setattr__(self, key, None) diff --git a/validphys2/src/validphys/photon/alpha.py b/validphys2/src/validphys/photon/alpha.py index 574f12d67c..2e1d5d5931 100644 --- a/validphys2/src/validphys/photon/alpha.py +++ b/validphys2/src/validphys/photon/alpha.py @@ -20,11 +20,11 @@ def __init__(self, theory, q2max): self.thresh_c = self.theory["kcThr"] * self.theory["mc"] self.thresh_b = self.theory["kbThr"] * self.theory["mb"] self.thresh_t = self.theory["ktThr"] * self.theory["mt"] - if self.theory["MaxNfAs"] <= 5: + if self.theory["MaxNfPDF"] <= 5: self.thresh_t = np.inf - if self.theory["MaxNfAs"] <= 4: + if self.theory["MaxNfPDF"] <= 4: self.thresh_b = np.inf - if self.theory["MaxNfAs"] <= 3: + if self.theory["MaxNfPDF"] <= 3: self.thresh_c = np.inf if self.theory["ModEv"] == "TRN": diff --git a/validphys2/src/validphys/photon/compute.py b/validphys2/src/validphys/photon/compute.py index 094c317753..a8635b8569 100644 --- a/validphys2/src/validphys/photon/compute.py +++ b/validphys2/src/validphys/photon/compute.py @@ -55,11 +55,9 @@ def __init__(self, theoryid, lux_params, replicas): theory = theoryid.get_description() fiatlux_runcard = FIATLUX_DEFAULT - fiatlux_runcard["qed_running"] = bool(np.isclose(theory["Qedref"], theory["Qref"])) - # cast explicitly from np.bool_ to bool otherwise problems in dumping it - # TODO: for the time being, we trigger alphaem running if Qedref=Qref. - # This is going to be changed in favor of a bool em_running - # in the runcard + # TODO: for the time being, Qedref=Qref and so alphaem running will never trigger + # This may be changed in the future in favor of a bool em_running in the runcard + fiatlux_runcard["qed_running"] = False fiatlux_runcard["mproton"] = float(theory["MP"]) # precision on final integration of double integral diff --git a/validphys2/src/validphys/tests/photon/test_alpha.py b/validphys2/src/validphys/tests/photon/test_alpha.py index 7db54055b6..1fdfbb5615 100644 --- a/validphys2/src/validphys/tests/photon/test_alpha.py +++ b/validphys2/src/validphys/tests/photon/test_alpha.py @@ -34,7 +34,7 @@ def test_set_thresholds_alpha_em(): # test all the thresholds np.testing.assert_almost_equal(alpha.alpha_em_ref, theory["alphaqed"]) - np.testing.assert_almost_equal(alpha.thresh[(5, 3)], theory["Qedref"]) + np.testing.assert_almost_equal(alpha.thresh[(5, 3)], theory["Qref"]) np.testing.assert_almost_equal(alpha.thresh[(4, 3)], theory["mb"]) np.testing.assert_almost_equal(alpha.thresh[(4, 2)], constants.MTAU) np.testing.assert_almost_equal(alpha.thresh[(3, 2)], theory["mc"]) @@ -46,7 +46,7 @@ def test_set_thresholds_alpha_em(): np.testing.assert_almost_equal(alpha.alphaem_thresh[(5, 3)], theory["alphaqed"]) np.testing.assert_almost_equal( alpha.alphaem_thresh[(4, 3)], - alpha.alphaem_fixed_flavor(theory["mb"], alpha_ref, theory["Qedref"], 5, 3), + alpha.alphaem_fixed_flavor(theory["mb"], alpha_ref, theory["Qref"], 5, 3), ) np.testing.assert_almost_equal( alpha.alphaem_thresh[(4, 2)], @@ -102,7 +102,7 @@ def test_couplings_exa(): alphaem=theory["alphaqed"], scale=theory["Qref"], num_flavs_ref=None, - max_num_flavs=theory["MaxNfAs"], + max_num_flavs=theory["MaxNfPDF"], em_running=True, ) ) diff --git a/validphys2/src/validphys/tests/photon/test_compute.py b/validphys2/src/validphys/tests/photon/test_compute.py index 64e3cda263..610db42fcc 100644 --- a/validphys2/src/validphys/tests/photon/test_compute.py +++ b/validphys2/src/validphys/tests/photon/test_compute.py @@ -70,7 +70,7 @@ def test_photon(): # runcard fiatlux_default = FIATLUX_DEFAULT.copy() fiatlux_default['mproton'] = theory['MP'] - fiatlux_default["qed_running"] = bool(np.isclose(theory["Qedref"], theory["Qref"])) + fiatlux_default["qed_running"] = False fiatlux_default["q2_max"] = float(f2.q2_max) fiatlux_default["eps_base"] = fiatlux_runcard["eps_base"] From 749ea4228d01da99532e6f6cc469b5cb12131210 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 12 Apr 2024 20:30:54 +0200 Subject: [PATCH 45/60] remove theory 522 --- nnpdf_data/nnpdf_data/theory_cards/522.yaml | 48 ------------------- validphys2/src/validphys/photon/alpha.py | 6 +-- .../src/validphys/tests/photon/test_alpha.py | 2 +- 3 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 nnpdf_data/nnpdf_data/theory_cards/522.yaml diff --git a/nnpdf_data/nnpdf_data/theory_cards/522.yaml b/nnpdf_data/nnpdf_data/theory_cards/522.yaml deleted file mode 100644 index c8b2ed9942..0000000000 --- a/nnpdf_data/nnpdf_data/theory_cards/522.yaml +++ /dev/null @@ -1,48 +0,0 @@ -ID: 522 -PTO: 2 -FNS: FONLL-C -DAMP: 0 -IC: 1 -ModEv: EXA -XIR: 1.0 -XIF: 1.0 -NfFF: 5 -MaxNfAs: 5 -MaxNfPdf: 5 -Q0: 1.65 -alphas: 0.118 -Qref: 91.2 -QED: 2 -alphaqed: 0.007496252 -Qedref: 1.777 -SxRes: 0 -SxOrd: LL -HQ: POLE -mc: 1.51 -Qmc: 1.51 -kcThr: 1.0 -mb: 4.92 -Qmb: 4.92 -kbThr: 1.0 -mt: 172.5 -Qmt: 172.5 -ktThr: 1.0 -CKM: -- 0.97428 -- 0.2253 -- 0.00347 -- 0.2252 -- 0.97345 -- 0.041 -- 0.00862 -- 0.0403 -- 0.999152 -MZ: 91.1876 -MW: 80.398 -GF: 1.1663787e-05 -SIN2TW: 0.23126 -TMC: 1 -MP: 0.938 -Comments: NNPDF4.0 QED nnlo exact evolution fixed alphaem, photon generated at 100GeV -global_nx: 0 -EScaleVar: 1 diff --git a/validphys2/src/validphys/photon/alpha.py b/validphys2/src/validphys/photon/alpha.py index 2e1d5d5931..8c1aa8f494 100644 --- a/validphys2/src/validphys/photon/alpha.py +++ b/validphys2/src/validphys/photon/alpha.py @@ -20,11 +20,11 @@ def __init__(self, theory, q2max): self.thresh_c = self.theory["kcThr"] * self.theory["mc"] self.thresh_b = self.theory["kbThr"] * self.theory["mb"] self.thresh_t = self.theory["ktThr"] * self.theory["mt"] - if self.theory["MaxNfPDF"] <= 5: + if self.theory["MaxNfPdf"] <= 5: self.thresh_t = np.inf - if self.theory["MaxNfPDF"] <= 4: + if self.theory["MaxNfPdf"] <= 4: self.thresh_b = np.inf - if self.theory["MaxNfPDF"] <= 3: + if self.theory["MaxNfPdf"] <= 3: self.thresh_c = np.inf if self.theory["ModEv"] == "TRN": diff --git a/validphys2/src/validphys/tests/photon/test_alpha.py b/validphys2/src/validphys/tests/photon/test_alpha.py index 1fdfbb5615..0d5071f53b 100644 --- a/validphys2/src/validphys/tests/photon/test_alpha.py +++ b/validphys2/src/validphys/tests/photon/test_alpha.py @@ -102,7 +102,7 @@ def test_couplings_exa(): alphaem=theory["alphaqed"], scale=theory["Qref"], num_flavs_ref=None, - max_num_flavs=theory["MaxNfPDF"], + max_num_flavs=theory["MaxNfPdf"], em_running=True, ) ) From 2526a637159ccbba5ef7c9a43458228986351f95 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Sat, 13 Apr 2024 09:57:42 +0200 Subject: [PATCH 46/60] raise exception only for new theories --- nnpdf_data/nnpdf_data/theory.py | 17 ++++++++++++++++- .../src/validphys/tests/photon/test_alpha.py | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 29114b28b8..6cf0626856 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -4,9 +4,16 @@ """ import dataclasses +import logging DEPRECATED_KEYS = ["MaxNfAs", "SxRes", "SxOrd" "EScaleVar", "Qedref", "global_nx"] +log = logging.getLogger(__name__) + + +class TheoryCardError(Exception): + pass + @dataclasses.dataclass(frozen=True) class TheoryCard: @@ -72,10 +79,18 @@ def __post_init__(self): if self.Qedref is not None and self.QED != 0: # Check that nobody is trying to use this with a wrong Qedref! if self.Qedref != self.Qref: - raise ValueError(f"Trying to use {self.ID} with {self.Qedref} != {self.Qref}. This is not supported!") + self._raise_or_warn( + f"Trying to use {self.ID} with {self.Qedref} != {self.Qref}. This is not supported!" + ) for key in DEPRECATED_KEYS: object.__setattr__(self, key, None) + def _raise_or_warn(self, msg): + """Raise an error for new theories and a warning for old ones""" + if self.ID >= 600: + raise TheoryCardError(msg) + log.warning(msg) + def asdict(self): return dataclasses.asdict(self) diff --git a/validphys2/src/validphys/tests/photon/test_alpha.py b/validphys2/src/validphys/tests/photon/test_alpha.py index 0d5071f53b..118ee2499b 100644 --- a/validphys2/src/validphys/tests/photon/test_alpha.py +++ b/validphys2/src/validphys/tests/photon/test_alpha.py @@ -138,7 +138,7 @@ def test_couplings_exa(): np.testing.assert_allclose( alpha.alpha_em(q), eko_alpha.a_em(q**2) * 4 * np.pi, rtol=5e-6 ) - for nf in range(3, theory["MaxNfAs"]): + for nf in range(3, theory["MaxNfPdf"]): np.testing.assert_allclose( alpha.alphaem_thresh[(nf, 2 if nf == 3 else 3)], eko_alpha.a_em(mass_list[nf - 3] ** 2, nf) * 4 * np.pi, From b8e80d5276f896882ff8bbcaa305f9ec6ea8e748 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Sat, 13 Apr 2024 15:38:48 +0200 Subject: [PATCH 47/60] flip qed running, pre-commit touched files --- validphys2/src/validphys/photon/alpha.py | 9 ++++++--- validphys2/src/validphys/photon/compute.py | 5 +++-- validphys2/src/validphys/tests/photon/test_compute.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/validphys2/src/validphys/photon/alpha.py b/validphys2/src/validphys/photon/alpha.py index 8c1aa8f494..f05d770c08 100644 --- a/validphys2/src/validphys/photon/alpha.py +++ b/validphys2/src/validphys/photon/alpha.py @@ -1,4 +1,5 @@ """Module that implements the alpha running""" + import numpy as np from scipy.integrate import solve_ivp @@ -10,6 +11,7 @@ class Alpha: """Class that solves the RGE for alpha_qed""" + def __init__(self, theory, q2max): self.theory = theory self.alpha_em_ref = theory["alphaqed"] @@ -145,7 +147,7 @@ def alphaem_fixed_flavor_exa(self, q, alphaem_ref, qref, nf, nl): # at LO in QED the TRN solution is exact if self.qed_order == 1: return self.alphaem_fixed_flavor_trn(q, alphaem_ref, qref, nf, nl) - + u = 2 * np.log(q / qref) # solve RGE @@ -214,7 +216,7 @@ def compute_betas(self, regions): for nf, nl in regions: betas_qed[(nf, nl)] = [ beta.beta_qed_aem2(nf, nl) / (4 * np.pi), - beta.beta_qed_aem3(nf, nl) / (4 * np.pi) ** 2 if self.theory['QED'] == 2 else 0., + beta.beta_qed_aem3(nf, nl) / (4 * np.pi) ** 2 if self.theory['QED'] == 2 else 0.0, ] return betas_qed @@ -249,6 +251,7 @@ def find_region(self, q): def _rge(_t, alpha_t, beta_qed_vec): """RGEs for the running of alphaem""" rge_qed = -(alpha_t**2) * ( - beta_qed_vec[0] + np.sum([alpha_t ** (k + 1) * beta for k, beta in enumerate(beta_qed_vec[1:])]) + beta_qed_vec[0] + + np.sum([alpha_t ** (k + 1) * beta for k, beta in enumerate(beta_qed_vec[1:])]) ) return rge_qed diff --git a/validphys2/src/validphys/photon/compute.py b/validphys2/src/validphys/photon/compute.py index a8635b8569..265a698d2c 100644 --- a/validphys2/src/validphys/photon/compute.py +++ b/validphys2/src/validphys/photon/compute.py @@ -1,4 +1,5 @@ """Module that calls fiatlux to add the photon PDF.""" + import logging import tempfile @@ -55,9 +56,9 @@ def __init__(self, theoryid, lux_params, replicas): theory = theoryid.get_description() fiatlux_runcard = FIATLUX_DEFAULT - # TODO: for the time being, Qedref=Qref and so alphaem running will never trigger + # TODO: for the time being, Qedref=Qref and so alphaem running will always trigger # This may be changed in the future in favor of a bool em_running in the runcard - fiatlux_runcard["qed_running"] = False + fiatlux_runcard["qed_running"] = True fiatlux_runcard["mproton"] = float(theory["MP"]) # precision on final integration of double integral diff --git a/validphys2/src/validphys/tests/photon/test_compute.py b/validphys2/src/validphys/tests/photon/test_compute.py index 610db42fcc..dd846bdcf2 100644 --- a/validphys2/src/validphys/tests/photon/test_compute.py +++ b/validphys2/src/validphys/tests/photon/test_compute.py @@ -10,8 +10,8 @@ from validphys.core import PDF as PDFset from validphys.loader import FallbackLoader from validphys.photon import structure_functions as sf -from validphys.photon.compute import FIATLUX_DEFAULT, Photon from validphys.photon.alpha import Alpha +from validphys.photon.compute import FIATLUX_DEFAULT, Photon from ..conftest import PDF, THEORY_QED From e0d8e769a2bc0399ca1dd5341da555da0ce45395 Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Mon, 15 Apr 2024 09:36:37 +0200 Subject: [PATCH 48/60] fix n3lo parameters --- nnpdf_data/nnpdf_data/theory.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 6cf0626856..3436426c0b 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -59,14 +59,17 @@ class TheoryCard: DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b # N3LO parameters - n3lo_cf_variation: list = dataclasses.field( + n3lo_ad_variation: list = dataclasses.field( default_factory=lambda: 7 * [0] - ) # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound + ) # N3LO anomalous dimension variations + n3lo_cf_variation: int = ( + 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound + ) use_fhmruvv: bool = ( - False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. + False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. ) - ###### Keys for compatibility with old NNPDF theories, their values will be dropped inmediately after reading to avoid problems - ###### they will be set to ``None`` inmediately after loading the theory + ###### Keys for compatibility with old NNPDF theories, their values will be dropped immediately after reading to avoid problems + ###### they will be set to ``None`` immediately after loading the theory MaxNfAs: int = None SxRes: int = None SxOrd: str = None From 1aaf91aeee9df1e78292449b263cc59f9549a6cc Mon Sep 17 00:00:00 2001 From: RoyStegeman Date: Mon, 15 Apr 2024 15:37:12 +0100 Subject: [PATCH 49/60] add theorycard 41_000_000 --- .../nnpdf_data/theory_cards/41000000.yaml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 nnpdf_data/nnpdf_data/theory_cards/41000000.yaml diff --git a/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml b/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml new file mode 100644 index 0000000000..a22f920575 --- /dev/null +++ b/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml @@ -0,0 +1,37 @@ +ID: 41_000_000 +Comments: NNPDF4.1 baseline +PTO: 2 +FNS: FONLL-C +DAMP: 0 +IC: 1 +ModEv: EXA +XIR: 1.0 +XIF: 1.0 +NfFF: 5 +QED: 0 +HQ: POLE +mc: 1.51 +Qmc: 1.51 +kcThr: 1.0 +mb: 4.92 +Qmb: 4.92 +kbThr: 1.0 +mt: 172.5 +Qmt: 172.5 +ktThr: 1.0 +CKM: +- 0.97428 +- 0.2253 +- 0.00347 +- 0.2252 +- 0.97345 +- 0.041 +- 0.00862 +- 0.0403 +- 0.999152 +MZ: 91.1876 +MW: 80.398 +GF: 1.1663787e-05 +SIN2TW: 0.23126 +TMC: 1 +MP: 0.938 From dbabec89c717d6696746a3fd3f8c221994beb9b1 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 18 Apr 2024 11:17:14 +0200 Subject: [PATCH 50/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Felix Hekhorn --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 3436426c0b..ed921ef1b5 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -27,7 +27,7 @@ class TheoryCard: XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed - HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko). + HQ: str = "POLE" # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). mc: float # [GeV] charm mass Qmc: float # [GeV] MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm From 9cb8a0697f5680fcefb3c79f799e7a4f37a99d4f Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 18 Apr 2024 11:17:41 +0200 Subject: [PATCH 51/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Felix Hekhorn --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index ed921ef1b5..eab0794895 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -19,7 +19,7 @@ class TheoryCardError(Exception): class TheoryCard: ID: int # ID number of the theory PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) - FNS: str # Flavor number scheme (i.e. FONLL-C) + FNS: str # Flavor number scheme (e.g. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed ModEv: str # DGLAP evolution solution method (EXA or TRN) From 648075531550ec40a72551be2c320f17566f3f17 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Thu, 18 Apr 2024 11:17:53 +0200 Subject: [PATCH 52/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Felix Hekhorn --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index eab0794895..6dd98593a1 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -22,7 +22,7 @@ class TheoryCard: FNS: str # Flavor number scheme (e.g. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed - ModEv: str # DGLAP evolution solution method (EXA or TRN) + ModEv: str # DGLAP evolution solution method (e.g. EXA or TRN) XIR: float # Renormalization scale over the hard scattering scale ratio XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes From f4f14e57bab9d5d1021ea15a27547084163424f3 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 18 Apr 2024 11:24:06 +0200 Subject: [PATCH 53/60] Correct QED description --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 6dd98593a1..73184219f6 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -26,7 +26,7 @@ class TheoryCard: XIR: float # Renormalization scale over the hard scattering scale ratio XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes - QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed + QED: int # Max order of alpha_qed in the splitting functions HQ: str = "POLE" # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). mc: float # [GeV] charm mass Qmc: float # [GeV] MSbar mass reference scale of the charm From a40b954d52ce7d66010915e6c78c3a12d109e5e2 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 18 Apr 2024 11:30:18 +0200 Subject: [PATCH 54/60] Move HQ with default at the bottom --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 73184219f6..012a715cde 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -27,7 +27,6 @@ class TheoryCard: XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes QED: int # Max order of alpha_qed in the splitting functions - HQ: str = "POLE" # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). mc: float # [GeV] charm mass Qmc: float # [GeV] MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm @@ -54,6 +53,7 @@ class TheoryCard: alphas: float = 0.118 # Value of alpha_s at the scale Qref alphaqed: float = 0.007496252 # Values of alpha QED at the scale Qref # Evolution parameters + HQ: str = "POLE" # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). IterEv: int = None # iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c From 73a7db6261e67849a22803c1bcdc5a24f8273993 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Thu, 18 Apr 2024 11:34:35 +0200 Subject: [PATCH 55/60] Add comment on CKM matrix --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 012a715cde..9d4d23248c 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -36,7 +36,7 @@ class TheoryCard: mt: float # # [GeV] top mass Qmt: float # [GeV] MSbar mass reference scale of the top ktThr: float # Threshold ratio of the top - CKM: list[float] # CKM matrix elements + CKM: list[float] # CKM matrix elements (running on the columns first, i.e. CKM_11 is CKM[0] and CKM_12 is CKM[1] and so on) MZ: float # [GeV] Mass of Z MW: float # [GeV] Mass of W GF: float # Fermi constant From fb83970d860dcc62c92dc84261d932103249f31b Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Mon, 22 Apr 2024 14:35:55 +0200 Subject: [PATCH 56/60] Update nnpdf_data/nnpdf_data/theory.py Co-authored-by: Felix Hekhorn --- nnpdf_data/nnpdf_data/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 9d4d23248c..8115eda35d 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -26,7 +26,7 @@ class TheoryCard: XIR: float # Renormalization scale over the hard scattering scale ratio XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes - QED: int # Max order of alpha_qed in the splitting functions + QED: int # Max order of alpha_qed in the evolution mc: float # [GeV] charm mass Qmc: float # [GeV] MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm From be362831d9bdb289e540d51b6feacf8cfe49a6cb Mon Sep 17 00:00:00 2001 From: juacrumar Date: Wed, 24 Apr 2024 14:12:16 +0200 Subject: [PATCH 57/60] add annotations and hints and a default for IterEv --- nnpdf_data/nnpdf_data/theory.py | 96 +++++++++++++------ nnpdf_data/nnpdf_data/utils.py | 4 +- .../src/validphys/tests/test_theorydbutils.py | 25 +++++ 3 files changed, 95 insertions(+), 30 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index 8115eda35d..deda488686 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -4,7 +4,11 @@ """ import dataclasses +from functools import lru_cache import logging +from typing import Literal, Optional + +from .utils import parse_yaml_inp DEPRECATED_KEYS = ["MaxNfAs", "SxRes", "SxOrd" "EScaleVar", "Qedref", "global_nx"] @@ -15,14 +19,18 @@ class TheoryCardError(Exception): pass +class TheoryNotFoundInDatabase(FileNotFoundError): + pass + + @dataclasses.dataclass(frozen=True) class TheoryCard: ID: int # ID number of the theory - PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) + PTO: Literal[0, 1, 2, 3] # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...) FNS: str # Flavor number scheme (e.g. FONLL-C) DAMP: int # Whether a damping function is applied or not for FONLL IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed - ModEv: str # DGLAP evolution solution method (e.g. EXA or TRN) + ModEv: Literal["EXA", "TRN"] # DGLAP evolution solution method (e.g. EXA or TRN) XIR: float # Renormalization scale over the hard scattering scale ratio XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes @@ -36,7 +44,9 @@ class TheoryCard: mt: float # # [GeV] top mass Qmt: float # [GeV] MSbar mass reference scale of the top ktThr: float # Threshold ratio of the top - CKM: list[float] # CKM matrix elements (running on the columns first, i.e. CKM_11 is CKM[0] and CKM_12 is CKM[1] and so on) + CKM: list[ + float + ] # CKM matrix elements (running on the columns first, i.e. CKM_11 is CKM[0] and CKM_12 is CKM[1] and so on) MZ: float # [GeV] Mass of Z MW: float # [GeV] Mass of W GF: float # Fermi constant @@ -44,41 +54,52 @@ class TheoryCard: TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory - MaxNfPdf: int = 5 # Used by pineko and the photon module to define the thresholds + MaxNfPdf: Optional[int] = 5 # Used by pineko and the photon module to define the thresholds # Fit theory parameters default - nf0: int = 4 # Number of active flavors at the parametrization scale Q0 - Q0: float = 1.65 # [GeV] Parametrization scale - nfref: int = 5 # Number of active flavors at Qref - Qref: float = 91.2 # [GeV] Reference scale for alphas and alphaqed - alphas: float = 0.118 # Value of alpha_s at the scale Qref - alphaqed: float = 0.007496252 # Values of alpha QED at the scale Qref + nf0: Optional[int] = 4 # Number of active flavors at the parametrization scale Q0 + Q0: Optional[float] = 1.65 # [GeV] Parametrization scale + nfref: Optional[int] = 5 # Number of active flavors at Qref + Qref: Optional[float] = 91.2 # [GeV] Reference scale for alphas and alphaqed + alphas: Optional[float] = 0.118 # Value of alpha_s at the scale Qref + alphaqed: Optional[float] = 0.007496252 # Values of alpha QED at the scale Qref # Evolution parameters - HQ: str = "POLE" # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). - IterEv: int = None # iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ModSV: str = None # Scale variations method in EKO (expanded or exponentiated) - DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c - DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b + HQ: Optional[Literal["POLE", "MSBAR"]] = ( + "POLE" # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). + ) + IterEv: Optional[int] = ( + None # iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA + ) + ModSV: Optional[str] = None # Scale variations method in EKO (expanded or exponentiated) + DAMPPOWERc: Optional[int] = None # Power of the damping factor in FONLL for the c + DAMPPOWERb: Optional[int] = None # Power of the damping factor in FONLL for the b # N3LO parameters - n3lo_ad_variation: list = dataclasses.field( + n3lo_ad_variation: Optional[list] = dataclasses.field( default_factory=lambda: 7 * [0] ) # N3LO anomalous dimension variations - n3lo_cf_variation: int = ( - 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound + n3lo_cf_variation: Optional[int] = ( + 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound ) - use_fhmruvv: bool = ( - False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. + use_fhmruvv: Optional[bool] = ( + False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. ) ###### Keys for compatibility with old NNPDF theories, their values will be dropped immediately after reading to avoid problems ###### they will be set to ``None`` immediately after loading the theory - MaxNfAs: int = None - SxRes: int = None - SxOrd: str = None - EScaleVar: int = None - Qedref: float = None - global_nx: int = None + MaxNfAs: Optional[int] = None + SxRes: Optional[int] = None + SxOrd: Optional[str] = None + EScaleVar: Optional[int] = None + Qedref: Optional[float] = None + global_nx: Optional[int] = None def __post_init__(self): - """Drop deprecated keys and apply some checks""" + self._set_defaults() + self._apply_checks() + + for key in DEPRECATED_KEYS: + object.__setattr__(self, key, None) + + def _apply_checks(self): + """Apply complex checks to the input keys after parsing is complete""" if self.Qedref is not None and self.QED != 0: # Check that nobody is trying to use this with a wrong Qedref! if self.Qedref != self.Qref: @@ -86,8 +107,15 @@ def __post_init__(self): f"Trying to use {self.ID} with {self.Qedref} != {self.Qref}. This is not supported!" ) - for key in DEPRECATED_KEYS: - object.__setattr__(self, key, None) + def _set_defaults(self): + """Function to be called by __post_init__ to set defaults that might depends + on other variables""" + if self.ModEv == "EXA" and self.IterEv is None: + object.__setattr__(self, "IterEv", 60) + if self.ModEv == "TRN" and self.IterEv is not None: + raise TheoryCardError( + f"IterEv should not be given when ModEv=TRN, received {self.IterEv}" + ) def _raise_or_warn(self, msg): """Raise an error for new theories and a warning for old ones""" @@ -97,3 +125,13 @@ def _raise_or_warn(self, msg): def asdict(self): return dataclasses.asdict(self) + + +@lru_cache +def parse_theory_card(theory_card): + """Read the theory card using validobj parsing + Returns the theory as a dictionary + """ + if theory_card.exists(): + return parse_yaml_inp(theory_card, TheoryCard) + raise TheoryNotFoundInDatabase(f"Theory card {theory_card} not found") diff --git a/nnpdf_data/nnpdf_data/utils.py b/nnpdf_data/nnpdf_data/utils.py index 0803ba34e8..33987134bd 100644 --- a/nnpdf_data/nnpdf_data/utils.py +++ b/nnpdf_data/nnpdf_data/utils.py @@ -22,7 +22,9 @@ def parse_yaml_inp(input_yaml, spec): return parse_input(inp, spec) except ValidationError as e: current_exc = e - current_inp = inp + # In order to provide a more complete error information, use round_trip_load + # to read the .yaml file again (insetad of using the CLoader) + current_inp = yaml.round_trip_load(input_yaml.open("r", encoding="utf-8")) error_text_lines = [] while current_exc: if hasattr(current_exc, 'wrong_field'): diff --git a/validphys2/src/validphys/tests/test_theorydbutils.py b/validphys2/src/validphys/tests/test_theorydbutils.py index c812508445..a72d86900d 100644 --- a/validphys2/src/validphys/tests/test_theorydbutils.py +++ b/validphys2/src/validphys/tests/test_theorydbutils.py @@ -1,4 +1,6 @@ import pytest +from ruamel import yaml +from validobj import ValidationError from nnpdf_data.theorydbutils import TheoryNotFoundInDatabase, fetch_all, fetch_theory from validphys.api import API @@ -25,3 +27,26 @@ def test_vp_theoryinfo_tables(): assert all_tables.loc[53, 'Comments'] == 'NNPDF3.1 NNLO central' tb53 = API.theory_info_table(theory_db_id=53) assert tb53.loc['Comments'].iloc[0] == 'NNPDF3.1 NNLO central' + + +def _dump_and_check_error(tdict, tmp, bad_number=999): + """Dump theory dict to a file and load expecting an error""" + tdict["ID"] = bad_number + ofile = tmp / f"{bad_number}.yaml" + yaml.dump(tdict, ofile.open("w")) + with pytest.raises(ValidationError): + fetch_theory(tmp, bad_number) + + +def test_fetch_with_errors(tmp): + """Test some of the errors that theories can raise""" + # Get a good theory and copy it before doing evil to it + th_good = fetch_theory(DBPATH, 700) + # Wrong PTO + bad_pto = dict(th_good) + bad_pto["PTO"] = 7 + _dump_and_check_error(bad_pto, tmp) + # Wrong ModEv + bad_ev = dict(th_good) + bad_ev["ModEv"] = "WRONG" + _dump_and_check_error(bad_ev, tmp) From 490ee74d23a397316879bdcb735f807f34e40a5c Mon Sep 17 00:00:00 2001 From: juacrumar Date: Wed, 24 Apr 2024 14:20:43 +0200 Subject: [PATCH 58/60] utilize the theory iterations by default ; fail inmediately with inconsistent options --- n3fit/src/evolven3fit/eko_utils.py | 56 ++++++++++------------- n3fit/src/n3fit/scripts/evolven3fit.py | 14 ++++-- n3fit/src/n3fit/tests/conftest.py | 13 ++++++ n3fit/src/n3fit/tests/test_evolven3fit.py | 7 ++- 4 files changed, 51 insertions(+), 39 deletions(-) diff --git a/n3fit/src/evolven3fit/eko_utils.py b/n3fit/src/evolven3fit/eko_utils.py index 7f47d7f5c0..ec32e2ff68 100644 --- a/n3fit/src/evolven3fit/eko_utils.py +++ b/n3fit/src/evolven3fit/eko_utils.py @@ -7,7 +7,6 @@ from eko.io import runcards from eko.matchings import Atlas, nf_default from eko.quantities.heavy_quarks import MatchingScales -from validphys.loader import Loader from . import utils @@ -22,7 +21,6 @@ } EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA = { - "ev_op_iterations": 30, "ev_op_max_order": (1, 0), "evolution_method": "iterate-exact", "inversion_method": "exact", @@ -33,7 +31,7 @@ def construct_eko_cards( - theoryID, + nnpdf_theory, q_fin, q_points, x_grid, @@ -43,13 +41,13 @@ def construct_eko_cards( ): """ Return the theory and operator cards used to construct the eko. - theoryID is the ID of the theory for which we are computing the theory and operator card. + nnpdf_theory is a NNPDF theory card for which we are computing the operator card and eko q_fin is the final point of the q grid while q_points is the number of points of the grid. x_grid is the x grid to be used. op_card_dict and theory_card_dict are optional updates that can be provided respectively to the operator card and to the theory card. """ - theory, thresholds = load_theory(theoryID, theory_card_dict) + theory, thresholds = load_theory(nnpdf_theory, theory_card_dict) # if is eko_photon then mu0 = q_gamma mu0 = theory["Q0"] @@ -62,7 +60,7 @@ def construct_eko_cards( theory["Qedref"] = theory["Qref"] theory["MaxNfAs"] = theory["MaxNfPdf"] - # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory + # The Legacy function is able to construct a theory card for eko starting from a NNPDF theory legacy_class = runcards.Legacy(theory, {}) theory_card = legacy_class.new_theory @@ -111,7 +109,7 @@ def construct_eko_cards( def construct_eko_photon_cards( - theoryID, + nnpdf_theory, q_fin, x_grid, q_gamma, @@ -120,13 +118,13 @@ def construct_eko_photon_cards( ): """ Return the theory and operator cards used to construct the eko_photon. - theoryID is the ID of the theory for which we are computing the theory and operator card. + nnpdf_theory is a NNPDF theory card for which we are computing the operator card and eko q_fin is the final point of the q grid while q_points is the number of points of the grid. x_grid is the x grid to be used. op_card_dict and theory_card_dict are optional updates that can be provided respectively to the operator card and to the theory card. """ - theory, thresholds = load_theory(theoryID, theory_card_dict) + theory, thresholds = load_theory(nnpdf_theory, theory_card_dict) # if is eko_photon then mu0 = q_gamma mu0 = q_gamma @@ -135,7 +133,7 @@ def construct_eko_photon_cards( if "nf0" not in theory: theory["nf0"] = find_nf(mu0, theory, thresholds) - # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory + # The Legacy function is able to construct a theory card for eko starting from a NNPDF theory legacy_class = runcards.Legacy(theory, {}) theory_card = legacy_class.new_theory @@ -152,12 +150,12 @@ def construct_eko_photon_cards( return theory_card, op_card -def load_theory(theoryID, theory_card_dict): +def load_theory(nnpdf_theory, theory_card_dict): """loads and returns the theory dictionary and the thresholds""" if theory_card_dict is None: theory_card_dict = {} # theory_card construction - theory = Loader().check_theoryID(theoryID).get_description() + theory = dict(nnpdf_theory) theory.pop("FNS") theory.update(theory_card_dict) @@ -178,7 +176,9 @@ def load_theory(theoryID, theory_card_dict): def build_opcard(op_card_dict, theory, x_grid, mu0, mugrid): - """builds the opcard""" + """Build the operator card. + The user provided options should be given as part of ``op_card_dict`` + """ if op_card_dict is None: op_card_dict = {} @@ -187,12 +187,17 @@ def build_opcard(op_card_dict, theory, x_grid, mu0, mugrid): op_card.update({"mu0": mu0, "mugrid": mugrid}) op_card["xgrid"] = x_grid - # Specific defaults for evolven3fit evolution - if theory["ModEv"] == "TRN": - op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN) - if theory["ModEv"] == "EXA": - op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA) - # User can still change the configs via op_card_dict + + # Specify the evolution options and defaults differently from TRN / EXA + configs = op_card["configs"] + if theory.get("ModEv") == "TRN": + configs.update(EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN) + elif theory.get("ModEv") == "EXA": + # Set the default from the theory card unless it was given in the input + op_card_dict.setdefault("ev_op_iterations", theory.get("IterEv")) + + configs.update(EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA) + configs["ev_op_iterations"] = op_card_dict["ev_op_iterations"] # Note that every entry that is not a dictionary should not be # touched by the user and indeed an user cannot touch them @@ -202,19 +207,7 @@ def build_opcard(op_card_dict, theory, x_grid, mu0, mugrid): elif key in op_card_dict: _logger.warning("Entry %s is not a dictionary and will be ignored", key) - # if no -e was given, take ev_op_iterations from EVOLVEN3FIT_CONFIGS_DEFAULTS_{TRN,EXA} - if op_card['configs']['ev_op_iterations'] is None: - if theory["ModEv"] == "TRN": - op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN[ - "ev_op_iterations" - ] - if theory["ModEv"] == "EXA": - op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA[ - "ev_op_iterations" - ] - op_card = runcards.OperatorCard.from_dict(op_card) - return op_card @@ -228,4 +221,3 @@ def find_nf(mu, theory, thresholds): nf = 5 else: nf = 6 - return nf diff --git a/n3fit/src/n3fit/scripts/evolven3fit.py b/n3fit/src/n3fit/scripts/evolven3fit.py index d0509bee5e..c1d6c0a143 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit.py +++ b/n3fit/src/n3fit/scripts/evolven3fit.py @@ -1,6 +1,7 @@ """ This module contains the CLI for evolven3fit """ + from argparse import ArgumentParser import logging import pathlib @@ -11,6 +12,7 @@ from eko.runner.managed import solve from n3fit.io.writer import XGRID +from validphys.loader import FallbackLoader _logger = logging.getLogger(__name__) @@ -117,7 +119,7 @@ def main(): "--ev-op-iterations", type=int, default=None, - help="ev_op_iterations for the EXA theory", + help="ev_op_iterations for the EXA theory. Overrides the settings given in the theory card.", ) parser.add_argument( "--use-fhmruvv", @@ -151,6 +153,12 @@ def main(): args.force, ) else: + # If we are in the business of producing an eko, do some checks before starting: + # 1. load the nnpdf theory early to check for inconsistent options and theory problems + nnpdf_theory = FallbackLoader().check_theoryID(args.theoryID).get_description() + if nnpdf_theory.get("ModEv") == "TRN" and args.ev_op_iterations is not None: + raise ValueError("ev_op_iterations is not accepted with ModEv=TRN solution") + stdout_log = logging.StreamHandler(sys.stdout) stdout_log.setLevel(evolve.LOGGING_SETTINGS["level"]) stdout_log.setFormatter(evolve.LOGGING_SETTINGS["formatter"]) @@ -173,7 +181,7 @@ def main(): x_grid = np.geomspace(args.x_grid_ini, 1.0, args.x_grid_points) if args.actions == "produce_eko": tcard, opcard = eko_utils.construct_eko_cards( - args.theoryID, + nnpdf_theory, args.q_fin, args.q_points, x_grid, @@ -183,7 +191,7 @@ def main(): ) elif args.actions == "produce_eko_photon": tcard, opcard = eko_utils.construct_eko_photon_cards( - args.theoryID, args.q_fin, x_grid, args.q_gamma, op_card_info, theory_card_info + nnpdf_theory, args.q_fin, x_grid, args.q_gamma, op_card_info, theory_card_info ) solve(tcard, opcard, args.dump) diff --git a/n3fit/src/n3fit/tests/conftest.py b/n3fit/src/n3fit/tests/conftest.py index c2acb69852..91489169b1 100644 --- a/n3fit/src/n3fit/tests/conftest.py +++ b/n3fit/src/n3fit/tests/conftest.py @@ -1,9 +1,22 @@ """ Add markers for pytest """ + import sys + import pytest +from validphys.loader import FallbackLoader + +THEORYID = 399 + + +@pytest.fixture(scope='module') +def nnpdf_theory_card(): + """Return a theory card already loaded as a dictionary""" + th = FallbackLoader().check_theoryID(THEORYID) + return th.get_description() + def pytest_runtest_setup(item): ALL = {"darwin", "linux"} diff --git a/n3fit/src/n3fit/tests/test_evolven3fit.py b/n3fit/src/n3fit/tests/test_evolven3fit.py index 955fec3071..52799829f6 100644 --- a/n3fit/src/n3fit/tests/test_evolven3fit.py +++ b/n3fit/src/n3fit/tests/test_evolven3fit.py @@ -118,16 +118,15 @@ def test_utils(): assert ID == 162 -def test_eko_utils(tmp_path): +def test_eko_utils(tmp_path, nnpdf_theory_card): # Testing construct eko cards - theoryID = 162 q_fin = 100 q_points = 5 x_grid = [1.0e-3, 0.1, 1.0] pto = 2 comments = "Test" t_card, op_card = eko_utils.construct_eko_cards( - theoryID, + nnpdf_theory_card, q_fin, q_points, x_grid, @@ -140,7 +139,7 @@ def test_eko_utils(tmp_path): t_card_dict["order"][0] == pto + 1 ) # This is due to a different convention in eko orders due to QED np.testing.assert_allclose(op_card_dict["xgrid"], x_grid) - # In theory 162 the charm threshold is at 1.51 + # In theory 399 the charm threshold is at 1.51 # and we should find two entries, one for nf=3 and another one for nf=4 np.testing.assert_allclose(op_card_dict["mugrid"][0], (1.51, 3)) np.testing.assert_allclose(op_card_dict["mugrid"][1], (1.51, 4)) From 1d894af1412bb0b3c35be09047db60ff194822fe Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 25 Apr 2024 08:51:48 +0200 Subject: [PATCH 59/60] add a default-depending-on-Q0 for nf0 --- n3fit/src/evolven3fit/eko_utils.py | 26 ++------- nnpdf_data/nnpdf_data/theory.py | 54 +++++++++++-------- .../nnpdf_data/theory_cards/41000000.yaml | 2 + 3 files changed, 36 insertions(+), 46 deletions(-) diff --git a/n3fit/src/evolven3fit/eko_utils.py b/n3fit/src/evolven3fit/eko_utils.py index ec32e2ff68..955ecacd9a 100644 --- a/n3fit/src/evolven3fit/eko_utils.py +++ b/n3fit/src/evolven3fit/eko_utils.py @@ -52,10 +52,6 @@ def construct_eko_cards( # if is eko_photon then mu0 = q_gamma mu0 = theory["Q0"] - # Set nf_0 according to the fitting scale unless set explicitly - if "nf0" not in theory: - theory["nf0"] = find_nf(mu0, theory, thresholds) - # eko needs a value for Qedref and for max nf alphas theory["Qedref"] = theory["Qref"] theory["MaxNfAs"] = theory["MaxNfPdf"] @@ -124,22 +120,18 @@ def construct_eko_photon_cards( op_card_dict and theory_card_dict are optional updates that can be provided respectively to the operator card and to the theory card. """ - theory, thresholds = load_theory(nnpdf_theory, theory_card_dict) + theory, _ = load_theory(nnpdf_theory, theory_card_dict) # if is eko_photon then mu0 = q_gamma mu0 = q_gamma - # Set nf_0 according to mu0 unless set explicitly - if "nf0" not in theory: - theory["nf0"] = find_nf(mu0, theory, thresholds) - # The Legacy function is able to construct a theory card for eko starting from a NNPDF theory legacy_class = runcards.Legacy(theory, {}) theory_card = legacy_class.new_theory + # The photon needs to be evolved down to Q0 q_fin = theory["Q0"] - - nf_fin = find_nf(q_fin, theory, thresholds) + nf_fin = theory["nf0"] # construct mugrid mugrid = [(q_fin, nf_fin)] @@ -209,15 +201,3 @@ def build_opcard(op_card_dict, theory, x_grid, mu0, mugrid): op_card = runcards.OperatorCard.from_dict(op_card) return op_card - - -def find_nf(mu, theory, thresholds): - """compute nf for a given mu""" - if mu < theory["mc"] * thresholds["c"]: - nf = 3 - elif mu < theory["mb"] * thresholds["b"]: - nf = 4 - elif mu < theory["mt"] * thresholds["t"]: - nf = 5 - else: - nf = 6 diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index deda488686..a17a3d7128 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -35,6 +35,7 @@ class TheoryCard: XIF: float # Factorization scale over the hard scattering scale ratio NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes QED: int # Max order of alpha_qed in the evolution + Q0: float # [GeV] Parametrization scale for the fit (and the photon) mc: float # [GeV] charm mass Qmc: float # [GeV] MSbar mass reference scale of the charm kcThr: float # Threshold ratio of the charm @@ -44,9 +45,8 @@ class TheoryCard: mt: float # # [GeV] top mass Qmt: float # [GeV] MSbar mass reference scale of the top ktThr: float # Threshold ratio of the top - CKM: list[ - float - ] # CKM matrix elements (running on the columns first, i.e. CKM_11 is CKM[0] and CKM_12 is CKM[1] and so on) + # CKM matrix elements (running on the columns first, i.e. CKM_11 is CKM[0] and CKM_12 is CKM[1] and so on) + CKM: list[float] MZ: float # [GeV] Mass of Z MW: float # [GeV] Mass of W GF: float # Fermi constant @@ -55,33 +55,28 @@ class TheoryCard: MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory MaxNfPdf: Optional[int] = 5 # Used by pineko and the photon module to define the thresholds - # Fit theory parameters default - nf0: Optional[int] = 4 # Number of active flavors at the parametrization scale Q0 - Q0: Optional[float] = 1.65 # [GeV] Parametrization scale + ## Fit theory parameters default + # Number of active flavors at the parametrization scale Q0, its default depends on Q0 + nf0: Optional[int] = None nfref: Optional[int] = 5 # Number of active flavors at Qref Qref: Optional[float] = 91.2 # [GeV] Reference scale for alphas and alphaqed alphas: Optional[float] = 0.118 # Value of alpha_s at the scale Qref alphaqed: Optional[float] = 0.007496252 # Values of alpha QED at the scale Qref - # Evolution parameters - HQ: Optional[Literal["POLE", "MSBAR"]] = ( - "POLE" # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). - ) - IterEv: Optional[int] = ( - None # iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA - ) + ## Evolution parameters + # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). + HQ: Optional[Literal["POLE", "MSBAR"]] = "POLE" + # iterations for the evolution of the PDF. Defaults to 60 when ModEv = EXA + IterEv: Optional[int] = None ModSV: Optional[str] = None # Scale variations method in EKO (expanded or exponentiated) DAMPPOWERc: Optional[int] = None # Power of the damping factor in FONLL for the c DAMPPOWERb: Optional[int] = None # Power of the damping factor in FONLL for the b - # N3LO parameters - n3lo_ad_variation: Optional[list] = dataclasses.field( - default_factory=lambda: 7 * [0] - ) # N3LO anomalous dimension variations - n3lo_cf_variation: Optional[int] = ( - 0 # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound - ) - use_fhmruvv: Optional[bool] = ( - False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. - ) + ## N3LO parameters + # N3LO anomalous dimension variations + n3lo_ad_variation: Optional[list] = dataclasses.field(default_factory=lambda: 7 * [0]) + # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound + n3lo_cf_variation: Optional[int] = 0 + # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization. + use_fhmruvv: Optional[bool] = False ###### Keys for compatibility with old NNPDF theories, their values will be dropped immediately after reading to avoid problems ###### they will be set to ``None`` immediately after loading the theory MaxNfAs: Optional[int] = None @@ -107,6 +102,17 @@ def _apply_checks(self): f"Trying to use {self.ID} with {self.Qedref} != {self.Qref}. This is not supported!" ) + def find_nf(self, mu): + """Given a value of q, find the corresponding number of flavours + for this theory.""" + if mu < self.mc * self.kcThr: + return 3 + elif mu < self.mb * self.kbThr: + return 4 + elif mu < self.mt * self.ktThr: + return 5 + return 6 + def _set_defaults(self): """Function to be called by __post_init__ to set defaults that might depends on other variables""" @@ -116,6 +122,8 @@ def _set_defaults(self): raise TheoryCardError( f"IterEv should not be given when ModEv=TRN, received {self.IterEv}" ) + if self.nf0 is None: + object.__setattr__(self, "nf0", self.find_nf(self.Q0)) def _raise_or_warn(self, msg): """Raise an error for new theories and a warning for old ones""" diff --git a/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml b/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml index a22f920575..83e0fbb12f 100644 --- a/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml +++ b/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml @@ -4,7 +4,9 @@ PTO: 2 FNS: FONLL-C DAMP: 0 IC: 1 +Q0: 1.65 ModEv: EXA +IterEv: 60 XIR: 1.0 XIF: 1.0 NfFF: 5 From 8f1be78af0314f9322dcad4d0609264485672422 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 30 Apr 2024 12:09:35 +0200 Subject: [PATCH 60/60] add alphas/alphaqed/qref to mandatory fields --- nnpdf_data/nnpdf_data/theory.py | 13 ++++++++----- nnpdf_data/nnpdf_data/theory_cards/41000000.yaml | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/nnpdf_data/nnpdf_data/theory.py b/nnpdf_data/nnpdf_data/theory.py index a17a3d7128..76f7287ca5 100644 --- a/nnpdf_data/nnpdf_data/theory.py +++ b/nnpdf_data/nnpdf_data/theory.py @@ -54,16 +54,17 @@ class TheoryCard: TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact MP: float # [GeV] Mass of the proton Comments: str # Comments on the theory + # Definition of the reference scale for alpha_s and alpha_qed + alphas: float # Value of alpha_s at the scale Qref + alphaqed: float # Values of alpha QED at the scale Qref + Qref: float # [GeV] Reference scale for alphas and alphaqed + nfref: Optional[int] = None # nf at Qref (its default depend on Qref) MaxNfPdf: Optional[int] = 5 # Used by pineko and the photon module to define the thresholds ## Fit theory parameters default # Number of active flavors at the parametrization scale Q0, its default depends on Q0 nf0: Optional[int] = None - nfref: Optional[int] = 5 # Number of active flavors at Qref - Qref: Optional[float] = 91.2 # [GeV] Reference scale for alphas and alphaqed - alphas: Optional[float] = 0.118 # Value of alpha_s at the scale Qref - alphaqed: Optional[float] = 0.007496252 # Values of alpha QED at the scale Qref ## Evolution parameters - # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used currently only in eko). + # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses HQ: Optional[Literal["POLE", "MSBAR"]] = "POLE" # iterations for the evolution of the PDF. Defaults to 60 when ModEv = EXA IterEv: Optional[int] = None @@ -124,6 +125,8 @@ def _set_defaults(self): ) if self.nf0 is None: object.__setattr__(self, "nf0", self.find_nf(self.Q0)) + if self.nfref is None: + object.__setattr__(self, "nfref", self.find_nf(self.Qref)) def _raise_or_warn(self, msg): """Raise an error for new theories and a warning for old ones""" diff --git a/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml b/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml index 83e0fbb12f..33b29c4ad4 100644 --- a/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml +++ b/nnpdf_data/nnpdf_data/theory_cards/41000000.yaml @@ -37,3 +37,6 @@ GF: 1.1663787e-05 SIN2TW: 0.23126 TMC: 1 MP: 0.938 +Qref: 91.2 +alphas: 0.118 +alphaqed: 0.0077553