ATLAS Offline Software
PhysicsValidationSkeleton.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 import sys
4 
5 from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
6 from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude
7 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
8 
9 # force no legacy job properties
10 from AthenaCommon import JobProperties
11 JobProperties.jobPropertiesDisallowed = True
12 
13 
14 def 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  # PerfMonSD
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())
python.TransformUtils.processPreExec
def processPreExec(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:41
python.TransformUtils.processPostExec
def processPostExec(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:50
python.PhysicsValidationSkeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: PhysicsValidationSkeleton.py:14
python.TransformUtils.processPostInclude
def processPostInclude(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:69
python.TransformUtils.processPreInclude
def processPreInclude(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:62
python.PerfMonCompsConfig.PerfMonMTSvcCfg
def PerfMonMTSvcCfg(flags, **kwargs)
A minimal new-style configuration for PerfMonMTSvc.
Definition: PerfMonCompsConfig.py:10
PhysValMonitoringConfig.PhysValMonitoringCfg
def PhysValMonitoringCfg(flags, name="PhysValMonManager", tools=None, **kwargs)
Definition: PhysValMonitoringConfig.py:81
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69