Skip to content
Merged
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
86 changes: 86 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_7TEV_LOMASS/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""
filter.py module for ATLAS_Z0_7TEV_LOMASS dataset

When running `python filter.py` the relevant uncertainties , data and kinematics yaml
file will be created in the `nnpdf_data/commondata/ATLAS_Z0_7TEV_LOMASS` directory.
"""

import yaml
from filter_utils import get_kinematics, get_data_values, get_systematics


def filter_ATLAS_Z0_7TEV_LOMASS_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_7TEV_LOMASS_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'] == 'sys_res') or (sys[0]['name'] == 'sys_MC'):
error_definitions[sys[0]['name']] = {
"description": f"{sys[0]['name']}",
"treatment": "MULT",
"type": "UNCORR",
}

else:
error_definitions[sys[0]['name']] = {
"description": f"{sys[0]['name']}",
"treatment": "MULT",
"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
with open(f"uncertainties.yaml", 'w') as file:
yaml.dump(uncertainties_yaml, file, sort_keys=False)


if __name__ == "__main__":
filter_ATLAS_Z0_7TEV_LOMASS_data_kinetic()
filter_ATLAS_Z0_7TEV_LOMASS_systematics()
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""
This module contains helper functions that are used to extract the uncertainties, kinematics and data values
from the rawdata files.
"""

import yaml
import pandas as pd
import numpy as np


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

hepdata_table = f"rawdata/HEPData-ins1288706-v1-Table_6.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 = {
'm_ll': {'min': M['low'], 'mid': (0.5 * (M['low'] + M['high'])), 'max': M['high']},
'sqrts': {'min': None, 'mid': 7000.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-ins1288706-v1-Table_6.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_dataframe():
"""
returns the absolute systematic uncertainties in the form of a pandas dataframe.
"""
sys_rawdata_path = "rawdata/ATLASLOMASSDY11EXT.csv"

df = pd.read_csv(sys_rawdata_path)
data_central = np.array(get_data_values())

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

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
bins:
- m_ll:
min: 12.0
mid: 14.5
max: 17.0
sqrts:
min: null
mid: 7000.0
max: null
- m_ll:
min: 17.0
mid: 19.5
max: 22.0
sqrts:
min: null
mid: 7000.0
max: null
- m_ll:
min: 22.0
mid: 25.0
max: 28.0
sqrts:
min: null
mid: 7000.0
max: null
- m_ll:
min: 28.0
mid: 32.0
max: 36.0
sqrts:
min: null
mid: 7000.0
max: null
- m_ll:
min: 36.0
mid: 41.0
max: 46.0
sqrts:
min: null
mid: 7000.0
max: null
- m_ll:
min: 46.0
mid: 56.0
max: 66.0
sqrts:
min: null
mid: 7000.0
max: null

This file was deleted.

50 changes: 23 additions & 27 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_7TEV_LOMASS/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,56 @@
setname: ATLAS_Z0_7TEV_LOMASS
version: 1
version_comment: Port of old commondata
version_comment: "First implementation"
nnpdf_metadata:
nnpdf31_process: DY NC
experiment: ATLAS
arXiv:
url: https://arxiv.org/abs/1404.1212
journal: JHEP 06 (2014) 112
iNSPIRE:
url: ''
url: 'https://inspirehep.net/literature/1288706'
hepdata:
url: 10.17182/hepdata.64183.v1/t6
version: -1
url: 'https://www.hepdata.net/record/ins1288706'
version: 1
implemented_observables:
- observable_name: M
observable:
description: Drell-Yan Mass Distribution
label: ATLAS low-mass DY 2011
units: ''
process_type: EWK_MLL
tables: []
npoints: []
process_type: DY_MLL
tables: [6]
npoints: [6]
ndata: 6
plotting:
kinematics_override: ewk_mll_sqrt_scale
kinematics_override: identity
dataset_label: ATLAS low-mass DY 2011
y_label: $d\sigma_{Z/\gamma^{*}}/dM_{ll}$ (fb)
plot_x: k2
plot_x: m_ll
kinematic_coverage:
- k1
- k2
- k3
- m_ll
- 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_M.yaml
m_ll:
description: dilepton mass
label: '$m_{ll}$'
units: 'GeV'
sqrts:
description: center of mass energy
label: sqrts
units: 'GeV'
file: kinematics.yaml
theory:
conversion_factor: 1000.0
operation: 'null'
FK_tables:
- - ATLAS_DY_7TEV_LOMASS_EXT
data_uncertainties: []
data_uncertainties:
- uncertainties.yaml
variants:
legacy:
data_uncertainties:
- uncertainties_legacy_M.yaml
data_central: data_legacy_M.yaml
data_central: data.yaml
ported_from: ATLASLOMASSDY11EXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Mlow, Mhigh,y,stat,sys_reco,sys_trig,sys_iso,sys_mjet,sys_pTsc,sys_res,sys_MC,lumi
12.0,17,12.41,4.2,2.5,4.0,11.3,-3.0,-0.2,0.5,0.6,3.5
17.0,22.0,22.57,3.1,1.4,3.7,11.3,-2.8,0.1,0.3,0.3,3.5
22.0,28.0,14.64,3.3,0.9,3.6,8.5,-1.8,0.0,0.1,0.4,3.5
28.0,36.0,6.73,4.0,0.7,3.6,6.2,-1.6,-0.1,0.2,0.4,3.5
36.0,46.0,2.81,5.2,0.7,3.6,4.2,-1.3,-0.1,0.1,0.5,3.5
46.0,66.0,1.27,4.7,0.6,3.6,3.6,-0.7,0.0,0.1,0.5,3.5
Loading