10 from AthenaConfiguration.ComponentFactory
import CompFactory
11 from AthenaMonitoringKernel.GenericMonitoringTool
import GenericMonitoringTool
14 import L1TopoHardware.L1TopoHardware
as HW
16 from AthenaCommon.Logging
import logging
17 logger = logging.getLogger(__name__)
19 logger.setLevel(VERBOSE)
33 logger.error(
'Attempting to build an AlgTool from None')
36 return {
'INPUT': inputToolFromAlgData,
37 'COUNT': countToolFromAlgData,
38 'SORT': sortToolFromAlgData,
39 'DECISION': decisionToolFromAlgData,
40 }[alg_data.globalL1AlgType](flags, alg_data)
44 return ad.menu[
'klass']
48 """helper function to extract values from a L1MenuAccessor object"""
62 if isinstance(val, str):
63 if val.startswith(
':')
and val.endswith(
':'):
64 val = getattr(HW, val[1:-1]).value
69 """helper function to extract values from a L1MenuAccessor object"""
71 vps = ad.menu[
'variableParameters']
79 """helper function to extract values from a L1MenuAccessor object"""
86 """Input Algs read in FEX outputs and output TOBs of various types."""
103 write_handle =
'_'.
join([ad.klass, out0,
str(ad.sn)])
104 writeHandleKeys[ad.sn] =write_handle
108 if out0 ==
'jJetTobs':
109 name =
'jJetInputAlgTool_'+ out0
110 tool = CompFactory.GlobalSim.jJetInputAlgTool(name)
112 elif out0 ==
'eEmTobs':
113 name =
'eEmInputAlgTool_'+ out0
114 tool = CompFactory.GlobalSim.eEmInputAlgTool(name)
116 name =
'cTauInputAlgTool_' + out0
117 tool = CompFactory.GlobalSim.cTauInputAlgTool(name)
119 name =
'jXEInputAlgTool_' + out0
120 tool = CompFactory.GlobalSim.jXEInputAlgTool(name)
123 monTool.defineHistogram(
'jXETOBPt', path=
'EXPERT', type=
'TH1I',
124 title=
'jXE TOB Pt;p_{T} [GeV];',
125 xbins=200, xmin=0, xmax=2000)
127 monTool.defineHistogram(
'jXETOBPhi', path=
'EXPERT', type=
'TH1I',
128 title=
'jXE TOB Phi;#phi;',
129 xbins=64, xmin=-3.2, xmax=3.2)
131 tool.monTool = monTool
133 logger.error(
'Unsupported input alg type ' +
str(out0))
135 'toolFromAlgData: Unsupported input alg type ' +
str(out0))
137 tool.TOBArrayWriteKey = writeHandleKeys[ad.sn]
141 """Count Algorithms write out a Count object determined
142 from TOBS produced by a single Input Algorithm."""
146 countToolSelector = {
147 'cTauMultiplicity': CompFactory.GlobalSim.cTauMultiplicityAlgTool,
148 (
'EnergyThreshold',
'jXE'): CompFactory.GlobalSim.EnergyThresholdAlgTool_jXE,
154 if ad.klass ==
'EnergyThreshold':
155 key = (ad.klass, ad.inputs[0])
160 tool = countToolSelector[key](ad.name)
161 tool.alg_instance_name = ad.name
163 tool.TOBArrayReadKey = writeHandleKeys[ad.input_sns[0]]
164 tool.CountWriteKey = ad.name +
'_Count_' +
str(ad.sn)
165 writeHandleKeys[ad.sn] = tool.CountWriteKey
167 if ad.klass
in (
'EnergyThreshold',):
170 tool.hundredMeVThreshold =
int(ad.threshold)*10 + 5
172 if ad.klass ==
'cTauMultiplicity':
173 tool.do_dump = do_dump
177 title =
"cTauMultiplicity_accept #eta Et_" + threshold_name
179 monTool.defineHistogram(
"accept_eta,accept_et",
183 xbins=200, xmin=-200, xmax=200,
184 ybins=100, ymin=0, ymax=100)
186 title_stub =
"cTauMultiplicityc " + threshold_name +
" "
187 title = title_stub +
"counts"
188 monTool.defineHistogram(
"counts",
192 xbins=15, xmin=0, xmax=15)
194 title = title_stub +
"TOB Et"
195 monTool.defineHistogram(
"Et",
199 xbins=200, xmin=0, xmax=400)
202 title = title_stub +
"#phi #eta"
203 monTool.defineHistogram(
"phi,eta",
207 xbins=200, xmin=0, xmax=400,
208 ybins=128, ymin=0, ymax=128)
211 title = title_stub +
"Et #eta"
212 monTool.defineHistogram(
"Et,eta",
216 xbins=200, xmin=0, xmax=200,
217 ybins=200, ymin=0, ymax=400)
219 title = title_stub +
"loose partial isolation"
220 monTool.defineHistogram(
"iso_loose",
224 xbins=200, xmin=0, xmax=10)
226 title = title_stub +
"medium partial isolation"
227 monTool.defineHistogram(
"iso_medium",
231 xbins=200, xmin=0, xmax=10)
234 title = title_stub +
"tight partial isolation"
235 monTool.defineHistogram(
"iso_tight",
239 xbins=200, xmin=0, xmax=10)
241 tool.monTool = monTool
246 """Sort Algorithms write out a GenericTOBArray produced by sorting,
247 and possibly selecting, TOBs produced by an Input Algorithm"""
253 'eEmSelect': CompFactory.GlobalSim.eEmSelectAlgTool,
254 'jJetSelect': CompFactory.GlobalSim.jJetSelectAlgTool,
259 tool = sortToolSelector[ad.klass](ad.name)
261 tool.alg_instance_name = ad.name
262 tool.TOBArrayReadKey = writeHandleKeys[ad.input_sns[0]]
263 writeHandleKeys[ad.sn] = ad.klass+
'_' + out0 +
'_' +
str(ad.sn)
264 tool.TOBArrayWriteKey = writeHandleKeys[ad.sn]
265 if klass(ad) ==
'eEmSelect':
272 if klass(ad) ==
'jJetSelect':
283 """Decision Algorithms all write out a L1Topo Decision object
284 determined by processing the outputs of 1 or more Sort Algorithms.
285 They also write out a vector of GenericTOBs."""
291 decisionToolSelector = {
292 'DeltaRSqrIncl2': CompFactory.GlobalSim.DeltaRSqrIncl2AlgTool,
293 'SimpleCone': CompFactory.GlobalSim.SimpleConeAlgTool,
296 tool = decisionToolSelector[ad.klass](ad.name)
297 tool.alg_instance_name = ad.name
299 assert len(ad.outputs) == 1
300 writeHandleKeys[ad.sn] = ad.klass +
'_'+ ad.outputs[0] +
'_' +
str(ad.sn)
301 tool.TOBArrayVectorWriteKey = writeHandleKeys[ad.sn]
302 tool.DecisionWriteKey = ad.name +
'_Decision_' +
str(ad.sn)
304 if klass(ad) ==
'DeltaRSqrIncl2':
305 tool.TOBArrayReadKey0 = writeHandleKeys[ad.input_sns[0]]
306 tool.TOBArrayReadKey1 = writeHandleKeys[ad.input_sns[1]]
310 tool.NumResultBits =
fixedValue(ad,
'NumResultBits')
319 assert tool.NumResultBits == 1
324 for i
in range(tool.NumResultBits):
326 label = ad.name +
"_pass_by_bit_" +
str(i)
327 monTool.defineHistogram(label,
328 path=
"EXPERT", type=
"TH1F",
329 title=
"DeltaR pass, bit " +
str(i),
330 xbins=10, xmin=0, xmax=100.)
332 label = ad.name +
"_fail_by_bit_" +
str(i)
333 monTool.defineHistogram(label,
334 path=
"EXPERT", type=
"TH1F",
335 title=
"DeltaR fail, bit " +
str(i),
336 xbins=10, xmin=0, xmax=100.)
337 tool.monTool = monTool
338 tool.do_dump = do_dump
342 if klass(ad) ==
'SimpleCone':
344 tool.TOBArrayReadKey = writeHandleKeys[ad.input_sns[0]]
360 for i
in range(numResultBits):
361 monTool.defineHistogram(ad.name+
"_pass_by_bit_" +
str(i),
362 path=
"EXPERT", type=
"TH1F",
363 title=
"ET pass, bit " +
str(i),
364 xbins=10, xmin=0, xmax=100.)
366 monTool.defineHistogram(ad.name+
"_fail_by_bit_" +
str(i),
367 path=
"EXPERT", type=
"TH1F",
368 title=
"ET fail, bit " +
str(i),
369 xbins=10, xmin=0, xmax=100.)
370 tool.monTool = monTool