Belle II Software light-2601-hyperion
utils.py
1#!/usr/bin/env python3
2
3
10from yaml import full_load
11from basf2 import find_file
12
13
14def get_variables(particle_list, ranked_variable, variables=None, particleNumber=1):
15 """ creates variable name pattern requested by the basf2 variable getVariableByRank()
16 :param particle_list:
17 :param ranked_variable:
18 :param variables:
19 :param particleNumber:
20 :return:
21 """
22 var_list = []
23 for i_num in range(1, particleNumber + 1):
24 for var in variables:
25 var_list.append(f'getVariableByRank({particle_list}, {ranked_variable}, {var}, {str(i_num)})')
26 return var_list
27
28
29def load_config(uniqueIdentifier):
30 """
31 Loads the correct yaml config file for the specified TFlaT uniqueIdentifier.
32 All dynamic alterations of the config are handeled in this function.
33 The final config is returned as a dict.
34 """
35 with open(find_file(f'analysis/data/{uniqueIdentifier}.yaml')) as f:
36 config = full_load(f)
37
38 # Calculate input list lengths
39 config["parameters"]["num_trk_features"] = len(config["trk_variable_list"])
40 config["parameters"]["num_ecl_features"] = len(config["ecl_variable_list"])
41 config["parameters"]["num_roe_features"] = len(config["roe_variable_list"])
42
43 return config