Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dc31efd
added dataset folder for new dataset implementation
comane Mar 13, 2023
bc01afb
.
comane Mar 14, 2023
d3c558a
added statistical covariance matrix for ATLAS_2JET_7TEV_R06
comane Mar 20, 2023
e4436b0
added tmp filter module
comane Mar 20, 2023
a876b84
filter file generating data.yaml, kin.yaml, and uncertainties.yaml fo…
comane Mar 22, 2023
d985671
/
comane Mar 22, 2023
5702c90
.
comane Mar 22, 2023
9cc18c7
added FKtable name
comane Mar 22, 2023
092a22e
added uncertainties yaml files
comane Mar 22, 2023
8e1eefd
split filter_dataset into kinematics / data and uncertainties
comane Mar 23, 2023
193daca
added module to reproduce bugged sys from old CD implementation
comane Mar 23, 2023
7da0b76
ignore pandas warnings
comane Mar 23, 2023
23bc3d4
lum unc treated as special unc, correlated with all ATLAS 7 TEV
comane Mar 23, 2023
2182d19
cholesky decomposition of Csys + Cstat matrix is not unique
comane Mar 23, 2023
11ef765
compute special sys in bugged filter
comane Mar 27, 2023
5a1b785
added bugged uncertainties
comane Mar 27, 2023
f3a7ba7
added folder for CMS_2JET_7TEV datasetss
comane Mar 27, 2023
4621db1
read correlation matrix into numpy array
comane Mar 27, 2023
2a2a90f
added corr to cov function + computed the Block diagonal stat cov mat
comane Mar 28, 2023
5c19ddd
added module with utils for CMS_2JET_7TEV filter
comane Apr 11, 2023
f64ace3
import utils from filter_utils
comane Apr 11, 2023
3dc9f74
modify metadata
comane Apr 11, 2023
31af403
fixed typo
comane Apr 11, 2023
8243307
added ATLAS_1JET_8TEV_R06 folder
comane Apr 11, 2023
8e71f69
added functions to utils
comane Apr 12, 2023
2fca2cf
added CMS 2Jet uncertainty file
comane Apr 12, 2023
8d0cd64
added unc file
comane Apr 13, 2023
5b396d3
added comment to filter func
comane Apr 13, 2023
a72f2bb
added comment
comane Apr 13, 2023
07f1114
added CMS_1JET_8TEV metadata file
comane Apr 13, 2023
fecf9f0
data central values
comane Apr 13, 2023
2ee1ae1
added filter functions
comane Apr 13, 2023
aa95a5c
removed non needed import
comane Apr 13, 2023
32831a6
added HEPData tables
comane Apr 13, 2023
fcfb27c
added func to read stat corr dat
comane Apr 13, 2023
573c098
added space for readability by pd.read_csv
comane Apr 17, 2023
9e037ef
.
comane Apr 17, 2023
3e640c4
small modifications to ATLAS_1JET_8TEV_R06
comane Jul 31, 2023
b0ce842
added dataset ATLAS_1JET_8TEV_R06_DEC
comane Jul 31, 2023
acd64a9
black on filter
comane Jul 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions buildmaster/ATLAS_1JET_8TEV_R06/data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
data_central:
- 36994.0
- 15405.6
- 7009.4
- 3319.54
- 1627.69
- 822.52
- 421.667
- 223.264
- 123.88
- 69.53
- 40.254
- 23.062
- 13.626
- 8.337
- 5.1569
- 3.1134
- 1.8922
- 1.1635
- 0.7111
- 0.44279
- 0.27428
- 0.17043
- 0.10614
- 0.06661
- 0.041322
- 0.025443
- 0.015691
- 0.009639
- 0.005995
- 0.003448
- 0.0014775
- 0.0003872
- 5.009e-05
- 1.42e-06
- 35232.5
- 14221.5
- 6519.5
- 3066.07
- 1499.1
- 757.76
- 392.639
- 206.944
- 114.55
- 63.287
- 36.287
- 20.861
- 12.404
- 7.5669
- 4.5112
- 2.7158
- 1.6382
- 0.9953
- 0.6045
- 0.37186
- 0.22762
- 0.13906
- 0.085314
- 0.051916
- 0.031895
- 0.018985
- 0.011346
- 0.006725
- 0.003879
- 0.0020569
- 0.0008497
- 0.0001838
- 6.58e-06
- 30557.3
- 12452.7
- 5745.3
- 2630.59
- 1263.8
- 638.88
- 319.543
- 165.698
- 90.26
- 49.844
- 28.205
- 15.919
- 9.281
- 5.5009
- 3.2102
- 1.8731
- 1.1101
- 0.6558
- 0.38074
- 0.22072
- 0.12796
- 0.07427
- 0.042121
- 0.023943
- 0.013329
- 0.007287
- 0.003872
- 0.0019997
- 0.0010205
- 0.0004429
- 0.0001189
- 5.37e-06
- 24622.2
- 9795.9
- 4208.2
- 1970.38
- 949.4
- 466.875
- 229.994
- 116.89
- 62.17
- 33.357
- 18.199
- 9.772
- 5.426
- 3.0905
- 1.7167
- 0.90963
- 0.5003
- 0.26684
- 0.13761
- 0.07125
- 0.03547
- 0.017315
- 0.0082752
- 0.003744
- 0.0016581
- 0.0006909
- 0.0002583
- 0.00011
- 3.58e-05
- 3.04e-06
- 20104.9
- 7668.9
- 3167.6
- 1414.54
- 653.61
- 311.066
- 145.509
- 69.5
- 34.69
- 16.754
- 8.301
- 4.009
- 1.952
- 0.9391
- 0.4353
- 0.1905
- 0.08173
- 0.032263
- 0.012586
- 0.004426
- 0.001531
- 0.0004622
- 0.0001046
- 1.348e-05
- 13644.5
- 5071.1
- 2024.3
- 824.82
- 353.16
- 143.567
- 57.724
- 22.944
- 9.31
- 3.705
- 1.415
- 0.5147
- 0.1678
- 0.04826
- 0.01333
- 0.002652
- 0.000539
- 4.6e-05
170 changes: 170 additions & 0 deletions buildmaster/ATLAS_1JET_8TEV_R06/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import yaml
import numpy as np
import pandas as pd
from filter_utils import get_data_values, get_kinematics, fill_df, decompose_covmat

# ignore pandas warning
import warnings

warnings.filterwarnings("ignore")


def filter_ATLAS_1JET_8TEV_data_kinetic():
"""
write kinematics and central data values
in kinematics.yaml and data.yaml files
respectively.
"""

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

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

# get kinematics from hepdata tables
kin = get_kinematics(tables, version)

# get central values from hepdata tables
data_central = get_data_values(tables, version)

data_central_yaml = {"data_central": data_central}
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_1JET_8TEV_uncertainties():
"""
write uncertainties to uncertainties.yaml
file.
There are three types of uncertainties:

1. Statistical Uncertainties: CORR
-> correlated over the full dataset

2. Artificial Uncertainties: CORR, these
are obtained by following the steps:

- Construct an Error matrix in which
each part of an asymmetric error is considered
as as separate error (hence dividing by sqrt(2))
see also filter_utils/process_error and
filter_utils/HEP_table_to_df

- Construct covariance matrix from the Error matrix

- Decompose covariance matrix so as to get ndat art unc

3. Luminosity Uncertainty: ATLASLUMI12
this uncertainty is correlated with all
the other ATLASLUMI12 datasets
"""

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

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

# get df of uncertainties
dfs = []
for table in tables:
# uncertainties dataframe
df = fill_df(table, version)
dfs.append(df)

df_unc = pd.concat([df for df in dfs], axis=0)

# statistical errors fully uncorrelated
stat_errors = df_unc["stat"].to_numpy()

# luminosity errors
lum_errors = df_unc["syst_lumi"].to_numpy()

# note: in the old implementation some sys are decorrelated.
# however the systype file used for the covmat construction is
# fully correlated (see difference between systype file in buildmaster and nnpdfcpp).

A_corr = df_unc.drop(["stat", "syst_lumi"], axis=1).to_numpy() / np.sqrt(2.0)
cov_corr = np.einsum("ij,kj->ik", A_corr, A_corr)
A_art_corr = decompose_covmat(covmat=cov_corr)

# error definition
error_definition = {
f"art_sys_corr_{i}": {
"description": f"artificial systematic {i}",
"treatment": "ADD",
"type": "CORR",
}
for i in range(1, A_art_corr.shape[0] + 1)
}

error_definition["luminosity_uncertainty"] = {
"description": "luminosity uncertainty",
"treatment": "ADD",
"type": "ATLASLUMI12",
}

error_definition["statistical_uncertainty"] = {
"description": "statistical uncertainty",
"treatment": "ADD",
"type": "UNCORR",
}

# store error in dict
error = []
for n in range(A_art_corr.shape[0]):
error_value = {}
for m in range(A_art_corr.shape[1]):
error_value[f"art_sys_corr_{m+1}"] = float(A_art_corr[n, m])

error_value["luminosity_uncertainty"] = float(lum_errors[n])
error_value["statistical_uncertainty"] = float(stat_errors[n])
error.append(error_value)

uncertainties_yaml = {"definition": error_definition, "bins": error}

# write uncertainties to file
with open(f"uncertainties.yaml", "w") as file:
yaml.dump(uncertainties_yaml, file, sort_keys=False)

# @@@@@@@@@@@ code below for testing only, should be removed at some point @@@@@@@@@@@@#
cov_lum = np.einsum("i,j->ij", lum_errors, lum_errors)
cov_stat = np.diag(stat_errors**2)

covmat = cov_corr + cov_stat + cov_lum

return np.real(covmat)


if __name__ == "__main__":
# # write kinematics and central data values
# filter_ATLAS_1JET_8TEV_data_kinetic()

# # write uncertainties file
# filter_ATLAS_1JET_8TEV_uncertainties()

# code below for testing only. Should be removed at some point
covmat = filter_ATLAS_1JET_8TEV_uncertainties()

from validphys.api import API


setname = "ATLAS_1JET_8TEV_R06"
dsinps = [
{"dataset": setname},
]
inp = dict(dataset_inputs=dsinps, theoryid=200, use_cuts="internal")
cov = API.dataset_inputs_covmat_from_systematics(**inp)


ones = cov / covmat
print(ones)
print(np.max(ones), np.min(ones))
print(np.allclose(ones, np.ones(cov.shape), rtol=1e-5))
Loading