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)))
239 GoSam_path = os.environ[
'GOSAM_PATH']
241 raise RuntimeError(
"GOSAM_PATH environment variable not set")
242 if not os.path.isfile(os.path.join(GoSam_path,
'bin',
'gosam.py')):
243 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)))
246 OpenLoops_path= os.environ[
'OPENLOOPSPATH']
248 raise RuntimeError(
"OPENLOOPSPATH environment variable not set")
249 if not os.path.isdir(os.path.join(OpenLoops_path,
"proclib")):
250 athMsgLog.warn(hw7Utils.ansi_format_warning(
"The OpenLoops process libraries can't be found from $OPENLOOPS_PATH = {}".
format(OpenLoops_path)))
253 ## ================================================
254 ## Local Pre-Commands from Herwig7ConfigMatchbox.py
255 ## ================================================
257 ## Fixing interface locations for MadGraph
258 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
259 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
260 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
262 ## Fixing interface locations for GoSam
263 set /Herwig/MatrixElements/Matchbox/Amplitudes/GoSam:BinDir {0}
264 set /Herwig/MatrixElements/Matchbox/Amplitudes/GoSam:DataDir {1}
265 set /Herwig/MatrixElements/Matchbox/Amplitudes/GoSam:GoSamPrefix {3}
267 ##Fixing interface locations of Openloops
268 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {5}
269 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsPrefix {6}
271 read snippets/Matchbox.in
272 read snippets/{4}Collider.in
273 """.
format(hw7Control.herwig7_bin_path,
274 hw7Control.herwig7_share_path,
278 os.path.join(OpenLoops_path,
"proclib"),
285 ## =================================================
286 ## Local Post-Commands from Herwig7ConfigMatchbox.py
287 ## =================================================
289 do /Herwig/MatrixElements/Matchbox/Factory:ProductionMode
290 saverun {} /Herwig/Generators/EventGenerator
298 self.default_commands += self.energy_commands()
299 self.default_commands += self.random_seed_commands()
301 if not self.set_printout_commands:
302 self.default_commands += self.printout_commands()
303 if not self.set_physics_parameter_commands:
304 self.default_commands += self.physics_parameter_commands()
305 if not self.set_technical_parameter_commands:
306 self.default_commands += self.technical_parameter_commands()
324 def run(self, integration_jobs=1, gridpack=None, cleanup_herwig_scratch=True, integrate=False):
329 hw7Control.matchbox_run_gridpack(self, integration_jobs, gridpack, cleanup_herwig_scratch, integrate)
331 hw7Control.matchbox_run(self, integration_jobs, cleanup_herwig_scratch)
345 hw7Control.do_build(self, integration_jobs)
346 hw7Control.do_abort()
351 hw7Control.do_integrate(self.run_name, integration_job)
352 hw7Control.do_abort()
360 hw7Control.do_mergegrids(self.run_name, integration_jobs)
362 hw7Control.do_compress_gridpack(self.run_name, gridpack)
363 hw7Control.do_abort()
370 def do_run(self, gridpack=None, cleanup_herwig_scratch=True):
372 hw7Control.do_uncompress_gridpack(gridpack)
373 hw7Control.do_run(self, cleanup_herwig_scratch)
394 initial_points=10000, n_iterations=1, remapper_points=50000,
395 exploration_steps=4, exploration_points=500, alpha=0.8, grid_divisions=48):
397 bin_samplers = [
"CellGridSampler",
"MonacoSampler",
"FlatBinSampler"]
399 if bin_sampler
not in bin_samplers:
400 raise RuntimeError(hw7Utils.ansi_format_error(
"Parameter 'bin_sampler' must be one of {}!".
format(bin_samplers)))
403 ##################################################
404 ## Sampler Configuration
405 ##################################################
406 set /Herwig/Samplers/Sampler:BinSampler /Herwig/Samplers/{}
407 set /Herwig/Samplers/Sampler:BinSampler:InitialPoints {}
408 set /Herwig/Samplers/Sampler:BinSampler:NIterations {}
409 set /Herwig/Samplers/Sampler:BinSampler:RemapperPoints {}
410 set /Herwig/Samplers/Sampler:BinSampler:Alpha {}
411 set /Herwig/Samplers/Sampler:BinSampler:GridDivisions {}
412 """.
format(bin_sampler, initial_points, n_iterations, remapper_points, alpha, grid_divisions)
414 if bin_sampler ==
"CellGridSampler":
416 set /Herwig/Samplers/CellGridSampler:ExplorationSteps {}
417 set /Herwig/Samplers/CellGridSampler:ExplorationPoints {}
418 """.
format(exploration_steps, exploration_points)