Skip to content
Merged
9 changes: 9 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_7TEV_36PB/data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
data_central:
- 1.31687349e+05
- 1.31860528e+05
- 1.28162647e+05
- 1.20440901e+05
- 1.15490019e+05
- 1.07228362e+05
- 9.39037660e+04
- 5.43782060e+04
100 changes: 100 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_7TEV_36PB/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"""
When running `python filter.py` the relevant data yaml
file will be created in the `nnpdf_data/commondata/ATLAS_WPWM_7TEV_46FB` directory.
"""

import yaml
from filter_utils import get_data_values, get_kinematics, get_systematics

from nnpdf_data.filter_utils.utils import prettify_float

yaml.add_representer(float, prettify_float)


def filter_ATLAS_Z0_7TEV_36FB_data_kinematic():
"""
This function writes the systematics to yaml files.
"""

central_values = get_data_values()

kin = get_kinematics()

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_7TEV_36FB_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 = []
counter_1 = 1
counter_2 = 0
for sys in systematics:
if sys[0]['name'] == 'stat':
error_definitions[sys[0]['name']] = {
"description": "Uncorrelated statistical uncertainties",
"treatment": "ADD",
"type": "UNCORR",
}

elif sys[0]['name'] == 'uncor':
error_definitions[sys[0]['name']] = {
"description": f"Sys uncertainty idx: {counter_1}",
"treatment": "MULT",
"type": "UNCORR",
}
counter_1 += 1

elif sys[0]['name'] == 'atlaslumi10':
error_definitions[sys[0]['name']] = {
"description": f"Sys uncertainty idx: {counter_1}",
"treatment": "MULT",
"type": "ATLASLUMI10",
}
counter_1 += 1

else:
error_definitions[sys[0]['name']] = {
"description": f"Sys uncertainty idx: {counter_1}",
"treatment": "MULT",
"type": f"ATLASWZRAP36PB_{counter_2}",
}
counter_1 += 1
counter_2 += 1

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_7TEV_36FB_data_kinematic()
filter_ATLAS_Z0_7TEV_36FB_systematics()
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
This module contains helper functions that are used to extract the data values
from the rawdata files.
"""

import yaml
import pandas as pd
import numpy as np


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

data_central = []

hepdata_table = f"rawdata/HEPData-ins928289-v1-Table_1.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 and apply the correction factor
data_central.append(value['value'] * 1000 * 1.0187)

return data_central


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

hepdata_table = f"rawdata/HEPData-ins928289-v1-Table_1.yaml"

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

for i, M in enumerate(input["independent_variables"][0]['values']):
kin_value = {
'abs_eta': {'min': None, 'mid': (0.5 * (M['low'] + M['high'])), 'max': None},
'm_Z2': {'min': None, 'mid': 8315.17839376, 'max': None},
'sqrts': {'min': None, 'mid': 7000.0, 'max': None},
}
kin.append(kin_value)

return kin


def get_systematics_dataframe():
"""
returns the absolute systematic uncertainties in the form of a pandas dataframe.
"""
sys_rawdata_path = "rawdata/ATLAS-36PB_Z.csv"

abs_unc_df_arr = []

data_central = get_data_values()

df = pd.read_csv(sys_rawdata_path)

# convert (MULT) percentage unc to absolute unc
abs_unc_df = (df.T[2:] * data_central).T / 100
abs_unc_df_arr.append(abs_unc_df)

return abs_unc_df


def get_systematics():
""" """
abs_unc_df = get_systematics_dataframe()

uncertainties = []

for i, unc_dp in enumerate(abs_unc_df.values.T):
name = f"{abs_unc_df.columns[i]}"
values = [unc_dp[j] for j in range(len(unc_dp))]
uncertainties.append([{"name": name, "values": values}])

return uncertainties


if __name__ == "__main__":
get_data_values()
get_kinematics()
get_systematics()
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
bins:
- abs_eta:
min: null
mid: 0.2
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
- abs_eta:
min: null
mid: 6.00000000e-01
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
- abs_eta:
min: null
mid: 1.0
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
- abs_eta:
min: null
mid: 1.4
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
- abs_eta:
min: null
mid: 1.8
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
- abs_eta:
min: null
mid: 2.2
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
- abs_eta:
min: null
mid: 2.60000000e+00
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
- abs_eta:
min: null
mid: 3.2
max: null
m_Z2:
min: null
mid: 8.31517839e+03
max: null
sqrts:
min: null
mid: 7000.0
max: null
53 changes: 27 additions & 26 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_7TEV_36PB/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
setname: ATLAS_Z0_7TEV_36PB
version: 1
version_comment: Port of old commondata
version: 2
version_comment: Reimplementation of old commondata
nnpdf_metadata:
nnpdf31_process: DY NC
experiment: ATLAS
arXiv:
url: https://arxiv.org/abs/1109.5141
journal: Phys.Rev. D85 (2012) 072004
iNSPIRE:
url: ''
url: 'https://inspirehep.net/literature/928289'
hepdata:
url: ''
version: -1
url: 'https://www.hepdata.net/record/ins928289'
version: 1
implemented_observables:
- observable_name: ETA
observable:
description: Drell-Yan Rapidity Distribution
label: ATLAS $Z$ 7 TeV 2010
units: ''
process_type: EWK_RAP
tables: []
process_type: DY_Z_Y
tables: [1]
npoints: []
ndata: 8
plotting:
kinematics_override: ewk_rap_sqrt_scale
kinematics_override: identity
dataset_label: ATLAS $Z$ 7 TeV 2010
x_label: $\left\|\eta/y\right|$
y_label: $d\sigma/dy$ (fb)
Expand All @@ -42,35 +42,36 @@ implemented_observables:
- $Z$
- $Z$
- $Z$
plot_x: k1
plot_x: abs_eta
kinematic_coverage:
- k1
- k2
- k3
- abs_eta
- m_Z2
- sqrts
kinematics:
variables:
k1:
description: Variable k1
label: k1
abs_eta:
description: Absolute value of the rapidity of the Z boson
label: "$|y|$"
units: ''
k2:
description: Variable k2
label: k2
units: ''
k3:
description: Variable k3
label: k3
units: ''
file: kinematics_ETA.yaml
m_Z2:
description: Squared invariant mass of the Z boson
label: '$m_Z^2$'
units: 'GeV^2'
sqrts:
description: Square root of the center of mass energy
label: r"\sqrt{s}"
units: 'GeV'
file: kinematics.yaml
theory:
conversion_factor: 1.0
operation: 'null'
FK_tables:
- - ATLASWZRAP36PB-ATLAS-arXiv:1109.5141-Z0_eta34
data_uncertainties: []
data_uncertainties: [uncertainties.yaml]
variants:
legacy:
data_uncertainties:
- uncertainties_legacy_ETA.yaml
data_central: data_legacy_ETA.yaml
data_central: data_legacy_ETA.yaml
data_central: data.yaml
ported_from: ATLASZRAP36PB
Loading