ATLAS Offline Software
extract_chain_from_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 import pprint
7 
8 import argparse
9 parser = argparse.ArgumentParser(description='Get the inputs for chain extraction')
10 
11 parser.add_argument('--chain', dest='chain', action='store', default='',
12  help='What chain are we extracting')
13 parser.add_argument('--menu_json', dest='input_json', action='store', default='',
14  help='What menu are we extracting the chain from')
15 
16 args = parser.parse_args()
17 
18 chain = args.chain
19 input_json = args.input_json
20 
21 the_menu = json.loads(open(input_json).read())
22 
23 print("...extracting",chain,"from menu json",input_json)
24 
25 if chain not in the_menu['chains']:
26  raise Exception("The requested chain isn't in the provided menu json, please try again.")
27 
28 pprint.pprint(the_menu['chains'][chain])
29 
30 print("Steps in the chain:")
31 
32 for isq,seq in enumerate(the_menu['chains'][chain]['sequencers']):
33 
34  if not seq:
35  print('step',isq+1,'is empty')
36  continue
37  else:
38  print('step',isq+1,'is sequence ',seq)
39 
40  other_chains = []
41  for chain in the_menu['chains']:
42  if seq in the_menu['chains'][chain]['sequencers']:
43  other_chains += [chain]
44  if len(other_chains) > 0:
45  print (' also used in the following chains:')
46  pprint.pprint(other_chains)
47  else:
48  print (' is not used in any other chains.')
49 
50  print (' contains algorithms/hypos:')
51  pprint.pprint(the_menu['sequencers'][seq])
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
Trk::open
@ open
Definition: BinningType.h:40
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28