ATLAS Offline Software
Loading...
Searching...
No Matches
EmuStepProcessingConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon.Logging import logging
4from AthenaConfiguration.ComponentAccumulator import CompFactory
5import functools
6
7log = logging.getLogger('EmuStepProcessingConfig')
8
9
10def generateEmuMenu(flags):
11 """
12 set Emu menu and reproduce generateMT
13 """
14 log.info("generateEmuMenu")
15 from TriggerMenuMT.HLT.Menu import Dev_pp_run3_v1
16 from TriggerMenuMT.HLT.Menu import Dev_pp_run3_emu_v1
17 from TriggerMenuMT.HLT.Config.GenerateMenuMT import GenerateMenuMT
18
19 # overwrite Dev_pp_run3_v1
20 Dev_pp_run3_v1.setupMenu = Dev_pp_run3_emu_v1.setupMenu
21
22 # Generate the menu
23 menu = GenerateMenuMT()
24 chains = menu.generateAllChainConfigs(flags)
25 return chains
26
27
28
29
31 log.info("generateEmuEvents")
32 # 4 events
33 data = {
34 'noreco': [';', ';', ';',';'],
35 'emclusters': [';', ';', ';',';'],
36 'msmu': [';', ';', ';',';'],
37 'ctp': [';', ';', ';',';'],
38 'l1emroi': [';', ';', ';',';'],
39 'l1muroi': [';', ';', ';',';']
40 } # in the lists there are the events
41
42 # event 0: empty
43 data['ctp'] [0] = 'HLT_TestChain5_ev1_L1EM3 \
44 HLT_TestChain8_ev1_L1EM3 \
45 HLT_g5_EM7'
46 data['l1emroi'][0] = ';'
47 data['emclusters'][0]= ';'
48 data['l1muroi'][0] = ';'
49 data['msmu'][0] = ';'
50
51
52 #event 1: 3e (1 not passing at L1, 1 not passing at step1) + 2mu (2 not passing) - HLT_e5_e8_L12EM3 HLT_2TestChain6_mv1_L12MU5VF
53 data['ctp'] [1] = 'HLT_TestChain5_ev1_L1EM3 \
54 HLT_TestChain8_ev1_L1EM3 \
55 HLT_TestChain5_gv1_L1EM7 \
56 HLT_TestChain5_ev3_L1EM7 \
57 HLT_2TestChain6_mv1_L12MU5VF \
58 HLT_TestChain10_mv2_L1MU8F \
59 HLT_TestChain6_mv1_TestChain10_mv1_L12MU5VF \
60 HLT_TestChain6_mEmpty3_TestChain10_mv1_L12MU5VF \
61 HLT_2TestChain4_mv1_dr_L12MU5VF'
62 data['l1emroi'][1] = '1,1,0,EM3,EM7,EM20,EM30,EM100; 2.,-1.2,0,EM3,EM7; 3.,0.2,0,EM3;'
63 data['emclusters'][1]= 'eta:1,phi:1,et:180000; eta:2,phi:-1.2,et:6000; eta:3.,phi:0.2,et:3000;'
64 data['l1muroi'][1] = '2,0.5,0,MU5VF; 3,0.5,0,MU5VF;'
65 data['msmu'][1] = 'eta:2,phi:0.5,pt:1500,pt2:1500; eta:3,phi:0.5,pt:1500,pt2:1500;'
66
67 # event 2: 2e+ 3mu : HLT_TestChain5_ev1_TestChain8_ev1_2TestChain6_mv1_L1_2EM8VH_MU8F, HLT_TestChain6_mv1_TestChain10_ev1_L12eEM10L_MU8F
68 data['ctp'] [2] = 'HLT_TestChain6_mv1_L1MU5VF \
69 HLT_TestChain8_mv1_L1MU8F \
70 HLT_TestChain10_mv2_L1MU8F \
71 HLT_TestChain8_mv1step_L1MU8F \
72 HLT_TestChain5_ev1_L1EM3 \
73 HLT_TestChain8_ev1_L1EM3 \
74 HLT_TestChain8_mEmpty2_L1MU8F \
75 HLT_TestChain8_mEmpty3_L1MU8F \
76 HLT_TestChain6_mEmpty3_TestChain10_mv1_L12MU5VF \
77 HLT_TestChain6_mv1_TestChain10_ev1_L12eEM10L_MU8F \
78 HLT_TestChain6_mv2_TestChain8_ev2_L12eEM10L_MU8F \
79 HLT_2TestChain6_mv1_L12MU5VF \
80 HLT_2TestChain6_mEmpty1_L12MU5VF \
81 HLT_TestChain6_mv1_TestChain10_mv1_L12MU5VF \
82 HLT_2TestChain4_mv1_dr_L12MU5VF HLT_e5_e8_L12EM3 \
83 HLT_TestChain5_ev1_TestChain8_ev1_2TestChain6_mv1_L12EM8VH_MU8F \
84 HLT_TestChain10_mEmpty1_TestChain6_mEmpty1_L12MU5VF \
85 HLT_TestChain10_mv1_TestChain6_mEmpty1_L1MU5VF \
86 HLT_TestChain5_ev1_TestChain8_ev1_merge_L12EM3 \
87 HLT_TestChain5_ev1_TestChain8_ev1_L12EM3 \
88 HLT_TestChain6_mv1_TestChain5_ev1_dr_L12MU5VF'
89 data['l1emroi'][2] = '0.5,0.1,0,EM3,EM7,EM15,EM20,EM30,EM100; 1,-1.2,0,EM3,EM7,EM15,EM20,EM30;'
90 data['emclusters'][2]= 'eta:0.5,phi:0.1,et:120000; eta:1,phi:-1.2,et:65000;'
91 data['l1muroi'][2] = '-1.2,0.7,0,MU5VF,MU8VF; -1.1,0.6,0,MU5VF,MU8F,MU8VF;1.1,0.6,0,MU5VF;'
92 data['msmu'][2] = 'eta:-1.2,phi:0.7,pt:6500,pt2:8500; eta:-1.1,phi:0.6,pt:10500,pt2:8500;eta:1.1,phi:0.6,pt:8500,pt2:8500;'
93
94 #event 3: 1e + 1mu; HLT_TestChain6_mv1_TestChain10_ev1_L12eEM10L_MU8F does not pass because of e10
95 data['ctp'] [3] = 'HLT_TestChain20_mv1_L1MU8F \
96 HLT_TestChain10_mv1_L1MU8F \
97 HLT_TestChain8_mv1_L1MU8F \
98 HLT_TestChain8_mEmpty3_L1MU8F \
99 HLT_TestChain8_mEmpty2_L1MU8F \
100 HLT_TestChain6_mEmpty3_TestChain8_mv1_L12MU5VF \
101 HLT_TestChain8_mv1step_L1MU8F \
102 HLT_TestChain8_ev1_L1EM3 \
103 HLT_TestChain6_mv1_TestChain10_ev1_L12eEM10L_MU8F\
104 HLT_TestChain6_mv2_TestChain8_ev2_L12eEM10L_MU8F'
105 data['l1emroi'][3] = '-0.6,1.7,0,EM3,EM7;'
106 data['emclusters'][3]= 'eta:-0.6,phi:1.7,et:9000;'
107 data['l1muroi'][3] = '-1.7,-0.2,0,MU5VF,MU8F,MU8VF;'
108 data['msmu'][3] = 'eta:-1.7,phi:-0.2,pt:29500,pt2:8500;'
109
110 # otehr vectors
111
112 data['tracks'] = ['eta:1,phi:1,pt:120000; eta:1,phi:-1.2,et:32000;',
113 'eta:1,phi:1,pt:120000; eta:1,phi:-1.2,et:32000;',
114 'eta:0.5,phi:0,pt:130000; eta:1,phi:-1.2,pt:60000;eta:-1.2,phi:0.7,pt:6700; eta:-1.1,phi:0.6,pt:8600;',
115 'eta:-0.6,phi:1.7,et:9000;'] # no MU track for MS candidate 'eta:-1.7,phi:-0.2,pt:9500;'
116
117 data['mucomb'] = [';',
118 ';',
119 'eta:-1.2,phi:0.7,pt:6600; eta:-1.1,phi:0.6,pt:8600;',
120 ';']
121
122 data['electrons'] = [';',
123 'eta:1,phi:1,pt:120000; eta:1,phi:-1.2,et:32000;',
124 ';',
125 ';']
126 data['photons'] = [';',
127 'eta:1,phi:1,pt:130000;',
128 ';',
129 ';']
130
131 from TriggerMenuMT.CFtest.TestUtils import writeEmulationFiles
132 writeEmulationFiles(data)
133
134
135
136def generateChainsManually(flags, maskbit=0x7):
137 """
138 generates chains without menu, directly adding Chain configuration to HLTConfig
139 maskbits used to enable signature-lke group of chains
140 """
141 log.info("generateChainsManually mask=0x%d",maskbit)
142 from TriggerMenuMT.CFtest.TestUtils import makeChain, makeChainStep
143 from TriggerMenuMT.HLT.Config.MenuComponents import EmptyMenuSequence
144 doMuon = maskbit & 0x1
145 doElectron = maskbit>>1 & 0x1
146 doCombo = maskbit>>2 & 0x1
147
148 HLTChains = []
149
150 # muon chains
151 if doMuon:
152 from TriggerMenuMT.CFtest.HLTSignatureConfig import muMenuSequence
153 #step1
154 mu11 = functools.partial(muMenuSequence, flags,step="1",reconame="v1", hyponame="v1")
155 mu12 = functools.partial(muMenuSequence,flags,step="1",reconame="v2", hyponame="v2")
156
157 #step2
158 mu21 = functools.partial(muMenuSequence,flags,step="2",reconame="v1", hyponame="v1")
159 mu22 = functools.partial(muMenuSequence,flags,step="2",reconame="v2", hyponame="v2")
160 #step3
161 mu31 = functools.partial(muMenuSequence,flags,step="3",reconame="v1", hyponame="v1")
162 mu32 = functools.partial(muMenuSequence,flags,step="3",reconame="v2", hyponame="v2")
163 #step4
164 mu41 = functools.partial(muMenuSequence,flags,step="4",reconame="v1", hyponame="v1")
165
166 step_mu11 = makeChainStep("Step1_mu11", [mu11] )
167 step_mu21 = makeChainStep("Step2_mu21", [mu21] )
168 step_mu22 = makeChainStep("Step2_mu22", [mu22] )
169 step_mu31 = makeChainStep("Step3_mu31", [mu31] )
170 step_mu32 = makeChainStep("Step3_mu32", [mu32] )
171 step_mu41 = makeChainStep("Step4_mu41", [mu41] )
172
173 step_empy= makeChainStep("Step2_mu1empty", isEmpty=True)
174
175 MuChains = [
176 makeChain(flags, name='HLT_TestChain8_mv1step_L1MU8F', L1Thresholds=["MU5VF"], ChainSteps=[step_mu11]),
177 makeChain(flags, name='HLT_TestChain8_mv1_L1MU8F', L1Thresholds=["MU8F"], ChainSteps=[step_mu11 , step_mu21 , step_mu31, step_mu41] ),
178 makeChain(flags, name='HLT_TestChain20_mv1_L1MU8F', L1Thresholds=["MU8F"], ChainSteps=[step_mu11 , step_mu21 , step_mu31, step_mu41] ),
179 makeChain(flags, name='HLT_TestChain10_mv2_L1MU8F', L1Thresholds=["MU8F"], ChainSteps=[step_mu11 , step_mu22 , step_mu31] ),
180 makeChain(flags, name='HLT_TestChain8_mEmpty2_L1MU8F', L1Thresholds=["MU5VF"], ChainSteps=[step_mu11 , step_empy , step_mu32, step_mu41] )
181 ]
182
183
184 HLTChains += MuChains
185
186
187
188 if doElectron:
189 from TriggerMenuMT.CFtest.HLTSignatureConfig import elMenuSequence, gamMenuSequence
190 el11 = functools.partial(elMenuSequence,flags,step="1",reconame="v1", hyponame="v1")
191 el21 = functools.partial(elMenuSequence,flags,step="2",reconame="v1", hyponame="v1")
192 el22 = functools.partial(elMenuSequence,flags,step="2",reconame="v2", hyponame="v2")
193 el23 = functools.partial(elMenuSequence,flags,step="2",reconame="v2", hyponame="v3")
194 el31 = functools.partial(elMenuSequence,flags,step="3",reconame="v1", hyponame="v1")
195 el41 = functools.partial(elMenuSequence,flags,step="4",reconame="v1", hyponame="v1")
196
197 # gamma
198 gamm11 = functools.partial(gamMenuSequence,flags,"1", reconame="v1", hyponame="v1")
199
200 ElChains = [
201 makeChain(flags, name='HLT_TestChain5_ev1_L1EM3', L1Thresholds=["EM3"], ChainSteps=[ makeChainStep("Step1_em11", [el11]), makeChainStep("Step2_em21", [el21]), makeChainStep("Step3_em31", [el31])] ),
202 makeChain(flags, name='HLT_TestChain8_ev1_L1EM3', L1Thresholds=["EM3"], ChainSteps=[ makeChainStep("Step1_em11", [el11]), makeChainStep("Step2_em21", [el21]), makeChainStep("Step3_em31", [el31]) ] ),
203 makeChain(flags, name='HLT_TestChain5_ev2_L1EM7', L1Thresholds=["EM7"], ChainSteps=[ makeChainStep("Step1_em11", [el11]), makeChainStep("Step2_em22", [el22]) ] ),
204 makeChain(flags, name='HLT_TestChain5_ev3_L1EM7', L1Thresholds=["EM7"], ChainSteps=[ makeChainStep("Step1_em11", [el11]), makeChainStep("Step2_em23", [el23]) ] ),
205 makeChain(flags, name='HLT_TestChain5_gv1_L1EM7', L1Thresholds=["EM7"], ChainSteps=[ makeChainStep("Step1_gam11", [gamm11]) ] )
206 ]
207
208 HLTChains += ElChains
209
210
211 # combined chain
212 if doCombo:
213
214 emptySeq1 = functools.partial(EmptyMenuSequence,"step1EmptySeqence")
215 emptySeq2 = functools.partial(EmptyMenuSequence,"step2EmptySeqence")
216
217 if not doElectron:
218 from TriggerMenuMT.CFtest.HLTSignatureConfig import elMenuSequence
219 el11 = functools.partial(elMenuSequence,flags,step="1",reconame="v1", hyponame="v1")
220 el21 = functools.partial(elMenuSequence,flags,step="2",reconame="v1", hyponame="v1")
221 el41 = functools.partial(elMenuSequence,flags,step="4",reconame="v1", hyponame="v1")
222
223 if not doMuon:
224 from TriggerMenuMT.CFtest.HLTSignatureConfig import muMenuSequence
225 #step1
226 mu11 = functools.partial(muMenuSequence,flags,step="1",reconame="v1", hyponame="v1")
227 mu12 = functools.partial(muMenuSequence,flags,step="1",reconame="v2", hyponame="v2")
228 #step2
229 mu21 = functools.partial(muMenuSequence,flags,step="2",reconame="v1", hyponame="v1")
230 mu22 = functools.partial(muMenuSequence,flags,step="2",reconame="v2", hyponame="v2")
231 #step3
232 mu31 = functools.partial(muMenuSequence,flags,step="3",reconame="v1", hyponame="v1")
233 mu32 = functools.partial(muMenuSequence,flags,step="3",reconame="v2", hyponame="v2")
234 #step4
235 mu41 = functools.partial(muMenuSequence,flags,step="4",reconame="v1", hyponame="v1")
236
237
238 from TriggerMenuMT.CFtest.HLTSignatureHypoTools import dimuDrComboHypoTool
239
240
241 CombChains =[
242 # This is an example of a chain running in "serial"
243 makeChain(flags, name='HLT_TestChain6_mv1_TestChain10_ev1_L12eEM10L_MU8F', L1Thresholds=["MU5VF","EM3"], ChainSteps=[
244 makeChainStep("Step1_mu_em_serial", [mu11, emptySeq1]),
245 makeChainStep("Step2_mu_em_serial", [emptySeq2, el21]),
246 makeChainStep("Step3_mu_em_serial", isEmpty=True),
247 makeChainStep("Step4_mu_em_serial", [mu41, el41])] ),
248
249 makeChain(flags, name='HLT_TestChain6_mv2_TestChain8_ev2_L12eEM10L_MU8F', L1Thresholds=["MU5VF","EM3"], ChainSteps=[
250 makeChainStep("Step1_mu2_em", [mu12, el11]),
251 makeChainStep("Step2_mu_em", [mu21, el21])] ),
252
253 makeChain(flags, name='HLT_TestChain5_ev1_TestChain8_ev1_L12EM3', L1Thresholds=["EM3","EM3"], ChainSteps=[ #norun
254 makeChainStep("Step1_2emAs", [el11, el11]),
255 makeChainStep("Step2_2emAs", [el21, el21]) ]),
256
257 makeChain(flags, name='HLT_TestChain5_ev1_TestChain8_ev1_2TestChain6_mv1_L12EM8VH_MU8F', L1Thresholds=["EM8VH","EM8VH","MU8F"], ChainSteps=[
258 makeChainStep("Step1_2em_2mu", [el11,el11,mu11]),
259 makeChainStep("Step2_2em_2mu", [el21,el21,mu21]) ]),
260
261 makeChain(flags, name='HLT_2TestChain6_mv1_L12MU5VF', L1Thresholds=["MU5VF"], ChainSteps=[
262 makeChainStep("Step1_2mu", [mu11]),
263 makeChainStep("Step2_2mu", [mu21]) ]),
264
265 makeChain(flags, name='HLT_3TestChain6_mv1_L12MU5VF', L1Thresholds=["MU5VF"], ChainSteps=[
266 makeChainStep("Step1_2mu", [mu11]),
267 makeChainStep("Step2_2mu", [mu21]) ]),
268
269 makeChain(flags, name='HLT_TestChain6_mv1_TestChain10_mv1_L12MU5VF', L1Thresholds=["MU5VF", "MU5VF"], ChainSteps=[
270 makeChainStep("Step1_2muAs", [mu11,mu11]),
271 makeChainStep("Step2_2muAs", [mu21,mu21]) ]),
272
273 makeChain(flags, name='HLT_2TestChain6_mEmpty1_L12MU5VF', L1Thresholds=["MU5VF"], ChainSteps=[
274 makeChainStep("Step1_2mu_empty", isEmpty=True),
275 makeChainStep("Step2_2mu", [mu21]) ]),
276
277 makeChain(flags, name='HLT_TestChain6_mv1_TestChain5_ev1dr_L12MU5VF', L1Thresholds=["MU5VF","EM3"], ChainSteps=[
278 makeChainStep("Step1_mu_em", [mu11, el11], comboToolConfs=[dimuDrComboHypoTool]),
279 makeChainStep("Step2_mu_em", [mu21, el21], comboToolConfs=[dimuDrComboHypoTool])] ),
280
281
282 makeChain(flags, name='HLT_2TestChain4_mv1dr_L12MU5VF', L1Thresholds=["MU5VF"], ChainSteps=[
283 makeChainStep("Step1_2mu", [mu11], comboToolConfs=[dimuDrComboHypoTool]),
284 makeChainStep("Step2_2mu22", [mu22]) ] ),
285
286 # FSNOSEED not implemented in emulation
287 # L1Thresholds=["MU5VF", "MU5VF"],
288 makeChain(flags, name='HLT_TestChain10_mEmpty1_TestChain6_mEmpty1_L12MU5VF', L1Thresholds=["MU5VF", "MU5VF"], ChainSteps=[
289 makeChainStep("Step1_2muAs_empty", isEmpty=True),
290 makeChainStep("Step2_2muAs", [mu21, mu21]) ])
291 ]
292
293 HLTChains += CombChains
294
295 return HLTChains
296
297
298
299
300def emulateHLTSeedingCfg(flags, seqName = None):
301 """
302 copy of HLTSeeding/python/HLTSeedingConfig.py to allow seeding with emulated data with CA
303 """
304
305 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
306 acc = ComponentAccumulator()
307
308 decoderAlg = CompFactory.HLTSeeding()
309 decoderAlg.RoIBResult = "RoIBResult" # emulation based on legacy L1 data flow
310 decoderAlg.L1TriggerResult = "" # emulation based on legacy L1 data flow
311 decoderAlg.HLTSeedingSummaryKey = "HLTSeedingSummary" # Transient, consumed by DecisionSummaryMakerAlg
312
313 decoderAlg.ctpUnpacker = CompFactory.CTPUnpackingEmulationTool( ForceEnableAllChains=False , InputFilename="ctp.dat" )
314
315 from TrigEDMConfig.TriggerEDM import recordable
316 from HLTSeeding.HLTSeedingConfig import mapThresholdToL1RoICollection, mapThresholdToL1DecisionCollection, createKeyWriterTool
317 decoderAlg.RoIBRoIUnpackers += [
318 CompFactory.FSRoIsUnpackingTool("FSRoIsUnpackingTool", Decisions=mapThresholdToL1DecisionCollection("FSNOSEED"),
319 OutputTrigRoIs = recordable(mapThresholdToL1RoICollection("FSNOSEED")) ) ]
320
321 # emulate prescaler:
322
323 decoderAlg.prescaler = CompFactory.PrescalingEmulationTool()
324 decoderAlg.KeyWriterTool = createKeyWriterTool()
325 decoderAlg.DoCostMonitoring = False
326
327 # emulate L1 Unpackers
328 emUnpacker = CompFactory.RoIsUnpackingEmulationTool("EMRoIsEmuUnpackingTool", InputFilename="l1emroi.dat", OutputTrigRoIs=mapThresholdToL1RoICollection("EM"), Decisions=mapThresholdToL1DecisionCollection("EM"), ThresholdPrefix="EM" )
329 muUnpacker = CompFactory.RoIsUnpackingEmulationTool("MURoIsEmuUnpackingTool", InputFilename="l1muroi.dat", OutputTrigRoIs=mapThresholdToL1RoICollection("MU"), Decisions=mapThresholdToL1DecisionCollection("MU"), ThresholdPrefix="MU" )
330 decoderAlg.RoIBRoIUnpackers = [emUnpacker, muUnpacker]
331
332 acc.addEventAlgo( decoderAlg, sequenceName = seqName )
333
334 from TrigConfigSvc.TrigConfigSvcCfg import TrigConfigSvcCfg, HLTPrescaleCondAlgCfg
335 acc.merge( TrigConfigSvcCfg( flags ) )
336 acc.merge( HLTPrescaleCondAlgCfg( flags ) )
337
338 return acc
generateChainsManually(flags, maskbit=0x7)
emulateHLTSeedingCfg(flags, seqName=None)
L1 #################################################.