10 from .getMenu
import getMenu
11 from .Digraph
import Digraph
14 from AthenaCommon.Logging
import logging
15 logger = logging.getLogger(__name__)
17 logger.setLevel(VERBOSE)
48 for k, v
in self.__dict__.
items():
49 s.append(k +
': ' +
str(v))
54 """Find the L1Topo call graph. For each node, provide a AlgData
55 object. These objects carry information needed to configure
59 if os.path.exists(
'L1Menu.pkl'):
60 with open(
'L1Menu.pkl',
'rb')
as fh:
61 L1Menu = pickle.load(fh)
62 logger.info(
'L1Menu from .pkl file')
65 with open(
'L1Menu.pkl',
'wb')
as fh:
66 pickle.dump(L1Menu, fh)
67 logger.info(
'L1Menu not from .pkl file')
69 logger.debug(
'menu object')
70 logger.debug(L1Menu.printSummary())
75 for algType
in (
"TOPO",
"MULTTOPO"):
76 algs = L1Menu.topoAlgorithms(algType)
78 for alg_key
in algs.keys():
79 keyed_algs = algs[alg_key]
80 for name, value
in keyed_algs.items():
84 ad.klass = value[
'klass']
85 ad.l1AlgType = algType
86 if algType ==
'MULTTOPO':
87 ad.globalL1AlgType =
'COUNT'
89 threshold_name = value[
'threshold']
90 ad.threshold = L1Menu.thresholds()[threshold_name][
'value']
91 ad.threshold_flavour = value[
'flavour']
93 logger.info(
'No threshold data for COUNT alg '+name)
95 inputs = value[
'input']
96 if isinstance(inputs, list):
101 outputs = value[
'output']
102 if isinstance(outputs, list):
105 ad.outputs = [outputs]
111 alg_data_list.append(ad)
117 [all_inputs.extend(ad.inputs)
for ad
in alg_data_list]
118 all_inputs = {}.fromkeys(all_inputs)
119 all_inputs = all_inputs.keys()
122 [all_outputs.extend(ad.outputs)
for ad
in alg_data_list]
123 all_outputs = {}.fromkeys(all_outputs)
124 all_outputs = all_outputs.keys()
129 if k
not in all_outputs:
130 missing_inputs.append(k)
132 logger.debug(
'input algs to be added ['+
str(len(missing_inputs))+
']')
133 for io
in missing_inputs:
134 logger.debug(
'input alg: ' + io)
139 klass =
'TopoEventInputAlg'
140 ad.name = klass +
'_' + io
143 ad.globalL1AlgType =
'INPUT'
146 alg_data_list.append(ad)
149 for ad
in alg_data_list:
150 if ad.globalL1AlgType
is not None:
continue
151 isSortAlg = ad.inputs[0]
in missing_inputs
153 if len(ad.inputs) != 1:
154 raise RuntimeError(
'AlgData with > 1 inputs '
155 'at least 1 from input alg')
157 ad.globalL1AlgType =
'SORT'
159 for inp
in ad.inputs:
160 if inp
in missing_inputs:
161 raise RuntimeError(
'AlgData with >1 inputs'
162 'at least 1 from input alg')
164 ad.globalL1AlgType =
'DECISION'
169 for ad
in alg_data_list:
171 assert algname
not in alg2inputs
173 alg2inputs[algname] = ad.inputs
175 for outp
in ad.outputs:
176 assert outp
not in output2alg
177 output2alg[outp] = algname
179 logger.verbose(
'\nalg2inputs')
180 logger.verbose(pprint.pformat(alg2inputs, indent=4))
182 logger.verbose(
'\noutput2alg')
183 logger.verbose(pprint.pformat(output2alg, indent=4))
187 alg_names = [ad.name
for ad
in alg_data_list]
188 assert len(alg_names) == len(
set(alg_names))
192 [outputs.extend(ad.outputs)
for ad
in alg_data_list]
193 assert len(outputs) == len(
set(outputs))
199 for a
in alg_data_list:
204 for ad
in alg_data_list:
205 ad.input_sns = [output2sn[inp]
for inp
in ad.inputs]
208 logger.verbose(
'\nalg data:')
209 for ad
in alg_data_list:
210 logger.verbose(pprint.pformat(
str(ad), indent=4))
217 for a
in alg_data_list:
220 adj_table[a.sn].
append(output2sn[i])
224 for w
in adj_table[v]:
230 return G, alg_data_list
232 if __name__ ==
'__main__':