Angular analysis of B+->K*+(K+pi0)mumu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

83 lines
5.4 KiB

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
| q2_split_$1.10 < q^2 < 6.00$_average |\n
+----------+-----------------------+-----------------------+----------------------+\n
| Variable | Value | Lower Error | Upper Error |\n
+----------+-----------------------+-----------------------+----------------------+\n
| AFB | -0.03611162259371692 | -0.008731742137981694 | 0.008731742137981694 |\n
| FL | 0.7816031469957773 | -0.010041813091402643 | 0.010041813091402643 |\n
| S3 | -0.004913319742985065 | -0.010997797016445892 | 0.010997797016445892 |\n
| S4 | -0.11446696701061239 | -0.0177373887414066 | 0.0177373887414066 |\n
| S5 | -0.1162615465324004 | -0.016777187198089353 | 0.016777187198089353 |\n
| S7 | 0.013450446832457594 | -0.017351060768029697 | 0.017351060768029697 |\n
| S8 | 0.012943806403734165 | -0.018166933762978635 | 0.018166933762978635 |\n
| S9 | -0.015991133298640343 | -0.011753160273233804 | 0.011753160273233804 |\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 Average - 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} Average over 3 Bins in MC"
print(info_table)
if __name__ == "__main__":
main()