ATLAS Offline Software
Loading...
Searching...
No Matches
G4Optimizations.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, LArParameterization
3
4
6 """Turns on GFlash shower parametrization for FCAL"""
7 flags.Sim.LArParameterization = LArParameterization.FrozenShowersFCalOnly
8 flags.Sim.CalibrationRun = CalibrationRun.Off
9
10
12 """Turns off GFlash shower parametrization for FCAL"""
13 flags.Sim.LArParameterization = LArParameterization.NoFrozenShowers
14
15
17 flags.Sim.BeamPipeCut = 0.
18 flags.Sim.BeamPipeSimMode = BeamPipeSimMode.FastSim
19
20
22 flags.Sim.BeamPipeCut = 100.0
23 flags.Sim.BeamPipeSimMode = BeamPipeSimMode.Normal
24
25
27 flags.Sim.TightMuonStepping = True
28
29
31 flags.Sim.TightMuonStepping = False
32
33
35 """Activate magnetic field switch off in central LAr calorimeter"""
36 flags.Sim.MuonFieldOnlyInCalo = True
37
38
39def disableMuonFieldOnlyInCalo(flags):
40 flags.Sim.MuonFieldOnlyInCalo = False
41
42
43def enablePhotonRussianRoulette(flags):
44 """Activate Photon Russian Roulette: Fast simulation" killing low energy photons with some probability."""
45 flags.Sim.PRRThreshold = 0.5 # MeV
46 flags.Sim.PRRWeight = 10.
47
48
49def disablePhotonRussianRoulette(flags):
50 flags.Sim.PRRThreshold = False
51 flags.Sim.PRRWeight = False
52
53
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
59
60
61def disableNeutronRussianRoulette(flags):
62 flags.Sim.NRRThreshold = False
63 flags.Sim.NRRWeight = False
64
65
66def enableEMRangeCuts(flags):
67 """Turn on range cuts for gamma processes (conv, phot, compt)"""
68 flags.Sim.G4Commands += ['/process/em/applyCuts true']
69
70
71def disableEMRangeCuts(flags):
72 commands = flags.Sim.G4Commands
73 commands.remove("/process/em/applyCuts true")
74 flags.Sim.G4Commands = commands
75
76
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']
81
82
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
92
93
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']
102
103
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
112
113
114def enableG4Optimizations(flags):
115 """Enable G4 optimizations"""
116
117 # Activate magnetic field switch off in central LAr calorimeter
118 # More info: https://its.cern.ch/jira/browse/ATLPHYSVAL-773
119 enableMuonFieldOnlyInCalo(flags)
120
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)
125
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)
130
131 # EM Range Cuts
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)
135
136 # G4GammaGeneralProcess
137 # Activate the G4GammaGeneralProcess and the UserAction required
138 # to fix the creator process of secondary tracks.
139 enableG4GammaGeneralProcess(flags)
140
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"]
151
152 # Activate the Woodcock Tracking in the EMEC
153 # More info: https://its.cern.ch/jira/browse/ATLASSIM-5079
154 enableWoodcockTracking(flags)
155
156
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)
167
168
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
172 # of preIncludes.
173 commands = flags.Sim.G4Commands
174 commands.remove("/process/em/useWoodcockTracking EMECPara")
175 flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMEC"]
176
177
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
181 # of preIncludes.
182 commands = flags.Sim.G4Commands
183 commands.remove("/process/em/useWoodcockTracking EMEC")
184 flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMECPara"]
185
186
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
192 detConTool = None
193 try:
194 detConTool = cfg.getPublicTool('G4AtlasDetectorConstructionTool')
195 except ConfigurationError:
196 pass
197 if detConTool is None:
198 return
199 detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF198')
200 detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF199')