diff --git a/Event/xAOD/xAODTruthCnv/python/xAODTruthCnvConfigNew.py b/Event/xAOD/xAODTruthCnv/python/xAODTruthCnvConfigNew.py index fd79a44d960068b4498c03aaa8bfa86216d29b79..02abb885aeb3df983c9227b2746bfda160b0ac91 100644 --- a/Event/xAOD/xAODTruthCnv/python/xAODTruthCnvConfigNew.py +++ b/Event/xAOD/xAODTruthCnv/python/xAODTruthCnvConfigNew.py @@ -17,15 +17,9 @@ def GEN_AOD2xAODCfg(flags, name="GEN_AOD2xAOD", **kwargs): writeInTimePileUpTruth=False - # Use digiSteeringConf from metadata to write full-PU truth - # Not available yet in metadata - - from PyUtils.MetaReader import read_metadata - infile = flags.Input.Files[0] - thisFileMD = read_metadata(infile, None, 'full') - metadata = thisFileMD[infile] - digiSteeringConf = metadata['/Digitization/Parameters'].get("digiSteeringConf","") - if digiSteeringConf == 'StandardInTimeOnlyGeantinoTruthPileUpToolsAlg': + # Use digiSteeringConf from metadata to check whether full-PU + # truth should be written. + if flags.Digitization.DigiSteeringConf == 'StandardInTimeOnlyGeantinoTruthPileUpToolsAlg': writeInTimePileUpTruth = True kwargs.setdefault('WriteInTimePileUpTruth', writeInTimePileUpTruth) diff --git a/Simulation/Digitization/python/DigitizationConfigFlags.py b/Simulation/Digitization/python/DigitizationConfigFlags.py index a68cc5ca98db08cff876db35ab4f67fc469fbf4c..3eaaac9257be017c2f3d7095393877c18cc3b4ab 100644 --- a/Simulation/Digitization/python/DigitizationConfigFlags.py +++ b/Simulation/Digitization/python/DigitizationConfigFlags.py @@ -33,7 +33,14 @@ def createDigitizationCfgFlags(): flags = AthConfigFlags() # Digitization Steering - needed for easy comparison with the # old-style configuration, but can potentially drop - flags.addFlag("Digitization.DigiSteeringConf", "StandardPileUpToolsAlg") + def _checkDigiSteeringConf(prevFlags): + digiSteeringConf = "StandardPileUpToolsAlg" + if prevFlags.Input.Files: + from AthenaConfiguration.AutoConfigFlags import GetFileMD + digiSteeringConf = GetFileMD(prevFlags.Input.Files).get("digiSteeringConf", "StandardPileUpToolsAlg") + return digiSteeringConf + + flags.addFlag("Digitization.DigiSteeringConf", _checkDigiSteeringConf) # Run Inner Detector noise simulation flags.addFlag("Digitization.DoInnerDetectorNoise", True) # Run pile-up digitization on one bunch crossing at a time? diff --git a/Simulation/Digitization/python/DigitizationParametersConfig.py b/Simulation/Digitization/python/DigitizationParametersConfig.py index 1337cb9b44e093fea395ed8b4206dc4ee97921b4..4716e19b5addc0f9670e53780fc030b3212b9d85 100644 --- a/Simulation/Digitization/python/DigitizationParametersConfig.py +++ b/Simulation/Digitization/python/DigitizationParametersConfig.py @@ -24,7 +24,9 @@ def writeDigitizationMetadata(ConfigFlags): 'IOVDbGlobalTag' : 'IOVDb.GlobalTag', 'DetDescrVersion' : 'GeoModel.AtlasVersion', 'finalBunchCrossing' : 'Digitization.PU.FinalBunchCrossing', - 'initialBunchCrossing' : 'Digitization.PU.InitialBunchCrossing' + 'initialBunchCrossing' : 'Digitization.PU.InitialBunchCrossing', + 'physicsList' : 'Sim.PhysicsList', #TODO migrate clients to use /Simulation/Parameters metadata? + 'digiSteeringConf' : 'Digitization.DigiSteeringConf' } logDigitizationWriteMetadata.info('Filling Digitization MetaData') for testKey, testFlag in digitMetaDataKeys.items(): diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py b/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py index 06ea3ee8fb2883d93a4f8499da9502efc874401b..5e61640e10f04a800cf0f4baa19642b8b3ce2274 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py @@ -56,7 +56,17 @@ def createSimConfigFlags(): scf.addFlag("Sim.G4Version", _check_G4_version) - scf.addFlag("Sim.PhysicsList", "FTFP_BERT_ATL") + def _checkPhysicsListConf(prevFlags): + physicsList = "FTFP_BERT_ATL" + if prevFlags.Input.Files: + from AthenaConfiguration.AutoConfigFlags import GetFileMD + physicsList = GetFileMD(prevFlags.Input.Files).get("PhysicsList", "") + if not physicsList: + # Currently physicsList is also part of /Digitization/Parameters metadata. TODO migrate away from this. + physicsList = GetFileMD(prevFlags.Input.Files).get("physicsList", "FTFP_BERT_ATL") + return physicsList + + scf.addFlag("Sim.PhysicsList", _checkPhysicsListConf) scf.addFlag("Sim.NeutronTimeCut", 150.) # Sets the value for the neutron out of time cut in G4 scf.addFlag("Sim.NeutronEnergyCut", -1.) # Sets the value for the neutron energy cut in G4 scf.addFlag("Sim.ApplyEMCuts", False) # Turns on the G4 option to apply cuts for EM physics diff --git a/Tools/PyUtils/python/MetaReader.py b/Tools/PyUtils/python/MetaReader.py index 6babbca967ccca85160d34b99bf6b146d59e8cf9..8763380443a4edf0557e3da570044b814f111e80 100644 --- a/Tools/PyUtils/python/MetaReader.py +++ b/Tools/PyUtils/python/MetaReader.py @@ -931,6 +931,7 @@ def make_peeker(meta_dict): 'TRTRangeCut', 'SimulationFlavour', 'Simulator', + 'PhysicsList', ] for item in list(meta_dict[filename]['/Simulation/Parameters']): if item not in keys_to_keep: @@ -941,6 +942,8 @@ def make_peeker(meta_dict): 'numberOfCollisions', 'intraTrainBunchSpacing', 'BeamIntensityPattern' + 'physicsList', + 'digiSteeringConf', ] for item in list(meta_dict[filename]['/Digitization/Parameters']): if item not in keys_to_keep: