Skip to content

Commit

Permalink
Added kinematics funtion
Browse files Browse the repository at this point in the history
  • Loading branch information
ecole41 committed Nov 9, 2024
1 parent 1b63e1d commit fef7a56
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 8 deletions.
19 changes: 12 additions & 7 deletions nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_7TEV_46FB/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@
"""

import yaml
from filter_utils import get_data_values

def prettify_float(representer, value):
return representer.represent_scalar('tag:yaml.org,2002:float', '{:.1f}'.format(value))

from filter_utils import get_data_values, get_kinematics
from nnpdf_data.filter_utils.utils import prettify_float

yaml.add_representer(float, prettify_float)

def filter_ATLAS_Z0_7TEV_46FB_CC_data_central():

def filter_ATLAS_Z0_7TEV_46FB_CC_data_kinematics():
"""
This function writes the central values to yaml files.
"""
central_values = list(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)


if __name__ == "__main__":
filter_ATLAS_Z0_7TEV_46FB_CC_data_central()
filter_ATLAS_Z0_7TEV_46FB_CC_data_kinematics()
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import yaml

# import pandas as pd
# import numpy as np

Expand Down Expand Up @@ -41,6 +42,69 @@ def get_data_values():
return data_central


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

hepdata_table_1 = f"rawdata/HEPData-ins1502620-v1-Table_11.yaml"
hepdata_table_2 = f"rawdata/HEPData-ins1502620-v1-Table_12.yaml"
hepdata_table_3 = f"rawdata/HEPData-ins1502620-v1-Table_13.yaml"

with open(hepdata_table_1, 'r') as file:
input_1 = yaml.safe_load(file)

with open(hepdata_table_2, 'r') as file:
input_2 = yaml.safe_load(file)

with open(hepdata_table_3, 'r') as file:
input_3 = yaml.safe_load(file)

for i, M in enumerate(input_1["independent_variables"][0]['values']):

kin_value = {
'k1': {
'min': None,
'mid': (0.5 * (M['low'] + M['high'])),
'max': None,
}, # absolute lepton eta
'k2': {'min': None, 'mid': 3136.0, 'max': None},
'k3': {'min': None, 'mid': 7000.0, 'max': None},
}

kin.append(kin_value)

for i, M in enumerate(input_2["independent_variables"][0]['values']):

kin_value = {
'k1': {
'min': None,
'mid': (0.5 * (M['low'] + M['high'])),
'max': None,
}, # absolute lepton eta
'k2': {'min': None, 'mid': 8281.0, 'max': None},
'k3': {'min': None, 'mid': 7000.0, 'max': None},
}

kin.append(kin_value)

for i, M in enumerate(input_3["independent_variables"][0]['values']):

kin_value = {
'k1': {
'min': None,
'mid': (0.5 * (M['low'] + M['high'])),
'max': None,
}, # absolute lepton eta
'k2': {'min': None, 'mid': 17689.0, 'max': None},
'k3': {'min': None, 'mid': 7000.0, 'max': None},
}

kin.append(kin_value)

return kin


if __name__ == "__main__":
get_data_values()

Loading

0 comments on commit fef7a56

Please sign in to comment.