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.

80 lines
5.2 KiB

  1. import re
  2. import numpy as np
  3. from prettytable import PrettyTable
  4. def main():
  5. bin_labels = r"$1.10 < q^2 < 6.00$"
  6. sample_1 = """+----------+------------------------+------------------------+-----------------------+\n
  7. | Variable | Value | Lower Error | Upper Error |\n
  8. +----------+------------------------+------------------------+-----------------------+\n
  9. | AFB | -0.030693939006905927 | -0.0027448398251912667 | 0.0026690127045430573 |\n
  10. | FL | 0.7641860897390124 | -0.0031519177028962353 | 0.00318403722094425 |\n
  11. | S3 | -0.009793642767841643 | -0.0039500538800350165 | 0.003962284039325228 |\n
  12. | S4 | -0.11948833798312776 | -0.005018301784506872 | 0.005112053156795224 |\n
  13. | S5 | -0.14672854148123884 | -0.005077800231656763 | 0.0051383664423323315 |\n
  14. | S7 | -0.0009713979621990259 | -0.005287904531482017 | 0.005275166744474821 |\n
  15. | S8 | 0.003178551357900045 | -0.005257961171467131 | 0.005258879438751017 |\n
  16. | S9 | 0.005757808359963191 | -0.004016272402049568 | 0.004019873761938199 |\n
  17. +----------+------------------------+------------------------+-----------------------+""" # GENERATOR LEVEL
  18. sample_2 = """+----------+-----------------------+-----------------------+----------------------+\n
  19. | Variable | Value | Lower Error | Upper Error |\n
  20. +----------+-----------------------+-----------------------+----------------------+\n
  21. | AFB | -0.006858788562096526 | -0.006288887141153866 | 0.006202211516385528 |\n
  22. | FL | 0.7741933027966281 | -0.007196527356496095 | 0.006980839734409447 |\n
  23. | S3 | -0.005794055258693013 | -0.008257409210173627 | 0.008381420647898805 |\n
  24. | S4 | -0.13252141252161223 | -0.012754778513953539 | 0.012393845350580537 |\n
  25. | S5 | -0.13982805972042112 | -0.011883305368342971 | 0.011682110709131568 |\n
  26. | S7 | 0.01499315459684105 | -0.012227400419826324 | 0.012191295064893278 |\n
  27. | S8 | 0.010750628153590385 | -0.013096041377945507 | 0.013227158788846905 |\n
  28. | S9 | -0.013084904237743692 | -0.00855475117009418 | 0.008616146883219716 |\n
  29. +----------+-----------------------+-----------------------+----------------------+""" # MC LEVEL
  30. variables = ["AFB", "FL", "S3", "S4", "S5", "S7", "S8", "S9"]
  31. select_regex = [".*AFB.*\d+", ".*FL.*\d+", ".*S3.*\d+", ".*S4.*\d+", ".*S5.*\d+", ".*S7.*\d+", ".*S8.*\d+", ".*S9.*\d+"]
  32. value_regex = "[- ]\d+.\d+"
  33. sample_table_1 = {'1': {'AFB': None, 'FL': None, 'S3': None, 'S4': None, 'S5': None, 'S7': None, 'S8': None, 'S9': None}}
  34. sample_table_2 = {'1': {'AFB': None, 'FL': None, 'S3': None, 'S4': None, 'S5': None, 'S7': None, 'S8': None, 'S9': None}}
  35. samples = [sample_1, sample_2]
  36. for variable, regex in zip(variables, select_regex):
  37. sample_1_splitted = samples[0].splitlines()
  38. for line in sample_1_splitted:
  39. subresult = re.match(regex, line)
  40. if subresult != None:
  41. substring = subresult.group(0)
  42. result = re.findall(value_regex, substring)
  43. value = np.float64(result[0])
  44. lower_err = np.float64(result[1])
  45. upper_err = np.float64(result[2])
  46. sample_table_1['1'][variable] = (value, lower_err, upper_err)
  47. sample_2_splitted = samples[1].splitlines()
  48. for line in sample_2_splitted:
  49. subresult = re.match(regex, line)
  50. if subresult != None:
  51. substring = subresult.group(0)
  52. result = re.findall(value_regex, substring)
  53. value = np.float64(result[0])
  54. lower_err = np.float64(result[1])
  55. upper_err = np.float64(result[2])
  56. sample_table_2['1'][variable] = (value, lower_err, upper_err)
  57. info_table = PrettyTable(["Variable", r"|MC - Gen|", "Lower Error", "Upper Error", "Stat. Significance"])
  58. for name in variables:
  59. index = '1'
  60. delta_value = np.abs(sample_table_1[index][name][0] - sample_table_2[index][name][0])
  61. quadratic_lower = -np.sqrt(sample_table_1[index][name][1]**2 + sample_table_2[index][name][1]**2)
  62. quadratic_upper = np.sqrt(sample_table_1[index][name][2]**2 + sample_table_2[index][name][2]**2)
  63. stat_significance = np.abs(delta_value / quadratic_lower)
  64. info_table.add_row([name, delta_value, quadratic_lower, quadratic_upper, stat_significance])
  65. info_table.title = f"{bin_labels}"
  66. print(info_table)
  67. if __name__ == "__main__":
  68. main()