ATLAS Offline Software
Loading...
Searching...
No Matches
TrigIDR4MonRun.py
Go to the documentation of this file.
1#!/bin/env python
2#
3# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4#
5# create all the histograms for each analysis - this will get called once for each
6# configured chain - we can set the HistPath either already here, or from the c++
7# code
8# actual code to configure al;l the different algorithm instances for
9# the different slices
10
11from TrigIDR4Monitoring import TrigIDR4MonConfig
12from TrigIDR4Monitoring import TrigIDR4MonFlags
13
14from TrigIDR4Monitoring import decodeFlags
15from TrigIDR4Monitoring import updateFlags
16
17from TrigIDR4Monitoring.TrigIDR4MonConfig import histsvc
18from TrigIDR4Monitoring.TrigIDR4MonConfig import parse_files
19from TrigIDR4Monitoring.TrigIDR4MonConfig import parse_signatures
20
21
22import sys
23
24if __name__=='__main__':
25
26 # Set the Athena configuration flags
27 from AthenaConfiguration.AllConfigFlags import initConfigFlags
28
29 flags = initConfigFlags()
30
31 # Setup logs
32 from AthenaCommon.Logging import log
33 log.info( "test running" )
34
35 parser = flags.getArgumentParser(conflict_handler='resolve')
36
37 parser.add_argument( '--jsonConfig', type=str, default="", help='json config' )
38 parser.add_argument( '--output', type=str, default="", help='output file' )
39 parser.add_argument( '--filesInput', nargs='+', default=None, help='files' )
40 parser.add_argument( '--signatures', nargs='+', default=None, help='signatures to enable (default, all signatures)')
41
42 remaining = []
43
44 for arg in sys.argv[1:]:
45 if arg.endswith(".py") or ( not arg.startswith("-") and "=" in arg ) : continue
46 remaining.append(arg)
47
48 args, _ = parser.parse_known_args(remaining )
49
50 # parse_files also checks if the files actually exist ...
51 if args.filesInput is not None: flags.Input.Files = parse_files( args.filesInput, sys.argv )
52 else: flags.Input.Files = parse_files( 'AOD.pool.root' )
53
54 if not flags.Input.Files: sys.exit(0)
55
56 signatures = parse_signatures( args.signatures, sys.argv )
57
58 # default numbers of threads and slots - can be overridden from the cmd line
59 flags.Concurrency.NumThreads = 20
60 flags.Concurrency.NumConcurrentEvents = 10
61
62 args = flags.fillFromArgs(parser=parser)
63
64 if args.output: flags.Output.HISTFileName = args.output
65 else: flags.Output.HISTFileName = 'duff.root'
66
67 # allow command line argument to override flag
68 if args.evtMax and args.evtMax != -1 : flags.Input.FileNentries = args.evtMax
69
70 # in case we are looking at an express stream file ...
71 flags.Common.doExpressProcessing = True
72
73 if flags.Concurrency.NumThreads < flags.Concurrency.NumConcurrentEvents : flags.Concurrency.NumConcurrentEvents = flags.Concurrency.NumThreads
74
75 flags.Input.AODFixesDone = { "egammaAODFixesCfg" }
76
77 from TrigIDR4Monitoring.NodeUtils import timer
78
79 tflags = decodeFlags(flags)
80
81 jsonConfig=None
82
83 if args.jsonConfig :
84 jsonConfig = args.jsonConfig
85 log.info( f"json config: {jsonConfig}" )
86
87 log.info( f"enable idtpm2 signatures: {signatures}" )
88
89 timer( TrigIDR4MonFlags, tflags, signatures, jsonConfig )
90
91 updateFlags(flags,tflags)
92
93 tflags.Exec.FPE = 1
94
95 flags.lock()
96
97 tflags.lock()
98
99 for f in flags.Input.Files: log.info( f"input file: {f}" )
100
101 log.info( f"output file: {flags.Output.HISTFileName}" )
102
103 log.info( f"threads: {flags.Concurrency.NumThreads}" )
104 log.info( f"concurrent events: {flags.Concurrency.NumConcurrentEvents}" )
105
106 log.info( f"Nevents: {flags.Input.FileNentries}" )
107
108 # Initialize configuration object, add accumulator, merge, and run.
109 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
110 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
111
112 cfg = MainServicesCfg(tflags)
113
114 cfg.merge( PoolReadCfg(tflags) )
115
116 cfg.merge( histsvc(tflags) )
117
118 cfg.merge( TrigIDR4MonConfig( tflags ) )
119
120 # If you want to turn on more detailed messages ...
121 cfg.printConfig(withDetails=False) # set True for exhaustive info
122
123 # import ctypes
124
125 # libc = ctypes.CDLL("libm.so.6")
126 # libc.feenableexcept(0x01 | 0x04 | 0x08 )
127
128 cfg.run(flags.Input.FileNentries)
129
130
131