From 41f589c97ab2a50e010216f4cf18be65db3da808 Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Sat, 9 Nov 2024 16:30:03 +0000 Subject: [PATCH 1/9] added data and kinematics and code to generate it --- .../commondata/ATLAS_WPWM_13TEV/data.yaml | 3 + .../commondata/ATLAS_WPWM_13TEV/filter.py | 92 +++++++++++++++++++ .../ATLAS_WPWM_13TEV/filter_utils.py | 87 ++++++++++++++++++ .../ATLAS_WPWM_13TEV/kinematics.yaml | 25 +++++ .../commondata/ATLAS_WPWM_13TEV/metadata.yaml | 9 +- .../HEPData-ins1436497-v1-Table_8.yaml | 20 ++++ .../HEPData-ins1436497-v1-Table_9.yaml | 20 ++++ 7 files changed, 252 insertions(+), 4 deletions(-) create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/data.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/data.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/data.yaml new file mode 100644 index 0000000000..255639204c --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/data.yaml @@ -0,0 +1,3 @@ +data_central: +- 3.50000000e+06 +- 4.53000000e+06 diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py new file mode 100644 index 0000000000..218bd6d8a6 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py @@ -0,0 +1,92 @@ +""" +filter.py module for ATLAS_WPWM_13TEV dataset +When running `python filter.py` the relevant uncertainties , data and kinematics yaml +file will be created in the `nnpdf_data/commondata/ATLAS_WPWM_13TEV` directory. +""" + +import yaml +from filter_utils import get_kinematics, get_data_values, get_systematics +from nnpdf_data.filter_utils.utils import prettify_float + +yaml.add_representer(float, prettify_float) + + +def filter_ATLAS_WPWM_13TEV_TOT_data_kinetic(): + """ + This function writes the central values and kinematics to yaml files. + """ + + kin = get_kinematics() + central_values = list(get_data_values()) + + data_central_yaml = {"data_central": central_values} + + kinematics_yaml = {"bins": kin} + + # write central values and kinematics to yaml file + with open("data.yaml", "w") as file: + yaml.dump(data_central_yaml, file, sort_keys=False) + + with open("kinematics.yaml", "w") as file: + yaml.dump(kinematics_yaml, file, sort_keys=False) + + +def filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3): + """ + This function writes the systematics to a yaml file. + """ + + with open("metadata.yaml", "r") as file: + metadata = yaml.safe_load(file) + + systematics = get_systematics(version=version) + + # error definition + error_definitions = {} + errors = [] + + for sys in systematics: + if (sys[0]['name'] == 'stat') or (sys[0]['name'] == 'sys,uncor'): + error_definitions[sys[0]['name']] = { + "description": f"{sys[0]['name']}", + "treatment": "ADD", + "type": "UNCORR", + } + + elif (sys[0]['name'] == 'ATLAS_LUMI') or (sys[0]['name'] == 'Lumi:M'): + error_definitions[sys[0]['name']] = { + "description": f"{sys[0]['name']}", + "treatment": "MULT", + "type": "CORR", + } + + else: + error_definitions[sys[0]['name']] = { + "description": f"{sys[0]['name']}", + "treatment": "ADD", + "type": "CORR", + } + + # + for i in range(metadata['implemented_observables'][0]['ndata']): + error_value = {} + + for sys in systematics: + error_value[sys[0]['name']] = float(sys[0]['values'][i]) + + errors.append(error_value) + + uncertainties_yaml = {"definitions": error_definitions, "bins": errors} + + # write uncertainties + if version == 1: + with open(f"uncertainties_v1.yaml", 'w') as file: + yaml.dump(uncertainties_yaml, file, sort_keys=False) + else: + with open(f"uncertainties.yaml", 'w') as file: + yaml.dump(uncertainties_yaml, file, sort_keys=False) + + +if __name__ == "__main__": + filter_ATLAS_WPWM_13TEV_TOT_data_kinetic() + # filter_ATLAS_Z0_8TEV_LOWMASS_systematics() diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py new file mode 100644 index 0000000000..c37c0ddebe --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py @@ -0,0 +1,87 @@ +""" +This module contains helper functions that are used to extract the uncertainties, kinematics and data values +from the rawdata files. +""" + +import yaml + + +def get_kinematics(): + """ + returns the kinematics in the form of a list of dictionaries. + """ + kin = [] + + mw2 = 80.385**2 + + for i in range(2): + + kin_value = { + 'k1': {'min': None, 'mid': 0.0, 'max': None}, + 'M2': {'min': None, 'mid': mw2, 'max': None}, + 'sqrts': {'min': None, 'mid': 13000.0, 'max': None}, + } + + kin.append(kin_value) + + return kin + + +def get_data_values(): + """ + returns the central data values in the form of a list. + """ + hepdata_table_wp, hepdata_table_wm = ( + "rawdata/HEPData-ins1436497-v1-Table_8.yaml", + "rawdata/HEPData-ins1436497-v1-Table_9.yaml", + ) + + with open(hepdata_table_wp, 'r') as file: + input_wp = yaml.safe_load(file) + + with open(hepdata_table_wm, 'r') as file: + input_wm = yaml.safe_load(file) + + values_wm = input_wm['dependent_variables'][0]['values'] + values_wp = input_wp['dependent_variables'][0]['values'] + + data_central = [values_wm[0]['value'] * 1000000, values_wp[0]['value'] * 1000000] + + return data_central + + +def get_systematics(version=3): + """ """ + + uncertainties = [] + + hepdata_table = f"rawdata/HEPData-ins1630886-v{version}-Table_5.yaml" + + with open(hepdata_table, 'r') as file: + input = yaml.safe_load(file) + + # loop over systematics + for unc_labels in input['dependent_variables'][0]['values'][0]['errors']: + + name = f"{unc_labels['label']}" + values = [] + + # loop over data points + for unc in input['dependent_variables'][0]['values']: + err = unc['errors'] + # convert unc from TeV to GeV + for e in err: + if e['label'] == name: + if name == 'Lumi:M': + values.append(e['symerror'] * unc['value'] * 1000) + else: + values.append(e['symerror'] * 1000) + + uncertainties.append([{"name": name, "values": values}]) + + # # Luminosity uncertainty is 1.8 % of the central value (see https://inspirehep.net/literature/1630886) + if version == 3: # in version 1 Lumi is included in the hepdata file already + name = "ATLAS_LUMI" + values = [ATLAS_LUMI_UNC * val for val in get_data_values()] + uncertainties.append([{"name": name, "values": values}]) + return uncertainties diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml new file mode 100644 index 0000000000..d34432480c --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml @@ -0,0 +1,25 @@ +bins: +- k1: + min: null + mid: 0.0 + max: null + M2: + min: null + mid: 6.46174823e+03 + max: null + sqrts: + min: null + mid: 13000.0 + max: null +- k1: + min: null + mid: 0.0 + max: null + M2: + min: null + mid: 6.46174823e+03 + max: null + sqrts: + min: null + mid: 13000.0 + max: null diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml index 77f74cc9a5..12576f0e67 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml @@ -1,6 +1,6 @@ setname: ATLAS_WPWM_13TEV version: 1 -version_comment: Port of old commondata +version_comment: New implementation nnpdf_metadata: nnpdf31_process: DY CC experiment: ATLAS @@ -8,10 +8,11 @@ arXiv: url: https://arxiv.org/abs/1603.09222 journal: Phys. Lett. B759 (2016) 601 iNSPIRE: - url: '' + url: 'https://inspirehep.net/literature/1436497' hepdata: - url: '' - version: -1 + url: 'https://www.hepdata.net/record/73640, https://www.hepdata.net/record/73641' + + version: 1 implemented_observables: - observable_name: TOT observable: diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml new file mode 100644 index 0000000000..68cd381750 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml @@ -0,0 +1,20 @@ +dependent_variables: +- header: {name: SIG, units: NB} + qualifiers: + - {name: ABS(ETARAP(C=ELECTRON)), value: < 2.5} + - {name: ABS(ETARAP(C=MUON)), value: < 2.5} + - {name: MT, units: GEV, value: '> 50'} + - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} + - {name: PT(C=MUON), units: GEV, value: '> 25'} + - {name: PT(C=NU), units: GEV, value: '> 25'} + - {name: RE, value: P P --> W+ < E+ NUE + MU+ NUMU > X} + values: + - errors: + - {label: stat, symerror: 0.01} + - {label: sys, symerror: 0.09} + - {label: sys, symerror: 0.1} + value: 4.53 +independent_variables: +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml new file mode 100644 index 0000000000..efd8411b2a --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml @@ -0,0 +1,20 @@ +dependent_variables: +- header: {name: SIG, units: NB} + qualifiers: + - {name: 'ABS(ETARAP(C=ELECTRON)}', value: < 2.5} + - {name: ABS(ETARAP(C=MUON)), value: < 2.5} + - {name: MT, units: GEV, value: '> 50'} + - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} + - {name: PT(C=MUON), units: GEV, value: '> 25'} + - {name: PT(C=NU), units: GEV, value: '> 25'} + - {name: RE, value: P P --> W- < E- NUEBAR + MU- NUMUBAR > X} + values: + - errors: + - {label: stat, symerror: 0.01} + - {label: sys, symerror: 0.07} + - {label: sys, symerror: 0.07} + value: 3.5 +independent_variables: +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} From e50fa946ba16afdbcd668b7e017b0cd094a34f33 Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Sat, 9 Nov 2024 20:01:11 +0000 Subject: [PATCH 2/9] added covariance matrix decomposition --- .../commondata/ATLAS_WPWM_13TEV/filter.py | 31 +++---- .../ATLAS_WPWM_13TEV/filter_utils.py | 82 +++++++++++++------ .../commondata/ATLAS_WPWM_13TEV/metadata.yaml | 15 ++-- .../HEPData-ins1436497-v1-Table_24.yaml | 47 +++++++++++ .../ATLAS_WPWM_13TEV/uncertainties.yaml | 20 +++++ 5 files changed, 144 insertions(+), 51 deletions(-) create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py index 218bd6d8a6..a15cd45732 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py @@ -31,7 +31,7 @@ def filter_ATLAS_WPWM_13TEV_TOT_data_kinetic(): yaml.dump(kinematics_yaml, file, sort_keys=False) -def filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3): +def filter_ATLAS_WPWM_13TEV_TOT_systematics(): """ This function writes the systematics to a yaml file. """ @@ -39,35 +39,34 @@ def filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3): with open("metadata.yaml", "r") as file: metadata = yaml.safe_load(file) - systematics = get_systematics(version=version) + systematics = get_systematics() # error definition error_definitions = {} errors = [] for sys in systematics: - if (sys[0]['name'] == 'stat') or (sys[0]['name'] == 'sys,uncor'): + if sys[0]['name'] == 'stat': error_definitions[sys[0]['name']] = { "description": f"{sys[0]['name']}", - "treatment": "ADD", - "type": "UNCORR", + "treatment": "MULT", + "type": "CORR", } - elif (sys[0]['name'] == 'ATLAS_LUMI') or (sys[0]['name'] == 'Lumi:M'): - error_definitions[sys[0]['name']] = { - "description": f"{sys[0]['name']}", + elif sys[0]['name'] == 'lumi': + error_definitions["ATLASLUMI13"] = { + "description": f"ATLASLUMI13", "treatment": "MULT", - "type": "CORR", + "type": "SPECIAL", } else: error_definitions[sys[0]['name']] = { "description": f"{sys[0]['name']}", - "treatment": "ADD", + "treatment": "MULT", "type": "CORR", } - # for i in range(metadata['implemented_observables'][0]['ndata']): error_value = {} @@ -79,14 +78,10 @@ def filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3): uncertainties_yaml = {"definitions": error_definitions, "bins": errors} # write uncertainties - if version == 1: - with open(f"uncertainties_v1.yaml", 'w') as file: - yaml.dump(uncertainties_yaml, file, sort_keys=False) - else: - with open(f"uncertainties.yaml", 'w') as file: - yaml.dump(uncertainties_yaml, file, sort_keys=False) + with open(f"uncertainties.yaml", 'w') as file: + yaml.dump(uncertainties_yaml, file, sort_keys=False) if __name__ == "__main__": filter_ATLAS_WPWM_13TEV_TOT_data_kinetic() - # filter_ATLAS_Z0_8TEV_LOWMASS_systematics() + filter_ATLAS_WPWM_13TEV_TOT_systematics() diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py index c37c0ddebe..36833113e8 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py @@ -4,6 +4,8 @@ """ import yaml +import numpy as np +from nnpdf_data.filter_utils.utils import decompose_covmat def get_kinematics(): @@ -50,38 +52,66 @@ def get_data_values(): return data_central -def get_systematics(version=3): - """ """ +def get_correlation_matrix(): + """ + See extra material page: https://atlas.web.cern.ch/Atlas/GROUPS/PHYSICS/PAPERS/STDM-2015-03/tabaux_03.pdf - uncertainties = [] + Note that this does not include the normalisation uncertainty due to the luminosity. + """ + + correlation_matrix = np.ones((2, 2)) + correlation_matrix[0, 1] = 0.93 + correlation_matrix[1, 0] = correlation_matrix[0, 1] + + return correlation_matrix + + +def get_covariance_matrices(): + """ + For the systematics see Table 3 of paper: https://arxiv.org/abs/1603.09222 + + Returns: + -------- + tuple: (cov_matrix_no_lumi, lumi_cov) + cov_matrix_no_lumi: np.array, the sum of stat and syst covmats -> to be decomposed into artificial systematics + lumi_cov: np.array, the lumi covmat. This is correlated between experiments so needs to be saved with type: SPECIAL + """ + corr_matrix = get_correlation_matrix() + cv = get_data_values() + + stat_wm = 0.01 * cv[0] + stat_wp = 0.01 * cv[1] + + syst_wm = 0.07 * cv[0] + syst_wp = 0.09 * cv[1] - hepdata_table = f"rawdata/HEPData-ins1630886-v{version}-Table_5.yaml" + lumi_wm = 0.10 * cv[0] + lumi_wp = 0.07 * cv[1] - with open(hepdata_table, 'r') as file: - input = yaml.safe_load(file) + stat_cov = np.diag([stat_wm**2, stat_wp**2]) + # lumi_cov = np.einsum("i,j->ij", np.array([lumi_wm, lumi_wp]), np.array([lumi_wm, lumi_wp])) + lumi_unc = np.array([lumi_wm, lumi_wp]) + syst_cov = corr_matrix * np.outer(np.array([syst_wm, syst_wp]), np.array([syst_wm, syst_wp])) - # loop over systematics - for unc_labels in input['dependent_variables'][0]['values'][0]['errors']: + cov_matrix_no_lumi = stat_cov + syst_cov - name = f"{unc_labels['label']}" - values = [] + return cov_matrix_no_lumi, lumi_unc - # loop over data points - for unc in input['dependent_variables'][0]['values']: - err = unc['errors'] - # convert unc from TeV to GeV - for e in err: - if e['label'] == name: - if name == 'Lumi:M': - values.append(e['symerror'] * unc['value'] * 1000) - else: - values.append(e['symerror'] * 1000) - uncertainties.append([{"name": name, "values": values}]) +def get_systematics(): + """ + Does cholesky decomposition of syst + stat covmat and returns uncertainties + list with artificial sys + lumi uncertainties. + """ + cov_matrix_no_lumi, lumi_unc = get_covariance_matrices() + + # decompose covmat + syst_unc = decompose_covmat(cov_matrix_no_lumi) + + uncertainties = [] + + uncertainties.append([{"name": "stat", "values": [syst_unc[0, 0], syst_unc[1, 0]]}]) + uncertainties.append([{"name": "sys1", "values": [syst_unc[0, 1], syst_unc[1, 1]]}]) + uncertainties.append([{"name": "ATLAS_LUMI", "values": [lumi_unc[0], lumi_unc[1]]}]) - # # Luminosity uncertainty is 1.8 % of the central value (see https://inspirehep.net/literature/1630886) - if version == 3: # in version 1 Lumi is included in the hepdata file already - name = "ATLAS_LUMI" - values = [ATLAS_LUMI_UNC * val for val in get_data_values()] - uncertainties.append([{"name": name, "values": values}]) return uncertainties diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml index 12576f0e67..8f89740bf2 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml @@ -1,6 +1,6 @@ setname: ATLAS_WPWM_13TEV version: 1 -version_comment: New implementation +version_comment: New implementation, as for the old one, data is taken from Table 3 of the paper nnpdf_metadata: nnpdf31_process: DY CC experiment: ATLAS @@ -39,30 +39,31 @@ implemented_observables: plot_x: ' ' kinematic_coverage: - k1 - - k2 - - k3 + - M2 + - sqrts kinematics: variables: k1: description: Variable k1 label: k1 units: '' - k2: + M2: description: Variable k2 label: k2 units: '' - k3: + sqrts: description: Variable k3 label: k3 units: '' - file: kinematics_TOT.yaml + file: kinematics.yaml theory: conversion_factor: 1.0 operation: 'null' FK_tables: - - ATLAS_WZ_TOT_13TEV-ATLASWZTOT13TEV81PB_WM_tot - ATLAS_WZ_TOT_13TEV-ATLASWZTOT13TEV81PB_WP_tot - data_uncertainties: [] + data_uncertainties: + - uncertainties.yaml variants: legacy: data_uncertainties: diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml new file mode 100644 index 0000000000..738bd23b7d --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml @@ -0,0 +1,47 @@ +dependent_variables: +- header: {name: Q} + qualifiers: + - {name: ABS(ETARAP(C=ELECTRON)), value: < 2.5} + - {name: ABS(ETARAP(C=MUON)), value: < 2.5} + - {name: MT, units: GEV, value: '> 50'} + - {name: MZ, units: GEV, value: 66-116} + - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} + - {name: PT(C=MUON), units: GEV, value: '> 25'} + - {name: PT(C=NU), units: GEV, value: '> 25'} + - {name: RE(Q=W+), value: P P --> W+ < E+ MUE + MU+ NUMU > X} + - {name: RE(Q=W-), value: P P --> W- < E- NUEBAR + MU- NUMUBAR > X} + - {name: RE(Q=Z/GAMMA*), value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + + MU+ MU- > ) X} + values: + - {value: P P --> W- < E- NUEBAR + MU- NUMUBAR> X} + - {value: P P --> W- < E- NUEBAR + MU- NUMUBAR> X} + - {value: P P --> W+ < E+ NUE + MU+ NUMU> X} + - {value: P P --> W+ < E+ NUE + MU+ NUMU> X} + - {value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + MU+ MU- > ) X} + - {value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + MU+ MU- > ) X} + - {value: 0.93} + - {value: 0.18} + - {value: 0.19} +independent_variables: +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} + - {value: 13000.0} diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml new file mode 100644 index 0000000000..9229df46e7 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml @@ -0,0 +1,20 @@ +definitions: + stat: + description: stat + treatment: MULT + type: CORR + sys1: + description: sys1 + treatment: MULT + type: CORR + ATLAS_LUMI: + description: ATLAS_LUMI + treatment: MULT + type: CORR +bins: +- stat: -7.52597747e+04 + sys1: -2.35766763e+05 + ATLAS_LUMI: 350000.0 +- stat: 4.35006902e+04 + sys1: -4.07895906e+05 + ATLAS_LUMI: 3.17100000e+05 From 5a27d17f9875951cd0a79cddf335ef2a311fac6d Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Sun, 8 Dec 2024 16:13:58 +0000 Subject: [PATCH 3/9] correlation of Z taken into account => artificial sys --- .../commondata/ATLAS_WPWM_13TEV/filter.py | 17 +-- .../ATLAS_WPWM_13TEV/filter_utils.py | 102 ++++++++++-------- .../ATLAS_WPWM_13TEV/kinematics.yaml | 12 +-- .../commondata/ATLAS_WPWM_13TEV/metadata.yaml | 29 +++-- .../HEPData-ins1436497-v1-Table_24.yaml | 47 -------- .../ATLAS_WPWM_13TEV/uncertainties.yaml | 44 +++++--- 6 files changed, 111 insertions(+), 140 deletions(-) delete mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py index a15cd45732..70327a496f 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py @@ -17,7 +17,8 @@ def filter_ATLAS_WPWM_13TEV_TOT_data_kinetic(): """ kin = get_kinematics() - central_values = list(get_data_values()) + # only keep first 2 as the last bin is for Z observable + central_values = list(get_data_values())[:-1] data_central_yaml = {"data_central": central_values} @@ -49,22 +50,22 @@ def filter_ATLAS_WPWM_13TEV_TOT_systematics(): if sys[0]['name'] == 'stat': error_definitions[sys[0]['name']] = { "description": f"{sys[0]['name']}", - "treatment": "MULT", - "type": "CORR", + "treatment": "ADD", + "type": "UNCORR", } - elif sys[0]['name'] == 'lumi': + elif sys[0]['name'] == 'ATLAS_LUMI': error_definitions["ATLASLUMI13"] = { "description": f"ATLASLUMI13", - "treatment": "MULT", - "type": "SPECIAL", + "treatment": "ADD", + "type": "ATLASLUMI13", } else: error_definitions[sys[0]['name']] = { "description": f"{sys[0]['name']}", - "treatment": "MULT", - "type": "CORR", + "treatment": "ADD", + "type": f"{sys[0]['name']}", } for i in range(metadata['implemented_observables'][0]['ndata']): diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py index 36833113e8..68a97d7b6c 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py @@ -7,6 +7,10 @@ import numpy as np from nnpdf_data.filter_utils.utils import decompose_covmat +MW2 = 80.385**2 +UNIT_CONVERSION = 1000000 +TABLES = [9, 8, 11] # order is W-, W+, Z + def get_kinematics(): """ @@ -14,13 +18,10 @@ def get_kinematics(): """ kin = [] - mw2 = 80.385**2 - - for i in range(2): + for _ in range(2): kin_value = { - 'k1': {'min': None, 'mid': 0.0, 'max': None}, - 'M2': {'min': None, 'mid': mw2, 'max': None}, + 'm_W2': {'min': None, 'mid': MW2, 'max': None}, 'sqrts': {'min': None, 'mid': 13000.0, 'max': None}, } @@ -33,23 +34,41 @@ def get_data_values(): """ returns the central data values in the form of a list. """ - hepdata_table_wp, hepdata_table_wm = ( - "rawdata/HEPData-ins1436497-v1-Table_8.yaml", - "rawdata/HEPData-ins1436497-v1-Table_9.yaml", - ) + name_data = lambda tab: f"rawdata/HEPData-ins1436497-v1-Table_{tab}.yaml" - with open(hepdata_table_wp, 'r') as file: - input_wp = yaml.safe_load(file) + data_central = [] - with open(hepdata_table_wm, 'r') as file: - input_wm = yaml.safe_load(file) + for tab in TABLES: + with open(name_data(tab), 'r') as file: + input = yaml.safe_load(file) + values = input['dependent_variables'][0]['values'] + data_central.append(values[0]['value'] * UNIT_CONVERSION) - values_wm = input_wm['dependent_variables'][0]['values'] - values_wp = input_wp['dependent_variables'][0]['values'] + return data_central - data_central = [values_wm[0]['value'] * 1000000, values_wp[0]['value'] * 1000000] - return data_central +def get_uncertainties(): + """ + Returns array of shape (3,3) + Each row corresponds to a different observable: (W-, W+, Z) + Each column corresponds to a different systematic: (stat, sys, lumi) + + See table 3 of paper: https://arxiv.org/abs/1603.09222 + """ + + name_data = lambda tab: f"rawdata/HEPData-ins1436497-v1-Table_{tab}.yaml" + + uncertainties = [] + + for tab in TABLES: + with open(name_data(tab), 'r') as file: + input = yaml.safe_load(file) + errors = input['dependent_variables'][0]['values'][0]['errors'] + uncertainties.append( + np.array([errors[0]['symerror'], errors[1]['symerror'], errors[2]['symerror']]) + ) + + return np.array(uncertainties) * UNIT_CONVERSION def get_correlation_matrix(): @@ -59,9 +78,13 @@ def get_correlation_matrix(): Note that this does not include the normalisation uncertainty due to the luminosity. """ - correlation_matrix = np.ones((2, 2)) + correlation_matrix = np.ones((3, 3)) correlation_matrix[0, 1] = 0.93 correlation_matrix[1, 0] = correlation_matrix[0, 1] + correlation_matrix[0, 2] = 0.18 + correlation_matrix[2, 0] = correlation_matrix[0, 2] + correlation_matrix[1, 2] = 0.19 + correlation_matrix[2, 1] = correlation_matrix[1, 2] return correlation_matrix @@ -77,41 +100,36 @@ def get_covariance_matrices(): lumi_cov: np.array, the lumi covmat. This is correlated between experiments so needs to be saved with type: SPECIAL """ corr_matrix = get_correlation_matrix() - cv = get_data_values() - - stat_wm = 0.01 * cv[0] - stat_wp = 0.01 * cv[1] + uncertainties = get_uncertainties() - syst_wm = 0.07 * cv[0] - syst_wp = 0.09 * cv[1] + # build correlated systematics covariance + sys = np.array([uncertainties[i, 1] for i in range(3)]) + cov_sys = corr_matrix * np.outer(sys, sys) - lumi_wm = 0.10 * cv[0] - lumi_wp = 0.07 * cv[1] + # array of lumi uncertainties + lumi_unc = np.array([uncertainties[i, 2] for i in range(3)]) - stat_cov = np.diag([stat_wm**2, stat_wp**2]) - # lumi_cov = np.einsum("i,j->ij", np.array([lumi_wm, lumi_wp]), np.array([lumi_wm, lumi_wp])) - lumi_unc = np.array([lumi_wm, lumi_wp]) - syst_cov = corr_matrix * np.outer(np.array([syst_wm, syst_wp]), np.array([syst_wm, syst_wp])) + # array of stat uncertainties + stat = np.array([uncertainties[i, 0] for i in range(3)]) - cov_matrix_no_lumi = stat_cov + syst_cov - - return cov_matrix_no_lumi, lumi_unc + return stat, cov_sys, lumi_unc def get_systematics(): - """ - Does cholesky decomposition of syst + stat covmat and returns uncertainties - list with artificial sys + lumi uncertainties. - """ - cov_matrix_no_lumi, lumi_unc = get_covariance_matrices() + stat, cov_sys, lumi_unc = get_covariance_matrices() - # decompose covmat - syst_unc = decompose_covmat(cov_matrix_no_lumi) + # decompose sys covmat + syst_unc = decompose_covmat(cov_sys) uncertainties = [] - uncertainties.append([{"name": "stat", "values": [syst_unc[0, 0], syst_unc[1, 0]]}]) - uncertainties.append([{"name": "sys1", "values": [syst_unc[0, 1], syst_unc[1, 1]]}]) + # store only systematics for W+ and W- + for i in range(3): + uncertainties.append( + [{"name": f"ATLAS_WZ_TOT_13TEV_{i}", "values": [syst_unc[0, i], syst_unc[1, i]]}] + ) + + uncertainties.append([{"name": "stat", "values": [stat[0], stat[1]]}]) uncertainties.append([{"name": "ATLAS_LUMI", "values": [lumi_unc[0], lumi_unc[1]]}]) return uncertainties diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml index d34432480c..cc57c2bf4c 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml @@ -1,9 +1,5 @@ bins: -- k1: - min: null - mid: 0.0 - max: null - M2: +- m_W2: min: null mid: 6.46174823e+03 max: null @@ -11,11 +7,7 @@ bins: min: null mid: 13000.0 max: null -- k1: - min: null - mid: 0.0 - max: null - M2: +- m_W2: min: null mid: 6.46174823e+03 max: null diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml index 8f89740bf2..7410b6893e 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml @@ -20,11 +20,11 @@ implemented_observables: label: ATLAS $W$ inclusive 13 TeV units: '' process_type: INC - tables: [] - npoints: [] + tables: [9, 8, 11] + npoints: [2] ndata: 2 plotting: - kinematics_override: inc_sqrt_scale + kinematics_override: identity dataset_label: ATLAS $W$ inclusive 13 TeV y_label: $\sigma^{fid}$ (fb) figure_by: @@ -38,23 +38,18 @@ implemented_observables: - W plot_x: ' ' kinematic_coverage: - - k1 - - M2 + - m_W2 - sqrts kinematics: variables: - k1: - description: Variable k1 - label: k1 - units: '' - M2: - description: Variable k2 - label: k2 - units: '' + m_W2: + description: W boson squared mass + label: m_W2 + units: '$GeV^2$' sqrts: - description: Variable k3 - label: k3 - units: '' + description: center of mass energy + label: '$\sqrt{s}$' + units: 'GeV' file: kinematics.yaml theory: conversion_factor: 1.0 @@ -68,5 +63,5 @@ implemented_observables: legacy: data_uncertainties: - uncertainties_legacy_TOT.yaml - data_central: data_legacy_TOT.yaml + data_central: data.yaml ported_from: ATLAS_W_TOT_13TEV diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml deleted file mode 100644 index 738bd23b7d..0000000000 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_24.yaml +++ /dev/null @@ -1,47 +0,0 @@ -dependent_variables: -- header: {name: Q} - qualifiers: - - {name: ABS(ETARAP(C=ELECTRON)), value: < 2.5} - - {name: ABS(ETARAP(C=MUON)), value: < 2.5} - - {name: MT, units: GEV, value: '> 50'} - - {name: MZ, units: GEV, value: 66-116} - - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} - - {name: PT(C=MUON), units: GEV, value: '> 25'} - - {name: PT(C=NU), units: GEV, value: '> 25'} - - {name: RE(Q=W+), value: P P --> W+ < E+ MUE + MU+ NUMU > X} - - {name: RE(Q=W-), value: P P --> W- < E- NUEBAR + MU- NUMUBAR > X} - - {name: RE(Q=Z/GAMMA*), value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- - + MU+ MU- > ) X} - values: - - {value: P P --> W- < E- NUEBAR + MU- NUMUBAR> X} - - {value: P P --> W- < E- NUEBAR + MU- NUMUBAR> X} - - {value: P P --> W+ < E+ NUE + MU+ NUMU> X} - - {value: P P --> W+ < E+ NUE + MU+ NUMU> X} - - {value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + MU+ MU- > ) X} - - {value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + MU+ MU- > ) X} - - {value: 0.93} - - {value: 0.18} - - {value: 0.19} -independent_variables: -- header: {name: SQRT(S), units: GEV} - values: - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} -- header: {name: SQRT(S), units: GEV} - values: - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} - - {value: 13000.0} diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml index 9229df46e7..593bd2816e 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml @@ -1,20 +1,32 @@ definitions: + ATLAS_WZ_TOT_13TEV_0: + description: ATLAS_WZ_TOT_13TEV_0 + treatment: ADD + type: ATLAS_WZ_TOT_13TEV_0 + ATLAS_WZ_TOT_13TEV_1: + description: ATLAS_WZ_TOT_13TEV_1 + treatment: ADD + type: ATLAS_WZ_TOT_13TEV_1 + ATLAS_WZ_TOT_13TEV_2: + description: ATLAS_WZ_TOT_13TEV_2 + treatment: ADD + type: ATLAS_WZ_TOT_13TEV_2 stat: description: stat - treatment: MULT - type: CORR - sys1: - description: sys1 - treatment: MULT - type: CORR - ATLAS_LUMI: - description: ATLAS_LUMI - treatment: MULT - type: CORR + treatment: ADD + type: UNCORR + ATLASLUMI13: + description: ATLASLUMI13 + treatment: ADD + type: ATLASLUMI13 bins: -- stat: -7.52597747e+04 - sys1: -2.35766763e+05 - ATLAS_LUMI: 350000.0 -- stat: 4.35006902e+04 - sys1: -4.07895906e+05 - ATLAS_LUMI: 3.17100000e+05 +- ATLAS_WZ_TOT_13TEV_0: 6.80483165e+04 + ATLAS_WZ_TOT_13TEV_1: 1.64142169e+04 + ATLAS_WZ_TOT_13TEV_2: -1.03156424e+01 + stat: 10000.0 + ATLAS_LUMI: 70000.0 +- ATLAS_WZ_TOT_13TEV_0: 8.91232992e+04 + ATLAS_WZ_TOT_13TEV_1: -1.25312809e+04 + ATLAS_WZ_TOT_13TEV_2: -6.74297267e+01 + stat: 10000.0 + ATLAS_LUMI: 100000.0 From 3c5fbf1ffe81b21c792335bd0509141d8de17f52 Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Sun, 8 Dec 2024 16:45:07 +0000 Subject: [PATCH 4/9] added filter and filter utils for Z TOT, unc are correlated with WPWM --- .../commondata/ATLAS_Z0_13TEV/filter.py | 96 +++++++++++++++ .../commondata/ATLAS_Z0_13TEV/filter_utils.py | 115 ++++++++++++++++++ .../commondata/ATLAS_Z0_13TEV/metadata.yaml | 40 +++--- .../HEPData-ins1436497-v1-Table_11.yaml | 20 +++ .../HEPData-ins1436497-v1-Table_8.yaml | 20 +++ .../HEPData-ins1436497-v1-Table_9.yaml | 20 +++ 6 files changed, 289 insertions(+), 22 deletions(-) create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter_utils.py create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py new file mode 100644 index 0000000000..49636e4af6 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py @@ -0,0 +1,96 @@ +""" +filter.py module for ATLAS_WPWM_13TEV dataset +When running `python filter.py` the relevant uncertainties , data and kinematics yaml +file will be created in the `nnpdf_data/commondata/ATLAS_WPWM_13TEV` directory. +""" + +import yaml +from filter_utils import get_data_values, get_systematics +from nnpdf_data.filter_utils.utils import prettify_float + +yaml.add_representer(float, prettify_float) + +MZ2 = 91.1876**2 + + +def filter_ATLAS_Z0_13TEV_TOT_data_kinetic(): + """ + This function writes the central values and kinematics to yaml files. + """ + + kin = [ + { + 'm_Z2': {'min': None, 'mid': MZ2, 'max': None}, + 'sqrts': {'min': None, 'mid': 13000.0, 'max': None}, + } + ] + + # only keep the last entry corresponding to Z observable + central_values = [get_data_values()[-1]] + + data_central_yaml = {"data_central": central_values} + + kinematics_yaml = {"bins": kin} + + # write central values and kinematics to yaml file + with open("data.yaml", "w") as file: + yaml.dump(data_central_yaml, file, sort_keys=False) + + with open("kinematics.yaml", "w") as file: + yaml.dump(kinematics_yaml, file, sort_keys=False) + + +def filter_ATLAS_Z0_13TEV_TOT_systematics(): + """ + This function writes the systematics to a yaml file. + """ + + with open("metadata.yaml", "r") as file: + metadata = yaml.safe_load(file) + + systematics = get_systematics() + + # error definition + error_definitions = {} + errors = [] + + for sys in systematics: + if sys[0]['name'] == 'stat': + error_definitions[sys[0]['name']] = { + "description": f"{sys[0]['name']}", + "treatment": "ADD", + "type": "UNCORR", + } + + elif sys[0]['name'] == 'ATLAS_LUMI': + error_definitions["ATLASLUMI13"] = { + "description": f"ATLASLUMI13", + "treatment": "ADD", + "type": "ATLASLUMI13", + } + + else: + error_definitions[sys[0]['name']] = { + "description": f"{sys[0]['name']}", + "treatment": "ADD", + "type": f"{sys[0]['name']}", + } + + for i in range(metadata['implemented_observables'][0]['ndata']): + error_value = {} + + for sys in systematics: + error_value[sys[0]['name']] = float(sys[0]['values'][i]) + + errors.append(error_value) + + uncertainties_yaml = {"definitions": error_definitions, "bins": errors} + + # write uncertainties + with open(f"uncertainties.yaml", 'w') as file: + yaml.dump(uncertainties_yaml, file, sort_keys=False) + + +if __name__ == "__main__": + filter_ATLAS_Z0_13TEV_TOT_data_kinetic() + filter_ATLAS_Z0_13TEV_TOT_systematics() diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter_utils.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter_utils.py new file mode 100644 index 0000000000..63f31870ba --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter_utils.py @@ -0,0 +1,115 @@ +""" +This module contains helper functions that are used to extract the uncertainties, kinematics and data values +from the rawdata files. +""" + +import yaml +import numpy as np +from nnpdf_data.filter_utils.utils import decompose_covmat + + +UNIT_CONVERSION = 1000000 +TABLES = [9, 8, 11] # order is W-, W+, Z + + +def get_data_values(): + """ + returns the central data values in the form of a list. + """ + name_data = lambda tab: f"rawdata/HEPData-ins1436497-v1-Table_{tab}.yaml" + + data_central = [] + + for tab in TABLES: + with open(name_data(tab), 'r') as file: + input = yaml.safe_load(file) + values = input['dependent_variables'][0]['values'] + data_central.append(values[0]['value'] * UNIT_CONVERSION) + + return data_central + + +def get_uncertainties(): + """ + Returns array of shape (3,3) + Each row corresponds to a different observable: (W-, W+, Z) + Each column corresponds to a different systematic: (stat, sys, lumi) + + See table 3 of paper: https://arxiv.org/abs/1603.09222 + """ + + name_data = lambda tab: f"rawdata/HEPData-ins1436497-v1-Table_{tab}.yaml" + + uncertainties = [] + + for tab in TABLES: + with open(name_data(tab), 'r') as file: + input = yaml.safe_load(file) + errors = input['dependent_variables'][0]['values'][0]['errors'] + uncertainties.append( + np.array([errors[0]['symerror'], errors[1]['symerror'], errors[2]['symerror']]) + ) + + return np.array(uncertainties) * UNIT_CONVERSION + + +def get_correlation_matrix(): + """ + See extra material page: https://atlas.web.cern.ch/Atlas/GROUPS/PHYSICS/PAPERS/STDM-2015-03/tabaux_03.pdf + + Note that this does not include the normalisation uncertainty due to the luminosity. + """ + + correlation_matrix = np.ones((3, 3)) + correlation_matrix[0, 1] = 0.93 + correlation_matrix[1, 0] = correlation_matrix[0, 1] + correlation_matrix[0, 2] = 0.18 + correlation_matrix[2, 0] = correlation_matrix[0, 2] + correlation_matrix[1, 2] = 0.19 + correlation_matrix[2, 1] = correlation_matrix[1, 2] + + return correlation_matrix + + +def get_covariance_matrices(): + """ + For the systematics see Table 3 of paper: https://arxiv.org/abs/1603.09222 + + Returns: + -------- + tuple: (cov_matrix_no_lumi, lumi_cov) + cov_matrix_no_lumi: np.array, the sum of stat and syst covmats -> to be decomposed into artificial systematics + lumi_cov: np.array, the lumi covmat. This is correlated between experiments so needs to be saved with type: SPECIAL + """ + corr_matrix = get_correlation_matrix() + uncertainties = get_uncertainties() + + # build correlated systematics covariance + sys = np.array([uncertainties[i, 1] for i in range(3)]) + cov_sys = corr_matrix * np.outer(sys, sys) + + # array of lumi uncertainties + lumi_unc = np.array([uncertainties[i, 2] for i in range(3)]) + + # array of stat uncertainties + stat = np.array([uncertainties[i, 0] for i in range(3)]) + + return stat, cov_sys, lumi_unc + + +def get_systematics(): + stat, cov_sys, lumi_unc = get_covariance_matrices() + + # decompose sys covmat + syst_unc = decompose_covmat(cov_sys) + + uncertainties = [] + + # store only systematics for W+ and W- + for i in range(3): + uncertainties.append([{"name": f"ATLAS_WZ_TOT_13TEV_{i}", "values": [syst_unc[2, i]]}]) + + uncertainties.append([{"name": "stat", "values": [stat[2]]}]) + uncertainties.append([{"name": "ATLAS_LUMI", "values": [lumi_unc[2]]}]) + + return uncertainties diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml index 4ca09d36f7..fe7817d6fb 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml @@ -1,6 +1,6 @@ setname: ATLAS_Z0_13TEV version: 1 -version_comment: Port of old commondata +version_comment: New implementation, as for the old one, data is taken from Table 3 of the paper nnpdf_metadata: nnpdf31_process: DY NC experiment: ATLAS @@ -19,11 +19,11 @@ implemented_observables: label: ATLAS $Z$ inclusive 13 TeV units: '' process_type: INC - tables: [] - npoints: [] + tables: [9, 8, 11] + npoints: [1] ndata: 1 plotting: - kinematics_override: inc_sqrt_scale + kinematics_override: identity dataset_label: ATLAS $Z$ inclusive 13 TeV y_label: $\sigma^{fid}$ (fb) figure_by: @@ -35,33 +35,29 @@ implemented_observables: - Z plot_x: ' ' kinematic_coverage: - - k1 - - k2 - - k3 + - m_Z2 + - sqrts kinematics: variables: - k1: - description: Variable k1 - label: k1 - units: '' - k2: - description: Variable k2 - label: k2 - units: '' - k3: - description: Variable k3 - label: k3 - units: '' - file: kinematics_TOT.yaml + m_Z2: + description: Z boson mass squared + label: '$m_{Z}^2$' + units: '$GeV^2$' + sqrts: + description: center of mass energy + label: '$\sqrt{s}$' + units: 'GeV' + file: kinematics.yaml theory: conversion_factor: 1.0 operation: 'null' FK_tables: - - ATLAS_WZ_TOT_13TEV-ATLASWZTOT13TEV81PB_Z_tot - data_uncertainties: [] + data_uncertainties: + - uncertainties.yaml variants: legacy: data_uncertainties: - uncertainties_legacy_TOT.yaml - data_central: data_legacy_TOT.yaml + data_central: data.yaml ported_from: ATLAS_Z_TOT_13TEV diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml new file mode 100644 index 0000000000..6c400ca342 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml @@ -0,0 +1,20 @@ +dependent_variables: +- header: {name: SIG, units: NB} + qualifiers: + - {name: ABS(ETARAP(C=ELECTRON)), value: < 2.5} + - {name: ABS(ETARAP(C=MUON)), value: < 2.5} + - {name: MZ, units: GEV, value: 66-116} + - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} + - {name: PT(C=MUON), units: GEV, value: '> 25'} + - {name: RE, value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + MU+ MU- + > ) X} + values: + - errors: + - {label: stat, symerror: 0.003} + - {label: sys, symerror: 0.006} + - {label: sys, symerror: 0.016} + value: 0.779 +independent_variables: +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml new file mode 100644 index 0000000000..68cd381750 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml @@ -0,0 +1,20 @@ +dependent_variables: +- header: {name: SIG, units: NB} + qualifiers: + - {name: ABS(ETARAP(C=ELECTRON)), value: < 2.5} + - {name: ABS(ETARAP(C=MUON)), value: < 2.5} + - {name: MT, units: GEV, value: '> 50'} + - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} + - {name: PT(C=MUON), units: GEV, value: '> 25'} + - {name: PT(C=NU), units: GEV, value: '> 25'} + - {name: RE, value: P P --> W+ < E+ NUE + MU+ NUMU > X} + values: + - errors: + - {label: stat, symerror: 0.01} + - {label: sys, symerror: 0.09} + - {label: sys, symerror: 0.1} + value: 4.53 +independent_variables: +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml new file mode 100644 index 0000000000..efd8411b2a --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/rawdata/HEPData-ins1436497-v1-Table_9.yaml @@ -0,0 +1,20 @@ +dependent_variables: +- header: {name: SIG, units: NB} + qualifiers: + - {name: 'ABS(ETARAP(C=ELECTRON)}', value: < 2.5} + - {name: ABS(ETARAP(C=MUON)), value: < 2.5} + - {name: MT, units: GEV, value: '> 50'} + - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} + - {name: PT(C=MUON), units: GEV, value: '> 25'} + - {name: PT(C=NU), units: GEV, value: '> 25'} + - {name: RE, value: P P --> W- < E- NUEBAR + MU- NUMUBAR > X} + values: + - errors: + - {label: stat, symerror: 0.01} + - {label: sys, symerror: 0.07} + - {label: sys, symerror: 0.07} + value: 3.5 +independent_variables: +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} From 1f0266ab05b0f58ea4531081875da61dfd9c0c84 Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Sun, 8 Dec 2024 16:46:02 +0000 Subject: [PATCH 5/9] added new data, unc and kin files --- .../commondata/ATLAS_Z0_13TEV/data.yaml | 2 ++ .../commondata/ATLAS_Z0_13TEV/kinematics.yaml | 9 +++++++ .../ATLAS_Z0_13TEV/uncertainties.yaml | 27 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/data.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/kinematics.yaml create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/data.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/data.yaml new file mode 100644 index 0000000000..06a6e43bd9 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/data.yaml @@ -0,0 +1,2 @@ +data_central: +- 779000.0 diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/kinematics.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/kinematics.yaml new file mode 100644 index 0000000000..a881171bd6 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/kinematics.yaml @@ -0,0 +1,9 @@ +bins: +- m_Z2: + min: null + mid: 8.31517839e+03 + max: null + sqrts: + min: null + mid: 13000.0 + max: null diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml new file mode 100644 index 0000000000..cc0a377eb2 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml @@ -0,0 +1,27 @@ +definitions: + ATLAS_WZ_TOT_13TEV_0: + description: ATLAS_WZ_TOT_13TEV_0 + treatment: ADD + type: ATLAS_WZ_TOT_13TEV_0 + ATLAS_WZ_TOT_13TEV_1: + description: ATLAS_WZ_TOT_13TEV_1 + treatment: ADD + type: ATLAS_WZ_TOT_13TEV_1 + ATLAS_WZ_TOT_13TEV_2: + description: ATLAS_WZ_TOT_13TEV_2 + treatment: ADD + type: ATLAS_WZ_TOT_13TEV_2 + stat: + description: stat + treatment: ADD + type: UNCORR + ATLASLUMI13: + description: ATLASLUMI13 + treatment: ADD + type: ATLASLUMI13 +bins: +- ATLAS_WZ_TOT_13TEV_0: 1.13953999e+03 + ATLAS_WZ_TOT_13TEV_1: -1.14718978e+02 + ATLAS_WZ_TOT_13TEV_2: 5.88967641e+03 + stat: 3000.0 + ATLAS_LUMI: 16000.0 From c782340fcac497d2ba3bbeb57a6c18b6fcd3f5f2 Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Sun, 8 Dec 2024 16:57:26 +0000 Subject: [PATCH 6/9] added table 11 --- .../HEPData-ins1436497-v1-Table_11.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml new file mode 100644 index 0000000000..6c400ca342 --- /dev/null +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml @@ -0,0 +1,20 @@ +dependent_variables: +- header: {name: SIG, units: NB} + qualifiers: + - {name: ABS(ETARAP(C=ELECTRON)), value: < 2.5} + - {name: ABS(ETARAP(C=MUON)), value: < 2.5} + - {name: MZ, units: GEV, value: 66-116} + - {name: PT(C=ELECTRON), units: GEV, value: '> 25'} + - {name: PT(C=MUON), units: GEV, value: '> 25'} + - {name: RE, value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + MU+ MU- + > ) X} + values: + - errors: + - {label: stat, symerror: 0.003} + - {label: sys, symerror: 0.006} + - {label: sys, symerror: 0.016} + value: 0.779 +independent_variables: +- header: {name: SQRT(S), units: GEV} + values: + - {value: 13000.0} From bebefea29aa9743e58fb4794388ce4b447bd0a6a Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Mon, 9 Dec 2024 17:36:52 +0000 Subject: [PATCH 7/9] corrected latex labels --- .../nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml | 4 ++-- nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml index 7410b6893e..f2b77796a0 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/metadata.yaml @@ -44,8 +44,8 @@ implemented_observables: variables: m_W2: description: W boson squared mass - label: m_W2 - units: '$GeV^2$' + label: '$m_W^2$' + units: 'GeV$^2$' sqrts: description: center of mass energy label: '$\sqrt{s}$' diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml index fe7817d6fb..e5f3d4b91a 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/metadata.yaml @@ -42,7 +42,7 @@ implemented_observables: m_Z2: description: Z boson mass squared label: '$m_{Z}^2$' - units: '$GeV^2$' + units: 'GeV$^2$' sqrts: description: center of mass energy label: '$\sqrt{s}$' From 61186235f8c96416c0d9fa450906f703be6bd95d Mon Sep 17 00:00:00 2001 From: Mark Nestor Costantini Date: Wed, 11 Dec 2024 16:55:43 +0000 Subject: [PATCH 8/9] add MULT unc for LUMI --- nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py | 2 +- .../nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml | 2 +- nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py | 2 +- .../nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py index 70327a496f..512d5a1d30 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py @@ -57,7 +57,7 @@ def filter_ATLAS_WPWM_13TEV_TOT_systematics(): elif sys[0]['name'] == 'ATLAS_LUMI': error_definitions["ATLASLUMI13"] = { "description": f"ATLASLUMI13", - "treatment": "ADD", + "treatment": "MULT", "type": "ATLASLUMI13", } diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml index 593bd2816e..e57bb9f4bb 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/uncertainties.yaml @@ -17,7 +17,7 @@ definitions: type: UNCORR ATLASLUMI13: description: ATLASLUMI13 - treatment: ADD + treatment: MULT type: ATLASLUMI13 bins: - ATLAS_WZ_TOT_13TEV_0: 6.80483165e+04 diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py index 49636e4af6..1ccca1ede4 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/filter.py @@ -65,7 +65,7 @@ def filter_ATLAS_Z0_13TEV_TOT_systematics(): elif sys[0]['name'] == 'ATLAS_LUMI': error_definitions["ATLASLUMI13"] = { "description": f"ATLASLUMI13", - "treatment": "ADD", + "treatment": "MULT", "type": "ATLASLUMI13", } diff --git a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml index cc0a377eb2..485c31e9e7 100644 --- a/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml +++ b/nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_13TEV/uncertainties.yaml @@ -17,7 +17,7 @@ definitions: type: UNCORR ATLASLUMI13: description: ATLASLUMI13 - treatment: ADD + treatment: MULT type: ATLASLUMI13 bins: - ATLAS_WZ_TOT_13TEV_0: 1.13953999e+03 From fb1bd76dcc1bd8acb60bb7c72a26bfbdada3ad10 Mon Sep 17 00:00:00 2001 From: Roy Stegeman Date: Thu, 12 Dec 2024 14:23:36 +0000 Subject: [PATCH 9/9] use nnpdf_data directly instead of Loader to get theorycard --- n3fit/src/n3fit/scripts/evolven3fit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/n3fit/src/n3fit/scripts/evolven3fit.py b/n3fit/src/n3fit/scripts/evolven3fit.py index c9b506b4e5..277de17858 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit.py +++ b/n3fit/src/n3fit/scripts/evolven3fit.py @@ -7,11 +7,13 @@ import pathlib import sys +from evolven3fit import cli, eko_utils, evolve, utils import numpy as np from eko.runner.managed import solve -from evolven3fit import cli, eko_utils, evolve, utils from n3fit.io.writer import XGRID +from nnpdf_data import theory_cards +from nnpdf_data.theorydbutils import fetch_theory from validphys.loader import FallbackLoader, Loader _logger = logging.getLogger(__name__) @@ -174,7 +176,7 @@ def main(): 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 = loader.check_theoryID(args.theoryID).get_description() + nnpdf_theory = fetch_theory(theory_cards, args.theoryID) 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")