9 from .
import Herwig7Config
as hw7Config
10 from .
import Herwig7Control
as hw7Control
11 from .
import Herwig7Utils
as hw7Utils
13 from AthenaCommon
import Logging
14 athMsgLog = 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
251 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
252 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
253 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
255 ##Fixing interface locations of Openloops
256 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {4}
257 set /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
261 read snippets/DipoleMerging.in
262 read snippets/{3}Collider.in
263 read Merging/Merging-Dipole-FactorCMWSchemeTune.in
264 read 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 ## =================================================
279 do /Herwig/Merging/MergingFactory:ProductionMode
280 saverun {} /Herwig/Generators/EventGenerator
288 self.default_commands += self.energy_commands()
289 self.default_commands += self.random_seed_commands()
291 if not self.set_printout_commands:
292 self.default_commands += self.printout_commands()
293 if not self.set_physics_parameter_commands:
294 self.default_commands += self.physics_parameter_commands()
295 if not self.set_technical_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
394 set /Herwig/Samplers/Sampler:BinSampler /Herwig/Samplers/{}
395 set /Herwig/Samplers/Sampler:BinSampler:InitialPoints {}
396 set /Herwig/Samplers/Sampler:BinSampler:NIterations {}
397 set /Herwig/Samplers/Sampler:BinSampler:RemapperPoints {}
398 """.
format(bin_sampler, initial_points, n_iterations, remapper_points)
400 if bin_sampler ==
"CellGridSampler":
402 set /Herwig/Samplers/CellGridSampler:ExplorationSteps {}
403 set /Herwig/Samplers/CellGridSampler:ExplorationPoints {}
404 """.
format(exploration_steps, exploration_points)
406 if bin_sampler ==
"MonacoSampler":
408 read 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
416 set /Herwig/Merging/MPreWeight:HTPower {}
417 set /Herwig/Merging/MPreWeight:MaxPTPower {}
418 set /Herwig/Merging/MPreWeight:OnlyColoured {}
419 """.
format(htPower,maxPtPower,onlyColoured)