Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Chek the ATLAS Z0 8 TeV low mass data set #2270

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 97 additions & 7 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_8TEV_LOWMASS/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import yaml
from filter_utils import get_kinematics, get_data_values, get_systematics
from filter_utils import get_kinematics, get_data_values, get_systematics, get_systematics_light
from nnpdf_data.filter_utils.utils import prettify_float

yaml.add_representer(float, prettify_float)
Expand Down Expand Up @@ -54,10 +54,16 @@ def filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3):
}

elif (sys[0]['name'] == 'ATLAS_LUMI') or (sys[0]['name'] == 'Lumi:M'):
if version == 3 or version == 1:
type_lumi = "ATLASLUMI12"
elif version == "3_uncorr" or version == "1_uncorr":
type_lumi = "UNCORR"
elif version == "3_corr" or version == "1_corr":
type_lumi = "CORR"
error_definitions[sys[0]['name']] = {
"description": f"{sys[0]['name']}",
"treatment": "MULT",
"type": "ATLASLUMI12",
"type": type_lumi
}

else:
Expand All @@ -80,14 +86,98 @@ def filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3):

# 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:

filename = "uncertainties_new_v1_corr_lumi_all.yaml"
elif version == 3:

filename = "uncertainties.yaml"
elif version == "3_uncorr":

filename = "uncertainties_new_v3_uncorr_lumi.yaml"
elif version == "1_uncorr":

filename = "uncertainties_new_v1_uncorr_lumi.yaml"
elif version == "3_corr":

filename = "uncertainties_new_v3_corr_lumi.yaml"
elif version == "1_corr":

filename = "uncertainties_new_v1_corr_lumi.yaml"
else:
raise ValueError(f"Version {version} is not supported.")

with open(filename, 'w') as file:
yaml.dump(uncertainties_yaml, file, sort_keys=False)

def filter_ATLAS_Z0_8TEV_LOWMASS_systematics_light(lumi_corr):
"""
This function writes the light version of systematics
to a yaml file.
"""

with open("metadata.yaml", "r") as file:
metadata = yaml.safe_load(file)

systematics = get_systematics_light()

# error definition
error_definitions = {}
errors = []

for sys in systematics:
# Uncorrelated uncertainties
if (sys['name'] == 'stat') or (sys['name'] == 'syst_unc'):
error_definitions[sys['name']] = {
"description": f"{sys['name']}",
"treatment": "ADD",
"type": "UNCORR",
}

elif sys['name'] == 'ATLAS_LUMI':
error_definitions[sys['name']] = {
"description": f"{sys['name']}",
"treatment": "MULT",
"type": lumi_corr
}

else:
error_definitions[sys['name']] = {
"description": f"{sys['name']}",
"treatment": "ADD",
"type": "CORR",
}

for i in range(metadata['implemented_observables'][0]['ndata']):
error_value = {}

for sys in systematics:
error_value[sys['name']] = float(sys['values'][i])

errors.append(error_value)

uncertainties_yaml = {"definitions": error_definitions, "bins": errors}

# write uncertainties
if lumi_corr == "ATLASLUMI12":
filename = "uncertainties_sys_light_corr_all.yaml"
elif lumi_corr == "CORR":
filename = "uncertainties_sys_light_corr.yaml"
elif lumi_corr == "UNCORR":
filename = "uncertainties_sys_light_uncorr.yaml"
else:
raise ValueError(f"{lumi_corr} is not supported.")

with open(filename, '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)
filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version="3_uncorr")
filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version="3_corr")
filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=1)
filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version="1_uncorr")
filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version="1_corr")
filter_ATLAS_Z0_8TEV_LOWMASS_systematics_light(lumi_corr="ATLASLUMI12")
filter_ATLAS_Z0_8TEV_LOWMASS_systematics_light(lumi_corr="CORR")
filter_ATLAS_Z0_8TEV_LOWMASS_systematics_light(lumi_corr="UNCORR")
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"""

import yaml
from functools import lru_cache

ATLAS_LUMI_UNC = 0.018
ATLAS_LUMI_UNC = 0.019

def get_kinematics():
"""
Expand Down Expand Up @@ -40,7 +41,7 @@ def get_kinematics():

return kin


@lru_cache()
def get_data_values():
"""
returns the central data values in the form of a list.
Expand All @@ -66,8 +67,8 @@ def get_systematics(version=3):
""" """

uncertainties = []

hepdata_table = f"rawdata/HEPData-ins1630886-v{version}-Table_5.yaml"
num_version = version if type(version) == int else int(version.split("_")[0]) # Split by "_" and take the first part
hepdata_table = f"rawdata/HEPData-ins1630886-v{num_version}-Table_5.yaml"

with open(hepdata_table, 'r') as file:
input = yaml.safe_load(file)
Expand All @@ -91,9 +92,41 @@ def get_systematics(version=3):

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
# # Luminosity uncertainty is 1.9 % of the central value (see https://inspirehep.net/literature/1630886)
if num_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


def get_systematics_light():

uncertainties = []
hepdata_table = "rawdata/unc_light.yaml"
data_values = get_data_values()

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

# loop over type of uncertainty (stat, syst_unc, syst_corr)
for unc_labels in input['dependent_variables'][0]['values'][0]['errors']:

name = f"{unc_labels['label']}"
values = []

# loop over bins
for idx_bin, unc in enumerate(input['dependent_variables'][0]['values']):
err = unc['errors']

for e in err:
if e['label'] == name:
values.append(e['symerror'] * data_values[idx_bin] / 100)

uncertainties.append({"name": name, "values": values})

# Luminosity is 1.9%
name = "ATLAS_LUMI"
values = [1.9 / 100 * val for val in data_values]
uncertainties.append({"name": name, "values": values})
return uncertainties
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ implemented_observables:
legacy:
data_uncertainties:
- uncertainties_legacy_M-Y.yaml

syst_light_lumi_corr_all:
data_uncertainties:
- uncertainties_sys_light_corr_all.yaml
syst_light_lumi_corr:
data_uncertainties:
- uncertainties_sys_light_corr.yaml
syst_light_lumi_uncorr:
data_uncertainties:
- uncertainties_sys_light_uncorr.yaml
v1_lumi_corr_all:
data_uncertainties:
- uncertainties_new_v1_corr_lumi_all.yaml
v1_lumi_corr:
data_uncertainties:
- uncertainties_new_v1_corr_lumi.yaml
v1_lumi_uncorr:
data_uncertainties:
- uncertainties_new_v1_uncorr_lumi.yaml
v3_lumi_corr:
data_uncertainties:
- uncertainties_new_v3_corr_lumi.yaml
v3_lumi_uncorr:
data_uncertainties:
- uncertainties_new_v3_uncorr_lumi.yaml

data_central: data.yaml
ported_from: ATLAS_DY_2D_8TEV_LOWMASS
Loading
Loading