81 lines
5.2 KiB
Python
81 lines
5.2 KiB
Python
import re
|
|
import numpy as np
|
|
|
|
from prettytable import PrettyTable
|
|
|
|
|
|
def main():
|
|
bin_labels = r"$1.10 < q^2 < 6.00$"
|
|
|
|
sample_1 = """+----------+------------------------+------------------------+-----------------------+\n
|
|
| Variable | Value | Lower Error | Upper Error |\n
|
|
+----------+------------------------+------------------------+-----------------------+\n
|
|
| AFB | -0.030693939006905927 | -0.0027448398251912667 | 0.0026690127045430573 |\n
|
|
| FL | 0.7641860897390124 | -0.0031519177028962353 | 0.00318403722094425 |\n
|
|
| S3 | -0.009793642767841643 | -0.0039500538800350165 | 0.003962284039325228 |\n
|
|
| S4 | -0.11948833798312776 | -0.005018301784506872 | 0.005112053156795224 |\n
|
|
| S5 | -0.14672854148123884 | -0.005077800231656763 | 0.0051383664423323315 |\n
|
|
| S7 | -0.0009713979621990259 | -0.005287904531482017 | 0.005275166744474821 |\n
|
|
| S8 | 0.003178551357900045 | -0.005257961171467131 | 0.005258879438751017 |\n
|
|
| S9 | 0.005757808359963191 | -0.004016272402049568 | 0.004019873761938199 |\n
|
|
+----------+------------------------+------------------------+-----------------------+""" # GENERATOR LEVEL
|
|
|
|
sample_2 = """+----------+-----------------------+-----------------------+----------------------+\n
|
|
| Variable | Value | Lower Error | Upper Error |\n
|
|
+----------+-----------------------+-----------------------+----------------------+\n
|
|
| AFB | -0.006858788562096526 | -0.006288887141153866 | 0.006202211516385528 |\n
|
|
| FL | 0.7741933027966281 | -0.007196527356496095 | 0.006980839734409447 |\n
|
|
| S3 | -0.005794055258693013 | -0.008257409210173627 | 0.008381420647898805 |\n
|
|
| S4 | -0.13252141252161223 | -0.012754778513953539 | 0.012393845350580537 |\n
|
|
| S5 | -0.13982805972042112 | -0.011883305368342971 | 0.011682110709131568 |\n
|
|
| S7 | 0.01499315459684105 | -0.012227400419826324 | 0.012191295064893278 |\n
|
|
| S8 | 0.010750628153590385 | -0.013096041377945507 | 0.013227158788846905 |\n
|
|
| S9 | -0.013084904237743692 | -0.00855475117009418 | 0.008616146883219716 |\n
|
|
+----------+-----------------------+-----------------------+----------------------+""" # MC LEVEL
|
|
|
|
variables = ["AFB", "FL", "S3", "S4", "S5", "S7", "S8", "S9"]
|
|
select_regex = [".*AFB.*\d+", ".*FL.*\d+", ".*S3.*\d+", ".*S4.*\d+", ".*S5.*\d+", ".*S7.*\d+", ".*S8.*\d+", ".*S9.*\d+"]
|
|
value_regex = "[- ]\d+.\d+"
|
|
sample_table_1 = {'1': {'AFB': None, 'FL': None, 'S3': None, 'S4': None, 'S5': None, 'S7': None, 'S8': None, 'S9': None}}
|
|
sample_table_2 = {'1': {'AFB': None, 'FL': None, 'S3': None, 'S4': None, 'S5': None, 'S7': None, 'S8': None, 'S9': None}}
|
|
samples = [sample_1, sample_2]
|
|
|
|
for variable, regex in zip(variables, select_regex):
|
|
sample_1_splitted = samples[0].splitlines()
|
|
for line in sample_1_splitted:
|
|
subresult = re.match(regex, line)
|
|
if subresult != None:
|
|
substring = subresult.group(0)
|
|
result = re.findall(value_regex, substring)
|
|
value = np.float64(result[0])
|
|
lower_err = np.float64(result[1])
|
|
upper_err = np.float64(result[2])
|
|
|
|
sample_table_1['1'][variable] = (value, lower_err, upper_err)
|
|
|
|
sample_2_splitted = samples[1].splitlines()
|
|
for line in sample_2_splitted:
|
|
subresult = re.match(regex, line)
|
|
if subresult != None:
|
|
substring = subresult.group(0)
|
|
result = re.findall(value_regex, substring)
|
|
value = np.float64(result[0])
|
|
lower_err = np.float64(result[1])
|
|
upper_err = np.float64(result[2])
|
|
|
|
sample_table_2['1'][variable] = (value, lower_err, upper_err)
|
|
|
|
info_table = PrettyTable(["Variable", r"|MC - Gen|", "Lower Error", "Upper Error", "Stat. Significance"])
|
|
for name in variables:
|
|
index = '1'
|
|
delta_value = np.abs(sample_table_1[index][name][0] - sample_table_2[index][name][0])
|
|
quadratic_lower = -np.sqrt(sample_table_1[index][name][1]**2 + sample_table_2[index][name][1]**2)
|
|
quadratic_upper = np.sqrt(sample_table_1[index][name][2]**2 + sample_table_2[index][name][2]**2)
|
|
stat_significance = np.abs(delta_value / quadratic_lower)
|
|
info_table.add_row([name, delta_value, quadratic_lower, quadratic_upper, stat_significance])
|
|
info_table.title = f"{bin_labels}"
|
|
print(info_table)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |