ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsValidationSkeleton.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3import sys
4
5from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
6from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude
7from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
8
9# force no legacy job properties
10from AthenaCommon import JobProperties
11JobProperties.jobPropertiesDisallowed = True
12
13
14def fromRunArgs(runArgs):
15 from AthenaCommon.Logging import logging
16 logDerivation = logging.getLogger('PhysicsValidation')
17 logDerivation.info('****************** STARTING NTUP_PHYSVAL *****************')
18
19 logDerivation.info('**** Transformation run arguments')
20 logDerivation.info(str(runArgs))
21
22 logDerivation.info('**** Setting-up configuration flags')
23 from AthenaConfiguration.AllConfigFlags import initConfigFlags
24 flags = initConfigFlags()
25 flags.Exec.EventPrintoutInterval = 100
26 commonRunArgsToFlags(runArgs, flags)
27
28 # Switch on PerfMon
29 flags.PerfMon.doFullMonMT = True
30
31 # Input types
32 if not hasattr(runArgs, 'inputDAOD_PHYSVALFile'):
33 raise ValueError('Input must be provided using --inputDAOD_PHYSVALFile')
34 flags.Input.Files = runArgs.inputDAOD_PHYSVALFile
35
36 # Physics Validation
37 if hasattr(runArgs, 'outputNTUP_PHYSVALFile'):
38 logDerivation.info('Will produce NTUP_PHYSVAL file')
39 flags.PhysVal.OutputFileName = runArgs.outputNTUP_PHYSVALFile
40
41 if not (hasattr(runArgs, 'inputAODFile') or hasattr(runArgs, 'inputDAOD_PHYSVALFile')):
42 logDerivation.error('NTUP_PHYSVAL requires AOD or DAOD_PHYSVAL input')
43 raise ValueError('Incorrect inputs for NTUP_PHYSVAL')
44
45 if not hasattr(runArgs, 'validationFlags'):
46 raise ValueError('--validationFlags is mandatory')
47
48 for flag in runArgs.validationFlags:
49 if flag == 'doPFlow_FlowElements': # backwards compatibility
50 flag = 'doPFlow'
51
52 name = f'PhysVal.{flag}'
53 if not flags.hasFlag(name):
54 raise ValueError(f"Unknown validation flag '{name}'")
55
56 logDerivation.info("Enabling validation flag '%s'", name)
57 flags._set(name, True)
58 else:
59 raise ValueError('Output file name needs to be set using --outputNTUP_PHYSVALFile')
60
61 # Pre-include
62 processPreInclude(runArgs, flags)
63
64 # Pre-exec
65 processPreExec(runArgs, flags)
66
67 # To respect --athenaopts
68 flags.fillFromArgs()
69
70 # Lock flags
71 flags.lock()
72
73 # The main services configuration
74 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
75 cfg = MainServicesCfg(flags)
76 cfg.merge(PoolReadCfg(flags))
77
78 # Run NTUP_PHYSVAL making
79 from PhysValMonitoring.PhysValMonitoringConfig import PhysValMonitoringCfg
80 cfg.merge(PhysValMonitoringCfg(flags))
81
82 # Enabling PerfMon always for physics validation jobs regardless of PerfMon flags (unlike most other skeletons)
83 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
84 cfg.merge(PerfMonMTSvcCfg(flags))
85
86 # Post-include
87 processPostInclude(runArgs, flags, cfg)
88
89 # Post-exec
90 processPostExec(runArgs, flags, cfg)
91
92 # Run the final configuration
93 sc = cfg.run()
94 sys.exit(not sc.isSuccess())