ATLAS Offline Software
generateTrigNavGraph.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 
6 if __name__=='__main__':
7  import sys
8  from argparse import ArgumentParser
9  parser = ArgumentParser()
10  parser.add_argument('--chain', default='HLT_mu50_L1MU20', type=str, help='Chain Group for which to plot the navigation graphs')
11  parser.add_argument('--excludeFailedHypoNodes', action='store_true', help='By default Hypo nodes are included which fail for a given chain, but there can be many, e.g. for jet. This excludes these nodes.')
12  parser.add_argument('--collection', type=str, help='Optional, restrict to nodes in a given collection, e.g. if the file contains multiple slim levels ')
13  parser.add_argument('--doTDTDump', action='store_true', help='Optional extra dump of TrigDecisionTool information for supplied chain')
14  parser.add_argument('--doNavDump', action='store_true', help='Optional extra dump of trigger navigation data to terminal (caution: large)')
15  parser.add_argument('--maxEvents', type=int, default=20, help='Maximum number of events to process')
16  parser.add_argument('--skipEvents', type=int, help='Number of events to skip')
17  parser.add_argument('--loglevel', type=int, default=3, help='Verbosity level')
18  parser.add_argument('flags', nargs='*', help='Config flag overrides')
19  args = parser.parse_args()
20 
21  from AthenaCommon.Logging import logging
22  log = logging.getLogger("generateTrigNavGraph.py")
23  log.info("Generating NavGraphs for :" + args.chain)
24 
25  from AthenaConfiguration.AllConfigFlags import initConfigFlags
26 
27  # Set the Athena configuration flags
28  flags = initConfigFlags()
29  flags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art//TrigAnalysisTest/AthenaTrigAOD_TrigEDMandTDTCheck_LS2_v1_chain/AOD.pool.root"]
30 
31  flags.Exec.MaxEvents = args.maxEvents
32  if args.skipEvents is not None:
33  flags.Exec.SkipEvents = args.skipEvents
34 
35  if args.flags:
36  flags.fillFromArgs(args.flags)
37 
38  flags.lock()
39 
40  if flags.Trigger.EDMVersion != 3:
41  log.error("Can only run over a Run 3 AOD or ESD file")
42  sys.exit(1)
43 
44  # Initialize configuration object, add accumulator, merge, and run.
45  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
46  from AthenaConfiguration.ComponentFactory import CompFactory
47 
48  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
49  cfg = MainServicesCfg(flags)
50  cfg.merge(PoolReadCfg(flags))
51 
52  from TrigDecisionTool.TrigDecisionToolConfig import TrigDecisionToolCfg
53  tdt_ca = TrigDecisionToolCfg(flags)
54  tdt = tdt_ca.getPrimary()
55  tdt.OutputLevel = args.loglevel
56  cfg.merge(tdt_ca)
57 
58  checker = CompFactory.TrigEDMChecker()
59  checker.doDumpAll = False
60  checker.OutputLevel = args.loglevel
61  checker.TriggerDecisionTool = tdt
62  checker.DumpNavigationForChain = args.chain
63  checker.dumpTrigCompositeContainers = [args.collection] if args.collection is not None else []
64  checker.doDumpTrigCompsiteNavigation = True
65  checker.excludeFailedHypoNodes = args.excludeFailedHypoNodes
66  # Other potentially useful commands
67  checker.doDumpAllTrigComposite = args.doNavDump
68  if args.doNavDump:
69  from Gaudi.Configuration import DEBUG
70  checker.OutputLevel = DEBUG
71  checker.doTDTCheck = args.doTDTDump
72  cfg.addEventAlgo(checker)
73 
74  sc = cfg.run()
75 
76  log.info("Converting .dot files to .dot.pdf")
77  import os
78  from subprocess import check_call
79  for f in os.listdir('.'):
80  if "NavGraph_" in f and not ".dot.pdf" in f:
81  check_call(['dot','-Tpdf',f,'-o',f+'.pdf'])
82 
83  sys.exit(0 if sc.isSuccess() else 1)
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.TriggerInterface.TrigDecisionToolCfg
def TrigDecisionToolCfg(flags)
Definition: TriggerInterface.py:14
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69