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.

82 lines
5.4 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. | q2_split_$1.10 < q^2 < 6.00$_average |\n
  20. +----------+-----------------------+-----------------------+----------------------+\n
  21. | Variable | Value | Lower Error | Upper Error |\n
  22. +----------+-----------------------+-----------------------+----------------------+\n
  23. | AFB | -0.03611162259371692 | -0.008731742137981694 | 0.008731742137981694 |\n
  24. | FL | 0.7816031469957773 | -0.010041813091402643 | 0.010041813091402643 |\n
  25. | S3 | -0.004913319742985065 | -0.010997797016445892 | 0.010997797016445892 |\n
  26. | S4 | -0.11446696701061239 | -0.0177373887414066 | 0.0177373887414066 |\n
  27. | S5 | -0.1162615465324004 | -0.016777187198089353 | 0.016777187198089353 |\n
  28. | S7 | 0.013450446832457594 | -0.017351060768029697 | 0.017351060768029697 |\n
  29. | S8 | 0.012943806403734165 | -0.018166933762978635 | 0.018166933762978635 |\n
  30. | S9 | -0.015991133298640343 | -0.011753160273233804 | 0.011753160273233804 |\n
  31. +----------+-----------------------+-----------------------+----------------------+""" # MC LEVEL
  32. variables = ["AFB", "FL", "S3", "S4", "S5", "S7", "S8", "S9"]
  33. select_regex = [".*AFB.*\d+", ".*FL.*\d+", ".*S3.*\d+", ".*S4.*\d+", ".*S5.*\d+", ".*S7.*\d+", ".*S8.*\d+", ".*S9.*\d+"]
  34. value_regex = "[- ]\d+.\d+"
  35. sample_table_1 = {'1': {'AFB': None, 'FL': None, 'S3': None, 'S4': None, 'S5': None, 'S7': None, 'S8': None, 'S9': None}}
  36. sample_table_2 = {'1': {'AFB': None, 'FL': None, 'S3': None, 'S4': None, 'S5': None, 'S7': None, 'S8': None, 'S9': None}}
  37. samples = [sample_1, sample_2]
  38. for variable, regex in zip(variables, select_regex):
  39. sample_1_splitted = samples[0].splitlines()
  40. for line in sample_1_splitted:
  41. subresult = re.match(regex, line)
  42. if subresult != None:
  43. substring = subresult.group(0)
  44. result = re.findall(value_regex, substring)
  45. value = np.float64(result[0])
  46. lower_err = np.float64(result[1])
  47. upper_err = np.float64(result[2])
  48. sample_table_1['1'][variable] = (value, lower_err, upper_err)
  49. sample_2_splitted = samples[1].splitlines()
  50. for line in sample_2_splitted:
  51. subresult = re.match(regex, line)
  52. if subresult != None:
  53. substring = subresult.group(0)
  54. result = re.findall(value_regex, substring)
  55. value = np.float64(result[0])
  56. lower_err = np.float64(result[1])
  57. upper_err = np.float64(result[2])
  58. sample_table_2['1'][variable] = (value, lower_err, upper_err)
  59. info_table = PrettyTable(["Variable", r"|MC Average - Gen|", "Lower Error", "Upper Error", "Stat. Significance"])
  60. for name in variables:
  61. index = '1'
  62. delta_value = np.abs(sample_table_1[index][name][0] - sample_table_2[index][name][0])
  63. quadratic_lower = -np.sqrt(sample_table_1[index][name][1]**2 + sample_table_2[index][name][1]**2)
  64. quadratic_upper = np.sqrt(sample_table_1[index][name][2]**2 + sample_table_2[index][name][2]**2)
  65. stat_significance = np.abs(delta_value / quadratic_lower)
  66. info_table.add_row([name, delta_value, quadratic_lower, quadratic_upper, stat_significance])
  67. info_table.title = f"{bin_labels} Average over 3 Bins in MC"
  68. print(info_table)
  69. if __name__ == "__main__":
  70. main()