ATLAS Offline Software
Loading...
Searching...
No Matches
test_menu_cf.py
Go to the documentation of this file.
1#!/usr/bin/env athena
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
4
6
7# - menuManual: chains are generated manually in generateCFChains, and run on input data file
8# - emuMenuTest: chains are generated in the menu framework as HLT_TestChain**, and run on emulated data
9# - emuManual: chains are genrated manually and run on emulated data
10
11import itertools
12import functools
13
14from AthenaCommon.Logging import logging
15log = logging.getLogger('test_menu_cf')
16from AthenaCommon.Constants import DEBUG
17
18
19# load all configuration as the real HLT
20def set_flags(flags):
21
22 # Prevent usage of legacy job properties
23 from AthenaCommon import JobProperties
24 JobProperties.jobPropertiesDisallowed = True
25
26 # generic trigger flags
27 flags.Trigger.doHLT = True # needs to be set early as other flags depend on it
28 flags.Trigger.EDMVersion = 3 # Run-3 EDM
29 flags.Common.isOnline = True # online environment
30 flags.Input.Files = [] # menu cannot depend on input files
31
32 from TriggerJobOpts.TriggerConfigFlags import ROBPrefetching
33 flags.Trigger.triggerMenuSetup = "Dev_pp_run3_v1"
34 flags.Trigger.ROBPrefetchingOptions = [ROBPrefetching.StepRoI]
35 flags.Trigger.enableL1MuonPhase1 = False # doesn't work in this minimal setup
36 flags.Trigger.enabledSignatures = ['Muon', 'Tau','MinBias','Bphysics','Egamma', 'Electron', 'Photon', 'MET', 'Jet','Bjet','Calib']
37 log.info("Running on these signatures: %s",flags.Trigger.enabledSignatures)
38
39 # these flags are proper for these tests
40 flags.Trigger.doCFEmulationTest = True # this enables this emulation tests
41 flags.Trigger.generateMenuDiagnostics = True
42 # set DEBUG flag on the control-flow builder (before building)
43 import TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig
44 TriggerMenuMT.HLT.Config.ControlFlow.HLTCFConfig.log.setLevel(DEBUG)
45
46
47def configure(flags, args):
48
49 from TriggerMenuMT.CFtest.generateCFChains import generateCFChains
50 from TriggerMenuMT.CFtest.EmuStepProcessingConfig import generateEmuEvents, generateChainsManually, generateEmuMenu
51
52 if args.menuType == 'menuManual':
53 # test generating chains from real sequences and real data
54 menu = generateCFChains(flags)
55 chains = list(itertools.chain(*menu.chainsInMenu.values()))
56 elif args.menuType == 'emuMenuTest':
57 # test using menu code (HLT_TestChain) with dummy sequences and events
58 generateEmuEvents()
59 chains = generateEmuMenu(flags)
60 elif args.menuType == 'emuManual':
61 # test generating emulation chains with dummy segments and events
62 generateEmuEvents()
63 chains = generateChainsManually(flags)
64 else:
65 log.error("Input parameter %s not accepted",args.menuType)
66
67 return chains
68
69def makeMenu(flags, args):
70 from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu
71 generateL1Menu(flags)
72 # from here generate the ControlFlow and the Dataflow
73 # doing the same as menu.generateMT()
74 chains = configure(flags, args)
75
76 from TriggerMenuMT.HLT.Config.GenerateMenuMT import makeHLTTree
77 menuCA, cfseqlist = makeHLTTree(flags, chains)
78
79 from TriggerMenuMT.HLT.Config.Utility.MenuPrescaleSet import AutoPrescaleSetGen
80 AutoPrescaleSetGen().generate(flags, store=True)
81
82 return menuCA
83
84def main():
85 from AthenaConfiguration.AllConfigFlags import initConfigFlags
86 flags = initConfigFlags()
87 set_flags(flags)
88 # Add options to command line parser
89 parser = flags.getArgumentParser()
90
91 parser.add_argument('--menuType', default='emuMenuTest', #'emuManual',
92 help='use either menu or manual chain building')
93
94 # Fill flags from command line
95 args = flags.fillFromArgs(parser=parser)
96 log.info('Setup options:')
97 log.info(' %20s = %s' , 'menuType', args.menuType)
98
99 # Configure main services
100 _allflags = flags.clone() # copy including Concurrency flags
101 _allflags.lock()
102 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
103 cfg = MainServicesCfg(_allflags)
104 del _allflags
105 flags.lock()
106
107 from TriggerJobOpts.TriggerConfig import triggerRunCfg
108 menu = triggerRunCfg(flags, menu=functools.partial(makeMenu, args=args))
109 cfg.merge(menu)
110 cfg.printConfig(withDetails=False, summariseProps=True, printDefaults=True)
111
112 from AthenaConfiguration.AccumulatorCache import AccumulatorDecorator
113 AccumulatorDecorator.printStats()
114
115 from AthenaCommon.CFElements import isSequence
116 for alg in menu.getSequence("HLTAllSteps").Members:
117 if isSequence( alg ):
118 continue
119
120 if "TriggerSummary" in alg.getName():
121 alg.OutputLevel = DEBUG # noqa: ATL900 (testing script)
122
123 return cfg
124
125# This entry point is only used when running in athena
126if __name__ == "__main__":
127 import sys
128 sys.exit(main().run().isFailure())
Definition run.py:1
set_flags(flags)
makeMenu(flags, args)
configure(flags, args)