10from .
import Herwig7Config
as hw7Config
11from .
import Herwig7Control
as hw7Control
12from .
import Herwig7Utils
as hw7Utils
14from AthenaCommon
import Logging
15athMsgLog = Logging.logging.getLogger(
'Herwig7ConfigMatchbox')
215 def __init__(self, genSeq, runArgs, run_name="Herwig", beams="pp"):
217 beams = beams.upper()
218 if beams
not in [
"EE",
"EP",
"PP"]:
219 raise RuntimeError(hw7Utils.ansi_format_error(
"Parameter 'beams' must be one of the following ['EE', 'EP', 'PP']!"))
222 super(Hw7ConfigMatchbox, self).
__init__(genSeq, runArgs, run_name)
231 MG5aMC_path = os.environ[
'MADPATH']
233 raise RuntimeError(
"MADPATH environment variable not set")
234 if not os.path.isfile(os.path.join(MG5aMC_path,
'bin',
'mg5_aMC')):
235 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)))
238 OpenLoops_path= os.environ[
'OPENLOOPSPATH']
240 raise RuntimeError(
"OPENLOOPSPATH environment variable not set")
241 if not os.path.isdir(os.path.join(OpenLoops_path,
"proclib")):
242 athMsgLog.warn(hw7Utils.ansi_format_warning(
"The OpenLoops process libraries can't be found from $OPENLOOPS_PATH = {}".format(OpenLoops_path)))
245## ================================================
246## Local Pre-Commands from Herwig7ConfigMatchbox.py
247## ================================================
249## Fixing interface locations for MadGraph
250set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
251set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
252set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
254##Fixing interface locations of Openloops
255set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {3}
256set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsPrefix {4}
258read snippets/Matchbox.in
259read snippets/{4}Collider.in
260""".format(hw7Control.herwig7_bin_path,
261 hw7Control.herwig7_share_path,
263 os.path.join(OpenLoops_path,
"proclib"),
270## =================================================
271## Local Post-Commands from Herwig7ConfigMatchbox.py
272## =================================================
274do /Herwig/MatrixElements/Matchbox/Factory:ProductionMode
275saverun {} /Herwig/Generators/EventGenerator
283 self.default_commands += self.energy_commands()
284 self.default_commands += self.random_seed_commands()
287 self.default_commands += self.printout_commands()
289 self.default_commands += self.physics_parameter_commands()
291 self.default_commands += self.technical_parameter_commands()
309 def run(self, integration_jobs=1, gridpack=None, cleanup_herwig_scratch=True, integrate=False):
314 hw7Control.matchbox_run_gridpack(self, integration_jobs, gridpack, cleanup_herwig_scratch, integrate)
316 hw7Control.matchbox_run(self, integration_jobs, cleanup_herwig_scratch)
330 hw7Control.do_build(self, integration_jobs)
331 hw7Control.do_abort()
336 hw7Control.do_integrate(self.
run_name, integration_job)
337 hw7Control.do_abort()
345 hw7Control.do_mergegrids(self.
run_name, integration_jobs)
347 hw7Control.do_compress_gridpack(self.
run_name, gridpack)
348 hw7Control.do_abort()
355 def do_run(self, gridpack=None, cleanup_herwig_scratch=True):
357 hw7Control.do_uncompress_gridpack(gridpack)
358 hw7Control.do_run(self, cleanup_herwig_scratch)
379 initial_points=10000, n_iterations=1, remapper_points=50000,
380 exploration_steps=4, exploration_points=500, alpha=0.8, grid_divisions=48):
382 bin_samplers = [
"CellGridSampler",
"MonacoSampler",
"FlatBinSampler"]
384 if bin_sampler
not in bin_samplers:
385 raise RuntimeError(hw7Utils.ansi_format_error(
"Parameter 'bin_sampler' must be one of {}!".format(bin_samplers)))
388##################################################
389## Sampler Configuration
390##################################################
391set /Herwig/Samplers/Sampler:BinSampler /Herwig/Samplers/{}
392set /Herwig/Samplers/Sampler:BinSampler:InitialPoints {}
393set /Herwig/Samplers/Sampler:BinSampler:NIterations {}
394set /Herwig/Samplers/Sampler:BinSampler:RemapperPoints {}
395set /Herwig/Samplers/Sampler:BinSampler:Alpha {}
396set /Herwig/Samplers/Sampler:BinSampler:GridDivisions {}
397""".format(bin_sampler, initial_points, n_iterations, remapper_points, alpha, grid_divisions)
399 if bin_sampler ==
"CellGridSampler":
401set /Herwig/Samplers/CellGridSampler:ExplorationSteps {}
402set /Herwig/Samplers/CellGridSampler:ExplorationPoints {}
403""".format(exploration_steps, exploration_points)
Configuration class for Matchbox runs with Herwig7.
set_technical_parameter_commands
do_run(self, gridpack=None, cleanup_herwig_scratch=True)
Atomic steering function for possibly unpacking a gridpack and generating events.
do_build(self, integration_jobs)
Atomic steering function for doing the build step alone.
__init__(self, genSeq, runArgs, run_name="Herwig", beams="pp")
Initialize a generator configuration object for the Matchbox run mode.
sampler_commands(self, bin_sampler="CellGridSampler", initial_points=10000, n_iterations=1, remapper_points=50000, exploration_steps=4, exploration_points=500, alpha=0.8, grid_divisions=48)
Configure the sampler.
local_post_commands(self)
do_integrate(self, integration_job)
Atomic steering function for doing one specific integration job.
do_mergegrids(self, integration_jobs, gridpack=None)
Atomic steering function for combining the integration grids and possibly creating a gridpack.
set_physics_parameter_commands
beams
provide variables initialized by the parent class