Skip to content
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

New metadata format #1684

1,054 changes: 1,054 additions & 0 deletions Playground for the new commondata format.ipynb

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions buildmaster/CMS_TTBAR_8TEV_LJ_DIF/data_dSig_dmttBar_norm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
data_central:
- 0.00469
- 0.0043
- 0.00267
- 0.00117
- 0.000466
- 0.000114
- 1.1e-05
9 changes: 9 additions & 0 deletions buildmaster/CMS_TTBAR_8TEV_LJ_DIF/data_dSig_dpTt_norm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
data_central:
- 0.00414
- 0.00669
- 0.00496
- 0.00266
- 0.00106
- 0.000399
- 0.00013
- 3.7e-05
11 changes: 11 additions & 0 deletions buildmaster/CMS_TTBAR_8TEV_LJ_DIF/data_dSig_dyt_norm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
data_central:
- 0.0736
- 0.175
- 0.261
- 0.3
- 0.333
- 0.331
- 0.3
- 0.247
- 0.188
- 0.0777
11 changes: 11 additions & 0 deletions buildmaster/CMS_TTBAR_8TEV_LJ_DIF/data_dSig_dyttBar_norm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
data_central:
- 0.0607
- 0.22
- 0.327
- 0.373
- 0.427
- 0.413
- 0.374
- 0.317
- 0.23
- 0.0641
278 changes: 278 additions & 0 deletions buildmaster/CMS_TTBAR_8TEV_LJ_DIF/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
# implemented by Tanishq Sharma

import yaml
from utils import covMat_to_artUnc as cta
from utils import percentage_to_absolute as pta

def processData():
with open('metadata.yaml', 'r') as file:
metadata = yaml.safe_load(file)

ndata_dSig_dpTt = metadata['implemented_observables'][0]['ndata']
ndata_dSig_dyt = metadata['implemented_observables'][1]['ndata']
ndata_dSig_dyttBar = metadata['implemented_observables'][2]['ndata']
ndata_dSig_dmttBar = metadata['implemented_observables'][3]['ndata']

data_central_dSig_dpTt = []
kin_dSig_dpTt = []
error_dSig_dpTt = []
data_central_dSig_dyt = []
kin_dSig_dyt = []
error_dSig_dyt = []
data_central_dSig_dyttBar = []
kin_dSig_dyttBar = []
error_dSig_dyttBar = []
data_central_dSig_dmttBar = []
kin_dSig_dmttBar = []
error_dSig_dmttBar = []

covMatArray_dSig_dpTt = []
covMatArray_dSig_dyt = []
covMatArray_dSig_dyttBar = []
covMatArray_dSig_dmttBar = []

# dSig_dpTt data

hepdata_tables="rawdata/Table15.yaml"
with open(hepdata_tables, 'r') as file:
input = yaml.safe_load(file)

covariance_matrix="rawdata/Table16.yaml"
with open(covariance_matrix, 'r') as file2:
input2 = yaml.safe_load(file2)

systematics_breakdown="rawdata/Table17.yaml"
with open(systematics_breakdown, 'r') as file3:
input3 = yaml.safe_load(file3)

for i in range(ndata_dSig_dpTt*ndata_dSig_dpTt):
covMatEl = input2['dependent_variables'][0]['values'][i]['value']
covMatArray_dSig_dpTt.append(covMatEl)
artUncMat_dSig_dpTt = cta(ndata_dSig_dpTt, covMatArray_dSig_dpTt, True)

sqrt_s = float(input['dependent_variables'][0]['qualifiers'][2]['value'])
mt_sqr = 29846.0176
values = input['dependent_variables'][0]['values']

for i in range(len(values)):
pT_t_min = input['independent_variables'][0]['values'][i]['low']
pT_t_mid = input['independent_variables'][1]['values'][i]['value']
pT_t_max = input['independent_variables'][0]['values'][i]['high']
error_value = {}
error_value['stat'] = 0
# error_value['sys'] = values[i]['errors'][1]['symerror']
for j in range(ndata_dSig_dpTt):
error_value['ArtUnc_'+str(j+1)] = float(artUncMat_dSig_dpTt[i][j])
data_central_value = values[i]['value']
for j in range(11):
error_value[input3['independent_variables'][0]['values'][j]['value']] = pta(str(input3['dependent_variables'][i]['values'][j]['value']), data_central_value)
kin_value = {'sqrt_s': {'min': None, 'mid': sqrt_s, 'max': None}, 'mt_sqr': {'min': None, 'mid': mt_sqr, 'max': None}, 'pT_t': {'min': pT_t_min, 'mid': pT_t_mid, 'max': pT_t_max}}
data_central_dSig_dpTt.append(data_central_value)
kin_dSig_dpTt.append(kin_value)
error_dSig_dpTt.append(error_value)

error_definition_dSig_dpTt = {}
error_definition_dSig_dpTt['stat'] = {'description': 'total statistical uncertainty', 'treatment': 'ADD', 'type': 'UNCORR'}
# error_definition_dSig_dpTt['sys'] = {'description': 'total systematic uncertainty', 'treatment': 'MULT', 'type': 'CORR'}
for i in range(ndata_dSig_dpTt):
error_definition_dSig_dpTt['ArtUnc_'+str(i+1)] = {'definition': 'artificial uncertainty '+str(i+1), 'treatment': 'ADD', 'type': 'CORR'}
for i in range(11):
error_definition_dSig_dpTt[input3['independent_variables'][0]['values'][i]['value']] = {'definition': 'systematic uncertainty- '+str(input3['independent_variables'][0]['values'][i]['value']), 'treatment': 'MULT', 'type': 'CORR'}

data_central_dSig_dpTt_norm_yaml = {'data_central': data_central_dSig_dpTt}
kinematics_dSig_dpTt_norm_yaml = {'bins': kin_dSig_dpTt}
uncertainties_dSig_dpTt_norm_yaml = {'definitions': error_definition_dSig_dpTt, 'bins': error_dSig_dpTt}

with open('data_dSig_dpTt_norm.yaml', 'w') as file:
yaml.dump(data_central_dSig_dpTt_norm_yaml, file, sort_keys=False)

with open('kinematics_dSig_dpTt_norm.yaml', 'w') as file:
yaml.dump(kinematics_dSig_dpTt_norm_yaml, file, sort_keys=False)

with open('uncertainties_dSig_dpTt_norm.yaml', 'w') as file:
yaml.dump(uncertainties_dSig_dpTt_norm_yaml, file, sort_keys=False)

# dSig_dyt data

hepdata_tables="rawdata/Table21.yaml"
with open(hepdata_tables, 'r') as file:
input = yaml.safe_load(file)

covariance_matrix="rawdata/Table22.yaml"
with open(covariance_matrix, 'r') as file2:
input2 = yaml.safe_load(file2)

systematics_breakdown="rawdata/Table23.yaml"
with open(systematics_breakdown, 'r') as file3:
input3 = yaml.safe_load(file3)

for i in range(ndata_dSig_dyt*ndata_dSig_dyt):
covMatEl = input2['dependent_variables'][0]['values'][i]['value']
covMatArray_dSig_dyt.append(covMatEl)
artUncMat_dSig_dyt = cta(ndata_dSig_dyt, covMatArray_dSig_dyt, True)

sqrt_s = float(input['dependent_variables'][0]['qualifiers'][2]['value'])
mt_sqr = 29846.0176
values = input['dependent_variables'][0]['values']

for i in range(len(values)):
y_t_min = input['independent_variables'][0]['values'][i]['low']
y_t_mid = input['independent_variables'][1]['values'][i]['value']
y_t_max = input['independent_variables'][0]['values'][i]['high']
error_value = {}
error_value['stat'] = 0
# error_value['sys'] = values[i]['errors'][1]['symerror']
for j in range(ndata_dSig_dyt):
error_value['ArtUnc_'+str(j+1)] = float(artUncMat_dSig_dyt[i][j])
data_central_value = values[i]['value']
for j in range(11):
error_value[input3['independent_variables'][0]['values'][j]['value']] = pta(str(input3['dependent_variables'][i]['values'][j]['value']), data_central_value)
kin_value = {'sqrt_s': {'min': None, 'mid': sqrt_s, 'max': None}, 'mt_sqr': {'min': None, 'mid': mt_sqr, 'max': None}, 'y_t': {'min': y_t_min, 'mid': y_t_mid, 'max': y_t_max}}
data_central_dSig_dyt.append(data_central_value)
kin_dSig_dyt.append(kin_value)
error_dSig_dyt.append(error_value)

error_definition_dSig_dyt = {}
error_definition_dSig_dyt['stat'] = {'description': 'total statistical uncertainty', 'treatment': 'ADD', 'type': 'UNCORR'}
# error_definition_dSig_dyt['sys'] = {'description': 'total systematic uncertainty', 'treatment': 'MULT', 'type': 'CORR'}
for i in range(ndata_dSig_dyt):
error_definition_dSig_dyt['ArtUnc_'+str(i+1)] = {'definition': 'artificial uncertainty '+str(i+1), 'treatment': 'ADD', 'type': 'CORR'}
for i in range(11):
error_definition_dSig_dyt[input3['independent_variables'][0]['values'][i]['value']] = {'definition': 'systematic uncertainty- '+str(input3['independent_variables'][0]['values'][i]['value']), 'treatment': 'MULT', 'type': 'CORR'}

data_central_dSig_dyt_norm_yaml = {'data_central': data_central_dSig_dyt}
kinematics_dSig_dyt_norm_yaml = {'bins': kin_dSig_dyt}
uncertainties_dSig_dyt_norm_yaml = {'definitions': error_definition_dSig_dyt, 'bins': error_dSig_dyt}

with open('data_dSig_dyt_norm.yaml', 'w') as file:
yaml.dump(data_central_dSig_dyt_norm_yaml, file, sort_keys=False)

with open('kinematics_dSig_dyt_norm.yaml', 'w') as file:
yaml.dump(kinematics_dSig_dyt_norm_yaml, file, sort_keys=False)

with open('uncertainties_dSig_dyt_norm.yaml', 'w') as file:
yaml.dump(uncertainties_dSig_dyt_norm_yaml, file, sort_keys=False)

# dSig_dyttBar data

hepdata_tables="rawdata/Table36.yaml"
with open(hepdata_tables, 'r') as file:
input = yaml.safe_load(file)

covariance_matrix="rawdata/Table37.yaml"
with open(covariance_matrix, 'r') as file2:
input2 = yaml.safe_load(file2)

systematics_breakdown="rawdata/Table38.yaml"
with open(systematics_breakdown, 'r') as file3:
input3 = yaml.safe_load(file3)

for i in range(ndata_dSig_dyttBar*ndata_dSig_dyttBar):
covMatEl = input2['dependent_variables'][0]['values'][i]['value']
covMatArray_dSig_dyttBar.append(covMatEl)
artUncMat_dSig_dyttBar = cta(ndata_dSig_dyttBar, covMatArray_dSig_dyttBar, True)

sqrt_s = float(input['dependent_variables'][0]['qualifiers'][2]['value'])
mt_sqr = 29846.0176
values = input['dependent_variables'][0]['values']

for i in range(len(values)):
y_ttBar_min = input['independent_variables'][0]['values'][i]['low']
y_ttBar_mid = input['independent_variables'][1]['values'][i]['value']
y_ttBar_max = input['independent_variables'][0]['values'][i]['high']
error_value = {}
error_value['stat'] = 0
# error_value['sys'] = values[i]['errors'][1]['symerror']
for j in range(ndata_dSig_dyttBar):
error_value['ArtUnc_'+str(j+1)] = float(artUncMat_dSig_dyttBar[i][j])
data_central_value = values[i]['value']
for j in range(11):
error_value[input3['independent_variables'][0]['values'][j]['value']] = pta(str(input3['dependent_variables'][i]['values'][j]['value']), data_central_value)
kin_value = {'sqrt_s': {'min': None, 'mid': sqrt_s, 'max': None}, 'mt_sqr': {'min': None, 'mid': mt_sqr, 'max': None}, 'y_ttBar': {'min': y_ttBar_min, 'mid': y_ttBar_mid, 'max': y_ttBar_max}}
data_central_dSig_dyttBar.append(data_central_value)
kin_dSig_dyttBar.append(kin_value)
error_dSig_dyttBar.append(error_value)

error_definition_dSig_dyttBar = {}
error_definition_dSig_dyttBar['stat'] = {'description': 'total statistical uncertainty', 'treatment': 'ADD', 'type': 'UNCORR'}
# error_definition_dSig_dyttBar['sys'] = {'description': 'total systematic uncertainty', 'treatment': 'MULT', 'type': 'CORR'}
for i in range(ndata_dSig_dyttBar):
error_definition_dSig_dyttBar['ArtUnc_'+str(i+1)] = {'definition': 'artificial uncertainty '+str(i+1), 'treatment': 'ADD', 'type': 'CORR'}
for i in range(11):
error_definition_dSig_dyttBar[input3['independent_variables'][0]['values'][i]['value']] = {'definition': 'systematic uncertainty- '+str(input3['independent_variables'][0]['values'][i]['value']), 'treatment': 'MULT', 'type': 'CORR'}

data_central_dSig_dyttBar_norm_yaml = {'data_central': data_central_dSig_dyttBar}
kinematics_dSig_dyttBar_norm_yaml = {'bins': kin_dSig_dyttBar}
uncertainties_dSig_dyttBar_norm_yaml = {'definitions': error_definition_dSig_dyttBar, 'bins': error_dSig_dyttBar}

with open('data_dSig_dyttBar_norm.yaml', 'w') as file:
yaml.dump(data_central_dSig_dyttBar_norm_yaml, file, sort_keys=False)

with open('kinematics_dSig_dyttBar_norm.yaml', 'w') as file:
yaml.dump(kinematics_dSig_dyttBar_norm_yaml, file, sort_keys=False)

with open('uncertainties_dSig_dyttBar_norm.yaml', 'w') as file:
yaml.dump(uncertainties_dSig_dyttBar_norm_yaml, file, sort_keys=False)

# dSig_dmttBar data

hepdata_tables="rawdata/Table39.yaml"
with open(hepdata_tables, 'r') as file:
input = yaml.safe_load(file)

covariance_matrix="rawdata/Table40.yaml"
with open(covariance_matrix, 'r') as file2:
input2 = yaml.safe_load(file2)

systematics_breakdown="rawdata/Table41.yaml"
with open(systematics_breakdown, 'r') as file3:
input3 = yaml.safe_load(file3)

for i in range(ndata_dSig_dmttBar*ndata_dSig_dmttBar):
covMatEl = input2['dependent_variables'][0]['values'][i]['value']
covMatArray_dSig_dmttBar.append(covMatEl)
artUncMat_dSig_dmttBar = cta(ndata_dSig_dmttBar, covMatArray_dSig_dmttBar, True)

sqrt_s = float(input['dependent_variables'][0]['qualifiers'][2]['value'])
mt_sqr = 29846.0176
values = input['dependent_variables'][0]['values']

for i in range(len(values)):
m_ttBar_min = input['independent_variables'][0]['values'][i]['low']
m_ttBar_mid = input['independent_variables'][1]['values'][i]['value']
m_ttBar_max = input['independent_variables'][0]['values'][i]['high']
error_value = {}
error_value['stat'] = 0
# error_value['sys'] = values[i]['errors'][1]['symerror']
for j in range(ndata_dSig_dmttBar):
error_value['ArtUnc_'+str(j+1)] = float(artUncMat_dSig_dmttBar[i][j])
data_central_value = values[i]['value']
for j in range(11):
error_value[input3['independent_variables'][0]['values'][j]['value']] = pta(str(input3['dependent_variables'][i]['values'][j]['value']), data_central_value)
kin_value = {'sqrt_s': {'min': None, 'mid': sqrt_s, 'max': None}, 'mt_sqr': {'min': None, 'mid': mt_sqr, 'max': None}, 'm_ttBar': {'min': m_ttBar_min, 'mid': m_ttBar_mid, 'max': m_ttBar_max}}
data_central_dSig_dmttBar.append(data_central_value)
kin_dSig_dmttBar.append(kin_value)
error_dSig_dmttBar.append(error_value)

error_definition_dSig_dmttBar = {}
error_definition_dSig_dmttBar['stat'] = {'description': 'total statistical uncertainty', 'treatment': 'ADD', 'type': 'UNCORR'}
# error_definition_dSig_dmttBar['sys'] = {'description': 'total systematic uncertainty', 'treatment': 'MULT', 'type': 'CORR'}
for i in range(ndata_dSig_dmttBar):
error_definition_dSig_dmttBar['ArtUnc_'+str(i+1)] = {'definition': 'artificial uncertainty '+str(i+1), 'treatment': 'ADD', 'type': 'CORR'}
for i in range(11):
error_definition_dSig_dmttBar[input3['independent_variables'][0]['values'][i]['value']] = {'definition': 'systematic uncertainty- '+str(input3['independent_variables'][0]['values'][i]['value']), 'treatment': 'MULT', 'type': 'CORR'}

data_central_dSig_dmttBar_norm_yaml = {'data_central': data_central_dSig_dmttBar}
kinematics_dSig_dmttBar_norm_yaml = {'bins': kin_dSig_dmttBar}
uncertainties_dSig_dmttBar_norm_yaml = {'definitions': error_definition_dSig_dmttBar, 'bins': error_dSig_dmttBar}

with open('data_dSig_dmttBar_norm.yaml', 'w') as file:
yaml.dump(data_central_dSig_dmttBar_norm_yaml, file, sort_keys=False)

with open('kinematics_dSig_dmttBar_norm.yaml', 'w') as file:
yaml.dump(kinematics_dSig_dmttBar_norm_yaml, file, sort_keys=False)

with open('uncertainties_dSig_dmttBar_norm.yaml', 'w') as file:
yaml.dump(uncertainties_dSig_dmttBar_norm_yaml, file, sort_keys=False)

processData()
Loading