ATLAS Offline Software
Functions | Variables
getAlgData Namespace Reference

Functions

def algdata_from_menu (flags, do_dot=False, root_names=[])
 

Variables

 logger
 
 root_names
 
 do_dot
 

Function Documentation

◆ algdata_from_menu()

def getAlgData.algdata_from_menu (   flags,
  do_dot = False,
  root_names = [] 
)
algdata_from_menu uses a graph created from an L1Menu to created
an execution oredered sequence of AlgData objects. AlgData have
configuration information that is used to configure a GlobalSim
L1TopoAlgorithm AlgTool

Definition at line 11 of file getAlgData.py.

11 def algdata_from_menu(flags, do_dot=False, root_names=[]):
12  """algdata_from_menu uses a graph created from an L1Menu to created
13  an execution oredered sequence of AlgData objects. AlgData have
14  configuration information that is used to configure a GlobalSim
15  L1TopoAlgorithm AlgTool"""
16 
17  from .l1MenuGraph import l1MenuGraph
18 
19  G, alg_data_list = l1MenuGraph(flags)
20  if do_dot:
21  dot(G, "menu_graph.dot")
22 
23 
24  algname2sn = {}
25  for ad in alg_data_list:
26  algname2sn[ad.name] = ad.sn
27 
28  assert len(algname2sn) == len(alg_data_list)
29 
30  if do_dot:
31  txt_l = ['%s %d' % (k, v) for k, v in algname2sn.items()]
32  txt = '\n'.join(txt_l)
33  txt += '\n\n'
34  txt_l = ['%d %s' % (v, k) for k, v in algname2sn.items()]
35  txt += '\n'.join(txt_l)
36  with open('algname2sn.txt', 'w') as fh:
37  fh.write(txt)
38 
39  # allow running of sub graphs.
40  # root_names contains the names of the roots of the subgraphs.
41  if root_names:
42  roots = [algname2sn[name]
43  for name in root_names if name in algname2sn]
44  if not roots:
45  logger.error("no requested root nodes present in menu")
46  elif len(roots) < len(root_names):
47  logger.debug(
48  'requested ' + str(len(root_names)) + ' root nodes ' +
49  'found ' + str(len(roots)) + ' in menu')
50 
51  else:
52  # if no nodes are named as root nodes, use all
53  # nodes except the node with sn = 0 for now.
54  # this is because there is currently no need to tie together
55  # the different components, and leaving them unjoined to node 0
56  # facilitates the visualisation of the graph structure.i
57  roots = [i for i in range(1, G.V)]
58 
59 
60 
61  # find the executrion order of the AlgTools in terms of graph node
62  # identifiers (ints)
63  topo_m = Topological(G, roots)
64 
65  logger.debug('G is a DAG:' + str(topo_m.isDAG()))
66  order_sn = topo_m.order()
67  logger.debug('root nodes:' + str(roots))
68  logger.debug('Topological order [' + str(len(order_sn)) + ']')
69  logger.debug(str(order_sn))
70  if do_dot:
71  dot(G, "G_ordered.dot", order_sn)
72 
73  # convert ordered sequence from graph node identifiers to AlgData objects
74  sn2algData = {}
75  for ad in alg_data_list:
76  sn2algData[ad.sn] = ad
77 
78  assert len(sn2algData) == len(alg_data_list)
79 
80  ordered_algs = ['%d %s %s' % (i,
81  sn2algData[i].name,
82  sn2algData[i].klass,
83  ) for i in order_sn]
84  for e in ordered_algs:
85  logger.debug(str(e))
86 
87  ordered_algData = [sn2algData[sn] for sn in order_sn]
88  logger.verbose('ordered_algData:[' + str(len(ordered_algData))+']:')
89  for ad in ordered_algData:
90  logger.verbose(str(ad))
91 
92  return ordered_algData
93 

Variable Documentation

◆ do_dot

getAlgData.do_dot

Definition at line 102 of file getAlgData.py.

◆ logger

getAlgData.logger

Definition at line 6 of file getAlgData.py.

◆ root_names

getAlgData.root_names

Definition at line 95 of file getAlgData.py.

l1MenuGraph
Definition: l1MenuGraph.py:1
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
getAlgData.algdata_from_menu
def algdata_from_menu(flags, do_dot=False, root_names=[])
Definition: getAlgData.py:11
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
Trk::open
@ open
Definition: BinningType.h:40
dot
Definition: dot.py:1
str
Definition: BTagTrackIpAccessor.cxx:11