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)))
238 GoSam_path = os.environ[
'GOSAM_PATH']
240 raise RuntimeError(
"GOSAM_PATH environment variable not set")
241 if not os.path.isfile(os.path.join(GoSam_path,
'bin',
'gosam.py')):
242 athMsgLog.warn(hw7Utils.ansi_format_warning(
"The GoSam installation can't be found from $GOSAMPATH = {}, so don't be surprised if your run crashes in you are using matrix elements from GoSam in Herwig7 / Matchbox. Please ensure that the location exists, that you have permissions to access it and that it contains the script 'bin/gosam.py'".
format(GoSam_path)))
245 OpenLoops_path= os.environ[
'OPENLOOPSPATH']
247 raise RuntimeError(
"OPENLOOPSPATH environment variable not set")
248 if not os.path.isdir(os.path.join(OpenLoops_path,
"proclib")):
249 athMsgLog.warn(hw7Utils.ansi_format_warning(
"The OpenLoops process libraries can't be found from $OPENLOOPSPATH = {}".
format(OpenLoops_path)))
254 ## ================================================
255 ## Local Pre-Commands from Herwig7ConfigMerging.py
256 ## ================================================
258 ## Fixing interface locations for MadGraph
259 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
260 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
261 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
263 ## Fixing interface locations for GoSam
264 set /Herwig/MatrixElements/Matchbox/Amplitudes/GoSam:BinDir {0}
265 set /Herwig/MatrixElements/Matchbox/Amplitudes/GoSam:DataDir {1}
266 set /Herwig/MatrixElements/Matchbox/Amplitudes/GoSam:GoSamPrefix {3}
268 ##Fixing interface locations of Openloops
269 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {5}
270 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsPrefix {6}
272 # Currently the Dipole Snippet is broken (reads to the Rivet interface which we don't build)
273 # For now manually copy all the relevant settings in
274 read snippets/DipoleMerging.in
275 read snippets/{4}Collider.in
276 read Merging/Merging-Dipole-FactorCMWSchemeTune.in
277 read Merging/FactorCMWScheme.in
278 """.
format(hw7Control.herwig7_bin_path,
279 hw7Control.herwig7_share_path,
283 os.path.join(OpenLoops_path,
"proclib"),
289 ## =================================================
290 ## Local Post-Commands from Herwig7ConfigMerging.py
291 ## =================================================
293 do /Herwig/Merging/MergingFactory:ProductionMode
294 saverun {} /Herwig/Generators/EventGenerator
302 self.default_commands += self.energy_commands()
303 self.default_commands += self.random_seed_commands()
305 if not self.set_printout_commands:
306 self.default_commands += self.printout_commands()
307 if not self.set_physics_parameter_commands:
308 self.default_commands += self.physics_parameter_commands()
309 if not self.set_technical_parameter_commands:
310 self.default_commands += self.technical_parameter_commands()
328 def run(self, integration_jobs=1, gridpack=None, cleanup_herwig_scratch=True):
333 hw7Control.matchbox_run_gridpack(self, integration_jobs, gridpack, cleanup_herwig_scratch)
335 hw7Control.matchbox_run(self, integration_jobs, cleanup_herwig_scratch)
349 hw7Control.do_build(self, integration_jobs)
350 hw7Control.do_abort()
355 hw7Control.do_integrate(self.run_name, integration_job)
356 hw7Control.do_abort()
364 hw7Control.do_mergegrids(self.run_name, integration_jobs)
366 hw7Control.do_compress_gridpack(self.run_name, gridpack)
367 hw7Control.do_abort()
374 def do_run(self, gridpack=None, cleanup_herwig_scratch=True):
376 hw7Control.do_uncompress_gridpack(gridpack)
377 hw7Control.do_run(self, cleanup_herwig_scratch)
398 initial_points=10000, n_iterations=1, remapper_points=50000,
399 exploration_steps=4, exploration_points=500):
401 bin_samplers = [
"CellGridSampler",
"MonacoSampler",
"FlatBinSampler"]
403 if bin_sampler
not in bin_samplers:
404 raise RuntimeError(hw7Utils.ansi_format_error(
"Parameter 'bin_sampler' must be one of {}!".
format(bin_samplers)))
407 ## Sampler Configuration
408 set /Herwig/Samplers/Sampler:BinSampler /Herwig/Samplers/{}
409 set /Herwig/Samplers/Sampler:BinSampler:InitialPoints {}
410 set /Herwig/Samplers/Sampler:BinSampler:NIterations {}
411 set /Herwig/Samplers/Sampler:BinSampler:RemapperPoints {}
412 """.
format(bin_sampler, initial_points, n_iterations, remapper_points)
414 if bin_sampler ==
"CellGridSampler":
416 set /Herwig/Samplers/CellGridSampler:ExplorationSteps {}
417 set /Herwig/Samplers/CellGridSampler:ExplorationPoints {}
418 """.
format(exploration_steps, exploration_points)
420 if bin_sampler ==
"MonacoSampler":
422 read snippets/MonacoSampler.in"""
425 if onlyColoured
not in [
"Yes",
"No"]:
426 raise RuntimeError(hw7Utils.ansi_format_error(
"OnlyColoured must be Yes or No"))
429 ##Merging Weighter for better phase space coverage
430 set /Herwig/Merging/MPreWeight:HTPower {}
431 set /Herwig/Merging/MPreWeight:MaxPTPower {}
432 set /Herwig/Merging/MPreWeight:OnlyColoured {}
433 """.
format(htPower,maxPtPower,onlyColoured)