9from .
import Herwig7Config
as hw7Config
10from .
import Herwig7Control
as hw7Control
11from .
import Herwig7Utils
as hw7Utils
13from AthenaCommon
import Logging
14athMsgLog = Logging.logging.getLogger(
'Herwig7ConfigMerging')
214 def __init__(self, genSeq, runArgs, run_name="Herwig", beams="pp"):
216 beams = beams.upper()
217 if beams
not in [
"EE",
"EP",
"PP"]:
218 raise RuntimeError(hw7Utils.ansi_format_error(
"Parameter 'beams' must be one of the following ['EE', 'EP', 'PP']!"))
221 super(Hw7ConfigMerging, self).
__init__(genSeq, runArgs, run_name)
230 MG5aMC_path = os.environ[
'MADPATH']
232 raise RuntimeError(
"MADPATH environment variable not set")
233 if not os.path.isfile(os.path.join(MG5aMC_path,
'bin',
'mg5_aMC')):
234 athMsgLog.warn(hw7Utils.ansi_format_warning(
"The MadGraph5_aMC@NLO installation can't be found from $MADPATH = {}, so don't be surprised if your run crashes in you are using matrix elements from MG5_aMC@NLO in Herwig7 / Matchbox. Please ensure that the location exists, that you have permissions to access it and that it contains the executable 'bin/mg5_aMC'".format(MG5aMC_path)))
237 OpenLoops_path= os.environ[
'OPENLOOPSPATH']
239 raise RuntimeError(
"OPENLOOPSPATH environment variable not set")
240 if not os.path.isdir(os.path.join(OpenLoops_path,
"proclib")):
241 athMsgLog.warn(hw7Utils.ansi_format_warning(
"The OpenLoops process libraries can't be found from $OPENLOOPSPATH = {}".format(OpenLoops_path)))
246## ================================================
247## Local Pre-Commands from Herwig7ConfigMerging.py
248## ================================================
250## Fixing interface locations for MadGraph
251set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
252set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
253set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
255##Fixing interface locations of Openloops
256set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {4}
257set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsPrefix {5}
259# Currently the Dipole Snippet is broken (reads to the Rivet interface which we don't build)
260# For now manually copy all the relevant settings in
261read snippets/DipoleMerging.in
262read snippets/{3}Collider.in
263read Merging/Merging-Dipole-FactorCMWSchemeTune.in
264read Merging/FactorCMWScheme.in
265""".format(hw7Control.herwig7_bin_path,
266 hw7Control.herwig7_share_path,
269 os.path.join(OpenLoops_path,
"proclib"),
275## =================================================
276## Local Post-Commands from Herwig7ConfigMerging.py
277## =================================================
279do /Herwig/Merging/MergingFactory:ProductionMode
280saverun {} /Herwig/Generators/EventGenerator
288 self.default_commands += self.energy_commands()
289 self.default_commands += self.random_seed_commands()
292 self.default_commands += self.printout_commands()
294 self.default_commands += self.physics_parameter_commands()
296 self.default_commands += self.technical_parameter_commands()
314 def run(self, integration_jobs=1, gridpack=None, cleanup_herwig_scratch=True):
319 hw7Control.matchbox_run_gridpack(self, integration_jobs, gridpack, cleanup_herwig_scratch)
321 hw7Control.matchbox_run(self, integration_jobs, cleanup_herwig_scratch)
335 hw7Control.do_build(self, integration_jobs)
336 hw7Control.do_abort()
341 hw7Control.do_integrate(self.
run_name, integration_job)
342 hw7Control.do_abort()
350 hw7Control.do_mergegrids(self.
run_name, integration_jobs)
352 hw7Control.do_compress_gridpack(self.
run_name, gridpack)
353 hw7Control.do_abort()
360 def do_run(self, gridpack=None, cleanup_herwig_scratch=True):
362 hw7Control.do_uncompress_gridpack(gridpack)
363 hw7Control.do_run(self, cleanup_herwig_scratch)
384 initial_points=10000, n_iterations=1, remapper_points=50000,
385 exploration_steps=4, exploration_points=500):
387 bin_samplers = [
"CellGridSampler",
"MonacoSampler",
"FlatBinSampler"]
389 if bin_sampler
not in bin_samplers:
390 raise RuntimeError(hw7Utils.ansi_format_error(
"Parameter 'bin_sampler' must be one of {}!".format(bin_samplers)))
393## Sampler Configuration
394set /Herwig/Samplers/Sampler:BinSampler /Herwig/Samplers/{}
395set /Herwig/Samplers/Sampler:BinSampler:InitialPoints {}
396set /Herwig/Samplers/Sampler:BinSampler:NIterations {}
397set /Herwig/Samplers/Sampler:BinSampler:RemapperPoints {}
398""".format(bin_sampler, initial_points, n_iterations, remapper_points)
400 if bin_sampler ==
"CellGridSampler":
402set /Herwig/Samplers/CellGridSampler:ExplorationSteps {}
403set /Herwig/Samplers/CellGridSampler:ExplorationPoints {}
404""".format(exploration_steps, exploration_points)
406 if bin_sampler ==
"MonacoSampler":
408read snippets/MonacoSampler.in"""
411 if onlyColoured
not in [
"Yes",
"No"]:
412 raise RuntimeError(hw7Utils.ansi_format_error(
"OnlyColoured must be Yes or No"))
415##Merging Weighter for better phase space coverage
416set /Herwig/Merging/MPreWeight:HTPower {}
417set /Herwig/Merging/MPreWeight:MaxPTPower {}
418set /Herwig/Merging/MPreWeight:OnlyColoured {}
419""".format(htPower,maxPtPower,onlyColoured)
Configuration class for Matchbox runs with Herwig7.
local_post_commands(self)
merging_weight(self, htPower=0, maxPtPower=0, onlyColoured="No")
do_integrate(self, integration_job)
Atomic steering function for doing one specific integration job.
sampler_commands(self, bin_sampler="CellGridSampler", initial_points=10000, n_iterations=1, remapper_points=50000, exploration_steps=4, exploration_points=500)
Configure the sampler.
set_technical_parameter_commands
beams
provide variables initialized by the parent class
do_build(self, integration_jobs)
Atomic steering function for doing the build step alone.
do_mergegrids(self, integration_jobs, gridpack=None)
Atomic steering function for combining the integration grids and possibly creating a gridpack.
do_run(self, gridpack=None, cleanup_herwig_scratch=True)
Atomic steering function for possibly unpacking a gridpack and generating events.
__init__(self, genSeq, runArgs, run_name="Herwig", beams="pp")
Initialize a generator configuration object for the Matchbox run mode.
set_physics_parameter_commands