ATLAS Offline Software
HITSMerge_Skeleton.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 import sys
4 from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
5 from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude
6 
7 # force no legacy job properties
8 from AthenaCommon import JobProperties
9 JobProperties.jobPropertiesDisallowed = True
10 
11 
12 def fromRunArgs(runArgs):
13  from AthenaCommon.Logging import logging
14  log = logging.getLogger('HITSMerge_tf')
15  log.info('****************** STARTING HIT MERGING *****************')
16 
17  log.info('**** Transformation run arguments')
18  log.info(str(runArgs))
19 
20  log.info('**** Setting-up configuration flags')
21  from AthenaConfiguration.AllConfigFlags import initConfigFlags
22  flags = initConfigFlags()
23 
24  commonRunArgsToFlags(runArgs, flags)
25 
26  if hasattr(runArgs, 'inputHITSFile'):
27  flags.Input.Files = runArgs.inputHITSFile
28  else:
29  raise RuntimeError('No input HITS file defined')
30 
31  if hasattr(runArgs, 'outputHITS_MRGFile'):
32  if runArgs.outputHITS_MRGFile == 'None':
33  flags.Output.HITSFileName = ''
34  # TODO decide if we need a specific HITS_MRGFileName flag
35  else:
36  flags.Output.HITSFileName = runArgs.outputHITS_MRGFile
37  else:
38  raise RuntimeError('No outputHITS_MRGFile defined')
39 
40  # Generate detector list and setup detector flags
41  from SimuJobTransforms.SimulationHelpers import getDetectorsFromRunArgs
42  detectors = getDetectorsFromRunArgs(flags, runArgs)
43  from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
44  setupDetectorFlags(flags, detectors, use_metadata=True, toggle_geometry=True, keep_beampipe=True)
45 
46  # Pre-include
47  processPreInclude(runArgs, flags)
48 
49  # Pre-exec
50  processPreExec(runArgs, flags)
51 
52  # To respect --athenaopts
53  flags.fillFromArgs()
54 
55  # Lock flags
56  flags.lock()
57 
58  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
59  cfg = MainServicesCfg(flags)
60 
61  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
62  cfg.merge(PoolReadCfg(flags))
63 
64  # Identifiers
65  from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg
66  cfg.merge(DetDescrCnvSvcCfg(flags))
67 
68  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
69  cfg.merge(OutputStreamCfg(flags, 'HITS', disableEventTag=("xAOD::EventInfo#EventInfo" not in flags.Input.TypedCollections),
70  takeItemsFromInput = True, extendProvenanceRecord = False))
71 
72  # Add in-file MetaData
73  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
74  from AthenaConfiguration.Enums import MetadataCategory
75 
76  cfg.merge(
78  flags,
79  "HITS",
80  createMetadata=[
81  MetadataCategory.IOVMetaData,
82  ],
83  )
84  )
85 
86  # Post-include
87  processPostInclude(runArgs, flags, cfg)
88 
89  # Post-exec
90  processPostExec(runArgs, flags, cfg)
91 
92  # Write AMI tag into in-file metadata
93  from PyUtils.AMITagHelperConfig import AMITagCfg
94  cfg.merge(AMITagCfg(flags, runArgs))
95 
96  import time
97  tic = time.time()
98  # Run the final accumulator
99  sc = cfg.run()
100  log.info("Ran HITSMerge_tf in " + str(time.time()-tic) + " seconds")
101 
102  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.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
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.DetDescrCnvSvcConfig.DetDescrCnvSvcCfg
def DetDescrCnvSvcCfg(flags, **kwargs)
Definition: DetDescrCnvSvcConfig.py:6
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.HITSMerge_Skeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: HITSMerge_Skeleton.py:12
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.AMITagHelperConfig.AMITagCfg
def AMITagCfg(flags, runArgs=None, fixBroken=False)
Definition: AMITagHelperConfig.py:77
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.SimulationHelpers.getDetectorsFromRunArgs
def getDetectorsFromRunArgs(flags, runArgs)
Definition: SimulationHelpers.py:5
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:219
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69