282def decisionToolFromAlgData(flags, ad):
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."""
286
287
288
289
290
291 decisionToolSelector = {
292 'DeltaRSqrIncl2': CompFactory.GlobalSim.DeltaRSqrIncl2AlgTool,
293 'SimpleCone': CompFactory.GlobalSim.SimpleConeAlgTool,
294 }
295
296 tool = decisionToolSelector[ad.klass](ad.name)
297 tool.alg_instance_name = ad.name
298
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)
303
304 if klass(ad) == 'DeltaRSqrIncl2':
305 tool.TOBArrayReadKey0 = writeHandleKeys[ad.input_sns[0]]
306 tool.TOBArrayReadKey1 = writeHandleKeys[ad.input_sns[1]]
307
308 tool.MaxTOB1 = int(fixedValue(ad, 'InputWidth1'))
309 tool.MaxTOB2 = int(fixedValue(ad, 'InputWidth2'))
310 tool.NumResultBits = fixedValue(ad, 'NumResultBits')
311
312 tool.MinET1 = [int(variableValue(ad, 'MinET1'))]
313 tool.MinET2 = [int(variableValue(ad, 'MinET2'))]
314 tool.DeltaRMin = [int(variableValue(ad, 'DeltaRMin'))]
315 tool.DeltaRMax = [int(variableValue(ad, 'DeltaRMax'))]
316
317
318
319 assert tool.NumResultBits == 1
320
321 tool.NumResultBits = int(fixedValue(ad, 'NumResultBits'))
322
324 for i in range(tool.NumResultBits):
325
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.)
331
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
339
340
341
342 if klass(ad) == 'SimpleCone':
343
344 tool.TOBArrayReadKey = writeHandleKeys[ad.input_sns[0]]
345
346 tool.InputWidth = int(fixedValue(ad, 'InputWidth'))
347 tool.MaxRSqr = int(variableValue(ad, 'MaxRSqr'))
348 tool.MinET = int(variableValue(ad, 'MinET'))
349
350
351
352
353 numResultBits = 1
354
355
356 tool.MinSumET = [int(variableValue(ad, 'MinSumET'))]
357
358
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.)
365
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
371
372
373 return tool
374