diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py b/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py index c4b7af3ed2c49915989d26b588f93fdf67eeba0e..622e481cd1ba0f099f4f0d76f7f22afcb6ea424a 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimConfigFlags.py @@ -75,6 +75,7 @@ def createSimConfigFlags(): scf.addFlag("Sim.NRRWeight", False) scf.addFlag("Sim.PRRThreshold", False) scf.addFlag("Sim.PRRWeight", False) + scf.addFlag("Sim.OptionalUserActionList", []) # For G4FieldConfigNew scf.addFlag("Sim.G4Stepper", "AtlasRK4") diff --git a/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py b/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py index ca856e7bb7e8b508e0b8d5ecafe88ff426844ea3..2936cc8c8d952bfc61e8afee732b4403541c5fad 100644 --- a/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py +++ b/Simulation/G4Atlas/G4AtlasServices/python/G4AtlasUserActionConfigNew.py @@ -18,6 +18,29 @@ from ISF_Services.ISF_ServicesConfigNew import ( from ISF_Geant4CommonTools.ISF_Geant4CommonToolsConfigNew import EntryLayerToolCfg, EntryLayerToolMTCfg from G4CosmicFilter.G4CosmicFilterConfigNew import CosmicFilterToolCfg +def OptionalUserActionCfg(flags): + """ flags.Sim.OptionalUserActionList = ['G4UserActions.G4UserActionsConfigNew.FixG4CreatorProcessToolCfg']""" + result = ComponentAccumulator() + optionalUserActions = [] + for userActionString in flags.Sim.OptionalUserActionList: + optionalUserActions += [result.popToolsAndMerge(getOptionalUACfg(flags, userActionString))] + result.setPrivateTools(optionalUserActions) + return result + + +def getOptionalUACfg(flags, userActionString): + """Execute a function to configure and optional UserAction""" + parts = userActionString.split('.') + if len(parts) < 2: + raise ValueError('OptionalUserAction strings should be of the form Package.Module.Function or Package.Function if defined in __init__.py') + function = parts[-1] + module = '.'.join(parts[:-1]) + from importlib import import_module + loaded_module = import_module(module) + function_def = getattr(loaded_module, function) + return function_def(flags) + + # Pulled in from ISF G4 to avoid circular dependence def FullG4TrackProcessorUserActionToolCfg(flags, name="FullG4TrackProcessorUserActionTool", **kwargs): result = ComponentAccumulator() @@ -177,15 +200,10 @@ def ISFUserActionSvcCfg(ConfigFlags, name="G4UA::ISFUserActionSvc", **kwargs): MCTruthUserAction = kwargs.pop("MCTruthUserAction", [result.popToolsAndMerge(MCTruthUserActionToolCfg(ConfigFlags))]) - # FIXME migrate an alternative to this - #from G4AtlasApps.SimFlags import simFlags - #optActions = simFlags.OptionalUserActionList.get_Value() - - generalActions = ( - TrackProcessorUserAction + MCTruthUserAction + - result.popToolsAndMerge(getDefaultActions(ConfigFlags)) + - PhysicsValidationUserAction - ) + generalActions = ( TrackProcessorUserAction + MCTruthUserAction + + result.popToolsAndMerge(getDefaultActions(ConfigFlags)) + + result.popToolsAndMerge(OptionalUserActionCfg(ConfigFlags)) + + PhysicsValidationUserAction ) # New user action tools kwargs.setdefault("UserActionTools", generalActions) diff --git a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigNew.py b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigNew.py index 0e55a8b13359106b32da664dcd23a171c25b4b71..7fce7b3b4abbcd8eb364c555607f5d07d4cec664 100644 --- a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigNew.py +++ b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigNew.py @@ -76,6 +76,12 @@ def StoppedParticleActionToolCfg(ConfigFlags, name="G4UA::StoppedParticleActionT return result +def FixG4CreatorProcessToolCfg(ConfigFlags, name="G4UA::FixG4CreatorProcessTool", **kwargs): + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.G4UA.FixG4CreatorProcessTool(name, **kwargs)) + return result + + def HitWrapperToolCfg(ConfigFlags, name="G4UA::HitWrapperTool", **kwargs): result = ComponentAccumulator() # FIXME UserActionConfig not yet migrated @@ -87,6 +93,7 @@ def HitWrapperToolCfg(ConfigFlags, name="G4UA::HitWrapperTool", **kwargs): result.setPrivateTools(CompFactory.G4UA.HitWrapperTool(name, **kwargs)) return result + def LengthIntegratorToolCfg(ConfigFlags, name="G4UA::UserActionSvc.LengthIntegratorTool", **kwargs): THistSvc= CompFactory.THistSvc result = ComponentAccumulator() diff --git a/Simulation/SimuJobTransforms/python/G4Optimizations.py b/Simulation/SimuJobTransforms/python/G4Optimizations.py index 7266ecd4433855c8831c8ab6c19acf3bcb371fdd..35fcfe6eb6763ec02ff483dcfc0b2cfd16501548 100644 --- a/Simulation/SimuJobTransforms/python/G4Optimizations.py +++ b/Simulation/SimuJobTransforms/python/G4Optimizations.py @@ -17,8 +17,15 @@ def enableG4Optimizations(flags): # More info: its.cern.ch/jira/browse/ATLASSIM-3924 flags.Sim.NRRThreshold = 2. # MeV flags.Sim.NRRWeight = 10. + flags.Sim.CalibrationRun = 'Off' # EM Range Cuts # Turn on range cuts for gamma processes (conv, phot, compt) # More info: https://its.cern.ch/jira/browse/ATLASSIM-3956 flags.Sim.G4Commands += ['/process/em/applyCuts true'] + + # G4GammaGeneralProcess + # Activate the G4GammaGeneralProcess and the UserAction required + # to fix the creator process of secondary tracks. + flags.Sim.G4Commands+=["/process/em/UseGeneralProcess true"] + flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfigNew.FixG4CreatorProcessToolCfg'] diff --git a/Simulation/SimulationJobOptions/share/g4/preInclude.G4Optimizations.py b/Simulation/SimulationJobOptions/share/g4/preInclude.G4Optimizations.py index d6f9acc2a0dfcbea709b84928c20bdf59fbf203a..dafb381bd629dd1a7f298107e3372800d4df88af 100644 --- a/Simulation/SimulationJobOptions/share/g4/preInclude.G4Optimizations.py +++ b/Simulation/SimulationJobOptions/share/g4/preInclude.G4Optimizations.py @@ -63,6 +63,7 @@ from G4AtlasApps.SimFlags import simFlags if hasattr(simFlags, 'ApplyNRR') and \ hasattr(simFlags, 'NRRThreshold') and \ hasattr(simFlags, 'NRRWeight'): + simFlags.CalibrationRun.set_Off() simFlags.ApplyNRR = True simFlags.NRRThreshold = nrr_threshold simFlags.NRRWeight = nrr_weight diff --git a/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar.sh b/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar.sh index 6cc46cba6fde6d1ae27738206da6725a5b030d90..0e6aa0fee7ceaf898477b90a9fa272b72588f2dd 100755 --- a/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar.sh +++ b/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar.sh @@ -9,13 +9,13 @@ # art-output: test.HITS.pool.root # art-output: truth.root -# RUN3 setup -# ATLAS-R3S-2021-02-00-00 and OFLCOND-MC16-SDR-RUN3-02 +# RUN3 setup - Frozen Showers currently off by default +# ATLAS-R3S-2021-02-00-00 and OFLCOND-MC21-SDR-RUN3-03 Sim_tf.py \ ---conditionsTag 'default:OFLCOND-MC16-SDR-RUN3-02' \ +--conditionsTag 'default:OFLCOND-MC21-SDR-RUN3-03' \ --simulator 'FullG4' \ --postInclude 'default:PyJobTransforms/UseFrontier.py' \ ---preInclude 'EVNTtoHITS:Campaigns/MC21Simulation.py' \ +--preInclude 'EVNTtoHITS:Campaigns/MC21Simulation.py,SimulationJobOptions/preInclude.FrozenShowersFCalOnly.py' \ --geometryVersion 'default:ATLAS-R3S-2021-02-00-00_VALIDATION' \ --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ --outputHITSFile "test.HITS.pool.root" \ diff --git a/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar_CAvsCG.sh b/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar_CAvsCG.sh index 29da03ca633a2469f8dd59bfd6cb7dc261942916..a53bc02561446dd0464b83c12bcc187e53ddce2e 100755 --- a/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar_CAvsCG.sh +++ b/Simulation/Tests/ISF_Validation/test/test_RUN3_FullG4_ttbar_CAvsCG.sh @@ -8,12 +8,12 @@ # art-output: Config* # RUN3 setup -# ATLAS-R3S-2021-02-00-00 and OFLCOND-MC16-SDR-RUN3-02 +# ATLAS-R3S-2021-02-00-00 and OFLCOND-MC21-SDR-RUN3-03 Sim_tf.py \ ---conditionsTag 'default:OFLCOND-MC16-SDR-RUN3-02' \ +--conditionsTag 'default:OFLCOND-MC21-SDR-RUN3-03' \ --simulator 'FullG4MT' \ --postInclude 'default:PyJobTransforms/UseFrontier.py' \ ---preInclude 'EVNTtoHITS:Campaigns/MC21Simulation.py' \ +--preInclude 'EVNTtoHITS:Campaigns/MC21Simulation.py,SimulationJobOptions/preInclude.FrozenShowersFCalOnly.py' \ --geometryVersion 'default:ATLAS-R3S-2021-02-00-00_VALIDATION' \ --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ --outputHITSFile "test.CG.HITS.pool.root" \ @@ -22,10 +22,10 @@ Sim_tf.py \ --athenaopts '"--config-only=ConfigCG.pkl"' Sim_tf.py \ ---conditionsTag 'default:OFLCOND-MC16-SDR-RUN3-02' \ +--conditionsTag 'default:OFLCOND-MC21-SDR-RUN3-03' \ --simulator 'FullG4MT' \ --postInclude 'default:PyJobTransforms/UseFrontier.py' \ ---preInclude 'EVNTtoHITS:Campaigns/MC21Simulation.py' \ +--preInclude 'EVNTtoHITS:Campaigns/MC21Simulation.py,SimulationJobOptions/preInclude.FrozenShowersFCalOnly.py' \ --geometryVersion 'default:ATLAS-R3S-2021-02-00-00_VALIDATION' \ --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ --outputHITSFile "test.CG.HITS.pool.root" \ @@ -41,11 +41,11 @@ if [ $rc1 -eq 0 ] then Sim_tf.py \ --CA \ - --conditionsTag 'default:OFLCOND-MC16-SDR-RUN3-02' \ + --conditionsTag 'default:OFLCOND-MC21-SDR-RUN3-03' \ --simulator 'FullG4MT' \ --postExec 'with open("ConfigCA.pkl", "wb") as f: cfg.store(f)' \ --postInclude 'default:PyJobTransforms.UseFrontier' \ - --preInclude 'EVNTtoHITS:Campaigns.MC21Simulation' \ + --preInclude 'EVNTtoHITS:Campaigns.MC21Simulation,SimuJobTransforms.SimulationHelpers.enableFrozenShowersFCalOnly' \ --geometryVersion 'default:ATLAS-R3S-2021-02-00-00' \ --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \ --outputHITSFile "test.CA.HITS.pool.root" \ diff --git a/Tools/Campaigns/python/MC21.py b/Tools/Campaigns/python/MC21.py index 521a6335b68bdf642fd4eb62992f494088844b9c..94e13db83713441922c8f41cde0fd6d8f12ed8ce 100644 --- a/Tools/Campaigns/python/MC21.py +++ b/Tools/Campaigns/python/MC21.py @@ -55,8 +55,8 @@ def MC21Simulation(flags): flags.Digitization.TRTRangeCut = 30.0 flags.Sim.TightMuonStepping = True - from SimuJobTransforms.SimulationHelpers import enableBeamPipeKill, enableFrozenShowersFCalOnly + from SimuJobTransforms.SimulationHelpers import enableBeamPipeKill #, enableFrozenShowersFCalOnly enableBeamPipeKill(flags) - enableFrozenShowersFCalOnly(flags) + # enableFrozenShowersFCalOnly(flags) # Not tuned yet for G4 10.6 from SimuJobTransforms.G4Optimizations import enableG4Optimizations enableG4Optimizations(flags) diff --git a/Tools/Campaigns/share/MC21Simulation.py b/Tools/Campaigns/share/MC21Simulation.py index b36f387cfd044d5b3e98bb8397e72b78be408920..37346788e70accfb65197159660d0d2b179beb5f 100644 --- a/Tools/Campaigns/share/MC21Simulation.py +++ b/Tools/Campaigns/share/MC21Simulation.py @@ -11,6 +11,6 @@ simFlags.TightMuonStepping = True from AthenaCommon.Resilience import protectedInclude protectedInclude("SimulationJobOptions/preInclude.BeamPipeKill.py") -protectedInclude("SimulationJobOptions/preInclude.FrozenShowersFCalOnly.py") +#protectedInclude("SimulationJobOptions/preInclude.FrozenShowersFCalOnly.py") # Not tuned yet for G4 10.6 # enable G4 optimisations protectedInclude("SimulationJobOptions/preInclude.G4Optimizations.py")