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 enableMultipleStepsInMSCTransport(flags):
55 flags.Sim.MultipleStepsInMSCTransport = True
56
57
58def disableMultipleStepsInMSCTransport(flags):
59 flags.Sim.MultipleStepsInMSCTransport = False
60
61
62def enableNeutronRussianRoulette(flags):
63 """Activate Neutron Russian Roulette: Fast simulation" killing low energy neutrons with some probability."""
64 flags.Sim.NRRThreshold = 2. # MeV
65 flags.Sim.NRRWeight = 10.
66 flags.Sim.CalibrationRun = CalibrationRun.Off
67
68
69def disableNeutronRussianRoulette(flags):
70 flags.Sim.NRRThreshold = False
71 flags.Sim.NRRWeight = False
72
73
74def enableEMRangeCuts(flags):
75 """Turn on range cuts for gamma processes (conv, phot, compt)"""
76 flags.Sim.G4Commands += ['/process/em/applyCuts true']
77
78
79def disableEMRangeCuts(flags):
80 commands = flags.Sim.G4Commands
81 commands.remove("/process/em/applyCuts true")
82 flags.Sim.G4Commands = commands
83
84
85def enableG4GammaGeneralProcess(flags):
86 """Activate the G4GammaGeneralProcess and the UserAction required"""
87 flags.Sim.G4Commands+=["/process/em/UseGeneralProcess true"]
88 flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg']
89
90
91def disableG4GammaGeneralProcess(flags):
92 """Disables G4GammaGeneralProcess AND Woodcock tracking"""
93 commands = flags.Sim.G4Commands
94 commands.remove("/process/em/UseGeneralProcess true")
95 commands.remove("/process/em/useWoodcockTracking EMEC") # Woodcock tracking requires G4GammaGeneralProcess
96 flags.Sim.G4Commands = commands
97 optionalUserActions = flags.Sim.OptionalUserActionList
98 optionalUserActions.remove("G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg")
99 flags.Sim.OptionalUserActionList = optionalUserActions
100
101
102def enableWoodcockTracking(flags):
103 """Activate the Woodcock Tracking in the EMEC"""
104 flags.Sim.G4Commands += ['/process/em/useWoodcockTracking EMEC']
105 # Please note that the Woodcock tracking enables the
106 # G4GammaGeneralProcess therefore the FixG4CreatorProcessTool must
107 # be added if it's not done before
108 if "G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg" not in flags.Sim.OptionalUserActionList:
109 flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg']
110
111
112def disableWoodcockTracking(flags):
113 commands = flags.Sim.G4Commands
114 commands.remove("/process/em/useWoodcockTracking EMEC")
115 flags.Sim.G4Commands = commands
116 if "/process/em/UseGeneralProcess true" not in flags.Sim.G4Commands:
117 optionalUserActions = flags.Sim.OptionalUserActionList
118 optionalUserActions.remove("G4UserActions.G4UserActionsConfig.FixG4CreatorProcessToolCfg")
119 flags.Sim.OptionalUserActionList = optionalUserActions
120
121
122def enableG4Optimizations(flags):
123 """Enable G4 optimizations"""
124
125 # Activate magnetic field switch off in central LAr calorimeter
126 # More info: https://its.cern.ch/jira/browse/ATLPHYSVAL-773
127 enableMuonFieldOnlyInCalo(flags)
128
129 # Photon Russian Roulette
130 # "Fast simulation" killing low energy photons with some probability.
131 # More info: https://its.cern.ch/jira/browse/ATLASSIM-4096
132 enablePhotonRussianRoulette(flags)
133
134 # Neutron Russian Roulette
135 # "Fast simulation" killing low energy neutrons with some probability.
136 # More info: its.cern.ch/jira/browse/ATLASSIM-3924
137 enableNeutronRussianRoulette(flags)
138
139 # EM Range Cuts
140 # Turn on range cuts for gamma processes (conv, phot, compt)
141 # More info: https://its.cern.ch/jira/browse/ATLASSIM-3956
142 enableEMRangeCuts(flags)
143
144 # G4GammaGeneralProcess
145 # Activate the G4GammaGeneralProcess and the UserAction required
146 # to fix the creator process of secondary tracks.
147 enableG4GammaGeneralProcess(flags)
148
149 # Energy Loss fluctuation OFF
150 # Switch off the Energy loss fluctuation process
151 # More info: https://its.cern.ch/jira/browse/ATLASSIM-6995
152 # Main physics validation: https://its.cern.ch/jira/browse/ATLPHYSVAL-1009
153 # Follow-up validation for Muons: https://its.cern.ch/jira/browse/ATLPHYSVAL-1022
154 # Follow-up validation for Egamma: https://its.cern.ch/jira/browse/ATLPHYSVAL-1030
155 # This optimization is on hold for mc23e - for discrepancies seen in the
156 # follow-up validations by EgammaCP group.
157 # It will be evaluated for future campaigns.
158 # flags.Sim.G4Commands+=["/process/eLoss/fluct false"]
159
160 # Activate the Woodcock Tracking in the EMEC
161 # More info: https://its.cern.ch/jira/browse/ATLASSIM-5079
162 enableWoodcockTracking(flags)
163
164
165def disableG4Optimizations(flags):
166 """ Ensure all G4Optimizations are disabled - useful for debugging """
167 disableMuonFieldOnlyInCalo(flags)
168 disablePhotonRussianRoulette(flags)
169 disableNeutronRussianRoulette(flags)
170 disableEMRangeCuts(flags)
171 disableG4GammaGeneralProcess(flags)
172 disableWoodcockTracking(flags)
173 disableBeamPipeKill(flags)
174 disableFrozenShowersFCalOnly(flags)
175 disableMultipleStepsInMSCTransport(flags)
176
177
178def WoodcockTrackingInEMEC(flags):
179 # Use Woodcock Tracking in the EMEC rather than the EMECPara
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 EMECPara")
184 flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMEC"]
185
186
187def WoodcockTrackingInEMECPara(flags):
188 # Use Woodcock Tracking in the EMECPara rather than the EMEC
189 # G4Region. This preInclude should be added at the end of the list
190 # of preIncludes.
191 commands = flags.Sim.G4Commands
192 commands.remove("/process/em/useWoodcockTracking EMEC")
193 flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMECPara"]
194
195
196def PostIncludeTweakPhysicsRegionsCfg(flags, cfg):
197 # This postInclude drops BeamPipe::SectionF198 and
198 # BeamPipe::SectionF199 from the DeadMaterial G4Region, to avoid a
199 # clash with the BeampipeFwdCut G4Region.
200 from AthenaConfiguration.ComponentAccumulator import ConfigurationError
201 detConTool = None
202 try:
203 detConTool = cfg.getPublicTool('G4AtlasDetectorConstructionTool')
204 except ConfigurationError:
205 pass
206 if detConTool is None:
207 return
208 detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF198')
209 detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF199')