ATLAS Offline Software
TestUtils.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg
5 from TriggerMenuMT.HLT.Config.MenuComponents import Chain, ChainStep
6 from TriggerMenuMT.HLT.Config.Utility.ChainDefInMenu import ChainProp
7 from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitChainDictInLegs
8 from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName
9 from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig import HLTMenuConfig
10 from HLTSeeding.HLTSeedingConfig import mapThresholdToL1DecisionCollection
11 
12 import 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 
34 chainsCounter = 0
35 
36 def 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
TestUtils.makeChain
def makeChain(flags, name, L1Thresholds, ChainSteps, Streams="physics:Main", Groups=["RATE:TestRateGroup", "BW:TestBW"])
Definition: TestUtils.py:36
ChainDictTools.splitChainDictInLegs
def splitChainDictInLegs(chainDict)
Definition: ChainDictTools.py:112
DictFromChainName.dictFromChainName
def dictFromChainName(flags, chainInfo)
Definition: DictFromChainName.py:652
TestUtils.makeChainStep.__init__
def __init__(self, name, seq=None, comboHypoCfg=None, comboToolConfs=None, chainDicts=None, isEmpty=False)
Definition: TestUtils.py:25
TestUtils.makeChainStep
Definition: TestUtils.py:23
TestUtils.writeEmulationFiles
def writeEmulationFiles(data)
Definition: TestUtils.py:14
TestUtils.makeChainStep.comboHypoCfg
comboHypoCfg
Definition: TestUtils.py:28
TestUtils.makeChainStep.comboToolConfs
comboToolConfs
Definition: TestUtils.py:29
TestUtils.makeChainStep.seq
seq
Definition: TestUtils.py:27
TestUtils.makeChainStep.name
name
Definition: TestUtils.py:26
TestUtils.makeChainStep.isEmpty
isEmpty
Definition: TestUtils.py:31
TestUtils.makeChainStep.chainDicts
chainDicts
Definition: TestUtils.py:30
Trk::open
@ open
Definition: BinningType.h:40
pickleTool.object
object
Definition: pickleTool.py:29
HLTSeedingConfig.mapThresholdToL1DecisionCollection
def mapThresholdToL1DecisionCollection(threshold)
Definition: HLTSeedingConfig.py:79