8parser = argparse.ArgumentParser(description=
'Get the inputs for activating only the prescale of a given group')
10parser.add_argument(
'-g',
'--group',
13 help=
'Which group we are selecting')
14parser.add_argument(
'-p',
'--prescale_json',
16 help=
'Which prescale json we are modifying')
17parser.add_argument(
'-m',
'--menu_json',
19 help=
'Name of the menu file')
21args = parser.parse_args()
22the_groups = args.group
24prescale_json = args.prescale_json
25prescale_file = open(prescale_json)
26the_prescale = json.load(prescale_file)
29menu_json = args.menu_json
30menu_file = open(menu_json)
31the_menu = json.load(menu_file)
34list_of_good_chains = []
35for chain
in the_menu[
'chains']:
36 for group
in the_groups:
37 if group
in the_menu[
'chains'][chain][
'groups']:
38 list_of_good_chains.append(chain)
40if len(list_of_good_chains)==0:
41 raise Exception(
"There are no chains with the specified group in the Menu file.")
43print(
"[modify_prescale_json] resetting all the chains that do not contain the groups:", the_groups)
44print(
"[modify_prescale_json] number of chains found with the selected groups:", len(list_of_good_chains))
46for chain
in the_prescale[
'prescales']:
47 if chain
not in list_of_good_chains:
48 the_prescale[
'prescales'][chain][
'prescale'] = 0
49 the_prescale[
'prescales'][chain][
'enabled'] =
False
51print(
"[modify_prescale_json] overwriting the prescale json file:", prescale_json)
52with open( prescale_json,
'w' )
as fp:
53 json.dump( the_prescale, fp, indent=4, sort_keys=
False )
void print(char *figname, TCanvas *c1)