2from SimulationConfig.SimEnums
import BeamPipeSimMode, CalibrationRun, LArParameterization
54def enableNeutronRussianRoulette(flags):
55 """Activate Neutron Russian Roulette: Fast simulation" killing low energy neutrons with some probability."""
56 flags.Sim.NRRThreshold = 2. # MeV
57 flags.Sim.NRRWeight = 10.
58 flags.Sim.CalibrationRun = CalibrationRun.Off
77def enableG4GammaGeneralProcess(flags):
78 """Activate the G4GammaGeneralProcess and the UserAction required"""
79 flags.Sim.G4Commands+=["/process/em/UseGeneralProcess true"]
80 flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg']
83def disableG4GammaGeneralProcess(flags):
84 """Disables G4GammaGeneralProcess AND Woodcock tracking"""
85 commands = flags.Sim.G4Commands
86 commands.remove("/process/em/UseGeneralProcess true")
87 commands.remove("/process/em/useWoodcockTracking EMEC") # Woodcock tracking requires G4GammaGeneralProcess
88 flags.Sim.G4Commands = commands
89 optionalUserActions = flags.Sim.OptionalUserActionList
90 optionalUserActions.remove("G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg")
91 flags.Sim.OptionalUserActionList = optionalUserActions
94def enableWoodcockTracking(flags):
95 """Activate the Woodcock Tracking in the EMEC"""
96 flags.Sim.G4Commands += ['/process/em/useWoodcockTracking EMEC']
97 # Please note that the Woodcock tracking enables the
98 # G4GammaGeneralProcess therefore the FixG4CreatorProcessTool must
99 # be added if it's not done before
100 if "G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg" not in flags.Sim.OptionalUserActionList:
101 flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg']
104def disableWoodcockTracking(flags):
105 commands = flags.Sim.G4Commands
106 commands.remove("/process/em/useWoodcockTracking EMEC")
107 flags.Sim.G4Commands = commands
108 if "/process/em/UseGeneralProcess true" not in flags.Sim.G4Commands:
109 optionalUserActions = flags.Sim.OptionalUserActionList
110 optionalUserActions.remove("G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg")
111 flags.Sim.OptionalUserActionList = optionalUserActions
114def enableG4Optimizations(flags):
115 """Enable G4 optimizations"""
117 # Activate magnetic field switch off in central LAr calorimeter
118 # More info: https://its.cern.ch/jira/browse/ATLPHYSVAL-773
119 enableMuonFieldOnlyInCalo(flags)
121 # Photon Russian Roulette
122 # "Fast simulation" killing low energy photons with some probability.
123 # More info: https://its.cern.ch/jira/browse/ATLASSIM-4096
124 enablePhotonRussianRoulette(flags)
126 # Neutron Russian Roulette
127 # "Fast simulation" killing low energy neutrons with some probability.
128 # More info: its.cern.ch/jira/browse/ATLASSIM-3924
129 enableNeutronRussianRoulette(flags)
132 # Turn on range cuts for gamma processes (conv, phot, compt)
133 # More info: https://its.cern.ch/jira/browse/ATLASSIM-3956
134 enableEMRangeCuts(flags)
136 # G4GammaGeneralProcess
137 # Activate the G4GammaGeneralProcess and the UserAction required
138 # to fix the creator process of secondary tracks.
139 enableG4GammaGeneralProcess(flags)
141 # Energy Loss fluctuation OFF
142 # Switch off the Energy loss fluctuation process
143 # More info: https://its.cern.ch/jira/browse/ATLASSIM-6995
144 # Main physics validation: https://its.cern.ch/jira/browse/ATLPHYSVAL-1009
145 # Follow-up validation for Muons: https://its.cern.ch/jira/browse/ATLPHYSVAL-1022
146 # Follow-up validation for Egamma: https://its.cern.ch/jira/browse/ATLPHYSVAL-1030
147 # This optimization is on hold for mc23e - for discrepancies seen in the
148 # follow-up validations by EgammaCP group.
149 # It will be evaluated for future campaigns.
150 # flags.Sim.G4Commands+=["/process/eLoss/fluct false"]
152 # Activate the Woodcock Tracking in the EMEC
153 # More info: https://its.cern.ch/jira/browse/ATLASSIM-5079
154 enableWoodcockTracking(flags)
157def disableG4Optimizations(flags):
158 """ Ensure all G4Optimizations are disabled - useful for debugging """
159 disableMuonFieldOnlyInCalo(flags)
160 disablePhotonRussianRoulette(flags)
161 disableNeutronRussianRoulette(flags)
162 disableEMRangeCuts(flags)
163 disableG4GammaGeneralProcess(flags)
164 disableWoodcockTracking(flags)
165 disableBeamPipeKill(flags)
166 disableFrozenShowersFCalOnly(flags)
169def WoodcockTrackingInEMEC(flags):
170 # Use Woodcock Tracking in the EMEC rather than the EMECPara
171 # G4Region. This preInclude should be added at the end of the list
173 commands = flags.Sim.G4Commands
174 commands.remove("/process/em/useWoodcockTracking EMECPara")
175 flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMEC"]
178def WoodcockTrackingInEMECPara(flags):
179 # Use Woodcock Tracking in the EMECPara rather than the EMEC
180 # G4Region. This preInclude should be added at the end of the list
182 commands = flags.Sim.G4Commands
183 commands.remove("/process/em/useWoodcockTracking EMEC")
184 flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMECPara"]
187def PostIncludeTweakPhysicsRegionsCfg(flags, cfg):
188 # This postInclude drops BeamPipe::SectionF198 and
189 # BeamPipe::SectionF199 from the DeadMaterial G4Region, to avoid a
190 # clash with the BeampipeFwdCut G4Region.
191 from AthenaConfiguration.ComponentAccumulator import ConfigurationError
194 detConTool = cfg.getPublicTool('G4AtlasDetectorConstructionTool')
195 except ConfigurationError:
197 if detConTool is None:
199 detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF198')
200 detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF199')