diff --git a/Event/EventOverlay/EventOverlayJobTransforms/share/Looper.py b/Event/EventOverlay/EventOverlayJobTransforms/share/Looper.py index 61950654e7d84a57ff1d6a5ca2dae3094d23ceff..f9835f3453b78fbe378f10b97e96849320892d41 100644 --- a/Event/EventOverlay/EventOverlayJobTransforms/share/Looper.py +++ b/Event/EventOverlay/EventOverlayJobTransforms/share/Looper.py @@ -1,31 +1,5 @@ ## Enable the looper killer, with options for overlay # Don't kill the event, but flag it as bad -try: - if (hasattr(simFlags, 'UseV2UserActions') and simFlags.UseV2UserActions()): - # this configures the MT LooperKiller - from G4UserActions import G4UserActionsConfig - try: - G4UserActionsConfig.addLooperKillerTool() #FIXME should be LooperKillerEventOverlay - except AttributeError: - atlasG4log.warning("Could not add the MT-version of the LooperKiller") - else: - # this configures the non-MT looperKiller - try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - except ImportError: - from G4AtlasServices.UserActionStore import UAStore - from AthenaCommon.CfgGetter import getPublicToolClone - # create a special instance of the LooperKiller, with specific configuration - lkAction = getPublicToolClone("LooperKillerEventOverlay", "LooperKiller", PrintSteps=10, MaxSteps=1000000, VerboseLevel=1, AbortEvent=0, SetError=1) - UAStore.addAction(lkAction,['Step']) -except: - # Pre UserAction Migration - def use_looperkiller(): - from G4AtlasApps import PyG4Atlas, AtlasG4Eng - lkAction = PyG4Atlas.UserAction('G4UserActions', 'LooperKiller', ['BeginOfRun', 'EndOfRun', 'BeginOfEvent', 'EndOfEvent', 'Step']) - #lkAction.set_Properties( {"PrintSteps":"0", "MaxSteps":"10", "VerboseLevel":"0", "AbortEvent":"0", "SetError":"1"} ) #to kill most everything - lkAction.set_Properties( {"PrintSteps":"10", "MaxSteps":"1000000", "VerboseLevel":"1", "AbortEvent":"0", "SetError":"1"} ) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(lkAction) - - simFlags.InitFunctions.add_function("postInit", use_looperkiller) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::LooperKillerEventOverlayTool', ['Step']) diff --git a/Event/EventOverlay/EventOverlayJobTransforms/share/skeleton.combinedinput.py b/Event/EventOverlay/EventOverlayJobTransforms/share/skeleton.combinedinput.py index 2e9925f4c94dfddf70b16d9dd302b45cda07c383..5613117dc7a4aaf0a78f64319e2e564f2a5971cc 100644 --- a/Event/EventOverlay/EventOverlayJobTransforms/share/skeleton.combinedinput.py +++ b/Event/EventOverlay/EventOverlayJobTransforms/share/skeleton.combinedinput.py @@ -152,6 +152,11 @@ if jobproperties.Beam.beamType.get_Value() != 'cosmics': else: simFlags.EventFilter.set_On() +## Always enable the looper killer, unless it's been disabled +if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: + simFlags.OptionalUserActionList.addAction('G4UA::LooperKillerTool', ['Step']) +else: + atlasG4log.warning("The looper killer will NOT be run in this job.") ## Add G4 alg to alg sequence from AthenaCommon.AlgSequence import AlgSequence @@ -217,31 +222,3 @@ if hasattr(runArgs, "postExec"): atlasG4log.info(cmd) exec(cmd) - -## Always enable the looper killer, unless it's been disabled -if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: - try: - # Pre UserAction Migration - def use_looperkiller(): - from G4AtlasApps import PyG4Atlas, AtlasG4Eng - lkAction = PyG4Atlas.UserAction('G4UserActions', 'LooperKiller', ['BeginOfRun', 'EndOfRun', 'BeginOfEvent', 'EndOfEvent', 'Step']) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(lkAction) - simFlags.InitFunctions.add_function("postInit", use_looperkiller) - except: - if (hasattr(simFlags, 'UseV2UserActions') and simFlags.UseV2UserActions()): - # this configures the MT LooperKiller - from G4UserActions import G4UserActionsConfig - try: - G4UserActionsConfig.addLooperKillerTool() - except AttributeError: - atlasG4log.warning("Could not add the MT-version of the LooperKiller") - else: - # this configures the non-MT looperKiller - try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - except ImportError: - from G4AtlasServices.UserActionStore import UAStore - # add default configurable - UAStore.addAction('LooperKiller',['Step']) -else: - atlasG4log.warning("The looper killer will NOT be run in this job.") diff --git a/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_ITk_jobOptions.py b/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_ITk_jobOptions.py index 075d293c80636afaab3d98da1fe8cf1039aaa040..b9e06b01f2e8d5245b1dc5f6688dfbed0f4ae51b 100644 --- a/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_ITk_jobOptions.py +++ b/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_ITk_jobOptions.py @@ -102,25 +102,9 @@ myAtRndmGenSvc.OutputLevel = VERBOSE myAtRndmGenSvc.EventReseeding = False ServiceMgr += myAtRndmGenSvc - ## Add an action -try: - # Post UserAction Migration (ATLASSIM-1752) - # NB the migrated MaterialStepRecorder does not have any special - # properties, hence these are not set here. - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - UAStore.addAction('MaterialStepRecorder',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) -except: - # Pre UserAction Migration - def geantino_action(): - from G4AtlasApps import AtlasG4Eng,PyG4Atlas - GeantinoAction = PyG4Atlas.UserAction('TrkG4UserActions','MaterialStepRecorder', ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) - GeantinoAction.set_Properties({ "verboseLevel" : "1", - "recordELoss" : "1", - "recordMSc" : "1" }) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(GeantinoAction) - - SimFlags.InitFunctions.add_function('preInitG4', geantino_action) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::MaterialStepRecorderTool'['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) ############### The Material hit collection ################## diff --git a/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_jobOptionsOverride.py b/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_jobOptionsOverride.py index 69a821e090f2ae37000ee988d804089303c3b93d..33ffa860f63931987500ec91eb240cfbf9f23dd4 100755 --- a/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_jobOptionsOverride.py +++ b/InnerDetector/InDetExample/InDetSLHC_Example/share/GeantinoMapping_jobOptionsOverride.py @@ -95,23 +95,8 @@ except: topSeq += CopyEventWeight(TruthCollKey="GEN_EVENT") ## Add an action -try: - # Post UserAction Migration (ATLASSIM-1752) - # NB the migrated MaterialStepRecorder does not have any special - # properties, hence these are not set here. - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - UAStore.addAction('MaterialStepRecorder',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) -except: - # Pre UserAction Migration - def geantino_action(): - from G4AtlasApps import AtlasG4Eng,PyG4Atlas - GeantinoAction = PyG4Atlas.UserAction('TrkG4UserActions','MaterialStepRecorder', ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) - GeantinoAction.set_Properties({ "verboseLevel" : "1", - "recordELoss" : "1", - "recordMSc" : "1" }) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(GeantinoAction) - - simFlags.InitFunctions.add_function('preInitG4', geantino_action) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::MaterialStepRecorderTool'['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) # suppress the enormous amount of MC output from TruthExamples.TruthExamplesConf import DumpMC diff --git a/InnerDetector/InDetExample/InDetSLHC_Example/share/jobOptions_XX0_GMX.py b/InnerDetector/InDetExample/InDetSLHC_Example/share/jobOptions_XX0_GMX.py index e8a738083dd144f3356016262fe05700e13689ae..55ce158561b0ad3726a743597d2572f2611ef9af 100755 --- a/InnerDetector/InDetExample/InDetSLHC_Example/share/jobOptions_XX0_GMX.py +++ b/InnerDetector/InDetExample/InDetSLHC_Example/share/jobOptions_XX0_GMX.py @@ -28,16 +28,8 @@ topSeq += pg MessageSvc.Format = "% F%40W%S%7W%R%T %0W%M" MessageSvc.defaultLimit = 500 -from RadLengthIntTool.RadLengthIntToolConf import XX0_Tool -mXX0_Tool = XX0_Tool() - from AthenaCommon.AppMgr import ServiceMgr -from UserActionSvc.UserActionSvcConf import UserActionSvc; -ServiceMgr += UserActionSvc() -ServiceMgr.UserActionSvc.UserActions += [ mXX0_Tool] -theApp.CreateSvc += [ "UserActionSvc"] - if not hasattr(ServiceMgr, 'THistSvc'): from GaudiSvc.GaudiSvcConf import THistSvc ServiceMgr += THistSvc() @@ -45,33 +37,6 @@ ServiceMgr.THistSvc.Output += ["xx0 DATAFILE='xx0.root' OPT='RECREATE'"]; print ServiceMgr -mXX0_Tool.ActionName = "XX0_ActionTool" -mXX0_Tool.volumePartsFile = "VolumeNameParts.txt" -mXX0_Tool.DoIntLength = False -mXX0_Tool.DoEta = True - -mXX0_Tool.NBinsEta = 480 -mXX0_Tool.EtaMin = -5 -mXX0_Tool.EtaMax = 5. - -mXX0_Tool.DoPhi = False -mXX0_Tool.NBinsPhi = 50 - -mXX0_Tool.DoRadial = False -mXX0_Tool.NBinsRadial = 200 - -mXX0_Tool.RMin = 0. * mm -mXX0_Tool.RMax = 1150. * mm - -mXX0_Tool.DoZScan = False - -mXX0_Tool.ZMin = -3490. * mm -mXX0_Tool.ZMax = 3490. * mm - - -print mXX0_Tool -print UserActionSvc - from G4AtlasApps import SimKernel @@ -83,12 +48,26 @@ if 'GeometryTextFile' in dir(): # enter interactive mode theApp.initialize() -from G4AtlasApps import AtlasG4Eng,PyG4Atlas -XX0_Action = PyG4Atlas.UserAction( 'RadLengthIntTool','XX0_ActionTool',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(XX0_Action) +## TODO Something like this should work with the appropriate CfgGetter method: +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('XX0_Tool',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) +simFlags.UserActionConfig.addConfig('XX0_Tool','volumePartsFile', "VolumeNameParts.txt") +simFlags.UserActionConfig.addConfig('XX0_Tool','DoIntLength', False) +simFlags.UserActionConfig.addConfig('XX0_Tool','DoEta', True) +simFlags.UserActionConfig.addConfig('XX0_Tool','NBinsEta', 480) +simFlags.UserActionConfig.addConfig('XX0_Tool','EtaMin', -5) +simFlags.UserActionConfig.addConfig('XX0_Tool','EtaMax', 5.) +simFlags.UserActionConfig.addConfig('XX0_Tool','DoPhi', False) +simFlags.UserActionConfig.addConfig('XX0_Tool','NBinsPhi', 50) +simFlags.UserActionConfig.addConfig('XX0_Tool','DoRadial', False) +simFlags.UserActionConfig.addConfig('XX0_Tool','NBinsRadial', 200) +simFlags.UserActionConfig.addConfig('XX0_Tool','RMin', 0. * mm) +simFlags.UserActionConfig.addConfig('XX0_Tool','RMax', 1150. * mm) +simFlags.UserActionConfig.addConfig('XX0_Tool','DoZScan', False) +simFlags.UserActionConfig.addConfig('XX0_Tool','ZMin', -3490. * mm) +simFlags.UserActionConfig.addConfig('XX0_Tool','ZMax', 3490. * mm) -SimFlags.InitFunctions.add_function('preInitG4', XX0_Action) #AtlasG4Eng.G4Eng.init_Simulation(3) from G4AtlasApps.PyG4Atlas import PyG4AtlasAlg diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py index 9cdf0bb7d4f99525b760c0110f0582aea61d759e..5ea8f1df2ababb10c997977678c4ccff61b64e09 100755 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py @@ -1,25 +1,16 @@ ## ## # $Id: LArG4FastSimulation_VPTimer_EHist_jobOptions.py 708108 2015-11-16 12:34:05Z jchapman $ ## -## # jobOptions file for preparing detailed program timer and histogramming of +## # jobOptions file for preparing detailed program timer and histogramming of ## # MC-level energy by particle and volume -## # must be imported after the command: -## theApp.initialize() - -from G4AtlasApps import PyG4Atlas,AtlasG4Eng - actionProperties={ -## EHist-only options: -'ROOTFileName':'top_ke_test.root', # name of .root file output -'MaxHists':'1000', # maximum number of histograms to store ( <~10000 for < 2MB of RAM) - ## Depths: level in geometry tree under Atlas::Atlas volume at which to truncate output; ## counted Atlas::Atlas level = 0, CALO::CALO level = 1, etc. -'CaloDepth':'4', # hadron calorimeter, CALO::CALO -'BeamPipeDepth':'2', # beampipe, BeamPipe::BeamPipe -'InDetDepth':'2', # inner detector, IDET::IDET -'MuonDepth':'2', # muon detector, MUONQ02::MUONQ02 +'CaloDepth':'4', # hadron calorimeter, CALO::CALO +'BeamPipeDepth':'2', # beampipe, BeamPipe::BeamPipe +'InDetDepth':'2', # inner detector, IDET::IDET +'MuonDepth':'2', # muon detector, MUONQ02::MUONQ02 ## Detail depth: output data for a specific volume and its parents; format /Atlas::Atlas/[lvl1Vol]/.../[Volume] 'DetailDepth':'/Atlas::Atlas/CALO::CALO/LArMgr::LArMgr/LArBarrel/Total LAR Volume/LAr::Barrel::Cryostat::HalfLAr::PosPhysical/LArMgr::LAr::EMB::ECAM' @@ -27,31 +18,20 @@ actionProperties={ ## # volume/particle timing - prints cpu time spent per particle, per volume to outfile ## # DO NOT USE SIMULTANEOUSLY WITH EHistAction! -try: - # Post UserAction Migration (ATLASSIM-1752) - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - from AthenaCommon.CfgGetter import getPublicTool - UAStore.addAction(getPublicTool('TestActionVPTimer'),['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) -except: - # Pre UserAction Migration - TimerAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionVPTimer', - ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) - TimerAction.set_Properties(actionProperties) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(TimerAction) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::TestActionVPTimerTool',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) +for key, value in actionProperties.iteritems(): + simFlags.UserActionConfig.addConfig('G4UA::TestActionVPTimerTool',key,value) print "volume/particle timing ON (see stdout)" ## # energy histogramming - creates ROOT file with histograms of kinetic energy by particle, by volume -#try: -# # Post UserAction Migration (ATLASSIM-1752) -# from G4AtlasServices.G4AtlasUserActionConfig import UAStore -# from AthenaCommon.CfgGetter import getPublicTool -# UAStore.addAction(getPublicTool('TestActionEHist'),['BeginOfRun','EndOfRun','Step']) -#except: -# # Pre UserAction Migration -# EHistAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionEHist', -# ['BeginOfRun','EndOfRun','Step']) -# EHistAction.set_Properties(actionProperties) -# AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(EHistAction) + +## EHist-only options: +#simFlags.OptionalUserActionList.addAction('G4UA::TestActionEHistTool',['BeginOfRun','EndOfRun','PreTracking','PostTracking','Step']) +#for key, value in actionProperties.iteritems(): +# simFlags.UserActionConfig.addConfig('G4UA::TestActionEHistTool',key,value) +#simFlags.UserActionConfig.addConfig('G4UA::TestActionEHistTool','ROOTFileName','top_ke_test.root') # name of .root file output +#simFlags.UserActionConfig.addConfig('G4UA::TestActionEHistTool','MaxHists','1000') # maximum number of histograms to store ( <~10000 for < 2MB of RAM) #print "energy histogramming ON (outfile:",actionProperties['ROOTFileName'],")" ## # must be imported prior to the commands: diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py index 45dea86ac47bb1cf30af91c3a2f42544afd287db..b3d7078fcf9a0a37f4c39f287d640758f105541b 100755 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py @@ -7,27 +7,8 @@ # # Include this file in your simulation job options to apply the timer # - -try: - if (hasattr(simFlags, 'UseV2UserActions') and simFlags.UseV2UserActions()): - # this configures the MT - from G4AtlasServices import G4AtlasServicesConfig - G4AtlasServicesConfig.addAction('G4UA::TestActionTimerTool',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step'],False) - else: - # Post UserAction Migration (ATLASSIM-1752) - try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - except ImportError: - from G4AtlasServices.UserActionStore import UAStore - from AthenaCommon.CfgGetter import getPublicTool - UAStore.addAction(getPublicTool('TestActionTimer'),['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) -except: - # Pre UserAction Migration - def LArG4Timer_preG4Init(): - from G4AtlasApps import PyG4Atlas,AtlasG4Eng - MyAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionTimer',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) - simFlags.InitFunctions.add_function("preInitG4", LArG4Timer_preG4Init) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::TestActionTimerTool',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) from AthenaCommon.AppMgr import ServiceMgr from GaudiSvc.GaudiSvcConf import THistSvc diff --git a/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py b/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py index af27039578ed956ef25f01c754bae49fd85e6df2..c477d213dccd15ecfb72c03810047c396fdceb14 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py @@ -43,8 +43,6 @@ def add_LLP_truth_strategies(): mcTruthMenu.add_McTruthStrategy(astrategy) def add_EnergyConservationTest(): - from G4AtlasApps import PyG4Atlas,AtlasG4Eng + from G4AtlasApps.SimFlags import simFlags # Enable the energy conservation test action - MyAction = PyG4Atlas.UserAction('G4UserActions','EnergyConservationTest', ['BeginOfEvent','EndOfEvent','Step']) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) - + simFlags.OptionalUserActionList.addAction('G4UA::EnergyConservationTestTool', ['BeginOfEvent','PreTracking','Step','PostTracking','EndOfEvent']) diff --git a/Simulation/G4Extensions/G4CosmicFilter/share/G4CosmicAndFilter.py b/Simulation/G4Extensions/G4CosmicFilter/share/G4CosmicAndFilter.py deleted file mode 100644 index eb8f56ea328702211c1b8cedee6a6b178191af2d..0000000000000000000000000000000000000000 --- a/Simulation/G4Extensions/G4CosmicFilter/share/G4CosmicAndFilter.py +++ /dev/null @@ -1,13 +0,0 @@ -## add G4CosmicFilter action... -#from G4AtlasApps import PyG4Atlas -#MyAction= PyG4Atlas.UserAction('G4CosmicFilter','G4CosmicAndFilter',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -# -##MyAction= PyG4Atlas.UserAction('G4CosmicFilter','G4CosmicFilter',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -# -##actionProperties={"VolumeName":"CaloEntryLayer"} -##actionProperties={"VolumeName":"MuonExitLayer"} -#actionProperties={"VolumeName":"TRTBarrelEntryLayer"} -#actionProperties={"VolumeName2":"PixelEntryLayer"} -# -#MyAction.set_Properties(actionProperties) -#AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) diff --git a/Simulation/G4Extensions/G4CosmicFilter/share/G4CosmicFilter.py b/Simulation/G4Extensions/G4CosmicFilter/share/G4CosmicFilter.py deleted file mode 100755 index 16562793ae125630925388ef05c38fffc8d72d5c..0000000000000000000000000000000000000000 --- a/Simulation/G4Extensions/G4CosmicFilter/share/G4CosmicFilter.py +++ /dev/null @@ -1,60 +0,0 @@ -#from G4AtlasApps import PyG4Atlas, AtlasG4Eng -#from G4AtlasApps.SimFlags import simFlags -#MyAction = PyG4Atlas.UserAction('G4CosmicFilter','G4CosmicFilter',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -# -#volumeName="CaloEntryLayer" -#if simFlags.CosmicFilterVolumeName=="Muon": -# volumeName="MuonExitLayer" -#if simFlags.CosmicFilterVolumeName=="Calo": -# volumeName="MuonEntryLayer" -#if simFlags.CosmicFilterVolumeName=="TRT_Barrel": -# volumeName="TRTBarrelEntryLayer" -#if simFlags.CosmicFilterVolumeName=="TRT_EC": -# volumeName="TRTECAEntryLayer" -#if simFlags.CosmicFilterVolumeName=="SCT_Barrel": -# volumeName="SCTBarrelEntryLayer" -#if simFlags.CosmicFilterVolumeName=="Pixel": -# volumeName="PixelEntryLayer" -#print 'G4CosmicFilter: Filter volume is %s' % volumeName -# -#if simFlags.CosmicFilterVolumeName=="TRT_EC": -# print 'G4CosmicFilter: adding TRTECBEntryLayer' -# MyAction= PyG4Atlas.UserAction('G4CosmicFilter','G4CosmicAndFilter',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -# actionProperties={"VolumeName":volumeName,"VolumeName2":"TRTECBEntryLayer"} -#else: -# actionProperties={"VolumeName":volumeName} -# -#if simFlags.CosmicFilterVolumeName2.statusOn: -# if simFlags.CosmicFilterVolumeName2=="Muon": -# volumeName2="MuonExitLayer" -# if simFlags.CosmicFilterVolumeName=="Calo": -# volumeName="MuonEntryLayer" -# if simFlags.CosmicFilterVolumeName2=="InnerDetector": -# volumeName2="CaloEntryLayer" -# if simFlags.CosmicFilterVolumeName2=="TRT_Barrel": -# volumeName2="TRTBarrelEntryLayer" -# if simFlags.CosmicFilterVolumeName2=="TRT_EC": -# volumeName2="TRTECAEntryLayer" -# if simFlags.CosmicFilterVolumeName2=="SCT_Barrel": -# volumeName2="SCTBarrelEntryLayer" -# if simFlags.CosmicFilterVolumeName2=="Pixel": -# volumeName2="PixelEntryLayer" -# if "volumeName2" in dir(): -# print 'G4CosmicFilter: Filter volume #2 is %s' % volumeName2 -# if simFlags.CosmicFilterVolumeName2=="TRT_EC": -# print 'G4CosmicFilter: adding TRTECBEntryLayer' -# MyAction = PyG4Atlas.UserAction('G4CosmicFilter','G4CosmicOrFilter',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -# actionProperties = {"VolumeName":volumeName,"VolumeName2":volumeName2,"VolumeName3":"TRTECBEntryLayer"} -# else: -# MyAction = PyG4Atlas.UserAction('G4CosmicFilter','G4CosmicAndFilter',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -# actionProperties = {"VolumeName":volumeName,"VolumeName2":volumeName2 } -# -#if simFlags.CosmicFilterID.statusOn: -# actionProperties["PDG_ID"] = simFlags.CosmicFilterID.get_Value() -#if simFlags.CosmicFilterPTmin.statusOn: -# actionProperties["pTmin"] = simFlags.CosmicFilterPTmin.get_Value() -#if simFlags.CosmicFilterPTmax.statusOn: -# actionProperties["pTmax"] = simFlags.CosmicFilterPTmax.get_Value() -# -#MyAction.set_Properties(actionProperties) -#AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) diff --git a/Simulation/G4Extensions/Monopole/share/jobOptions.Qball_Sim_Monopole.py b/Simulation/G4Extensions/Monopole/share/jobOptions.Qball_Sim_Monopole.py index 07432437b40d1ae15a2d00bfb4e694f9da5c6ca2..e24b03d7343808ecb8f67167ef8ff22ecb1d8218 100644 --- a/Simulation/G4Extensions/Monopole/share/jobOptions.Qball_Sim_Monopole.py +++ b/Simulation/G4Extensions/Monopole/share/jobOptions.Qball_Sim_Monopole.py @@ -25,11 +25,11 @@ print "Number of requested events is ", evtmax from AthenaCommon.GlobalFlags import globalflags globalflags.ConditionsTag = "OFLCOND-SDR-BS7T-04-03" -from G4AtlasApps.SimFlags import SimFlags -SimFlags.load_atlas_flags() -#SimFlags.MagneticField.set_Off() -SimFlags.EventFilter.set_On() -SimFlags.SimLayout.set_On() +from G4AtlasApps.SimFlags import simFlags +simFlags.load_atlas_flags() +#simFlags.MagneticField.set_Off() +simFlags.EventFilter.set_On() +simFlags.SimLayout.set_On() ## Use single particle generator import AthenaCommon.AtlasUnixGeneratorJob @@ -44,31 +44,20 @@ spgorders = ['pdgcode: constant '+str(PDGcode), 'pt: constant 1000000'] ## Use the monopole equation of motion for B field propagation -SimFlags.EquationOfMotion.set_On() -SimFlags.EquationOfMotion = "MonopoleEquationOfMotion" +simFlags.EquationOfMotion.set_On() +simFlags.EquationOfMotion = "MonopoleEquationOfMotion" -## Load Monopole library in the sim init flow -def load_monopole_lib(): - from G4AtlasApps import AtlasG4Eng - AtlasG4Eng.G4Eng.load_Lib("Monopole") -SimFlags.initFunctions.add_function("preInitPhysics", load_monopole_lib) -#SimFlags.G4Commands += ['/tracking/verbose 1'] +## ## Load Monopole library in the sim init flow +## def load_monopole_lib(): +## from G4AtlasApps import AtlasG4Eng +## AtlasG4Eng.G4Eng.load_Lib("Monopole") +## simFlags.initFunctions.add_function("preInitPhysics", load_monopole_lib) +## #simFlags.G4Commands += ['/tracking/verbose 1'] -SimFlags.G4Stepper = 'ClassicalRK4' +simFlags.G4Stepper = 'ClassicalRK4' +simFlags.OptionalUserActionList.addAction('G4UA::HIPKillerTool', ['Step']) -def setup_hipkiller(): - from G4AtlasApps import PyG4Atlas,AtlasG4Eng - myHipKiller = PyG4Atlas.UserAction('G4UserActions', 'HIPKiller', ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(myHipKiller) -SimFlags.InitFunctions.add_function("postInit", setup_hipkiller) - -#def setup_looperkiller(): -# from G4AtlasApps import PyG4Atlas,AtlasG4Eng -# myLooperKiller = PyG4Atlas.UserAction('G4UserActions', 'LooperKiller', ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) -# myLooperKiller.set_Properties({"MaxSteps":"2000000","PrintSteps":"2","VerboseLevel":"0"}) -# AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(myLooperKiller) - -#SimFlags.InitFunctions.add_function("postInit", setup_looperkiller) +#simFlags.OptionalUserActionList.addAction('G4UA::LooperKillerTool', ['Step']) ## Populate alg sequence from AthenaCommon.AlgSequence import AlgSequence diff --git a/Simulation/G4Utilities/G4DebuggingTools/python/G4DebuggingToolsConfig.py b/Simulation/G4Utilities/G4DebuggingTools/python/G4DebuggingToolsConfig.py index c8e45e8f89e15bcc453619e0931fa58d26fc673d..2da18166b06c75c3290360c6995a7cca252bf469 100644 --- a/Simulation/G4Utilities/G4DebuggingTools/python/G4DebuggingToolsConfig.py +++ b/Simulation/G4Utilities/G4DebuggingTools/python/G4DebuggingToolsConfig.py @@ -4,40 +4,47 @@ from AthenaCommon import CfgMgr, Logging from G4AtlasServices import G4AtlasServicesConfig def getVerboseSelectorTool(name="G4UA::VerboseSelectorTool", **kwargs): - from G4DebuggingTools.G4DebuggingToolsConf import G4UA__VerboseSelectorTool - return G4UA__VerboseSelectorTool(name, **kwargs) + from G4AtlasApps.SimFlags import simFlags + # example custom configuration + if name in simFlags.UserActionConfig.get_Value().keys(): + for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): + kwargs.setdefault(prop,value) + return CfgMgr.G4UA__VerboseSelectorTool(name, **kwargs) + def addVerboseSelectorTool(name="G4UA::VerboseSelectorTool",system=False): G4AtlasServicesConfig.addAction(name,['BeginOfEvent','Step','BeginOfTracking','EndOfTracking'],system) + def getG4AtlantisDumperTool(name="G4UA::G4AtlantisDumperTool", **kwargs): - from G4DebuggingTools.G4DebuggingToolsConf import G4UA__G4AtlantisDumperTool - return G4UA__G4AtlantisDumperTool(name, **kwargs) + return CfgMgr.G4UA__G4AtlantisDumperTool(name, **kwargs) + def addG4AtlantisDumperTool(name="G4UA::G4AtlantisDumperTool",system=False): G4AtlasServicesConfig.addAction(name,['EndOfEvent','Step','BeginOfEvent'],system) def getEnergyConservationTestTool(name="G4UA::EnergyConservationTestTool", **kwargs): - from G4DebuggingTools.G4DebuggingToolsConf import G4UA__EnergyConservationTestTool - return G4UA__EnergyConservationTestTool(name, **kwargs) + return CfgMgr.G4UA__EnergyConservationTestTool(name, **kwargs) + def addEnergyConservationTestTool(name="G4UA::EnergyConservationTestTool",system=False): G4AtlasServicesConfig.addAction(name,['EndOfEvent','Step','BeginOfTracking','EndOfTracking'],system) + def getHyperspaceCatcherTool(name="G4UA::HyperspaceCatcherTool", **kwargs): from G4AtlasApps.SimFlags import simFlags # example custom configuration if name in simFlags.UserActionConfig.get_Value().keys(): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) + return CfgMgr.G4UA__HyperspaceCatcherTool(name, **kwargs) - from G4DebuggingTools.G4DebuggingToolsConf import G4UA__HyperspaceCatcherTool - return G4UA__HyperspaceCatcherTool(name, **kwargs) def addHyperspaceCatcherTool(name="G4UA::HyperspaceCatcherTool",system=False): G4AtlasServicesConfig.addAction(name,['BeginOfRun','Step'],system) + def getStepNtupleTool(name="G4UA::StepNtupleTool", **kwargs): from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps if concurrencyProps.ConcurrencyFlags.NumThreads() >1: @@ -46,9 +53,7 @@ def getStepNtupleTool(name="G4UA::StepNtupleTool", **kwargs): #from AthenaCommon.AppMgr import theApp #theApp.exit(1) return False - - from G4DebuggingTools.G4DebuggingToolsConf import G4UA__StepNtupleTool - return G4UA__StepNtupleTool(name, **kwargs) + return CfgMgr.G4UA__StepNtupleTool(name, **kwargs) def getVolumeDebuggerTool(name="G4UA::VolumeDebuggerTool", **kwargs): @@ -59,9 +64,8 @@ def getVolumeDebuggerTool(name="G4UA::VolumeDebuggerTool", **kwargs): if name in simFlags.UserActionConfig.get_Value().keys(): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) + return CfgMGr.G4UA__VolumeDebuggerTool(name, **kwargs) - from G4DebuggingTools.G4DebuggingToolsConf import G4UA__VolumeDebuggerTool - return G4UA__VolumeDebuggerTool(name, **kwargs) def getGeant4SetupCheckerTool(name="G4UA::Geant4SetupCheckerTool", **kwargs): # Set reference based on geometry @@ -77,6 +81,5 @@ def getGeant4SetupCheckerTool(name="G4UA::Geant4SetupCheckerTool", **kwargs): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) # Set up the user action - from G4DebuggingTools.G4DebuggingToolsConf import G4UA__Geant4SetupCheckerTool - return G4UA__Geant4SetupCheckerTool(name, **kwargs) + return CfgMgr.G4UA__Geant4SetupCheckerTool(name, **kwargs) diff --git a/Simulation/G4Utilities/G4ProfilingTools/python/G4ProfilingToolsConfig.py b/Simulation/G4Utilities/G4ProfilingTools/python/G4ProfilingToolsConfig.py index 96f70777eec5906b8ed9afa1efc50278b53355ae..bee5bd5e03868ddf7089bf305f882ac9c6f14340 100644 --- a/Simulation/G4Utilities/G4ProfilingTools/python/G4ProfilingToolsConfig.py +++ b/Simulation/G4Utilities/G4ProfilingTools/python/G4ProfilingToolsConfig.py @@ -12,31 +12,22 @@ def getTestActionTimerTool(name="G4UA::TestActionTimerTool", **kwargs): #from AthenaCommon.AppMgr import theApp #theApp.exit(1) return False - from G4AtlasApps.SimFlags import simFlags # example custom configuration if name in simFlags.UserActionConfig.get_Value().keys(): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) - from G4ProfilingTools.G4ProfilingToolsConf import G4UA__TestActionTimerTool - return G4UA__TestActionTimerTool(name, **kwargs) - + return CfgMgr.G4UA__TestActionTimerTool(name, **kwargs) + + def getTestActionVPTimerTool(name="G4UA::TestActionVPTimerTool", **kwargs): - from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps - # ADS: this tool should be safe to run in MT - #if concurrencyProps.ConcurrencyFlags.NumThreads() >1: - # log=Logging.logging.getLogger(name) - # log.fatal('Attempt to run '+name+' with more than one thread, which is not supported') - # return False - from G4AtlasApps.SimFlags import simFlags # example custom configuration if name in simFlags.UserActionConfig.get_Value().keys(): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) - - from G4ProfilingTools.G4ProfilingToolsConf import G4UA__TestActionVPTimerTool - return G4UA__TestActionVPTimerTool(name, **kwargs) + return CfgMgr.G4UA__TestActionVPTimerTool(name, **kwargs) + def getTestActionEHistTool(name="G4UA::TestActionEHistTool", **kwargs): from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps @@ -46,12 +37,9 @@ def getTestActionEHistTool(name="G4UA::TestActionEHistTool", **kwargs): #from AthenaCommon.AppMgr import theApp #theApp.exit(1) return False - from G4AtlasApps.SimFlags import simFlags # example custom configuration if name in simFlags.UserActionConfig.get_Value().keys(): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) - - from G4ProfilingTools.G4ProfilingToolsConf import G4UA__TestActionEHistTool - return G4UA__TestActionEHistTool(name, **kwargs) + return CfgMgr.G4UA__TestActionEHistTool(name, **kwargs) diff --git a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py index 512b0b7e7b192eaec6e68cabcf617610ee5c89f3..e8802dd2a1ed6570ebab89e23785e3d01db9f6bc 100644 --- a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py +++ b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py @@ -8,55 +8,86 @@ from G4AtlasServices import G4AtlasServicesConfig # This way, e.g., after the getter is called the tool is automatically added # to the ToolSvc and can be assigned to a ToolHandle by the add function. # Also, passing arguments to the getter (like "this is a system action") is not straightforward - + +def getHitWrapperTool(name="G4UA::HitWrapperTool", **kwargs): + from G4AtlasApps.SimFlags import simFlags + # example custom configuration + if name in simFlags.UserActionConfig.get_Value().keys(): + for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): + kwargs.setdefault(prop,value) + return CfgMgr.G4UA__HitWrapperTool(name, **kwargs) + + def getFastIDKillerTool(name="G4UA::FastIDKillerTool", **kwargs): - from G4UserActions.G4UserActionsConf import G4UA__FastIDKillerTool - return G4UA__FastIDKillerTool(name, **kwargs) + return CfgMgr.G4UA__FastIDKillerTool(name, **kwargs) + + +def getFastMBKillerTool(name="G4UA::FastMBKillerTool", **kwargs): + kwargs.setdefault('Z',3600) + kwargs.setdefault('R',14) + return getFastIDKillerTool(name, **kwargs) + def addFastIDKillerTool(name="G4UA::FastIDKillerTool",system=False): G4AtlasServicesConfig.addAction(name,['BeginOfRun','Step'],system) + def getHIPKillerTool(name="G4UA::HIPKillerTool", **kwargs): - from G4UserActions.G4UserActionsConf import G4UA__HIPKillerTool - return G4UA__HIPKillerTool(name, **kwargs) + return CfgMgr.G4UA__HIPKillerTool(name, **kwargs) + def addHIPKillerTool(name="G4UA::HIPKillerTool",system=False): G4AtlasServicesConfig.addAction(name,['Step'],system) + def getHIPLArVolumeAcceptTool(name="G4UA::HIPLArVolumeAcceptTool", **kwargs): - from G4UserActions.G4UserActionsConf import G4UA__HIPLArVolumeAcceptTool - return G4UA__HIPLArVolumeAcceptTool(name, **kwargs) + return CfgMgr.G4UA__HIPLArVolumeAcceptTool(name, **kwargs) + def addHIPLArVolumeAcceptTool(name="G4UA::HIPLArVolumeAcceptTool", system=False): G4AtlasServicesConfig.addAction(theTool,['Step','BeginOfEvent','EndOfEvent'],system) + def getLooperKillerTool(name="G4UA::LooperKillerTool", **kwargs): - from G4UserActions.G4UserActionsConf import G4UA__LooperKillerTool - return G4UA__LooperKillerTool(name, **kwargs) + return CfgMgr.G4UA__LooperKillerTool(name, **kwargs) + + +def getLooperKillerEventOverlayTool(name="G4UA::LooperKillerEventOverlayTool", **kwargs): + kwargs.setdefault("MaxSteps",1000000) + kwargs.setdefault("PrintSteps",10) + kwargs.setdefault("VerboseLevel",1) + kwargs.setdefault("AbortEvent",False) + kwargs.setdefault("SetError",True) + return getLooperKillerTool(name, **kwargs) + def addLooperKillerTool(name="G4UA::LooperKillerTool", system=False): G4AtlasServicesConfig.addAction(name,['Step'],system) + def getMonopoleLooperKillerTool(name="MonopoleLooperKillerTool", **kwargs): kwargs.setdefault("PrintSteps", 2) kwargs.setdefault("MaxSteps", 2000000) kwargs.setdefault("VerboseLevel", 0) return getLooperKillerTool(name, **kwargs) + def getMomentumConservationTool(name="G4UA::MomentumConservationTool", **kwargs): - from G4UserActions.G4UserActionsConf import G4UA__MomentumConservationTool - return G4UA__MomentumConservationTool(name, **kwargs) + return CfgMgr.G4UA__MomentumConservationTool(name, **kwargs) + def addMomentumConservationTool(name="G4UA::MomentumConservationTool", system=False): G4AtlasServicesConfig.addAction(name,['Step','EndOfEvent'],system) + def getScoringVolumeTrackKillerTool(name="G4UA::ScoringVolumeTrackKillerTool", **kwargs): - from G4UserActions.G4UserActionsConf import G4UA__ScoringVolumeTrackKillerTool - return G4UA__ScoringVolumeTrackKillerTool(name, **kwargs) + return CfgMgr.G4UA__ScoringVolumeTrackKillerTool(name, **kwargs) + def addScoringVolumeTrackKillerTool(name="G4UA::ScoringVolumeTrackKillerTool", system=False): G4AtlasServicesConfig.addAction(theTool,['Step','EndOfEvent'],system) + def getScoringPlaneTool(name="G4UA::ScoringPlaneTool", **kwargs): from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps if concurrencyProps.ConcurrencyFlags.NumThreads() >1: @@ -65,15 +96,13 @@ def getScoringPlaneTool(name="G4UA::ScoringPlaneTool", **kwargs): #from AthenaCommon.AppMgr import theApp #theApp.exit(1) return False - from G4AtlasApps.SimFlags import simFlags # example custom configuration if name in simFlags.UserActionConfig.get_Value().keys(): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) + return CfgMgr.G4UA__ScoringPlaneTool(name, **kwargs) - from G4UserActions.G4UserActionsConf import G4UA__ScoringPlaneTool - return G4UA__ScoringPlaneTool(name, **kwargs) def getFluxRecorderTool(name="G4UA::FluxRecorderTool", **kwargs): from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps @@ -83,6 +112,4 @@ def getFluxRecorderTool(name="G4UA::FluxRecorderTool", **kwargs): #from AthenaCommon.AppMgr import theApp #theApp.exit(1) return False - - from G4UserActions.G4UserActionsConf import G4UA__FluxRecorderTool - return G4UA__FluxRecorderTool(name, **kwargs) + return CfgMgr.G4UA__FluxRecorderTool(name, **kwargs) diff --git a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py index 311df1311b0693ff2f6d7b09c46759a499e3968f..24851a3f84cd0496294b711a537361b739d0de28 100644 --- a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py +++ b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py @@ -6,16 +6,18 @@ from AthenaCommon.CfgGetter import addTool addTool("G4UserActions.G4UserActionsConf.G4UA__G4SimTimerTool", "G4UA::G4SimTimerTool") addTool("G4UserActions.G4UserActionsConf.G4UA__CosmicPerigeeActionTool", "G4UA::CosmicPerigeeActionTool") addTool("G4UserActions.G4UserActionsConf.G4UA__G4TrackCounterTool", "G4UA::G4TrackCounterTool") -addTool("G4UserActions.G4UserActionsConf.G4UA__HitWrapperTool", "G4UA::HitWrapperTool") addTool("G4UserActions.G4UserActionsConf.G4UA__LengthIntegratorTool", "G4UA::LengthIntegratorTool") addTool("G4UserActions.G4UserActionsConf.G4UA__PhotonKillerTool", "G4UA::PhotonKillerTool") addTool("G4UserActions.G4UserActionsConf.G4UA__StoppedParticleActionTool", "G4UA::StoppedParticleActionTool") addTool("G4UserActions.G4UserActionsConfig.getFastIDKillerTool", "G4UA::FastIDKillerTool") +addTool("G4UserActions.G4UserActionsConfig.getFastMBKillerTool", "G4UA::FastMBKillerTool") +addTool("G4UserActions.G4UserActionsConfig.getHitWrapperTool", "G4UA::HitWrapperTool") addTool("G4UserActions.G4UserActionsConfig.getHIPKillerTool", "G4UA::HIPKillerTool") addTool("G4UserActions.G4UserActionsConfig.getHIPLArVolumeAcceptTool", "G4UA::HIPLArVolumeAcceptTool") addTool("G4UserActions.G4UserActionsConfig.getLooperKillerTool", "G4UA::LooperKillerTool") addTool("G4UserActions.G4UserActionsConfig.getMonopoleLooperKillerTool", "MonopoleLooperKillerTool") +addTool("G4UserActions.G4UserActionsConfig.getLooperKillerEventOverlayTool", "G4UA::LooperKillerEventOverlayTool") addTool("G4UserActions.G4UserActionsConfig.getMomentumConservationTool", "G4UA::MomentumConservationTool") addTool("G4UserActions.G4UserActionsConfig.getScoringVolumeTrackKillerTool", "G4UA::ScoringVolumeTrackKillerTool") diff --git a/Simulation/G4Utilities/G4UserActions/share/LengthIntegrator_options.py b/Simulation/G4Utilities/G4UserActions/share/LengthIntegrator_options.py index e91c1e955e6785254a6e4a8bfc4f9229b763faac..41c6cf41eac0b900f80d665e2c26d164aeccbc48 100644 --- a/Simulation/G4Utilities/G4UserActions/share/LengthIntegrator_options.py +++ b/Simulation/G4Utilities/G4UserActions/share/LengthIntegrator_options.py @@ -1,7 +1,7 @@ ## Add RadLengthIntegrator to the UserActions, and produce a histogram from G4AtlasApps.SimFlags import simFlags simFlags.OptionalUserActionList.addAction('G4UA::LengthIntegratorTool',['BeginOfEvent','EndOfEvent','Step']) - + from AthenaCommon.AppMgr import ServiceMgr from GaudiSvc.GaudiSvcConf import THistSvc diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude.py index 0755665a169c6da85ad169b71d8b2ea2657a76dd..80b973f56f7a3f5a14d9077aa1c85739166a1bf7 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude.py +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPostInclude.py @@ -1,10 +1,3 @@ -def add_my_user_action(): - from G4AtlasApps import PyG4Atlas,AtlasG4Eng - MyAction = PyG4Atlas.UserAction( 'ISF_Geant4UserActions','FastCaloSimParamAction',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) - MyAction.set_Properties({"shift_lar_subhit":"1"}) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) -simFlags.InitFunctions.add_function("postInit", add_my_user_action) - from ISF_FastCaloSimParametrization.ISF_FastCaloSimParametrizationConf import FastCaloSimParamAlg topSeq += FastCaloSimParamAlg() ISF_HITSStream.stream1.ItemList += ["ISF_FCS_Parametrization::FCS_StepInfoCollection#ZHMergedEventSteps"] diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPreInclude.py b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPreInclude.py new file mode 100644 index 0000000000000000000000000000000000000000..94f785a95d8b5808c249d22471f0a7e98ca9a1b2 --- /dev/null +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/share/ISF_FastCaloSimParametrization_SimPreInclude.py @@ -0,0 +1,3 @@ +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::FastCaloSimParamActionTool',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) +simFlags.UserActionConfig.addConfig('G4UA::FastCaloSimParamActionTool','shift_lar_subhit','1') diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/python/ISF_Geant4UserActionsConfig.py b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/python/ISF_Geant4UserActionsConfig.py index b023af977f4255648c1f31d3dbf5131bcdacb8f3..56e4801963b40e1f16d25ec481646e8a85a4cd1b 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/python/ISF_Geant4UserActionsConfig.py +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/python/ISF_Geant4UserActionsConfig.py @@ -1,14 +1,21 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +from AthenaCommon import CfgMgr def getFastCaloSimParamActionTool(name='G4UA::FastCaloSimParamActionTool', **kwargs): - from ISF_Geant4UserActions.ISF_Geant4UserActionsConf import G4UA__FastCaloSimParamActionTool - return G4UA__FastCaloSimParamActionTool(name,**kwargs) + from G4AtlasApps.SimFlags import simFlags + # example custom configuration + if name in simFlags.UserActionConfig.get_Value().keys(): + for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): + kwargs.setdefault(prop,value) + return CfgMgr.G4UA__FastCaloSimParamActionTool(name,**kwargs) + def addFastCaloSimParamActionTool(name='G4UA::FastCaloSimParamActionTool',system=False): from G4AtlasServices import G4AtlasServicesConfig G4AtlasServicesConfig.addAction(name,['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step'],system) + def getTestBoundariesUserActionTool(name='G4UA::iGeant4::TestBoundariesUserActionTool', **kwargs): from AthenaCommon import Logging from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps @@ -18,5 +25,4 @@ def getTestBoundariesUserActionTool(name='G4UA::iGeant4::TestBoundariesUserActio #from AthenaCommon.AppMgr import theApp #theApp.exit(1) return False - from ISF_Geant4UserActions.ISF_Geant4UserActionsConf import G4UA__iGeant4__TestBoundariesUserActionTool - return G4UA__iGeant4__TestBoundariesUserActionTool(name,**kwargs) + return CfgMgr.G4UA__iGeant4__TestBoundariesUserActionTool(name,**kwargs) diff --git a/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_ISF.py b/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_ISF.py index c829800c18655a95eb2b0cf73756e3a4acf73917..dbb0477c0e0d549a73ef953bb0f4884693211f18 100644 --- a/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_ISF.py +++ b/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_ISF.py @@ -274,6 +274,13 @@ else: ISF_Flags.EntryLayerFilter = 'ISF_MC12EntryLayerFilter' ISF_Flags.TruthStrategy = 'MC12' simFlags.SimBarcodeOffset = 200000 #MC12 setting + +## Always enable the looper killer, unless it's been disabled +if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: + simFlags.OptionalUserActionList.addAction('G4UA::LooperKillerTool', ['Step']) +else: + atlasG4log.warning("The looper killer will NOT be run in this job.") + #### *********** import ISF_Example code here **************** #### include("ISF_Config/ISF_ConfigJobInclude.py") @@ -312,23 +319,3 @@ if hasattr(runArgs, "postExec"): for cmd in runArgs.postExec: atlasG4log.info(cmd) exec(cmd) - - -## Always enable the looper killer, unless it's been disabled -if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: - if ISF_Flags.UsingGeant4(): - # this configures the MT LooperKiller - try: - from G4UserActions import G4UserActionsConfig - G4UserActionsConfig.addLooperKillerTool() - except AttributeError, ImportError: - atlasG4log.warning("Could not add the MT-version of the LooperKiller") - # this configures the non-MT looperKiller - try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - except ImportError: - from G4AtlasServices.UserActionStore import UAStore - # add default configurable - UAStore.addAction('LooperKiller',['Step']) -else: - atlasG4log.warning("The looper killer will NOT be run in this job.") diff --git a/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_MC12.py b/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_MC12.py index 43422861a11a242e71102a921a211fbc6863b292..dca17b2f9722555a67cb3fb81d55aebff68fae2c 100644 --- a/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_MC12.py +++ b/Simulation/SimuJobTransforms/share/skeleton.EVGENtoHIT_MC12.py @@ -220,6 +220,13 @@ if jobproperties.Beam.beamType.get_Value() != 'cosmics': else: simFlags.EventFilter.set_On() +## Always enable the looper killer, unless it's been disabled +if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: + simFlags.OptionalUserActionList.addAction('G4UA::LooperKillerTool', ['Step']) +else: + atlasG4log.warning("The looper killer will NOT be run in this job.") + + from AthenaCommon.AlgSequence import AlgSequence topSeq = AlgSequence() @@ -284,22 +291,3 @@ if hasattr(runArgs, "postExec"): for cmd in runArgs.postExec: atlasG4log.info(cmd) exec(cmd) - - -## Always enable the looper killer, unless it's been disabled -if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: - # this configures the MT LooperKiller - try: - from G4UserActions import G4UserActionsConfig - G4UserActionsConfig.addLooperKillerTool() - except AttributeError, ImportError: - atlasG4log.warning("Could not add the MT-version of the LooperKiller") - # this configures the non-MT looperKiller - try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - except ImportError: - from G4AtlasServices.UserActionStore import UAStore - # add default configurable - UAStore.addAction('LooperKiller',['Step']) -else: - atlasG4log.warning("The looper killer will NOT be run in this job.") diff --git a/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastIDKiller.py b/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastIDKiller.py index e2d208c5dac1a5d830fce935d56d097e6d305751..cfdca70217488c04f3e84ca7cec00ae6ece2c5f2 100644 --- a/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastIDKiller.py +++ b/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastIDKiller.py @@ -10,8 +10,5 @@ # energy above a certain threshold. ######################################################### -try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore -except ImportError: - from G4AtlasServices.UserActionStore import UAStore -UAStore.addAction('FastIDKiller', ['BeginOfRun','Step']) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::FastIDKillerTool', ['BeginOfRun','Step']) diff --git a/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastMBKiller.py b/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastMBKiller.py index a1256369409e720f6a859a0aa11c4ed3240a67e7..c8611bac8ab5a97507bb3df2b92c4db78e06fb16 100644 --- a/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastMBKiller.py +++ b/Simulation/SimulationJobOptions/share/atlfast2/preInclude.FastMBKiller.py @@ -6,14 +6,5 @@ # Requested for the Atlfast-II and MinBias groups ######################################################### -try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore -except ImportError: - from G4AtlasServices.UserActionStore import UAStore -from AthenaCommon.CfgGetter import getPublicTool - -FastMBKiller=getPublicTool('FastIDKiller/FastMBKiller',tryDefaultConfigurable=True) -FastMBKiller.Z=3600 -FastMBKiller.R=14 - -UAStore.addAction(FastMBKiller, ['BeginOfRun','Step']) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::FastMBKillerTool', ['BeginOfRun','Step']) diff --git a/Simulation/SimulationJobOptions/share/cosmics/preInclude.MuonFilter.py b/Simulation/SimulationJobOptions/share/cosmics/preInclude.MuonFilter.py index c235bb926f24aa3bb651633f88d16e5d4358b971..3dfd198020e5bcf868f0abfc8a157b35432e92d8 100644 --- a/Simulation/SimulationJobOptions/share/cosmics/preInclude.MuonFilter.py +++ b/Simulation/SimulationJobOptions/share/cosmics/preInclude.MuonFilter.py @@ -13,9 +13,3 @@ simFlags.CosmicFilterVolumeName = "Calo" simFlags.CosmicFilterID = "13" simFlags.CosmicFilterPTmin = "6000" # in MeV simFlags.CosmicFilterPTmax = "50000" # in MeV - -def cosmics_muonfilter(): - from G4AtlasApps import AtlasG4Eng - include('G4CosmicFilter/G4CosmicFilter.py') - -simFlags.InitFunctions.add_function("preInitG4", cosmics_muonfilter) diff --git a/Simulation/SimulationJobOptions/share/g4/preInclude.HyperspaceCatcher.py b/Simulation/SimulationJobOptions/share/g4/preInclude.HyperspaceCatcher.py index a4e368d059ef1cd90dd1ef1a27d63626692798ba..8fa77959d7f25e4a0ab559c7ff6e933a981198a8 100644 --- a/Simulation/SimulationJobOptions/share/g4/preInclude.HyperspaceCatcher.py +++ b/Simulation/SimulationJobOptions/share/g4/preInclude.HyperspaceCatcher.py @@ -3,14 +3,7 @@ # This is VERY handy for looking into problems in G4 - it should NOT be used for standard production. # Set "killAfter" in order to crash the job after a certain number of hyperspace particles -try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore -except ImportError: - from G4AtlasServices.UserActionStore import UAStore -from AthenaCommon.CfgGetter import getPublicTool - -catcher=getPublicTool('HyperspaceCatcher',tryDefaultConfigurable=True) -catcher.TreatmentLevel=1 -catcher.KillAfter=-1 - -UAStore.addAction(catcher,['BeginOfRun','Step']) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::HyperspaceCatcherTool', ['BeginOfRun','Step']) +simFlags.UserActionConfig.addConfig('G4UA::HyperspaceCatcherTool', 'TreatmentLevel',1) +simFlags.UserActionConfig.addConfig('G4UA::HyperspaceCatcherTool', 'KillAfter',-1) diff --git a/Simulation/SimulationJobOptions/share/g4/preInclude.ScoringVolumeKiller.py b/Simulation/SimulationJobOptions/share/g4/preInclude.ScoringVolumeKiller.py index ddd009440fb08a238ab717988ed3479d098af83c..00310cb5e0a759db22bc1523ec2484ccf2aa3c39 100644 --- a/Simulation/SimulationJobOptions/share/g4/preInclude.ScoringVolumeKiller.py +++ b/Simulation/SimulationJobOptions/share/g4/preInclude.ScoringVolumeKiller.py @@ -19,9 +19,4 @@ getService('DetectorGeometrySvc').RegionCreators += [getPublicTool('MuonPhysicsR #currently initializing the DetectorGeometrySvc too early causes #problems with the GeoModelSvc configuration. -try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore -except ImportError: - from G4AtlasServices.UserActionStore import UAStore -svkiller=getPublicTool('ScoringVolumeTrackKiller',tryDefaultConfigurable=True) -UAStore.addAction(svkiller,['EndOfEvent', 'Step']) +simFlags.OptionalUserActionList.addAction('G4UA::ScoringVolumeTrackKillerTool',['EndOfEvent', 'Step']) diff --git a/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelector.py b/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelector.py index 97598bb4a9741ec35bb411b039f998e7f6840bfa..fe528fce24a33bf3932ef2606ff4105d77adea50 100644 --- a/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelector.py +++ b/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelector.py @@ -2,15 +2,9 @@ # Very handy for debugging crashes on the grid when you know what track caused the crash # Most powerful in conjunction with the verbose selector area -try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore -except ImportError: - from G4AtlasServices.UserActionStore import UAStore -from AthenaCommon.CfgGetter import getPublicTool - -verboseSelector= getPublicTool('VerboseSelector',tryDefaultConfigurable=True).TargetEvent=1 -verboseSelector.TargetTrack=15932 -verboseSelector.VerboseLevel=2 -verboseSelector.TargetBarcode=-1 - -UAStore.addAction('VerboseSelector',['EndOfEvent','BeginOfTracking','EndOfTracking']) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::VerboseSelectorTool',['BeginOfEvent','PreTracking','Step','PostTracking']) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','TargetEvent',1) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','TargetTrack',15932) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','VerboseLevel',2) +#simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','TargetBarcode',-1) diff --git a/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelectorArea.py b/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelectorArea.py index dbb16aa62dbe0d93743e38ad2ff29810a5616717..7ad00c0d19bc26a05a7facee2992891b39b0e30e 100644 --- a/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelectorArea.py +++ b/Simulation/SimulationJobOptions/share/g4/preInclude.VerboseSelectorArea.py @@ -4,22 +4,14 @@ # Verbose level is transmitted to several G4 classes to increase their verbosity. # Note that the event number is the number of events into the G4 run, rather than the ATLAS event number. -try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore -except ImportError: - from G4AtlasServices.UserActionStore import UAStore -from AthenaCommon.CfgGetter import getPublicToolClone,getPublicTool - -vsArea=getPublicTool('VerboseSelector/VerboseSelectorArea',tryDefaultConfigurable=True) - -vsArea.Xmin=-25000 -vsArea.Xmax=25000 -vsArea.Ymin=-25000 -vsArea.Ymax=25000 -vsArea.Zmin=-30000 -vsArea.Zmax=30000 -vsArea.TargetEvent=1 -vsArea.VerboseLevel=1 - -UAStore.addAction(vsArea,['EndOfEvent','Step']) +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::VerboseSelectorTool',['BeginOfEvent','PreTracking','Step','PostTracking']) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','Xmin',-25000) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','Xmax',25000) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','Ymin',-25000) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','Ymax',25000) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','Zmin',-30000) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','Zmax',30000) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','TargetEvent',1) +simFlags.UserActionConfig.addConfig('G4UA::VerboseSelectorTool','VerboseLevel',1) diff --git a/TileCalorimeter/TileGeoModel/share/jobOptions.intLength.py b/TileCalorimeter/TileGeoModel/share/jobOptions.intLength.py index 9db761d85386e1c77dbde2b4f3bbc721def59000..0208660f8f6861996590e3855393eded395d1b25 100755 --- a/TileCalorimeter/TileGeoModel/share/jobOptions.intLength.py +++ b/TileCalorimeter/TileGeoModel/share/jobOptions.intLength.py @@ -89,9 +89,6 @@ from GaudiSvc.GaudiSvcConf import THistSvc ServiceMgr += THistSvc("THistSvc") ServiceMgr.THistSvc.Output = ["intLen DATAFILE='intLength.root' OPT='NEW'"]; -from G4AtlasApps import PyG4Atlas -IntLengthAction= PyG4Atlas.UserAction( 'G4UserActions','InteractionLengthIntegrator',['BeginOfEvent','EndOfEvent','Step']) - from G4AtlasApps import SimKernel # enter interactive mode diff --git a/Tools/FullChainTransforms/share/skeleton.EVGENtoRDO.py b/Tools/FullChainTransforms/share/skeleton.EVGENtoRDO.py index d3e73219f4290a82e65c1b6890216bc7dec941b5..5fc50fc607f8e587cab9885108a433a76eb63f0c 100644 --- a/Tools/FullChainTransforms/share/skeleton.EVGENtoRDO.py +++ b/Tools/FullChainTransforms/share/skeleton.EVGENtoRDO.py @@ -156,6 +156,12 @@ else: ## Don't use the SeedsG4 override simFlags.SeedsG4.set_Off() +## Always enable the looper killer, unless it's been disabled +if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: + simFlags.OptionalUserActionList.addAction('G4UA::LooperKillerTool', ['Step']) +else: + fast_chain_log.warning("The looper killer will NOT be run in this job.") + ## Set the Run Number (if required) if hasattr(runArgs,"DataRunNumber"): @@ -227,22 +233,6 @@ if hasattr(runArgs, "postSimExec"): fast_chain_log.info(cmd) exec(cmd) -## Always enable the looper killer, unless it's been disabled -if not hasattr(runArgs, "enableLooperKiller") or runArgs.enableLooperKiller: - try: - # Post UserAction Migration (ATLASSIM-1752) - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - UAStore.addAction('LooperKiller',['Step']) # add default configurable - except: - # Pre UserAction Migration - def use_looperkiller(): - from G4AtlasApps import PyG4Atlas, AtlasG4Eng - lkAction = PyG4Atlas.UserAction('G4UserActions', 'LooperKiller', ['BeginOfRun', 'EndOfRun', 'BeginOfEvent', 'EndOfEvent', 'Step']) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(lkAction) - simFlags.InitFunctions.add_function("postInit", use_looperkiller) -else: - fast_chain_log.warning("The looper killer will NOT be run in this job.") - ### End of Sim