Skip to content

Commit

Permalink
added metadata, kinematics, and data of CMS_WP_13TEV
Browse files Browse the repository at this point in the history
  • Loading branch information
comane committed Nov 16, 2023
1 parent ce6c05c commit fe46214
Show file tree
Hide file tree
Showing 6 changed files with 692 additions and 0 deletions.
11 changes: 11 additions & 0 deletions buildmaster/CMS_WP_13TEV/data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
data_central:
- 2944.0
- 2918.0
- 2966.0
- 2902.0
- 2906.0
- 2844.0
- 2887.0
- 2634.0
- 3100.0
- 2670.0
103 changes: 103 additions & 0 deletions buildmaster/CMS_WP_13TEV/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import yaml

from filter_utils import get_kinematics, get_data_values, get_systematics


def filter_CMS_WP_13TEV_data_kinetic():
"""
writes data central values and kinematics
to respective .yaml file
"""
with open("metadata.yaml", "r") as file:
metadata = yaml.safe_load(file)

version = metadata["hepdata"]["version"]
tables = metadata["implemented_observables"][0]["tables"]

kin = get_kinematics(version)
central_values = get_data_values(version)


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_Z_13TEV_PT_uncertainties():
"""
writes uncertainties to respective .yaml file
"""

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

version = metadata["hepdata"]["version"]
# tables for Z->e+e- observable
tables_E = metadata["implemented_observables"][0]["tables"]
# tables for Z->mu+mu- observable
tables_MU = metadata["implemented_observables"][1]["tables"]
tables = {"E": tables_E, "MU": tables_MU}

systematics_E = get_systematics(tables_E, version)
systematics_MU = get_systematics(tables_MU, version)
systematics = {"E": systematics_E, "MU": systematics_MU}

# error definition
error_definitions = {}
errors = {}

for obs in ["E","MU"]:

error_definitions[obs] = {}

for sys in systematics[obs]:

if sys[0]['name'] in UNCORRELATED_SYS:
error_definitions[obs][sys[0]['name']] = {
"description": f"{sys[0]['name']} from HEPDATA",
"treatment": "ADD",
"type": "UNCORR",
}

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

# TODO:
# store error in dict
errors[obs] = []
central_values = get_data_values(tables[obs], version)

for i in range(len(central_values)):
error_value = {}

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

errors[obs].append(error_value)

uncertainties_yaml = {"definitions": error_definitions[obs], "bins": errors[obs]}

# write uncertainties
with open(f"uncertainties_{obs}.yaml", 'w') as file:
yaml.dump(uncertainties_yaml, file, sort_keys=False)






if __name__ == "__main__":
filter_CMS_WP_13TEV_data_kinetic()


98 changes: 98 additions & 0 deletions buildmaster/CMS_WP_13TEV/filter_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import yaml


def get_kinematics(version):
"""
returns the relevant kinematics values.
Parameters
----------
version : int
integer read from metadata.yaml that
indicated the version of the hepdata
tables
Returns
-------
list
list containing the kinematic values for all
hepdata tables
"""
kin = []

hepdata_table = f"rawdata/HEPData-ins1810913-v{version}-Figure_A2.yaml"

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

for y in input["independent_variables"][0]['values']:
kin_value = {
'yW': {'min': y['low'], 'mid': 0.5 * (y['low'] + y['high']), 'max': y['high']},
'mZ_2': {'min': None, 'mid': 6460.5, 'max': None},
'sqrt_s': {'min': None, 'mid': 13000.0, 'max': None},
}

kin.append(kin_value)

return kin



def get_data_values(version):
"""
returns the central data.
Parameters
----------
version : int
integer read from metadata.yaml that
indicated the version of the hepdata
tables
Returns
-------
list
list containing the central values for all
hepdata tables
"""

data_central = []

hepdata_table = f"rawdata/HEPData-ins1810913-v{version}-Figure_A2.yaml"

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

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

for value in values:
data_central.append(value['value'])

return data_central


def get_systematics(tables, version):
"""
"""
uncertainties = []

hepdata_table = f"rawdata/HEPData-ins1768911-v{version}-Table_{tables[0]}.yaml"

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

dependent_vars = input['dependent_variables']

# skip 1st entry as these are central data values
for dep_var in dependent_vars[1:]:

name = dep_var['header']['name']
values = [d['value'] for d in dep_var['values']]
uncertainties.append([{"name":name, "values":values}])

return uncertainties

if __name__ == "__main__":
get_kinematics(version=1)
get_data_values(version=1)
121 changes: 121 additions & 0 deletions buildmaster/CMS_WP_13TEV/kinematics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
bins:
- yW:
min: 0.0
mid: 0.125
max: 0.25
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 0.25
mid: 0.375
max: 0.5
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 0.5
mid: 0.625
max: 0.75
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 0.75
mid: 0.875
max: 1.0
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 1.0
mid: 1.125
max: 1.25
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 1.25
mid: 1.375
max: 1.5
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 1.5
mid: 1.625
max: 1.75
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 1.75
mid: 1.875
max: 2.0
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 2.0
mid: 2.125
max: 2.25
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
- yW:
min: 2.25
mid: 2.375
max: 2.5
mZ_2:
min: null
mid: 6460.5
max: null
sqrt_s:
min: null
mid: 13000.0
max: null
Loading

0 comments on commit fe46214

Please sign in to comment.