ATLAS Offline Software
MonopoleConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.AccumulatorCache import AccumulatorCache
4 import os
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7 from AthenaConfiguration.Enums import ProductionStep
8 from ExtraParticles.PDGHelpers import getPDGTABLE
9 
10 
11 @AccumulatorCache
13  if getPDGTABLE('PDGTABLE.MeV'):
14  ALINE1="M 4110000 {intmass}.E+03 +0.0E+00 -0.0E+00 Monopole 0".format(intmass=int(MASS))
15  ALINE2="W 4110000 0.E+00 +0.0E+00 -0.0E+00 Monopole 0"
16  BLINE1="4110000 {intmass}.00 0.0 {gcharge} # Monopole".format(intmass=int(MASS), gcharge=GCHARGE)
17  BLINE2="-4110000 {intmass}.00 0.0 -{gcharge} # MonopoleBar".format(intmass=int(MASS), gcharge=GCHARGE)
18 
19  f=open('PDGTABLE.MeV','a')
20  f.writelines(str(ALINE1))
21  f.writelines('\n')
22  f.writelines(str(ALINE2))
23  f.writelines('\n')
24  f.close()
25  partmod = os.path.isfile('particles.txt')
26  if partmod is True:
27  os.remove('particles.txt')
28  f=open('particles.txt','w')
29  f.writelines(str(BLINE1))
30  f.writelines('\n')
31  f.writelines(str(BLINE2))
32  f.writelines('\n')
33  f.close()
34 
35  del ALINE1
36  del ALINE2
37  del BLINE1
38  del BLINE2
39 
40 
41 @AccumulatorCache
43  if getPDGTABLE('PDGTABLE.MeV'):
44  CODE=10000000+int(float(CHARGE)*100)
45 
46  ALINE1="M {code} {intmass}.E+03 +0.0E+00 -0.0E+00 Qball +".format(code=CODE,intmass=int(MASS))
47  ALINE2="W {code} 0.E+00 +0.0E+00 -0.0E+00 Qball +".format(code=CODE)
48  BLINE1="{code} {intmass}.00 {charge} 0.0 # Qball".format(code=CODE,intmass=int(MASS), charge=CHARGE)
49  BLINE2="-{code} {intmass}.00 -{charge} 0.0 # QballBar".format(code=CODE,intmass=int(MASS), charge=CHARGE)
50 
51  f=open('PDGTABLE.MeV','a')
52  f.writelines(str(ALINE1))
53  f.writelines('\n')
54  f.writelines(str(ALINE2))
55  f.writelines('\n')
56  f.close()
57  partmod = os.path.isfile('particles.txt')
58  if partmod is True:
59  os.remove('particles.txt')
60  f=open('particles.txt','w')
61  f.writelines(str(BLINE1))
62  f.writelines('\n')
63  f.writelines(str(BLINE2))
64  f.writelines('\n')
65  f.close()
66 
67  del ALINE1
68  del ALINE2
69  del BLINE1
70  del BLINE2
71 
72 
73 @AccumulatorCache
74 def load_files_for_fcp_scenario(MASS, CHARGE, X, Y):
75  CODE=int(20000000)+int(X)*1000+int(Y)*10
76  print("Trying to load %s, %s for particle with code %s" % (X, Y, CODE))
77 
78  pdgLine1="M {code} {intmass}.E+03 +0.0E+00 -0.0E+00 fcp +\n".format(code=CODE,intmass=int(MASS))
79  pdgLine2="W {code} 0.E+00 +0.0E+00 -0.0E+00 fcp +\n".format(code=CODE)
80  particleLine1="{code} {intmass}.00 {fcharge} 0.0 # fcp\n".format(code=CODE,intmass=int(MASS), fcharge=float(CHARGE))
81  particleLine2="-{code} {intmass}.00 -{fcharge} 0.0 # fcpBar\n".format(code=CODE,intmass=int(MASS), fcharge=float(CHARGE))
82 
83  # retreive the PDGTABLE file
84  if getPDGTABLE('PDGTABLE.MeV'):
85  f=open('PDGTABLE.MeV','a')
86  f.writelines(str(pdgLine1))
87  f.writelines(str(pdgLine2))
88  f.close()
89  partmod = os.path.isfile('particles.txt')
90  if partmod is True:
91  os.remove('particles.txt')
92  f=open('particles.txt','w')
93  f.writelines(str(particleLine1))
94  f.writelines(str(particleLine2))
95  f.close()
96 
97  del pdgLine1
98  del pdgLine2
99  del particleLine1
100  del particleLine2
101 
102 
103 def MonopolePhysicsToolCfg(flags, name="MonopolePhysicsTool", **kwargs):
104  result = ComponentAccumulator()
105  result.setPrivateTools( CompFactory.MonopolePhysicsTool(name, **kwargs) )
106  return result
107 
108 
109 def G4mplEqMagElectricFieldToolCfg(flags, name="G4mplEqMagElectricField", **kwargs):
110  result = ComponentAccumulator()
111  result.setPrivateTools( CompFactory.G4mplEqMagElectricFieldTool(name, **kwargs) )
112  return result
113 
114 
115 def fcpPreInclude(flags):
116  simdict = flags.Input.SpecialConfiguration
117  if flags.Common.ProductionStep == ProductionStep.Simulation:
118  # add monopole-specific configuration for looper killer
119  flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.MonopoleLooperKillerToolCfg']
120  # add default HIP killer
121  flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.HIPKillerToolCfg']
122  if "InteractingPDGCodes" not in simdict: #FIXME This code would ideally update the ConfigFlag itself
123  assert "CHARGE" in simdict
124  assert "X" in simdict
125  assert "Y" in simdict
126  CODE=int(20000000)+int(simdict["X"])*1000+int(simdict["Y"])*10
127  simdict['InteractingPDGCodes'] = str([CODE,-1*CODE])
128  flags.Input.SpecialConfiguration = simdict
129 
130 
131 def fcpCfg(flags):
132  result = ComponentAccumulator()
133  if flags.Common.ProductionStep == ProductionStep.Simulation:
134  from G4AtlasServices.G4AtlasServicesConfig import PhysicsListSvcCfg
135  result.merge(PhysicsListSvcCfg(flags))
136 
137  simdict = flags.Input.SpecialConfiguration
138  load_files_for_fcp_scenario(simdict["MASS"], simdict["CHARGE"], simdict["X"], simdict["Y"])
139  pdgcodes = eval(simdict['InteractingPDGCodes']) if 'InteractingPDGCodes' in simdict else []
140  from ExtraParticles.PDGHelpers import updateExtraParticleAcceptList
141  updateExtraParticleAcceptList('G4particle_acceptlist_ExtraParticles.txt', pdgcodes)
142 
143  if flags.Common.ProductionStep == ProductionStep.Simulation:
144  physicsOptions = [ result.popToolsAndMerge(MonopolePhysicsToolCfg(flags)) ]
145  result.getService("PhysicsListSvc").PhysOption += physicsOptions
146  # add monopole-specific configuration for looper killer
147  #simFlags.OptionalUserActionList.addAction('G4UA::MonopoleLooperKillerTool') #FIXME missing functionality
148  # add default HIP killer
149  #simFlags.OptionalUserActionList.addAction('G4UA::HIPKillerTool') #FIXME missing functionality
150 
151  return result
152 
153 
154 def QballPreInclude(flags):
155  simdict = flags.Input.SpecialConfiguration
156  if flags.Common.ProductionStep == ProductionStep.Simulation:
157  # add monopole-specific configuration for looper killer
158  flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.MonopoleLooperKillerToolCfg']
159  # add default HIP killer
160  flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.HIPKillerToolCfg']
161  if "InteractingPDGCodes" not in simdict:
162  assert "CHARGE" in simdict
163  CODE=10000000+int(float(simdict["CHARGE"])*100)
164  simdict['InteractingPDGCodes'] = str([CODE,-1*CODE])
165  flags.Input.SpecialConfiguration = simdict
166 
167 
168 def QballCfg(flags):
169  result = ComponentAccumulator()
170  simdict = flags.Input.SpecialConfiguration
171  if flags.Common.ProductionStep == ProductionStep.Simulation:
172  from G4AtlasServices.G4AtlasServicesConfig import PhysicsListSvcCfg
173  result.merge(PhysicsListSvcCfg(flags))
174  if "InteractingPDGCodes" not in simdict:
175  assert "CHARGE" in simdict
176  CODE=10000000+int(float(simdict["CHARGE"])*100)
177  simdict['InteractingPDGCodes'] = str([CODE,-1*CODE])
178 
179  assert "MASS" in simdict
180  assert "CHARGE" in simdict
181  load_files_for_qball_scenario(simdict["MASS"], simdict["CHARGE"])
182  pdgcodes = eval(simdict['InteractingPDGCodes']) if 'InteractingPDGCodes' in simdict else []
183  from ExtraParticles.PDGHelpers import updateExtraParticleAcceptList
184  updateExtraParticleAcceptList('G4particle_acceptlist_ExtraParticles.txt', pdgcodes)
185 
186  if flags.Common.ProductionStep == ProductionStep.Simulation:
187  physicsOptions = [ result.popToolsAndMerge(MonopolePhysicsToolCfg(flags)) ]
188  result.getService("PhysicsListSvc").PhysOption += physicsOptions
189 
190  return result
191 
192 
194  if flags.Common.ProductionStep == ProductionStep.Simulation:
195  # add monopole-specific configuration for looper killer
196  flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.MonopoleLooperKillerToolCfg']
197  # add default HIP killer
198  flags.Sim.OptionalUserActionList += ['G4UserActions.G4UserActionsConfig.HIPKillerToolCfg']
199  flags.Sim.G4Stepper = 'ClassicalRK4'
200  flags.Sim.G4EquationOfMotion = "G4mplEqMagElectricField" #Monopole Equation of Motion
201  flags.Sim.TightMuonStepping = False
202  simdict = flags.Input.SpecialConfiguration
203  if "InteractingPDGCodes" not in simdict:
204  simdict['InteractingPDGCodes'] = str([4110000,-4110000])
205  flags.Input.SpecialConfiguration = simdict
206 
207 
208 def MonopoleCfg(flags):
209  result = ComponentAccumulator()
210  if flags.Common.ProductionStep == ProductionStep.Simulation:
211  from G4AtlasServices.G4AtlasServicesConfig import PhysicsListSvcCfg
212  result.merge(PhysicsListSvcCfg(flags))
213 
214  simdict = flags.Input.SpecialConfiguration
215  assert "MASS" in simdict
216  assert "GCHARGE" in simdict
217  load_files_for_monopole_scenario(simdict["MASS"], simdict["GCHARGE"])
218  pdgcodes = eval(simdict['InteractingPDGCodes']) if 'InteractingPDGCodes' in simdict else []
219  from ExtraParticles.PDGHelpers import updateExtraParticleAcceptList
220  updateExtraParticleAcceptList('G4particle_acceptlist_ExtraParticles.txt', pdgcodes)
221 
222  if flags.Common.ProductionStep == ProductionStep.Simulation:
223  from GaudiKernel.GaudiHandles import PrivateToolHandleArray
224  physicsOptions = PrivateToolHandleArray([ result.popToolsAndMerge(MonopolePhysicsToolCfg(flags)) ])
225  result.getService("PhysicsListSvc").PhysOption = physicsOptions + result.getService("PhysicsListSvc").PhysOption
226  return result
227 
228 
229 def Monopole_VerboseSelectorCfg(flags, name="G4UA::VerboseSelectorTool", **kwargs):
230  kwargs.setdefault('TargetEvent',1)
231  kwargs.setdefault('VerboseLevel',1)
232  kwargs.setdefault('TargetPdgIDs',
233  [
234  -4110000,4110000 #Monopoles
235  ])
236  from G4DebuggingTools.G4DebuggingToolsConfig import VerboseSelectorToolCfg
237  return VerboseSelectorToolCfg(flags, name, **kwargs)
PDGHelpers.updateExtraParticleAcceptList
def updateExtraParticleAcceptList(listName='G4particle_acceptlist_ExtraParticles.txt', pdgcodes=[])
Definition: PDGHelpers.py:57
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.G4DebuggingToolsConfig.VerboseSelectorToolCfg
def VerboseSelectorToolCfg(flags, name="G4UA::VerboseSelectorTool", **kwargs)
Definition: G4DebuggingToolsConfig.py:8
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MonopoleConfig.fcpCfg
def fcpCfg(flags)
Definition: MonopoleConfig.py:131
MonopoleConfig.MonopolePreInclude
def MonopolePreInclude(flags)
Definition: MonopoleConfig.py:193
PDGHelpers.getPDGTABLE
def getPDGTABLE(table)
Definition: PDGHelpers.py:37
MonopoleConfig.G4mplEqMagElectricFieldToolCfg
def G4mplEqMagElectricFieldToolCfg(flags, name="G4mplEqMagElectricField", **kwargs)
Definition: MonopoleConfig.py:109
MonopoleConfig.QballPreInclude
def QballPreInclude(flags)
Definition: MonopoleConfig.py:154
MonopoleConfig.load_files_for_monopole_scenario
def load_files_for_monopole_scenario(MASS, GCHARGE)
Definition: MonopoleConfig.py:12
MonopoleConfig.MonopoleCfg
def MonopoleCfg(flags)
Definition: MonopoleConfig.py:208
MonopoleConfig.MonopolePhysicsToolCfg
def MonopolePhysicsToolCfg(flags, name="MonopolePhysicsTool", **kwargs)
Definition: MonopoleConfig.py:103
G4AtlasServicesConfig.PhysicsListSvcCfg
def PhysicsListSvcCfg(flags, name="PhysicsListSvc", **kwargs)
Definition: G4AtlasServicesConfig.py:22
Trk::open
@ open
Definition: BinningType.h:40
MonopoleConfig.load_files_for_qball_scenario
def load_files_for_qball_scenario(MASS, CHARGE)
Definition: MonopoleConfig.py:42
MonopoleConfig.fcpPreInclude
def fcpPreInclude(flags)
Definition: MonopoleConfig.py:115
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
readCCLHist.float
float
Definition: readCCLHist.py:83
MonopoleConfig.Monopole_VerboseSelectorCfg
def Monopole_VerboseSelectorCfg(flags, name="G4UA::VerboseSelectorTool", **kwargs)
Definition: MonopoleConfig.py:229
MonopoleConfig.QballCfg
def QballCfg(flags)
Definition: MonopoleConfig.py:168
MonopoleConfig.load_files_for_fcp_scenario
def load_files_for_fcp_scenario(MASS, CHARGE, X, Y)
Definition: MonopoleConfig.py:74