Skip to content

Commit

Permalink
added data and kinematics and code to generate it
Browse files Browse the repository at this point in the history
  • Loading branch information
comane committed Nov 9, 2024
1 parent fabfb23 commit 85b7433
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 4 deletions.
3 changes: 3 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data_central:
- 3.50000000e+06
- 4.53000000e+06
92 changes: 92 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter.py
Original file line number Diff line number Diff line change
@@ -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()
87 changes: 87 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/filter_utils.py
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
setname: ATLAS_WPWM_13TEV
version: 1
version_comment: Port of old commondata
version_comment: New implementation
nnpdf_metadata:
nnpdf31_process: DY CC
experiment: ATLAS
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 85b7433

Please sign in to comment.