-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into reimplement_ATLAS_Z…
…0_7TEV_46FB_CC_AND_CF
- Loading branch information
Showing
19 changed files
with
688 additions
and
49 deletions.
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
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,3 @@ | ||
data_central: | ||
- 3.50000000e+06 | ||
- 4.53000000e+06 |
88 changes: 88 additions & 0 deletions
88
nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/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,88 @@ | ||
""" | ||
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() | ||
# only keep first 2 as the last bin is for Z observable | ||
central_values = list(get_data_values())[:-1] | ||
|
||
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_WPWM_13TEV_TOT_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'] == 'ATLAS_LUMI': | ||
error_definitions["ATLASLUMI13"] = { | ||
"description": f"ATLASLUMI13", | ||
"treatment": "MULT", | ||
"type": "ATLASLUMI13", | ||
} | ||
|
||
else: | ||
error_definitions[sys[0]['name']] = { | ||
"description": f"{sys[0]['name']}", | ||
"treatment": "ADD", | ||
"type": f"{sys[0]['name']}", | ||
} | ||
|
||
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_WPWM_13TEV_TOT_data_kinetic() | ||
filter_ATLAS_WPWM_13TEV_TOT_systematics() |
135 changes: 135 additions & 0 deletions
135
nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/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,135 @@ | ||
""" | ||
This module contains helper functions that are used to extract the uncertainties, kinematics and data values | ||
from the rawdata files. | ||
""" | ||
|
||
import yaml | ||
import numpy as np | ||
from nnpdf_data.filter_utils.utils import decompose_covmat | ||
|
||
MW2 = 80.385**2 | ||
UNIT_CONVERSION = 1000000 | ||
TABLES = [9, 8, 11] # order is W-, W+, Z | ||
|
||
|
||
def get_kinematics(): | ||
""" | ||
returns the kinematics in the form of a list of dictionaries. | ||
""" | ||
kin = [] | ||
|
||
for _ in range(2): | ||
|
||
kin_value = { | ||
'm_W2': {'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. | ||
""" | ||
name_data = lambda tab: f"rawdata/HEPData-ins1436497-v1-Table_{tab}.yaml" | ||
|
||
data_central = [] | ||
|
||
for tab in TABLES: | ||
with open(name_data(tab), 'r') as file: | ||
input = yaml.safe_load(file) | ||
values = input['dependent_variables'][0]['values'] | ||
data_central.append(values[0]['value'] * UNIT_CONVERSION) | ||
|
||
return data_central | ||
|
||
|
||
def get_uncertainties(): | ||
""" | ||
Returns array of shape (3,3) | ||
Each row corresponds to a different observable: (W-, W+, Z) | ||
Each column corresponds to a different systematic: (stat, sys, lumi) | ||
See table 3 of paper: https://arxiv.org/abs/1603.09222 | ||
""" | ||
|
||
name_data = lambda tab: f"rawdata/HEPData-ins1436497-v1-Table_{tab}.yaml" | ||
|
||
uncertainties = [] | ||
|
||
for tab in TABLES: | ||
with open(name_data(tab), 'r') as file: | ||
input = yaml.safe_load(file) | ||
errors = input['dependent_variables'][0]['values'][0]['errors'] | ||
uncertainties.append( | ||
np.array([errors[0]['symerror'], errors[1]['symerror'], errors[2]['symerror']]) | ||
) | ||
|
||
return np.array(uncertainties) * UNIT_CONVERSION | ||
|
||
|
||
def get_correlation_matrix(): | ||
""" | ||
See extra material page: https://atlas.web.cern.ch/Atlas/GROUPS/PHYSICS/PAPERS/STDM-2015-03/tabaux_03.pdf | ||
Note that this does not include the normalisation uncertainty due to the luminosity. | ||
""" | ||
|
||
correlation_matrix = np.ones((3, 3)) | ||
correlation_matrix[0, 1] = 0.93 | ||
correlation_matrix[1, 0] = correlation_matrix[0, 1] | ||
correlation_matrix[0, 2] = 0.18 | ||
correlation_matrix[2, 0] = correlation_matrix[0, 2] | ||
correlation_matrix[1, 2] = 0.19 | ||
correlation_matrix[2, 1] = correlation_matrix[1, 2] | ||
|
||
return correlation_matrix | ||
|
||
|
||
def get_covariance_matrices(): | ||
""" | ||
For the systematics see Table 3 of paper: https://arxiv.org/abs/1603.09222 | ||
Returns: | ||
-------- | ||
tuple: (cov_matrix_no_lumi, lumi_cov) | ||
cov_matrix_no_lumi: np.array, the sum of stat and syst covmats -> to be decomposed into artificial systematics | ||
lumi_cov: np.array, the lumi covmat. This is correlated between experiments so needs to be saved with type: SPECIAL | ||
""" | ||
corr_matrix = get_correlation_matrix() | ||
uncertainties = get_uncertainties() | ||
|
||
# build correlated systematics covariance | ||
sys = np.array([uncertainties[i, 1] for i in range(3)]) | ||
cov_sys = corr_matrix * np.outer(sys, sys) | ||
|
||
# array of lumi uncertainties | ||
lumi_unc = np.array([uncertainties[i, 2] for i in range(3)]) | ||
|
||
# array of stat uncertainties | ||
stat = np.array([uncertainties[i, 0] for i in range(3)]) | ||
|
||
return stat, cov_sys, lumi_unc | ||
|
||
|
||
def get_systematics(): | ||
stat, cov_sys, lumi_unc = get_covariance_matrices() | ||
|
||
# decompose sys covmat | ||
syst_unc = decompose_covmat(cov_sys) | ||
|
||
uncertainties = [] | ||
|
||
# store only systematics for W+ and W- | ||
for i in range(3): | ||
uncertainties.append( | ||
[{"name": f"ATLAS_WZ_TOT_13TEV_{i}", "values": [syst_unc[0, i], syst_unc[1, i]]}] | ||
) | ||
|
||
uncertainties.append([{"name": "stat", "values": [stat[0], stat[1]]}]) | ||
uncertainties.append([{"name": "ATLAS_LUMI", "values": [lumi_unc[0], lumi_unc[1]]}]) | ||
|
||
return uncertainties |
17 changes: 17 additions & 0 deletions
17
nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/kinematics.yaml
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,17 @@ | ||
bins: | ||
- m_W2: | ||
min: null | ||
mid: 6.46174823e+03 | ||
max: null | ||
sqrts: | ||
min: null | ||
mid: 13000.0 | ||
max: null | ||
- m_W2: | ||
min: null | ||
mid: 6.46174823e+03 | ||
max: null | ||
sqrts: | ||
min: null | ||
mid: 13000.0 | ||
max: null |
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
20 changes: 20 additions & 0 deletions
20
...f_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_11.yaml
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,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: MZ, units: GEV, value: 66-116} | ||
- {name: PT(C=ELECTRON), units: GEV, value: '> 25'} | ||
- {name: PT(C=MUON), units: GEV, value: '> 25'} | ||
- {name: RE, value: P P --> ( Z0 < E+ E- + MU+ MU- > + GAMMA* < E+ E- + MU+ MU- | ||
> ) X} | ||
values: | ||
- errors: | ||
- {label: stat, symerror: 0.003} | ||
- {label: sys, symerror: 0.006} | ||
- {label: sys, symerror: 0.016} | ||
value: 0.779 | ||
independent_variables: | ||
- header: {name: SQRT(S), units: GEV} | ||
values: | ||
- {value: 13000.0} |
20 changes: 20 additions & 0 deletions
20
nnpdf_data/nnpdf_data/commondata/ATLAS_WPWM_13TEV/rawdata/HEPData-ins1436497-v1-Table_8.yaml
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,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} |
Oops, something went wrong.