ATLAS Offline Software
Loading...
Searching...
No Matches
Run3DQTestingDriver.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'''@file DQTestingDriver.py
7@author C. D. Burton
8@author P. Onyisi
9@date 2019-06-20
10@brief Driver script to run DQ with new-style configuration on an ESD/AOD
11'''
12
13if __name__=='__main__':
14 import sys
15 from AthenaConfiguration.AllConfigFlags import initConfigFlags
16 from AthenaConfiguration.ComponentFactory import CompFactory
17 from AthenaConfiguration.Enums import Format
18 flags = initConfigFlags()
19 parser = flags.getArgumentParser()
20 parser.add_argument('--preExec', help='Code to execute before locking configs')
21 parser.add_argument('--postExec', help='Code to execute after setup')
22 parser.add_argument('--dqOffByDefault', action='store_true',
23 help='Set all DQ steering flags to False, user must then switch them on again explicitly')
24 # keep for compatibility reasons
25 parser.add_argument('--inputFiles',
26 help='Comma-separated list of input files (alias for --filesInput)')
27 # keep for compatibility reasons
28 parser.add_argument('--maxEvents', type=int,
29 help='Maximum number of events to process (alias for --evtMax)')
30 parser.add_argument('--printDetailedConfig', action='store_true',
31 help='Print detailed Athena configuration')
32
33 # change default
34 parser.set_defaults(threads=1)
35 args, _ = parser.parse_known_args()
36
37 # default input if nothing specified
38 flags.Input.Files = ['/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/AthenaMonitoring/q431/21.0/f946/myESD.pool.root']
39 flags.Output.HISTFileName = 'ExampleMonitorOutput.root'
40 if args.dqOffByDefault:
41 from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
42 allSteeringFlagsOff(flags)
43 flags.fillFromArgs(parser=parser)
44
45 # Setup logs
46 from AthenaCommon.Logging import log
47 from AthenaCommon import Constants
48 if args.loglevel:
49 log.setLevel(getattr(Constants, args.loglevel))
50
51 # override Input.Files with result from our own arguments
52 # if --filesInput was specified as well (!) this will override
53 if args.inputFiles is not None:
54 flags.Input.Files = args.inputFiles.split(',')
55 # if --evtMax was specified as well this will override
56 if args.maxEvents is not None:
57 flags.Exec.MaxEvents = args.maxEvents
58
59 if flags.Input.Format is Format.BS:
60 if flags.DQ.Environment not in ('tier0', 'tier0Raw', 'online'):
61 log.warning('Reading RAW file, but DQ.Environment set to %s',
62 flags.DQ.Environment)
63 log.warning('Will proceed but best guess is this is an error')
64 log.info('Will schedule reconstruction, as best we know')
65 else:
66 if flags.DQ.Environment in ('tier0', 'tier0Raw', 'online'):
67 log.warning('Reading POOL file, but DQ.Environment set to %s',
68 flags.DQ.Environment)
69 log.warning('Will proceed but best guess is this is an error')
70
71 if args.preExec:
72 # bring things into scope
73 from AthenaMonitoring.DQConfigFlags import allSteeringFlagsOff
74 log.info('Executing preExec: %s', args.preExec)
75 exec(args.preExec)
76
77 if flags.hasCategory("DQ.Steering") and flags.hasCategory("Detector"):
78 if flags.hasCategory("DQ.Steering.InDet"):
79 if (flags.hasFlag("DQ.Steering.InDet.doAlignMon") and flags.DQ.Steering.InDet.doAlignMon) or \
80 (flags.hasFlag("DQ.Steering.InDet.doGlobalMon") and flags.DQ.Steering.InDet.doGlobalMon) or \
81 (flags.hasFlag("DQ.Steering.InDet.doPerfMon") and flags.DQ.Steering.InDet.doPerfMon):
82 flags.Detector.GeometryID = True
83
84 # Just assume we want the full ID geometry, if we are reading in geometry
85 flags.Detector.GeometryPixel = True
86 flags.Detector.GeometrySCT = True
87 flags.Detector.GeometryTRT = True
88
89 log.info('FINAL CONFIG FLAGS SETTINGS FOLLOW')
90 if args.loglevel is None or getattr(Constants, args.loglevel) <= Constants.INFO:
91 flags.dump()
92 flags.lock()
93
94 # Initialize configuration object, add accumulator, merge, and run.
95 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
96 cfg = MainServicesCfg(flags)
97
98 if flags.Input.Format is Format.BS:
99 # attempt to start setting up reco ...
100 from CaloRec.CaloRecoConfig import CaloRecoCfg
101 cfg.merge(CaloRecoCfg(flags))
102 else:
103 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
104 cfg.merge(PoolReadCfg(flags))
105
106 # load DQ
107 from AthenaMonitoring.AthenaMonitoringCfg import AthenaMonitoringCfg
108 dq = AthenaMonitoringCfg(flags)
109 cfg.merge(dq)
110
111 # Force loading of conditions in MT mode
112 if flags.Concurrency.NumThreads > 0:
113 from AthenaConfiguration.ComponentAccumulator import ConfigurationError
114 for condalg, alg in [("PixelDetectorElementCondAlg", "ForceIDConditionsAlg")]:
115 try:
116 cfg.getCondAlgo(condalg)
117 except ConfigurationError:
118 pass # do nothing if the CondAlg is not present
119 else:
120 beginseq = cfg.getSequence("AthBeginSeq")
121 beginseq.Members.append(CompFactory.getComp(alg)())
122
123 # any last things to do?
124 if args.postExec:
125 log.info('Executing postExec: %s', args.postExec)
126 exec(args.postExec)
127
128 cfg.printConfig(withDetails=args.printDetailedConfig) # set True for exhaustive info
129
130 sc = cfg.run()
131 sys.exit(0 if sc.isSuccess() else 1)