ATLAS Offline Software
Loading...
Searching...
No Matches
TestUtils.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg
5from TriggerMenuMT.HLT.Config.MenuComponents import Chain, ChainStep
6from TriggerMenuMT.HLT.Config.Utility.ChainDefInMenu import ChainProp
7from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitChainDictInLegs
8from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName
9from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig
10from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection
11
12import functools
13
15 """Writes emulation files. key in the dict is a file name (+.dat), list which is value of each dict el is enetered into the file, one el. per line"""
16 for name, d in data.items():
17 with open(name+".dat", "w") as f:
18 for event in d:
19 f.write(event)
20 f.write("\n")
21
22
24 """Used to store the step info, regardless of the chainDict"""
25 def __init__(self, name, seq=None, comboHypoCfg=None, comboToolConfs=None, chainDicts=None, isEmpty=False):
26 self.name = name
27 self.seq = seq if seq is not None else []
28 self.comboHypoCfg = comboHypoCfg if comboHypoCfg is not None else functools.partial(ComboHypoCfg)
29 self.comboToolConfs = comboToolConfs if comboToolConfs is not None else []
30 self.chainDicts = chainDicts
31 self.isEmpty = isEmpty
32
33
34chainsCounter = 0
35
36def makeChain( flags, name, L1Thresholds, ChainSteps, Streams="physics:Main", Groups=["RATE:TestRateGroup", "BW:TestBW"]):
37 """
38 In addition to making the chain object fills the flags that are used to generate MnuCOnfig JSON file
39 """
40 prop = ChainProp( name=name, l1SeedThresholds=L1Thresholds, groups=Groups )
41 chainDict = dictFromChainName( flags, prop )
42 global chainsCounter
43 chainDict["chainCounter"] = chainsCounter
44 chainsCounter += 1
45
46 #set default chain prescale
47 chainDict['prescale'] = 1
48
49 listOfChainDicts = splitChainDictInLegs(chainDict)
50 L1decisions = [ mapThresholdToL1DecisionCollection(stri) for stri in L1Thresholds]
51 # create the ChainSteps, with the chaindict
52 StepConfig = []
53 for step in ChainSteps:
54 StepConfig+=[ChainStep(step.name,
55 step.seq,
56 chainDicts=step.chainDicts if step.chainDicts else listOfChainDicts,
57 comboHypoCfg=step.comboHypoCfg,
58 comboToolConfs=step.comboToolConfs, isEmpty=step.isEmpty)]
59
60 chainConfig = Chain( name=name, L1decisions=L1decisions, ChainSteps=StepConfig )
61 HLTMenuConfig.registerChain( chainDict )
62
63 return chainConfig
__init__(self, name, seq=None, comboHypoCfg=None, comboToolConfs=None, chainDicts=None, isEmpty=False)
Definition TestUtils.py:25
makeChain(flags, name, L1Thresholds, ChainSteps, Streams="physics:Main", Groups=["RATE:TestRateGroup", "BW:TestBW"])
Definition TestUtils.py:36
writeEmulationFiles(data)
Definition TestUtils.py:14