ATLAS Offline Software
Loading...
Searching...
No Matches
Herwig7Config.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
5
6from . import Herwig7Utils as hw7Utils
7
8# Helper for resetting process number
9from MCJobOptionUtils.JOsupport import check_reset_proc_number
10
11# import Athena modules
12from AthenaCommon import Logging
13athMsgLog = Logging.logging.getLogger('Herwig7Config')
14
15
16class Hw7Config(object):
17
18
19 def __init__(self, genSeq, runArgs, run_name="Herwig"):
20
21 # Force Herwig7 to run in single-core mode
22 check_reset_proc_number(runArgs)
23
24 self.genSeq = genSeq
25 self.runArgs = runArgs
26
27 self.run_name = run_name
28 # self.seed = runArgs.randomSeed
29 # self.energy = runArgs.ecmEnergy
30
31 self.me_pdf_name = "MMHT2014lo68cl"
32 self.mpi_pdf_name = "MMHT2014lo68cl"
33
37 self.use_PDGparams = False
38
39 self.default_commands = hw7Utils.ConfigurationCommands()
40 self.commands = hw7Utils.ConfigurationCommands()
41
42
45 return """
46## =========================================
47## Global Pre-Commands from Herwig7Config.py
48## =========================================
49
50## ensure JetFinder uses AntiKt with R=0.4
51set /Herwig/Cuts/JetFinder:Variant AntiKt
52set /Herwig/Cuts/JetFinder:ConeRadius 0.4
53"""
54
55
56
57 def add_commands(self, commands):
58
59 self.commands += commands
60
61
62
64
65 return("""
66## Random number generator seed
67set /Herwig/Random:Seed {}
68""".format(self.runArgs.randomSeed))
69
70
71 def beam_commands(self):
72
73 if self.beams == "EE":
74 return("""
75## Commands for lepton-lepton collisions
76read snippets/EECollider.in
77set /Herwig/Shower/PartnerFinder:QEDPartner IIandFF
78set /Herwig/Shower/ShowerHandler:MPIHandler NULL
79set /Herwig/DipoleShower/DipoleShowerHandler:MPIHandler NULL
80set /Herwig/Shower/PowhegShowerHandler:MPIHandler NULL
81""")
82 elif self.beams == "EP":
83 return("""
84## Commands for proton-lepton collisions
85read snippets/EPCollider.in
86do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting e-->e-,gamma; /Herwig/Shower/LtoLGammaSudakov
87do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting mu-->mu-,gamma; /Herwig/Shower/LtoLGammaSudakov
88do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting tau-->tau-,gamma; /Herwig/Shower/LtoLGammaSudakov
89set /Herwig/Shower/KinematicsReconstructor:ReconstructionOption Colour
90""")
91 else:
92 return("""
93## Commands for proton-proton collisions
94read snippets/PPCollider.in
95""")
96
97
109
110 return("""
111## Center-of-mass energy
112set /Herwig/Generators/EventGenerator:EventHandler:LuminosityFunction:Energy {}
113""".format(self.runArgs.ecmEnergy))
114
115
116
118
119 self.set_printout_commands = True
120
121 return("""
122
123## Verbosity and printout settings
124set /Herwig/Generators/EventGenerator:DebugLevel 1
125set /Herwig/Generators/EventGenerator:PrintEvent 2
126set /Herwig/Generators/EventGenerator:UseStdout Yes
127set /Herwig/Generators/EventGenerator:NumberOfEvents 1000000000
128set /Herwig/Generators/EventGenerator:MaxErrors 500
129
130## Make sampler print out cross sections for each subprocess
131set /Herwig/Samplers/Sampler:Verbose Yes
132""")
133
134
138
140 if self.use_PDGparams:
141 paramlist = []
143
144 paramlist.append("## Masses and widths: PDG 2019 values")
145
146
147 from EvgenProdTools.offline_dict import parameters
148 for k,v in parameters.items():
149 if k == 'particles':
150 for key,value in v.items():
151 if int(key) == 24:
152 paramlist.append("set /Herwig/Particles/"+value['name']+"+:NominalMass "+value['mass'])
153 paramlist.append("set /Herwig/Particles/"+value['name']+"+:Width "+value['width'])
154 paramlist.append("set /Herwig/Particles/"+value['name']+"-:NominalMass "+value['mass'])
155 paramlist.append("set /Herwig/Particles/"+value['name']+"-:Width "+value['width'])
156 if int(key) == 23:
157 paramlist.append("set /Herwig/Particles/"+value['name']+"0:NominalMass "+value['mass'])
158 paramlist.append("set /Herwig/Particles/"+value['name']+"0:Width "+value['width'])
159 if int(key) == 6:
160 paramlist.append("set /Herwig/Particles/"+value['name']+"bar:NominalMass "+value['mass'])
161 paramlist.append("set /Herwig/Particles/"+value['name']+"bar:Width "+value['width'])
162 paramlist.append("set /Herwig/Particles/"+value['name']+":NominalMass "+value['mass'])
163 paramlist.append("set /Herwig/Particles/"+value['name']+":Width "+value['width'])
164
165
166 if k == 'EW_parameters':
167 for key,value in v.items():
168 if key[2] == "Sin2ThetaW":
169 paramlist.append("set /Herwig/Model:EW/"+str(key[2])+" "+str(value))
170 paramstring = '\n'.join(paramlist)
171 return(paramstring)
172
173 else:
175
176 return("""
177## Masses and widths: PDG 2010 values (except TOP mass; kept at PDG2007)
178
179## top-quark
180set /Herwig/Particles/t:NominalMass 172.5*GeV
181set /Herwig/Particles/tbar:NominalMass 172.5*GeV
182## W boson
183set /Herwig/Particles/W+:NominalMass 80.399*GeV
184set /Herwig/Particles/W-:NominalMass 80.399*GeV
185set /Herwig/Particles/W+:Width 2.085*GeV
186set /Herwig/Particles/W-:Width 2.085*GeV
187## Z boson
188set /Herwig/Particles/Z0:NominalMass 91.1876*GeV
189set /Herwig/Particles/Z0:Width 2.4952*GeV
190## b quark
191set /Herwig/Particles/b:NominalMass 4.95*GeV
192set /Herwig/Particles/bbar:NominalMass 4.95*GeV
193
194## Weinberg angle
195set /Herwig/Model:EW/Sin2ThetaW 0.23113
196""")
197
199
201
202 return("""
203## Disable default attempts to use Pomeron PDF data files, until we're worked how to do that on the Grid!
204set /Herwig/Particles/pomeron:PDF /Herwig/Partons/NoPDF
205
206## Set long-lived particles stable
207set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
208""")
209
210
211
212
221 def me_alphas_commands(self, order="NLO", scale=91.1876, value=0.118):
222
223 if order not in ["LO", "NLO"]:
224 raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'order' must either be 'LO' or 'NLO'!"))
225
226 self.commands += """
227## Configure {0} AlphaS for the hard process
228## (LO: 1-loop-running / NLO: 2-loop running)
229set /Herwig/Couplings/{0}AlphaS:input_scale {1}
230set /Herwig/Couplings/{0}AlphaS:input_alpha_s {2}
231set /Herwig/Model:QCD/RunningAlphaS /Herwig/Couplings/{0}AlphaS
232""".format(order, scale, value)
233
234
235
241 def me_pdf_commands(self, order="NLO", name="MMHT2014nlo68cl", member=0, max_flav=5):
242
243 if order not in ["LO", "NLO"]:
244 raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'order' must either be 'LO' or 'NLO'!"))
245
246 self.me_pdf_name = name
247
248 self.commands += """
249## Configure {0} PDF set for the hard process
250set /Herwig/Partons/Hard{0}PDF:PDFName {1}
251set /Herwig/Partons/Hard{0}PDF:Member {2}
252set /Herwig/Partons/Hard{0}PDF:MaxFlav {3}
253set /Herwig/Partons/Hard{0}PDF:RemnantHandler /Herwig/Partons/HadronRemnants
254set /Herwig/Particles/p+:PDF /Herwig/Partons/Hard{0}PDF
255set /Herwig/Particles/pbar-:PDF /Herwig/Partons/Hard{0}PDF
256set /Herwig/Partons/PPExtractor:FirstPDF /Herwig/Partons/Hard{0}PDF
257set /Herwig/Partons/PPExtractor:SecondPDF /Herwig/Partons/Hard{0}PDF
258""".format(order, name, member, max_flav)
259
260
261
267 def shower_pdf_commands(self, order="LO", name="MMHT2014lo68cl", member=0, max_flav=5):
268
269 if order not in ["LO", "NLO"]:
270 raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'order' must either be 'LO' or 'NLO'!"))
271
272
274
275 self.commands += """
276## Configure {0} PDF set for the parton shower
277set /Herwig/Partons/Shower{0}PDF:PDFName {1}
278set /Herwig/Partons/Shower{0}PDF:Member {2}
279set /Herwig/Partons/Shower{0}PDF:MaxFlav {3}
280set /Herwig/Shower/ShowerHandler:PDFA /Herwig/Partons/Shower{0}PDF
281set /Herwig/Shower/ShowerHandler:PDFB /Herwig/Partons/Shower{0}PDF
282set /Herwig/Shower/PowhegShowerHandler:PDFA /Herwig/Partons/Shower{0}PDF
283set /Herwig/Shower/PowhegShowerHandler:PDFB /Herwig/Partons/Shower{0}PDF
284set /Herwig/DipoleShower/DipoleShowerHandler:PDFA /Herwig/Partons/Shower{0}PDF
285set /Herwig/DipoleShower/DipoleShowerHandler:PDFB /Herwig/Partons/Shower{0}PDF
286""".format(order, name, member, max_flav)
287
288
289
294 def mpi_pdf_commands(self, name="MMHT2014lo68cl", member=0, max_flav=5):
295
296 self.mpi_pdf_name = name
297
298 self.commands += """
299## Configure MPI PDF
300set /Herwig/Partons/MPIPDF:PDFName {}
301set /Herwig/Partons/MPIPDF:Member {}
302set /Herwig/Partons/MPIPDF:MaxFlav {}
303""".format(name, member, max_flav)
304
305
306
311 def remnant_pdf_commands(self, name="MMHT2014lo68cl", member=0, max_flav=5):
312
313 self.commands += """
314## Configure Remnant PDF
315set /Herwig/Partons/RemnantPDF:PDFName {}
316set /Herwig/Partons/RemnantPDF:Member {}
317set /Herwig/Partons/RemnantPDF:MaxFlav {}
318""".format(name, member, max_flav)
319
320
321
322
325 def tune_commands(self):
326
327 cmds = """
328## -------------
329## Tune Settings
330## -------------
331"""
332 self.commands += cmds
333
334
335
339
340 cmds = """
341## Parton shower / hadronization tune settings
342"""
343
344 self.commands += cmds
345
346
347 def load_PS_tune(self):
348
349 return """
350## some commands
351"""
352
353
354
358
359 cmds = """
360## Underlying event tune settings
361"""
362
363 self.commands += cmds
364
365
366 def load_ue_tune(self):
367
368 return """
369## some commands
370"""
371
372
373 def get_dpdf_path(self):
374 import os
375 cmt_path = os.environ.get("CMAKE_PREFIX_PATH")
376 cmt_dir = os.environ.get("BINARY_TAG")
377
378 cmtPaths = cmt_path.split(':')
379
380 for path in cmtPaths:
381 pathNow = path + "/InstallArea/" + cmt_dir + "/share/"
382 try:
383 fileList = os.listdir(pathNow)
384 except Exception:
385 fileList = []
386 if "HerwigDefaults.rpo" in fileList:
387 simSharePath = pathNow
388
389 dpdf_path = os.path.dirname(os.path.normpath(os.path.join(simSharePath, os.readlink(simSharePath + 'HerwigDefaults.rpo')))) + "/PDF/diffraction/"
390
391 return dpdf_path
392
393
394
395 def pdf_pomeron_cmds(self, flux, pdf):
396
397 dpdf_path = self.get_dpdf_path()
398
399 cmds = "\n"
400 cmds += "set /Herwig/Partons/PomeronPDF:RootName %s\n" % dpdf_path
401 cmds += "set /Herwig/Partons/PomeronFlux:PDFFit %s\n" % flux
402 cmds += "set /Herwig/Partons/PomeronPDF:PDFFit %s\n" % pdf
403
404 cmds += """\
405set /Herwig/Particles/pomeron:PDF /Herwig/Partons/PomeronPDF
406
407# Technical parameters for this run
408set /Herwig/Generators/EventGenerator:EventHandler:Sampler:Ntry 100000
409set /Herwig/Generators/EventGenerator:MaxErrors 500
410
411# MPI doesn't work
412# TODO: Is this a problem?
413set /Herwig/Generators/EventGenerator:EventHandler:CascadeHandler:MPIHandler NULL
414
415# Choice of phase-space generation for PDFs
416set /Herwig/Partons/PPExtractor:FlatSHatY 0
417
418"""
419 return cmds
420
421
422
425
426 return """
427
428# Technical parameters for this run
429set /Herwig/Generators/EventGenerator:EventHandler:Sampler:Ntry 100000
430
431# Choice of phase-space generation for PDFs
432set /Herwig/Partons/PPExtractor:FlatSHatY 0
433
434# Change the proton PDFs to those for photon radiation
435set /Herwig/Particles/p+:PDF /Herwig/Partons/BudnevPDF
436set /Herwig/Particles/pbar-:PDF /Herwig/Partons/BudnevPDF
437
438# MPI doesn't work
439# TODO: Is this a problem?
440set /Herwig/Generators/EventGenerator:EventHandler:CascadeHandler:MPIHandler NULL
441
442"""
443
444 # Set the tune schemes for the new angular ordering of the shower
445 def set_tune_scheme(self, tune_scheme="DotProduct"):
446 tune_schemes = ["DotProduct-Veto","DotProduct","pT","Q2"]
447 if tune_scheme not in tune_schemes:
448 athMsgLog.warn("Please choose one of the supported tune-schemes! (DotProduct-Veto,DotProduct,pT,Q2)")
449 else:
450 athMsgLog.info("{tune_scheme:s} was used for the tune scheme.".format(tune_scheme=tune_scheme))
451 # create a tune-section in the config
452 self.commands += """\
453\n## -------------
454## Tune Settings
455## -------------
456
457# Tune-{tune_scheme:s}
458read snippets/EvolutionScheme-{tune_scheme:s}.in
459read snippets/Tune-{tune_scheme:s}.in
460""".format(tune_scheme=tune_scheme)
461
462 # Add the commands for enabling shower scale variations
463 def enable_angularShowerScaleVariations(self, do_variations=False):
464 if do_variations:
465 self.commands += """\
466\n## -----------------------
467## Shower scale variation
468## -----------------------
469cd /Herwig/Shower
470do ShowerHandler:AddVariation MUR2_MUF2_SHOWER_HARD 2 2 Hard
471do ShowerHandler:AddVariation MUR2_MUF1_SHOWER_HARD 2 1 Hard
472do ShowerHandler:AddVariation MUR1_MUF2_SHOWER_HARD 1 2 Hard
473do ShowerHandler:AddVariation MUR1_MUF0.5_SHOWER_HARD 1 0.5 Hard
474do ShowerHandler:AddVariation MUR0.5_MUF1_SHOWER_HARD 0.5 1 Hard
475do ShowerHandler:AddVariation MUR0.5_MUF0.5_SHOWER_HARD 0.5 0.5 Hard
476do ShowerHandler:AddVariation MUR2_MUF2_SHOWER_SEC 2 2 Secondary
477do ShowerHandler:AddVariation MUR2_MUF1_SHOWER_SEC 2 1 Secondary
478do ShowerHandler:AddVariation MUR1_MUF2_SHOWER_SEC 1 2 Secondary
479do ShowerHandler:AddVariation MUR1_MUF0.5_SHOWER_SEC 1 0.5 Secondary
480do ShowerHandler:AddVariation MUR0.5_MUF1_SHOWER_SEC 0.5 1 Secondary
481do ShowerHandler:AddVariation MUR0.5_MUF0.5_SHOWER_SEC 0.5 0.5 Secondary
482set SplittingGenerator:Detuning 2.0
483"""
Configuration base class for Herwig7.
remnant_pdf_commands(self, name="MMHT2014lo68cl", member=0, max_flav=5)
Commands for setting the remnant PDF.
pdf_pomeron_cmds(self, flux, pdf)
Set pomeron structure function.
global_pre_commands(self)
Commands applied to all configuration classes before commands from the JobOptions.
add_commands(self, commands)
Add direct Herwig7 repository commands as they wo.
set_tune_scheme(self, tune_scheme="DotProduct")
printout_commands(self)
Sets printout verbosity and error tolerance.
shower_pdf_commands(self, order="LO", name="MMHT2014lo68cl", member=0, max_flav=5)
Commands for setting the PDF in the parton showers.
__init__(self, genSeq, runArgs, run_name="Herwig")
Constructor.
ue_tune_commands(self)
Commands for only setting the UE/MPI tune.
mpi_pdf_commands(self, name="MMHT2014lo68cl", member=0, max_flav=5)
Commands for setting the PDF in the underlying event (UE).
me_alphas_commands(self, order="NLO", scale=91.1876, value=0.118)
Commands for setting the strong coupling in the hard process.
enable_angularShowerScaleVariations(self, do_variations=False)
tune_commands(self)
Commands for setting PS/hadronization and UE/MPI tune simultaneously.
me_pdf_commands(self, order="NLO", name="MMHT2014nlo68cl", member=0, max_flav=5)
Commands for setting the PDF in the hard process.
beam_commands(self)
Commands specific to certain beam / collision types.
random_seed_commands(self)
Sets the seed for the random number generator.
energy_commands(self)
Sets center-of-mass energy sqrts(s) in GeV.
pdf_gammagamma_cmds(self)
Initialize Budnev Photon flux for two-photon exclusive exchange.
ps_tune_commands(self)
Commands for only setting the PS/hadronization tune.