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.

36 lines
1.4 KiB

  1. import os
  2. import re
  3. import uproot
  4. class RootIO:
  5. def __init__(self, path_to_file: str):
  6. if not os.path.exists(path = path_to_file):
  7. raise ValueError("Path does not exists!")
  8. self.path_to_file = path_to_file
  9. def get_information(self, regex: str = None) -> None:
  10. with uproot.open(self.path_to_file) as file:
  11. print(f"File classnames:\n{file.classnames()}")
  12. for classname, classtype in file.classnames().items():
  13. print(f"Classname:\n{classname}")
  14. print(f"Classtype:\n{classtype}")
  15. print(f"Content of the class:")
  16. for name, branch in file[classname].items():
  17. print(f"{name}: {branch}")
  18. if regex != None:
  19. print(f"Regex search results:")
  20. attributes = file[classname].keys()
  21. for attribute in attributes:
  22. result = self.__find_pattern_in_text(regex = regex, text = attribute)
  23. if result != "":
  24. print(f"{result}")
  25. def __find_pattern_in_text(self, regex: str, text: str) -> str:
  26. search_result = re.search(pattern = regex, string = text)
  27. result = ""
  28. if search_result != None:
  29. result = search_result.group(0)
  30. return result