Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
data_central:
- 184.96
- 186.96
- 1.86960000e+02
- 185.78
- 187.32
- 185.6
- 187.64
- 185.98
- 1.87640000e+02
- 1.85980000e+02
- 181.96
- 166.32
- 134.78
- 85.98
- 29.3
- 304.64
- 3.04640000e+02
- 301.96
- 302.34
- 300.66
- 3.00660000e+02
- 294.94
- 293.32
- 2.93320000e+02
- 281.74
- 254.34
- 208.32
- 154.02
- 92.66
- 1.54020000e+02
- 9.26600000e+01
- 30.5
- 5996.4
- 5.99640000e+03
- 5995.0
- 5970.0
- 5925.6
- 5868.6
- 5655.4
- 5.86860000e+03
- 5.65540000e+03
- 5185.4
- 4509.6
- 4.50960000e+03
- 3658.4
- 2674.0
- 1596.62
Expand All @@ -40,10 +40,10 @@ data_central:
- 7008.6
- 6978.6
- 6897.8
- 6597.4
- 6.59740000e+03
- 6017.0
- 5209.0
- 4227.6
- 4.22760000e+03
- 3069.4
- 1831.68
- 595.56
Expand All @@ -52,20 +52,20 @@ data_central:
- 234.6
- 233.08
- 228.94
- 215.76
- 195.84
- 2.15760000e+02
- 1.95840000e+02
- 166.38
- 134.9
- 98.4
- 57.62
- 18.48
- 48.44
- 47.86
- 47.38
- 4.73800000e+01
- 47.72
- 45.36
- 42.26
- 38.44
- 3.84400000e+01
- 32.28
- 26.58
- 19.32
Expand All @@ -75,11 +75,11 @@ data_central:
- 11.02
- 10.82
- 10.66
- 9.98
- 9.98000000e+00
- 9.22
- 8.56
- 7.12
- 5.72
- 4.06
- 7.12000000e+00
- 5.72000000e+00
- 4.06000000e+00
- 2.46
- 0.82
93 changes: 93 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_8TEV_LOWMASS/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
"""
filter.py module for ATLAS_Z0_8TEV_LOWMASS dataset
When running `python filter.py` the relevant uncertainties , data and kinematics yaml
file will be created in the `nnpdf_data/commondata/ATLAS_Z0_8TEV_LOWMASS` 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_Z0_8TEV_LOWMASS_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": "ATLASLUMI12",
}

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_Z0_8TEV_LOWMASS_data_kinetic()
filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3)
# filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""
This module contains helper functions that are used to extract the uncertainties, kinematics and data values
from the rawdata files.
"""

import yaml

ATLAS_LUMI_UNC = 0.018

def get_kinematics():
"""
returns the kinematics in the form of a list of dictionaries.
"""
kin = []

hepdata_table = f"rawdata/HEPData-ins1630886-v3-Table_5.yaml"

with open(hepdata_table, 'r') as file:
input = yaml.safe_load(file)

for indep_var1, indep_var2 in zip(
input["independent_variables"][1]['values'], input["independent_variables"][2]['values']
):

kin_value = {
'abs_y': {
'min': indep_var1['low'],
'mid': 0.5 * (indep_var1['low'] + indep_var1['high']),
'max': indep_var1['high'],
},
'm_Z2': {
'min': indep_var2['low']**2,
'mid': (0.5 * (indep_var2['low'] + indep_var2['high']))**2,
'max': indep_var2['high']**2,
},
'sqrts': {'min': None, 'mid': 8000.0, 'max': None},
}

kin.append(kin_value)

return kin


def get_data_values():
"""
returns the central data values in the form of a list.
"""

data_central = []

hepdata_table = f"rawdata/HEPData-ins1630886-v3-Table_5.yaml"

with open(hepdata_table, 'r') as file:
input = yaml.safe_load(file)

values = input['dependent_variables'][0]['values']

for value in values:
# store data central and convert the units
data_central.append(value['value'] * 1000)

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
Loading