ATLAS Offline Software
Loading...
Searching...
No Matches
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
5import json
6
7import argparse
8parser = argparse.ArgumentParser(description='Get the inputs for activating only the prescale of a given group')
9
10parser.add_argument('-g', '--group',
11 required=True,
12 action='append',
13 help='Which group we are selecting')
14parser.add_argument('-p', '--prescale_json',
15 required=True,
16 help='Which prescale json we are modifying')
17parser.add_argument('-m', '--menu_json',
18 required=True,
19 help='Name of the menu file')
20
21args = parser.parse_args()
22the_groups = args.group
23
24prescale_json = args.prescale_json
25prescale_file = open(prescale_json)
26the_prescale = json.load(prescale_file)
27prescale_file.close()
28
29menu_json = args.menu_json
30menu_file = open(menu_json)
31the_menu = json.load(menu_file)
32menu_file.close()
33
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)
39
40if len(list_of_good_chains)==0:
41 raise Exception("There are no chains with the specified group in the Menu file.")
42
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))
45
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
50
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)