ATLAS Offline Software
HITtoRDO_Skeleton.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 SimuJobTransforms.CommonSimulationSteering import specialConfigPreInclude, specialConfigPostInclude
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  log = logging.getLogger('HITtoRDO')
17  log.info('****************** STARTING HITtoRDO *****************')
18 
19  log.info('**** Transformation run arguments')
20  log.info(str(runArgs))
21 
22  log.info('**** Setting-up configuration flags')
23  from AthenaConfiguration.AllConfigFlags import initConfigFlags
24  flags = initConfigFlags()
25 
26  commonRunArgsToFlags(runArgs, flags)
27 
28  if not hasattr(runArgs, 'inputHITSFile'):
29  raise RuntimeError('No input HITS file defined')
30 
31  if not hasattr(runArgs, 'outputRDOFile'):
32  raise RuntimeError('No output RDO file defined')
33 
34  flags.Input.isMC = True
35  flags.Input.Files = runArgs.inputHITSFile
36  flags.Output.RDOFileName = runArgs.outputRDOFile
37 
38  # runNumber is MC channel number in reco
39  if hasattr(runArgs, 'runNumber'):
40  if flags.Input.MCChannelNumber != runArgs.runNumber:
41  log.warning('Got different MC channel number (%d) from runNumber than from metadata (%d)', runArgs.runNumber, flags.Input.MCChannelNumber)
42  flags.Input.MCChannelNumber = runArgs.runNumber
43  else:
44  log.info('MC channel number: %d', flags.Input.MCChannelNumber)
45 
46  # Autoconfigure enabled subdetectors
47  if hasattr(runArgs, 'detectors'):
48  detectors = runArgs.detectors
49  else:
50  detectors = None
51 
52  # Setup digitization flags
53  from DigitizationConfig.DigitizationConfigFlags import digitizationRunArgsToFlags
54  digitizationRunArgsToFlags(runArgs, flags)
55 
56  # Setup common digitization flags
57  from DigitizationConfig.DigitizationConfigFlags import setupDigitizationFlags
58  setupDigitizationFlags(runArgs, flags)
59  log.info('Running with pile-up: %s', flags.Digitization.PileUp)
60 
61  # Setup detector flags
62  from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
63  setupDetectorFlags(flags, detectors, use_metadata=True, toggle_geometry=True)
64 
65  # Setup perfmon flags from runargs
66  from PerfMonComps.PerfMonConfigHelpers import setPerfmonFlagsFromRunArgs
67  setPerfmonFlagsFromRunArgs(flags, runArgs)
68 
69  # Special Configuration preInclude
71 
72  # Pre-include
73  processPreInclude(runArgs, flags)
74 
75  # Pre-exec
76  processPreExec(runArgs, flags)
77 
78  # Load pile-up stuff after pre-include/exec to ensure everything is up-to-date
79  from DigitizationConfig.DigitizationConfigFlags import pileupRunArgsToFlags
80  pileupRunArgsToFlags(runArgs, flags)
81 
82  # Setup pile-up profile
83  if flags.Digitization.PileUp:
84  from RunDependentSimComps.PileUpUtils import setupPileUpProfile
85  setupPileUpProfile(flags)
86 
87  # TODO not parsed yet:
88  # '--outputRDO_FILTFile'
89 
90  # To respect --athenaopts
91  flags.fillFromArgs()
92 
93  # Lock flags
94  flags.lock()
95 
96  # Main overlay steering
97  from DigitizationConfig.DigitizationSteering import DigitizationMainCfg
98  cfg = DigitizationMainCfg(flags)
99 
100  # Special message service configuration
101  from DigitizationConfig.DigitizationSteering import DigitizationMessageSvcCfg
102  cfg.merge(DigitizationMessageSvcCfg(flags))
103 
104  # Special Configuration postInclude
105  specialConfigPostInclude(flags, cfg)
106 
107  # Post-include
108  processPostInclude(runArgs, flags, cfg)
109 
110  # Post-exec
111  processPostExec(runArgs, flags, cfg)
112 
113  from AthenaConfiguration.Utils import setupLoggingLevels
114  setupLoggingLevels(flags, cfg)
115 
116  # Write AMI tag into in-file metadata
117  from PyUtils.AMITagHelperConfig import AMITagCfg
118  cfg.merge(AMITagCfg(flags, runArgs))
119 
120  # Run the final configuration
121  sc = cfg.run()
122  sys.exit(not sc.isSuccess())
python.DigitizationConfigFlags.digitizationRunArgsToFlags
def digitizationRunArgsToFlags(runArgs, flags)
Definition: DigitizationConfigFlags.py:147
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.DigitizationConfigFlags.setupDigitizationFlags
def setupDigitizationFlags(runArgs, flags)
Definition: DigitizationConfigFlags.py:254
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.DigitizationSteering.DigitizationMessageSvcCfg
def DigitizationMessageSvcCfg(flags)
Definition: DigitizationSteering.py:217
python.Utils.setupLoggingLevels
def setupLoggingLevels(flags, ca)
Definition: Control/AthenaConfiguration/python/Utils.py:46
python.CommonSimulationSteering.specialConfigPostInclude
def specialConfigPostInclude(flags, cfg)
Definition: CommonSimulationSteering.py:29
python.DigitizationConfigFlags.pileupRunArgsToFlags
def pileupRunArgsToFlags(runArgs, flags)
Definition: DigitizationConfigFlags.py:186
python.PerfMonConfigHelpers.setPerfmonFlagsFromRunArgs
def setPerfmonFlagsFromRunArgs(flags, runArgs)
Definition: PerfMonConfigHelpers.py:3
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.HITtoRDO_Skeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: HITtoRDO_Skeleton.py:14
python.DigitizationSteering.DigitizationMainCfg
def DigitizationMainCfg(flags)
Definition: DigitizationSteering.py:50
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:289
python.CommonSimulationSteering.specialConfigPreInclude
def specialConfigPreInclude(flags)
Definition: CommonSimulationSteering.py:23
python.AMITagHelperConfig.AMITagCfg
def AMITagCfg(flags, runArgs=None, fixBroken=False)
Definition: AMITagHelperConfig.py:77
python.PileUpUtils.setupPileUpProfile
def setupPileUpProfile(flags)
Definition: PileUpUtils.py:335
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11