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