ATLAS Offline Software
RunTrigEgammaMonitoring.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 #
5 
6 if __name__=='__main__':
7 
8  import argparse
9  import sys,os
10 
11 
12  parser = argparse.ArgumentParser(description = '', add_help = False)
13  parser = argparse.ArgumentParser()
14 
15  #
16  # File configuration
17  #
18 
19  parser.add_argument('-i','--inputFiles', action='store', dest='inputFiles', required = False,
20  help = "Comma-separated list of input files (alias for --filesInput)")
21 
22  parser.add_argument('-o','--outputFile', action='store', dest='outputFile', required = False,
23  default = 'TrigEgammaMonitorOutput.root',
24  help = "Histogram output.")
25 
26  parser.add_argument('--nov','--numberOfEvents', action='store', dest='numberOfEvents', required = False,
27  type=int, default=-1,
28  help = "The number of events to run.")
29 
30  #
31  # Selector calib paths
32  #
33 
34  parser.add_argument('--pidConfigPath', action='store', required = False,
35  type=str, default='ElectronPhotonSelectorTools/trigger/rel22_20210611',
36  help = "Electron Likelihood and Photon CB config path to use in emulated precision step.")
37 
38  parser.add_argument('--dnnConfigPath', action='store', required = False,
39  type=str, default='ElectronPhotonSelectorTools/offline/mc16_20210430',
40  help = "Electron DNN config path to use in emulated precision step.")
41 
42  parser.add_argument('--ringerConfigPath', action='store', required = False,
43  type=str, default='RingerSelectorTools/TrigL2_20210702_r4',
44  help = "Electron ringer config path to use in emulated fast calo step.")
45 
46 
47 
48  parser.add_argument('--preExec', help='Code to execute before locking configs', default=None)
49  parser.add_argument('--postExec', help='Code to execute after setup', default=None)
50  parser.add_argument('--emulate', help='emulate the HLT e/g sequence', action='store_true')
51  parser.add_argument('--debug', help='debug mode', action='store_true')
52  parser.add_argument('--onlyHLT',help='compute final HLT decision', action='store_true', dest='onlyHLT')
53 
54  if len(sys.argv)==1:
55  parser.print_help()
56  sys.exit(1)
57 
58  args = parser.parse_args()
59 
60  # Set the Athena configuration flags
61  from AthenaConfiguration.AllConfigFlags import initConfigFlags
62  flags = initConfigFlags()
63 
64  if args.inputFiles is not None:
65  flags.Input.Files = args.inputFiles.split(',')
66  flags.Input.isMC = True
67  flags.Output.HISTFileName = args.outputFile
68 
69 
70  if args.preExec:
71  # bring things into scope
72  from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
73  exec(args.preExec)
74 
75  flags.lock()
76 
77 
78  # Initialize configuration object, add accumulator, merge, and run.
79  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
80  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
81  cfg = MainServicesCfg(flags)
82  cfg.merge(PoolReadCfg(flags))
83 
84  emulator=None
85  if args.emulate:
86  # create and configure emulator tool
87  from TrigEgammaEmulationTool.TrigEgammaEmulationToolConfigMT import TrigEgammaEmulationToolConfig
88  emulator = TrigEgammaEmulationToolConfig(flags, "EgammaEmulation")
89 
90  # configure all selectors
91  emulator.PhotonCBConfigFilePath = args.pidConfigPath # Cut-based
92  emulator.ElectronLHConfigFilePath = args.pidConfigPath # LH
93  emulator.ElectronCBConfigFilePath = args.pidConfigPath # Cut-based
94  emulator.ElectronDNNConfigFilePath = args.dnnConfigPath # DNN
95  emulator.FastCaloConfigFilePath = args.ringerConfigPath # NN
96  emulator.configure()
97 
98 
99 
100  # create the e/g monitoring tool and add into the component accumulator
101  from TrigEgammaMonitoring.TrigEgammaMonitorAlgorithm import TrigEgammaMonConfig
102  trigEgammaMonitorAcc = TrigEgammaMonConfig(flags, emulator=emulator, onlyHLT = args.onlyHLT)
103  cfg.merge(trigEgammaMonitorAcc)
104 
105 
106  # any last things to do?
107  if args.postExec:
108  exec(args.postExec)
109 
110  # If you want to turn on more detailed messages ...
111  if args.debug:
112  trigEgammaMonitorAcc.getEventAlgo('EgammaEmulation').OutputLevel = 2 # DEBUG
113 
114 
115 
116  cfg.printConfig(withDetails=False) # set True for exhaustive info
117  sc = cfg.run(args.numberOfEvents) #use cfg
118 
119  sys.exit(0 if sc.isSuccess() else 1)
120 
python.TrigEgammaMonitorAlgorithm.TrigEgammaMonConfig
def TrigEgammaMonConfig(inputFlags, emulator=None, onlyHLT=False)
Definition: TrigEgammaMonitorAlgorithm.py:17
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71