4 from AthenaCommon.Logging
import logging
5 logger = logging.getLogger(
'PhysValUtils')
15 requiredKeys = [
'title',
'xtitle',
'ytitle',
'path',
'xbins',
'xmin',
'xmax',
'type']
17 position = {
'name': 0,
'title': 1,
'path': 2,
'xbins': 3,
'xmin': 4,
'xmax': 5,
'type': 6,
'ymin': 7,
'ymax': 8}
20 if not os.path.isfile(fileName):
21 raise IOError(
"This path to the file does not exist:" + fileName)
25 with open(fileName)
as json_file:
26 file_dict = json.load(json_file)
29 for group
in file_dict:
30 for var
in file_dict[group]:
31 for required_key
in requiredKeys:
32 if required_key
not in file_dict[group][var]:
33 raise IOError(
"The key " + required_key +
" is missing in the dict for the variable " + var +
".")
38 for group
in file_dict:
40 if not (use_group ==
'ALL' or group == use_group)
or group ==
'template':
43 for var
in file_dict[group]:
45 if usage
in file_dict[group][var][
'path']:
47 if 'forEach' in file_dict[group][var]:
48 for type
in file_dict[group][var][
'forEach']:
49 var_list = [
'',
'',
'',
'',
'',
'',
'',
'',
'']
51 new_var_name = var +
'_' + type
53 var_list[position[
'name']] =
str(new_var_name)
55 var_list[position[
'title']] =
str(file_dict[group][var][
'title'] +
' ' + type +
';' + file_dict[group][var][
'xtitle'] +
';' + file_dict[group][var][
'ytitle'])
57 var_list[position[
'path']] =
str(file_dict[group][var][
'path'][usage])
59 for key
in [
'xbins',
'xmin',
'xmax',
'type']:
60 var_list[position[key]] =
str(file_dict[group][var][key])
61 if(file_dict[group][var][
'type'] ==
'TProfile'):
62 var_list[position[
'ymin']] =
str(file_dict[group][var][
'ymin'])
63 var_list[position[
'ymax']] =
str(file_dict[group][var][
'ymax'])
67 var_list = [
'',
'',
'',
'',
'',
'',
'',
'',
'']
69 var_list[position[
'name']] =
str(var)
71 var_list[position[
'title']] =
str(file_dict[group][var][
'title'] +
';' + file_dict[group][var][
'xtitle'] +
';' + file_dict[group][var][
'ytitle'])
73 var_list[position[
'path']] =
str(file_dict[group][var][
'path'][usage])
75 for key
in [
'xbins',
'xmin',
'xmax',
'type']:
76 var_list[position[key]] =
str(file_dict[group][var][key])
77 if(file_dict[group][var][
'type'] ==
'TProfile'):
78 var_list[position[
'ymin']] =
str(file_dict[group][var][
'ymin'])
79 var_list[position[
'ymax']] =
str(file_dict[group][var][
'ymax'])