10 from .
import Herwig7Config
as hw7Config
11 from .
import Herwig7Control
as hw7Control
12 from .
import Herwig7Utils
as hw7Utils
14 from AthenaCommon
import Logging
15 athMsgLog = 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
250 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
251 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
252 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
254 ##Fixing interface locations of Openloops
255 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {3}
256 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsPrefix {4}
258 read snippets/Matchbox.in
259 read 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 ## =================================================
274 do /Herwig/MatrixElements/Matchbox/Factory:ProductionMode
275 saverun {} /Herwig/Generators/EventGenerator
283 self.default_commands += self.energy_commands()
284 self.default_commands += self.random_seed_commands()
286 if not self.set_printout_commands:
287 self.default_commands += self.printout_commands()
288 if not self.set_physics_parameter_commands:
289 self.default_commands += self.physics_parameter_commands()
290 if not self.set_technical_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 ##################################################
391 set /Herwig/Samplers/Sampler:BinSampler /Herwig/Samplers/{}
392 set /Herwig/Samplers/Sampler:BinSampler:InitialPoints {}
393 set /Herwig/Samplers/Sampler:BinSampler:NIterations {}
394 set /Herwig/Samplers/Sampler:BinSampler:RemapperPoints {}
395 set /Herwig/Samplers/Sampler:BinSampler:Alpha {}
396 set /Herwig/Samplers/Sampler:BinSampler:GridDivisions {}
397 """.
format(bin_sampler, initial_points, n_iterations, remapper_points, alpha, grid_divisions)
399 if bin_sampler ==
"CellGridSampler":
401 set /Herwig/Samplers/CellGridSampler:ExplorationSteps {}
402 set /Herwig/Samplers/CellGridSampler:ExplorationPoints {}
403 """.
format(exploration_steps, exploration_points)