ATLAS Offline Software
trigmenu_modify_prescale_json.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4 
5 import json
6 
7 import argparse
8 parser = argparse.ArgumentParser(description='Get the inputs for activating only the prescale of a given group')
9 
10 parser.add_argument('-g', '--group',
11  required=True,
12  action='append',
13  help='Which group we are selecting')
14 parser.add_argument('-p', '--prescale_json',
15  required=True,
16  help='Which prescale json we are modifying')
17 parser.add_argument('-m', '--menu_json',
18  required=True,
19  help='Name of the menu file')
20 
21 args = parser.parse_args()
22 the_groups = args.group
23 
24 prescale_json = args.prescale_json
25 prescale_file = open(prescale_json)
26 the_prescale = json.load(prescale_file)
27 prescale_file.close()
28 
29 menu_json = args.menu_json
30 menu_file = open(menu_json)
31 the_menu = json.load(menu_file)
32 menu_file.close()
33 
34 list_of_good_chains = []
35 for 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)
39 
40 if len(list_of_good_chains)==0:
41  raise Exception("There are no chains with the specified group in the Menu file.")
42 
43 print("[modify_prescale_json] resetting all the chains that do not contain the groups:", the_groups)
44 print("[modify_prescale_json] number of chains found with the selected groups:", len(list_of_good_chains))
45 
46 for 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
50 
51 print("[modify_prescale_json] overwriting the prescale json file:", prescale_json)
52 with open( prescale_json, 'w' ) as fp:
53  json.dump( the_prescale, fp, indent=4, sort_keys=False )
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
Trk::open
@ open
Definition: BinningType.h:40