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
38 self.default_commands = hw7Utils.ConfigurationCommands()
39 self.commands = hw7Utils.ConfigurationCommands()
40
41
44 return """
45## =========================================
46## Global Pre-Commands from Herwig7Config.py
47## =========================================
48
49## ensure JetFinder uses AntiKt with R=0.4
50set /Herwig/Cuts/JetFinder:Variant AntiKt
51set /Herwig/Cuts/JetFinder:ConeRadius 0.4
52"""
53
54
55
56 def add_commands(self, commands):
57
58 self.commands += commands
59
60
61
63
64 return("""
65## Random number generator seed
66set /Herwig/Random:Seed {}
67""".format(self.runArgs.randomSeed))
68
69
70 def beam_commands(self):
71
72 if self.beams == "EE":
73 return("""
74## Commands for lepton-lepton collisions
75read snippets/EECollider.in
76set /Herwig/Shower/PartnerFinder:QEDPartner IIandFF
77set /Herwig/Shower/ShowerHandler:MPIHandler NULL
78set /Herwig/DipoleShower/DipoleShowerHandler:MPIHandler NULL
79set /Herwig/Shower/PowhegShowerHandler:MPIHandler NULL
80""")
81 elif self.beams == "EP":
82 return("""
83## Commands for proton-lepton collisions
84read snippets/EPCollider.in
85do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting e-->e-,gamma; /Herwig/Shower/LtoLGammaSudakov
86do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting mu-->mu-,gamma; /Herwig/Shower/LtoLGammaSudakov
87do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting tau-->tau-,gamma; /Herwig/Shower/LtoLGammaSudakov
88set /Herwig/Shower/KinematicsReconstructor:ReconstructionOption Colour
89""")
90 else:
91 return("""
92## Commands for proton-proton collisions
93read snippets/PPCollider.in
94""")
95
96
108
109 return("""
110## Center-of-mass energy
111set /Herwig/Generators/EventGenerator:EventHandler:LuminosityFunction:Energy {}
112""".format(self.runArgs.ecmEnergy))
113
114
115
117
118 self.set_printout_commands = True
119
120 return("""
121
122## Verbosity and printout settings
123set /Herwig/Generators/EventGenerator:DebugLevel 1
124set /Herwig/Generators/EventGenerator:PrintEvent 2
125set /Herwig/Generators/EventGenerator:UseStdout Yes
126set /Herwig/Generators/EventGenerator:NumberOfEvents 1000000000
127set /Herwig/Generators/EventGenerator:MaxErrors 500
128
129## Make sampler print out cross sections for each subprocess
130set /Herwig/Samplers/Sampler:Verbose Yes
131""")
132
133
137
140
141 return("""
142## Masses and widths: PDG 2010 values (except TOP mass; kept at PDG2007)
143
144## top-quark
145set /Herwig/Particles/t:NominalMass 172.5*GeV
146set /Herwig/Particles/tbar:NominalMass 172.5*GeV
147## W boson
148set /Herwig/Particles/W+:NominalMass 80.399*GeV
149set /Herwig/Particles/W-:NominalMass 80.399*GeV
150set /Herwig/Particles/W+:Width 2.085*GeV
151set /Herwig/Particles/W-:Width 2.085*GeV
152## Z boson
153set /Herwig/Particles/Z0:NominalMass 91.1876*GeV
154set /Herwig/Particles/Z0:Width 2.4952*GeV
155## b quark
156set /Herwig/Particles/b:NominalMass 4.95*GeV
157set /Herwig/Particles/bbar:NominalMass 4.95*GeV
158
159## Weinberg angle
160set /Herwig/Model:EW/Sin2ThetaW 0.23113
161""")
162
164
166
167 return("""
168## Disable default attempts to use Pomeron PDF data files, until we're worked how to do that on the Grid!
169set /Herwig/Particles/pomeron:PDF /Herwig/Partons/NoPDF
170
171## Set long-lived particles stable
172set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
173""")
174
175
176
177
186 def me_alphas_commands(self, order="NLO", scale=91.1876, value=0.118):
187
188 if order not in ["LO", "NLO"]:
189 raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'order' must either be 'LO' or 'NLO'!"))
190
191 self.commands += """
192## Configure {0} AlphaS for the hard process
193## (LO: 1-loop-running / NLO: 2-loop running)
194set /Herwig/Couplings/{0}AlphaS:input_scale {1}
195set /Herwig/Couplings/{0}AlphaS:input_alpha_s {2}
196set /Herwig/Model:QCD/RunningAlphaS /Herwig/Couplings/{0}AlphaS
197""".format(order, scale, value)
198
199
200
206 def me_pdf_commands(self, order="NLO", name="MMHT2014nlo68cl", member=0, max_flav=5):
207
208 if order not in ["LO", "NLO"]:
209 raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'order' must either be 'LO' or 'NLO'!"))
210
211 self.me_pdf_name = name
212
213 self.commands += """
214## Configure {0} PDF set for the hard process
215set /Herwig/Partons/Hard{0}PDF:PDFName {1}
216set /Herwig/Partons/Hard{0}PDF:Member {2}
217set /Herwig/Partons/Hard{0}PDF:MaxFlav {3}
218set /Herwig/Partons/Hard{0}PDF:RemnantHandler /Herwig/Partons/HadronRemnants
219set /Herwig/Particles/p+:PDF /Herwig/Partons/Hard{0}PDF
220set /Herwig/Particles/pbar-:PDF /Herwig/Partons/Hard{0}PDF
221set /Herwig/Partons/PPExtractor:FirstPDF /Herwig/Partons/Hard{0}PDF
222set /Herwig/Partons/PPExtractor:SecondPDF /Herwig/Partons/Hard{0}PDF
223""".format(order, name, member, max_flav)
224
225
226
232 def shower_pdf_commands(self, order="LO", name="MMHT2014lo68cl", member=0, max_flav=5):
233
234 if order not in ["LO", "NLO"]:
235 raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'order' must either be 'LO' or 'NLO'!"))
236
237
239
240 self.commands += """
241## Configure {0} PDF set for the parton shower
242set /Herwig/Partons/Shower{0}PDF:PDFName {1}
243set /Herwig/Partons/Shower{0}PDF:Member {2}
244set /Herwig/Partons/Shower{0}PDF:MaxFlav {3}
245set /Herwig/Shower/ShowerHandler:PDFA /Herwig/Partons/Shower{0}PDF
246set /Herwig/Shower/ShowerHandler:PDFB /Herwig/Partons/Shower{0}PDF
247set /Herwig/Shower/PowhegShowerHandler:PDFA /Herwig/Partons/Shower{0}PDF
248set /Herwig/Shower/PowhegShowerHandler:PDFB /Herwig/Partons/Shower{0}PDF
249set /Herwig/DipoleShower/DipoleShowerHandler:PDFA /Herwig/Partons/Shower{0}PDF
250set /Herwig/DipoleShower/DipoleShowerHandler:PDFB /Herwig/Partons/Shower{0}PDF
251""".format(order, name, member, max_flav)
252
253
254
259 def mpi_pdf_commands(self, name="MMHT2014lo68cl", member=0, max_flav=5):
260
261 self.mpi_pdf_name = name
262
263 self.commands += """
264## Configure MPI PDF
265set /Herwig/Partons/MPIPDF:PDFName {}
266set /Herwig/Partons/MPIPDF:Member {}
267set /Herwig/Partons/MPIPDF:MaxFlav {}
268""".format(name, member, max_flav)
269
270
271
276 def remnant_pdf_commands(self, name="MMHT2014lo68cl", member=0, max_flav=5):
277
278 self.commands += """
279## Configure Remnant PDF
280set /Herwig/Partons/RemnantPDF:PDFName {}
281set /Herwig/Partons/RemnantPDF:Member {}
282set /Herwig/Partons/RemnantPDF:MaxFlav {}
283""".format(name, member, max_flav)
284
285
286
287
290 def tune_commands(self):
291
292 cmds = """
293## -------------
294## Tune Settings
295## -------------
296"""
297 self.commands += cmds
298
299
300
304
305 cmds = """
306## Parton shower / hadronization tune settings
307"""
308
309 self.commands += cmds
310
311
312 def load_PS_tune(self):
313
314 return """
315## some commands
316"""
317
318
319
323
324 cmds = """
325## Underlying event tune settings
326"""
327
328 self.commands += cmds
329
330
331 def load_ue_tune(self):
332
333 return """
334## some commands
335"""
336
337
338 def get_dpdf_path(self):
339 import os
340 cmt_path = os.environ.get("CMAKE_PREFIX_PATH")
341 cmt_dir = os.environ.get("BINARY_TAG")
342
343 cmtPaths = cmt_path.split(':')
344
345 for path in cmtPaths:
346 pathNow = path + "/InstallArea/" + cmt_dir + "/share/"
347 try:
348 fileList = os.listdir(pathNow)
349 except Exception:
350 fileList = []
351 if "HerwigDefaults.rpo" in fileList:
352 simSharePath = pathNow
353
354 dpdf_path = os.path.dirname(os.path.normpath(os.path.join(simSharePath, os.readlink(simSharePath + 'HerwigDefaults.rpo')))) + "/PDF/diffraction/"
355
356 return dpdf_path
357
358
359
360 def pdf_pomeron_cmds(self, flux, pdf):
361
362 dpdf_path = self.get_dpdf_path()
363
364 cmds = "\n"
365 cmds += "set /Herwig/Partons/PomeronPDF:RootName %s\n" % dpdf_path
366 cmds += "set /Herwig/Partons/PomeronFlux:PDFFit %s\n" % flux
367 cmds += "set /Herwig/Partons/PomeronPDF:PDFFit %s\n" % pdf
368
369 cmds += """\
370set /Herwig/Particles/pomeron:PDF /Herwig/Partons/PomeronPDF
371
372# Technical parameters for this run
373set /Herwig/Generators/EventGenerator:EventHandler:Sampler:Ntry 100000
374set /Herwig/Generators/EventGenerator:MaxErrors 500
375
376# MPI doesn't work
377# TODO: Is this a problem?
378set /Herwig/Generators/EventGenerator:EventHandler:CascadeHandler:MPIHandler NULL
379
380# Choice of phase-space generation for PDFs
381set /Herwig/Partons/PPExtractor:FlatSHatY 0
382
383"""
384 return cmds
385
386
387
390
391 return """
392
393# Technical parameters for this run
394set /Herwig/Generators/EventGenerator:EventHandler:Sampler:Ntry 100000
395
396# Choice of phase-space generation for PDFs
397set /Herwig/Partons/PPExtractor:FlatSHatY 0
398
399# Change the proton PDFs to those for photon radiation
400set /Herwig/Particles/p+:PDF /Herwig/Partons/BudnevPDF
401set /Herwig/Particles/pbar-:PDF /Herwig/Partons/BudnevPDF
402
403# MPI doesn't work
404# TODO: Is this a problem?
405set /Herwig/Generators/EventGenerator:EventHandler:CascadeHandler:MPIHandler NULL
406
407"""
408
409 # Set the tune schemes for the new angular ordering of the shower
410 def set_tune_scheme(self, tune_scheme="DotProduct"):
411 tune_schemes = ["DotProduct-Veto","DotProduct","pT","Q2"]
412 if tune_scheme not in tune_schemes:
413 athMsgLog.warn("Please choose one of the supported tune-schemes! (DotProduct-Veto,DotProduct,pT,Q2)")
414 else:
415 athMsgLog.info("{tune_scheme:s} was used for the tune scheme.".format(tune_scheme=tune_scheme))
416 # create a tune-section in the config
417 self.commands += """\
418\n## -------------
419## Tune Settings
420## -------------
421
422# Tune-{tune_scheme:s}
423read snippets/EvolutionScheme-{tune_scheme:s}.in
424read snippets/Tune-{tune_scheme:s}.in
425""".format(tune_scheme=tune_scheme)
426
427 # Add the commands for enabling shower scale variations
428 def enable_angularShowerScaleVariations(self, do_variations=False):
429 if do_variations:
430 self.commands += """\
431\n## -----------------------
432## Shower scale variation
433## -----------------------
434cd /Herwig/Shower
435do ShowerHandler:AddVariation MUR2_MUF2_SHOWER_HARD 2 2 Hard
436do ShowerHandler:AddVariation MUR2_MUF1_SHOWER_HARD 2 1 Hard
437do ShowerHandler:AddVariation MUR1_MUF2_SHOWER_HARD 1 2 Hard
438do ShowerHandler:AddVariation MUR1_MUF0.5_SHOWER_HARD 1 0.5 Hard
439do ShowerHandler:AddVariation MUR0.5_MUF1_SHOWER_HARD 0.5 1 Hard
440do ShowerHandler:AddVariation MUR0.5_MUF0.5_SHOWER_HARD 0.5 0.5 Hard
441do ShowerHandler:AddVariation MUR2_MUF2_SHOWER_SEC 2 2 Secondary
442do ShowerHandler:AddVariation MUR2_MUF1_SHOWER_SEC 2 1 Secondary
443do ShowerHandler:AddVariation MUR1_MUF2_SHOWER_SEC 1 2 Secondary
444do ShowerHandler:AddVariation MUR1_MUF0.5_SHOWER_SEC 1 0.5 Secondary
445do ShowerHandler:AddVariation MUR0.5_MUF1_SHOWER_SEC 0.5 1 Secondary
446do ShowerHandler:AddVariation MUR0.5_MUF0.5_SHOWER_SEC 0.5 0.5 Secondary
447set SplittingGenerator:Detuning 2.0
448"""
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.