ATLAS Offline Software
RunTrigEgammaMonitoring.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2023 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 
53 
54  if len(sys.argv)==1:
55  parser.print_help()
56  sys.exit(1)
57 
58  args = parser.parse_args()
59 
60 
61 
62 
63  # ATR-11839 to fix the egammaPid import
64  from PyUtils.Helpers import ROOT6Setup
65  ROOT6Setup()
66 
67  # Set the Athena configuration flags
68  from AthenaConfiguration.AllConfigFlags import initConfigFlags
69  flags = initConfigFlags()
70 
71  if args.inputFiles is not None:
72  flags.Input.Files = args.inputFiles.split(',')
73  flags.Input.isMC = True
74  flags.Output.HISTFileName = args.outputFile
75 
76 
77  if args.preExec:
78  # bring things into scope
79  from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
80  exec(args.preExec)
81 
82  flags.lock()
83 
84 
85  # Initialize configuration object, add accumulator, merge, and run.
86  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
87  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
88  cfg = MainServicesCfg(flags)
89  cfg.merge(PoolReadCfg(flags))
90 
91  emulator=None
92  if args.emulate:
93  # create and configure emulator tool
94  from TrigEgammaEmulationTool.TrigEgammaEmulationToolConfigMT import TrigEgammaEmulationToolConfig
95  emulator = TrigEgammaEmulationToolConfig(flags, "EgammaEmulation")
96 
97  # configure all selectors
98  emulator.PhotonCBConfigFilePath = args.pidConfigPath # Cut-based
99  emulator.ElectronLHConfigFilePath = args.pidConfigPath # LH
100  emulator.ElectronCBConfigFilePath = args.pidConfigPath # Cut-based
101  emulator.ElectronDNNConfigFilePath = args.dnnConfigPath # DNN
102  emulator.FastCaloConfigFilePath = args.ringerConfigPath # NN
103  emulator.configure()
104 
105 
106 
107  # create the e/g monitoring tool and add into the component accumulator
108  from TrigEgammaMonitoring.TrigEgammaMonitorAlgorithm import TrigEgammaMonConfig
109  trigEgammaMonitorAcc = TrigEgammaMonConfig(flags, emulator=emulator)
110  cfg.merge(trigEgammaMonitorAcc)
111 
112 
113  # any last things to do?
114  if args.postExec:
115  exec(args.postExec)
116 
117  # If you want to turn on more detailed messages ...
118  if args.debug:
119  trigEgammaMonitorAcc.getEventAlgo('EgammaEmulation').OutputLevel = 2 # DEBUG
120 
121 
122 
123  cfg.printConfig(withDetails=False) # set True for exhaustive info
124  sc = cfg.run(args.numberOfEvents) #use cfg
125 
126  sys.exit(0 if sc.isSuccess() else 1)
127 
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.Helpers.ROOT6Setup
def ROOT6Setup(batch=False)
Definition: Tools/PyUtils/python/Helpers.py:19
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.TrigEgammaMonitorAlgorithm.TrigEgammaMonConfig
def TrigEgammaMonConfig(inputFlags, emulator=None)
Definition: TrigEgammaMonitorAlgorithm.py:17
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69