-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement Atlas Z0 8 TeV lowmass #2205
Open
comane
wants to merge
12
commits into
master
Choose a base branch
from
reimplement_ATLAS_Z0_8TEV_LOWMASS
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
015a332
added data and kinematics
comane c4110a5
added raw hepdata
comane 48448fe
added refereences to metadata
comane c4fd45c
renamed Stat to stat
comane 68590ca
added version 1 for checks
comane f533376
added version dep on filter file
comane ac3366b
updated metadata
comane 162a028
added def value of lumi unc
comane fcab0ae
LUMI unc should be of SPECIAL type
comane d86c293
added process type to metadata
comane 69a33a2
renamed local variable of filter rules
comane a8c3d01
changed labels and figure by
comane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_8TEV_LOWMASS/filter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
""" | ||
filter.py module for ATLAS_Z0_8TEV_LOWMASS dataset | ||
When running `python filter.py` the relevant uncertainties , data and kinematics yaml | ||
file will be created in the `nnpdf_data/commondata/ATLAS_Z0_8TEV_LOWMASS` 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_Z0_8TEV_LOWMASS_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": "UNCORR", | ||
} | ||
|
||
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_Z0_8TEV_LOWMASS_data_kinetic() | ||
filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=3) | ||
# filter_ATLAS_Z0_8TEV_LOWMASS_systematics(version=1) |
99 changes: 99 additions & 0 deletions
99
nnpdf_data/nnpdf_data/commondata/ATLAS_Z0_8TEV_LOWMASS/filter_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
""" | ||
This module contains helper functions that are used to extract the uncertainties, kinematics and data values | ||
from the rawdata files. | ||
""" | ||
|
||
import yaml | ||
|
||
ATLAS_LUMI_UNC = 0.018 | ||
|
||
def get_kinematics(): | ||
""" | ||
returns the kinematics in the form of a list of dictionaries. | ||
""" | ||
kin = [] | ||
|
||
hepdata_table = f"rawdata/HEPData-ins1630886-v3-Table_5.yaml" | ||
|
||
with open(hepdata_table, 'r') as file: | ||
input = yaml.safe_load(file) | ||
|
||
for indep_var1, indep_var2 in zip( | ||
input["independent_variables"][1]['values'], input["independent_variables"][2]['values'] | ||
): | ||
|
||
kin_value = { | ||
'y': { | ||
'min': indep_var1['low'], | ||
'mid': 0.5 * (indep_var1['low'] + indep_var1['high']), | ||
'max': indep_var1['high'], | ||
}, | ||
'm_Z2': { | ||
'min': indep_var2['low']**2, | ||
'mid': (0.5 * (indep_var2['low'] + indep_var2['high']))**2, | ||
'max': indep_var2['high']**2, | ||
}, | ||
'sqrts': {'min': None, 'mid': 8000.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-ins1630886-v3-Table_5.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(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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A possible bug here is that the LUMI in the legacy implementation was treated as UNCORR.
It should however be CORR (ATLASLUMI12). If I set it to CORR, however, the chi2 changes by an order of magnitude (see report)
Am I missing something here or is it genuine?
https://vp.nnpdf.science/X59c09ozTEmm9vwP3vYTRg==