ATLAS Offline Software
G4Optimizations.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 from 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 
16 def enableBeamPipeKill(flags):
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 
40  flags.Sim.MuonFieldOnlyInCalo = False
41 
42 
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 
50  flags.Sim.PRRThreshold = False
51  flags.Sim.PRRWeight = False
52 
53 
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 
62  flags.Sim.NRRThreshold = False
63  flags.Sim.NRRWeight = False
64 
65 
66 def enableEMRangeCuts(flags):
67  """Turn on range cuts for gamma processes (conv, phot, compt)"""
68  flags.Sim.G4Commands += ['/process/em/applyCuts true']
69 
70 
71 def disableEMRangeCuts(flags):
72  commands = flags.Sim.G4Commands
73  commands.remove("/process/em/applyCuts true")
74  flags.Sim.G4Commands = commands
75 
76 
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 
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 
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 
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 
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
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
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
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.
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
155 
156 
158  # Use Woodcock Tracking in the EMEC rather than the EMECPara
159  # G4Region. This preInclude should be added at the end of the list
160  # of preIncludes.
161  commands = flags.Sim.G4Commands
162  commands.remove("/process/em/useWoodcockTracking EMECPara")
163  flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMEC"]
164 
165 
167  # Use Woodcock Tracking in the EMECPara rather than the EMEC
168  # G4Region. This preInclude should be added at the end of the list
169  # of preIncludes.
170  commands = flags.Sim.G4Commands
171  commands.remove("/process/em/useWoodcockTracking EMEC")
172  flags.Sim.G4Commands = commands + ["/process/em/useWoodcockTracking EMECPara"]
173 
174 
176  # This postInclude drops BeamPipe::SectionF198 and
177  # BeamPipe::SectionF199 from the DeadMaterial G4Region, to avoid a
178  # clash with the BeampipeFwdCut G4Region.
179  from AthenaConfiguration.ComponentAccumulator import ConfigurationError
180  detConTool = None
181  try:
182  detConTool = cfg.getPublicTool('G4AtlasDetectorConstructionTool')
183  except ConfigurationError:
184  pass
185  if detConTool is None:
186  return
187  detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF198')
188  detConTool.RegionCreators['DeadMaterialPhysicsRegionTool'].VolumeList.remove('BeamPipe::SectionF199')
python.G4Optimizations.enableBeamPipeKill
def enableBeamPipeKill(flags)
Definition: G4Optimizations.py:16
python.G4Optimizations.disablePhotonRussianRoulette
def disablePhotonRussianRoulette(flags)
Definition: G4Optimizations.py:49
python.G4Optimizations.enableG4Optimizations
def enableG4Optimizations(flags)
Definition: G4Optimizations.py:114
python.G4Optimizations.enableG4GammaGeneralProcess
def enableG4GammaGeneralProcess(flags)
Definition: G4Optimizations.py:77
python.G4Optimizations.disableWoodcockTracking
def disableWoodcockTracking(flags)
Definition: G4Optimizations.py:104
python.G4Optimizations.disableBeamPipeKill
def disableBeamPipeKill(flags)
Definition: G4Optimizations.py:21
python.G4Optimizations.enablePhotonRussianRoulette
def enablePhotonRussianRoulette(flags)
Definition: G4Optimizations.py:43
python.G4Optimizations.enableWoodcockTracking
def enableWoodcockTracking(flags)
Definition: G4Optimizations.py:94
python.G4Optimizations.enableTightMuonStepping
def enableTightMuonStepping(flags)
Definition: G4Optimizations.py:26
python.G4Optimizations.PostIncludeTweakPhysicsRegionsCfg
def PostIncludeTweakPhysicsRegionsCfg(flags, cfg)
Definition: G4Optimizations.py:175
python.G4Optimizations.disableMuonFieldOnlyInCalo
def disableMuonFieldOnlyInCalo(flags)
Definition: G4Optimizations.py:39
python.G4Optimizations.disableFrozenShowersFCalOnly
def disableFrozenShowersFCalOnly(flags)
Definition: G4Optimizations.py:11
python.G4Optimizations.disableNeutronRussianRoulette
def disableNeutronRussianRoulette(flags)
Definition: G4Optimizations.py:61
python.G4Optimizations.enableMuonFieldOnlyInCalo
def enableMuonFieldOnlyInCalo(flags)
Definition: G4Optimizations.py:34
python.G4Optimizations.disableTightMuonStepping
def disableTightMuonStepping(flags)
Definition: G4Optimizations.py:30
python.G4Optimizations.WoodcockTrackingInEMECPara
def WoodcockTrackingInEMECPara(flags)
Definition: G4Optimizations.py:166
python.G4Optimizations.enableFrozenShowersFCalOnly
def enableFrozenShowersFCalOnly(flags)
Definition: G4Optimizations.py:5
python.G4Optimizations.WoodcockTrackingInEMEC
def WoodcockTrackingInEMEC(flags)
Definition: G4Optimizations.py:157
python.G4Optimizations.disableEMRangeCuts
def disableEMRangeCuts(flags)
Definition: G4Optimizations.py:71
python.G4Optimizations.disableG4GammaGeneralProcess
def disableG4GammaGeneralProcess(flags)
Definition: G4Optimizations.py:83
python.G4Optimizations.enableNeutronRussianRoulette
def enableNeutronRussianRoulette(flags)
Definition: G4Optimizations.py:54
python.G4Optimizations.enableEMRangeCuts
def enableEMRangeCuts(flags)
Definition: G4Optimizations.py:66