|
ATLAS Offline Software
|
|
def | get_share_path () |
| Get path to the share/Herwig folder. More...
|
|
def | run (gen_config) |
| Do the read/run sequence. More...
|
|
def | matchbox_run (gen_config, integration_jobs, cleanup_herwig_scratch) |
| Do the build, integrate, mergegrids and run step in one go without creating a gridpack. More...
|
|
def | matchbox_run_gridpack (gen_config, integration_jobs, gridpack_name, cleanup_herwig_scratch, integrate) |
| Either do the build, integrate and mergegrids steps and create a gridpack or extract it and generate events from it. More...
|
|
def | do_step (step, command, logfile_name=None) |
|
def | do_abort () |
|
def | do_read (gen_config) |
| Do the read step. More...
|
|
def | do_read_existing_infile (gen_config) |
| Do the read step and re-use an already existing infile. More...
|
|
def | do_build (gen_config, integration_jobs) |
| Do the build step. More...
|
|
def | do_integrate (run_name, integration_job) |
| Do the integrate step for one specific integration job. More...
|
|
def | do_mergegrids (run_name, integration_jobs) |
| This function provides the mergegrids step. More...
|
|
def | do_build_integrate_mergegrids (gen_config, integration_jobs) |
| Subsequent build, integrate and mergegrid steps. More...
|
|
def | do_compress_gridpack (run_name, gridpack_name) |
|
def | do_uncompress_gridpack (gridpack_name) |
|
def | do_run (gen_config, cleanup_herwig_scratch=True) |
|
def | do_run_existing_runfile (gen_config) |
| Do the run step and re-use an already existing runfile. More...
|
|
def | herwig_version () |
|
def | thepeg_version () |
|
def | start_banner () |
|
def | get_software_versions () |
|
def | get_infile_name (run_name="Herwig-Matchbox") |
|
def | get_setupfile_name (run_name="Herwig-Matchbox") |
|
def | get_runfile_name (run_name="Herwig-Matchbox") |
|
def | write_infile (gen_config, print_infile=True) |
|
def | write_setupfile (run_name, commands, print_setupfile=True) |
|
def | get_default_repository () |
| Copy default repository HerwigDefaults.rpo to current working directory. More...
|
|
def | log (level='info', message='') |
|
def | exit_banner (gridpack, cross_section, cross_section_error) |
|
◆ do_abort()
def Herwig7Control.do_abort |
( |
| ) |
|
Definition at line 142 of file Herwig7Control.py.
143 athMsgLog.info(hw7Utils.ansi_format_info(
"Doing abort"))
◆ do_build()
def Herwig7Control.do_build |
( |
|
gen_config, |
|
|
|
integration_jobs |
|
) |
| |
◆ do_build_integrate_mergegrids()
def Herwig7Control.do_build_integrate_mergegrids |
( |
|
gen_config, |
|
|
|
integration_jobs |
|
) |
| |
Subsequent build, integrate and mergegrid steps.
Definition at line 224 of file Herwig7Control.py.
227 do_build(gen_config, integration_jobs)
232 athMsgLog.info(hw7Utils.ansi_format_info(
'Starting integration with {} jobs'.
format(integration_jobs)))
234 integration_procs = []
235 for integration_job
in range(integration_jobs):
236 integrate_log = gen_config.run_name+
'.integrate'+
str(integration_job)+
'.log'
237 integrate_command = [herwig7_binary,
'integrate',runfile_name,
'--jobid='+
str(integration_job)]
239 integration_procs.append(hw7Utils.Process(integration_job, integrate_command, integrate_log))
241 integration_handler = hw7Utils.ProcessHandler(integration_procs, athMsgLog)
242 if not integration_handler.success():
243 raise RuntimeError(hw7Utils.ansi_format_error(
'Not all of the integration jobs finished successfully'))
245 athMsgLog.info(hw7Utils.ansi_format_ok(
'All integration jobs finished successfully'))
248 xsec, err =
do_mergegrids(gen_config.run_name, integration_jobs)
◆ do_compress_gridpack()
def Herwig7Control.do_compress_gridpack |
( |
|
run_name, |
|
|
|
gridpack_name |
|
) |
| |
Definition at line 253 of file Herwig7Control.py.
255 if not (gridpack_name.endswith(
'.tar.gz')
or gridpack_name.endswith(
'.tgz')): gridpack_name +=
'.tar.gz'
259 athMsgLog.debug(
"Scratch area, this is Herwig version '{}'".
format(version))
260 if "7.1" in version
or "7.0" in version:
261 do_step(
'compress', [
'tar',
'czf', gridpack_name, infile_name, runfile_name,
'Herwig-scratch'])
263 do_step(
'compress', [
'tar',
'czf', gridpack_name, infile_name, runfile_name,
'Herwig-cache'])
◆ do_integrate()
def Herwig7Control.do_integrate |
( |
|
run_name, |
|
|
|
integration_job |
|
) |
| |
Do the integrate step for one specific integration job.
- Todo:
- provide info about the range
Definition at line 196 of file Herwig7Control.py.
201 integrate_log = run_name+
'.integrate'+
str(integration_job)+
'.log'
202 integrate_command = [herwig7_binary,
'integrate',runfile_name,
'--jobid='+
str(integration_job)]
205 do_step(
'integrate', integrate_command, integrate_log)
◆ do_mergegrids()
def Herwig7Control.do_mergegrids |
( |
|
run_name, |
|
|
|
integration_jobs |
|
) |
| |
This function provides the mergegrids step.
Definition at line 209 of file Herwig7Control.py.
212 mergegrids_command = [herwig7_binary,
'mergegrids', runfile_name]
215 do_step(
'mergegrids', mergegrids_command)
218 xsec, err = hw7Utils.get_cross_section(run_name, integration_jobs)
◆ do_read()
def Herwig7Control.do_read |
( |
|
gen_config | ) |
|
◆ do_read_existing_infile()
def Herwig7Control.do_read_existing_infile |
( |
|
gen_config | ) |
|
Do the read step and re-use an already existing infile.
Definition at line 164 of file Herwig7Control.py.
174 do_step(
'read', [herwig7_binary,
'read', gen_config.infile_name,
'-I', share_path])
◆ do_run()
def Herwig7Control.do_run |
( |
|
gen_config, |
|
|
|
cleanup_herwig_scratch = True |
|
) |
| |
- Parameters
-
[in] | cleanup_herwig_scratch | Remove Herwig-scratch folder after event generation to save disk space |
Definition at line 273 of file Herwig7Control.py.
273 def do_run(gen_config, cleanup_herwig_scratch=True):
279 JOChecker.check_file()
282 if gen_config.runArgs.randomSeed
is None:
283 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
False
285 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
True
286 gen_config.genSeq.Herwig7.RandomSeedFromGeneratetf = gen_config.runArgs.randomSeed
289 gen_config.genSeq.Herwig7.PDFNameME = gen_config.me_pdf_name
292 gen_config.genSeq.Herwig7.PDFNameMPI = gen_config.mpi_pdf_name
295 gen_config.genSeq.Herwig7.CleanupHerwigScratch = cleanup_herwig_scratch
299 athMsgLog.info(hw7Utils.ansi_format_info(
"Returning to the job options and starting the event generation afterwards"))
◆ do_run_existing_runfile()
def Herwig7Control.do_run_existing_runfile |
( |
|
gen_config | ) |
|
Do the run step and re-use an already existing runfile.
Definition at line 303 of file Herwig7Control.py.
306 gen_config.genSeq.Herwig7.RunFile = gen_config.runfile_name
309 if gen_config.runArgs.randomSeed
is None:
310 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
False
312 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
True
313 gen_config.genSeq.Herwig7.RandomSeedFromGeneratetf = gen_config.runArgs.randomSeed
317 athMsgLog.info(hw7Utils.ansi_format_info(
"Returning to the job options and starting the event generation afterwards"))
◆ do_step()
def Herwig7Control.do_step |
( |
|
step, |
|
|
|
command, |
|
|
|
logfile_name = None |
|
) |
| |
Definition at line 123 of file Herwig7Control.py.
123 def do_step(step, command, logfile_name=None):
125 athMsgLog.info(hw7Utils.ansi_format_info(
"Starting Herwig7 '{}' step with command '{}'".
format(step,
' '.
join(command))))
127 logfile =
open(logfile_name,
'w')
if logfile_name
else None
128 do = subprocess.Popen(command, stdout=logfile, stderr=logfile)
130 if not do.returncode == 0:
131 raise RuntimeError(hw7Utils.ansi_format_error(
"Some error occured during the '{}' step.".
format(step)))
134 athMsgLog.info(
"Content of %s log file '%s':", step, logfile_name)
136 with open(logfile_name,
'r')
as logfile:
138 athMsgLog.info(
' %s', line.rstrip(
'\n'))
◆ do_uncompress_gridpack()
def Herwig7Control.do_uncompress_gridpack |
( |
|
gridpack_name | ) |
|
Definition at line 266 of file Herwig7Control.py.
268 athMsgLog.info(
"unpacking gridpack '%s'", gridpack_name)
269 do_step(
'uncompress', [
'tar',
'xzf', gridpack_name])
◆ exit_banner()
def Herwig7Control.exit_banner |
( |
|
gridpack, |
|
|
|
cross_section, |
|
|
|
cross_section_error |
|
) |
| |
Definition at line 459 of file Herwig7Control.py.
459 def exit_banner(gridpack, cross_section, cross_section_error):
461 size = hw7Utils.humanize_bytes(hw7Utils.get_size(gridpack))
462 space_size = hw7Utils.get_repeated_pattern(
' ', 31-len(size))
464 xsec =
'{:f}'.
format(cross_section)
465 err =
'{:f}'.
format(cross_section_error)
466 rel_err =
'{:.2f}'.
format(cross_section_error / cross_section * 100.0)
467 space_xsec = hw7Utils.get_repeated_pattern(
' ', 37-len(xsec)-len(err)-len(rel_err))
470 space =
' '.
join([
'' for i
in range(70+4+1-len(gridpack))])
471 banner +=
"##########################################################################################\n"
472 banner +=
"## ------------------------------------------------------------------------------- ##\n"
473 banner +=
"## {} (size: {}){} ##\n".
format(hw7Utils.ansi_format_ok(
"HERWIG 7 successfully created the gridpack"), size, space_size)
475 banner +=
"## {}{} ##\n".
format(hw7Utils.ansi_format_info(gridpack), space)
477 banner +=
"## cross section from integration: {} +/- {} ({}%) nb {} ##\n".
format(xsec, err, rel_err, space_xsec)
479 if cross_section_error / cross_section > hw7Utils.integration_grids_precision_threshold:
480 threshold =
'{}%'.
format(hw7Utils.integration_grids_precision_threshold*100.0)
481 space_threshold = hw7Utils.get_repeated_pattern(
' ', 6-len(threshold))
483 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_warning(
"! WARNING: The integration grids only have a low precision (worse than {}){}!".
format(threshold, space_threshold)))
486 banner +=
"## ------------------------------------------------------------------------------- ##\n"
488 banner +=
"## Please ignore the error ##\n"
490 banner +=
"## No such file or directory: 'evgen.root' raised while stating file evgen.root ##\n"
492 banner +=
"##########################################################################################\n"
◆ get_default_repository()
def Herwig7Control.get_default_repository |
( |
| ) |
|
Copy default repository HerwigDefaults.rpo
to current working directory.
Definition at line 445 of file Herwig7Control.py.
447 shutil.copy(os.path.join(
get_share_path(),
'HerwigDefaults.rpo'),
'HerwigDefaults.rpo')
◆ get_infile_name()
def Herwig7Control.get_infile_name |
( |
|
run_name = "Herwig-Matchbox" | ) |
|
◆ get_runfile_name()
def Herwig7Control.get_runfile_name |
( |
|
run_name = "Herwig-Matchbox" | ) |
|
Definition at line 379 of file Herwig7Control.py.
381 return(
'{}.run'.
format(run_name)
if not run_name.endswith(
'.run')
else run_name)
◆ get_setupfile_name()
def Herwig7Control.get_setupfile_name |
( |
|
run_name = "Herwig-Matchbox" | ) |
|
◆ get_share_path()
def Herwig7Control.get_share_path |
( |
| ) |
|
Get path to the share/Herwig
folder.
Try to get it from the InstallArea
first. If this fails fall back to $HERWIG7_PATH/share/Herwig
Definition at line 31 of file Herwig7Control.py.
33 cmt_paths = os.environ.get(
"CMAKE_PREFIX_PATH")
34 cmt_config = os.environ.get(
"BINARY_TAG")
37 for path
in cmt_paths.split(
':'):
38 path = os.path.join(path,
"InstallArea", cmt_config,
"share")
40 filelist = os.listdir(path)
43 if "HerwigDefaults.rpo" in filelist: return(path)
46 path = os.path.join(os.environ[
'HERWIG7_PATH'],
'share/Herwig')
47 if os.path.isfile(os.path.join(path,
'HerwigDefaults.rpo')):
51 raise RuntimeError(hw7Utils.ansi_format_error(
'Could not find a valid share/Herwig folder'))
◆ get_software_versions()
def Herwig7Control.get_software_versions |
( |
| ) |
|
Definition at line 364 of file Herwig7Control.py.
366 return(six.ensure_str(subprocess.check_output([herwig7_binary,
'--version'])).splitlines())
◆ herwig_version()
def Herwig7Control.herwig_version |
( |
| ) |
|
◆ log()
def Herwig7Control.log |
( |
|
level = 'info' , |
|
|
|
message = '' |
|
) |
| |
Definition at line 450 of file Herwig7Control.py.
450 def log(level='info', message=''):
452 if level
in [
'info',
'warn',
'error']:
453 logger = getattr(athMsgLog, level)
454 for line
in message.splitlines():
logger(line)
456 raise ValueError(
"Unknown logging level'{}' specified. Possible values are 'info', 'warn' or 'error'".
format(level))
◆ matchbox_run()
def Herwig7Control.matchbox_run |
( |
|
gen_config, |
|
|
|
integration_jobs, |
|
|
|
cleanup_herwig_scratch |
|
) |
| |
Do the build, integrate, mergegrids and run step in one go without creating a gridpack.
- Parameters
-
[in] | cleanup_herwig_scratch | Remove Herwig-scratch or 'Herwig-cache' folder after event generation to save disk space |
Definition at line 78 of file Herwig7Control.py.
78 def matchbox_run(gen_config, integration_jobs, cleanup_herwig_scratch):
84 do_run(gen_config, cleanup_herwig_scratch)
◆ matchbox_run_gridpack()
def Herwig7Control.matchbox_run_gridpack |
( |
|
gen_config, |
|
|
|
integration_jobs, |
|
|
|
gridpack_name, |
|
|
|
cleanup_herwig_scratch, |
|
|
|
integrate |
|
) |
| |
Either do the build, integrate and mergegrids steps and create a gridpack or extract it and generate events from it.
- Parameters
-
[in] | cleanup_herwig_scratch | Remove Herwig-scratch or 'Herwig-cache' folder after event generation to save disk space |
Definition at line 91 of file Herwig7Control.py.
91 def matchbox_run_gridpack(gen_config, integration_jobs, gridpack_name, cleanup_herwig_scratch, integrate):
96 if not gridpack_name
or integrate:
114 DSIS_dir = gen_config.runArgs.jobConfig[0]+
"/"
116 athMsgLog.info(
"Finished unpacking the gridpack")
119 do_run(gen_config, cleanup_herwig_scratch)
◆ run()
def Herwig7Control.run |
( |
|
gen_config | ) |
|
Do the read/run sequence.
This function should provide the read and run step in one go
Definition at line 65 of file Herwig7Control.py.
71 do_run(gen_config, cleanup_herwig_scratch=
False)
◆ start_banner()
def Herwig7Control.start_banner |
( |
| ) |
|
Definition at line 333 of file Herwig7Control.py.
337 herwig_version_space =
' '.
join([
'' for i
in range(14-len(herwig_version_number))])
338 thepeg_version_space =
' '.
join([
'' for i
in range(14-len(thepeg_version_number))])
341 banner +=
"#####################################\n"
342 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_ok(
"---------------------------"))
343 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_ok(
"Starting HERWIG 7 in ATHENA"))
344 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_ok(
"---------------------------"))
346 banner +=
"## with software versions: ##\n"
347 banner +=
"## - Herwig7: {}{} ##\n".
format(herwig_version_number, herwig_version_space)
348 banner +=
"## - ThePEG: {}{} ##\n".
format(thepeg_version_number, thepeg_version_space)
360 banner +=
"#####################################\n"
◆ thepeg_version()
def Herwig7Control.thepeg_version |
( |
| ) |
|
◆ write_infile()
def Herwig7Control.write_infile |
( |
|
gen_config, |
|
|
|
print_infile = True |
|
) |
| |
Definition at line 384 of file Herwig7Control.py.
387 gen_config.default_commands.lock()
388 gen_config.commands.lock()
391 if print_infile: athMsgLog.info(
"")
392 athMsgLog.info(hw7Utils.ansi_format_info(
"Writing infile '{}'".
format(infile_name)))
394 gen_config.global_pre_commands().splitlines() \
395 + gen_config.local_pre_commands().splitlines() \
397 "## ================",
398 "## Default Commands",
399 "## ================"] \
400 +
str(gen_config.default_commands.commands).splitlines() \
402 "## ========================",
403 "## Commands from jobOptions",
404 "## ========================"] \
405 +
str(gen_config.commands.commands).splitlines() \
406 + gen_config.local_post_commands().splitlines()
408 with open(infile_name,
'w')
as infile:
409 for command
in commands:
410 infile.write(command+
'\n')
412 raise RuntimeError(
'Could not write Herwig/Matchbox infile')
416 for command
in commands:
417 athMsgLog.info(
' %s', command)
◆ write_setupfile()
def Herwig7Control.write_setupfile |
( |
|
run_name, |
|
|
|
commands, |
|
|
|
print_setupfile = True |
|
) |
| |
Definition at line 421 of file Herwig7Control.py.
425 if len(commands) > 0:
426 if print_setupfile: athMsgLog.info(
"")
427 athMsgLog.info(
"Writing setupfile '%s'", setupfile_name)
429 with open(setupfile_name,
'w')
as setupfile:
430 for command
in commands: setupfile.write(command+
'\n')
432 raise RuntimeError(
'Could not write Herwig/Matchbox setupfile')
436 for command
in commands: athMsgLog.info(
' %s', command)
440 athMsgLog.info(
"No setupfile commands given.")
◆ athMsgLog
Herwig7Control.athMsgLog = Logging.logging.getLogger('Herwig7Control') |
◆ herwig7_bin_path
◆ herwig7_binary
◆ herwig7_path
Herwig7Control.herwig7_path = os.environ['HERWIG7_PATH'] |
◆ herwig7_share_path
def do_integrate(run_name, integration_job)
Do the integrate step for one specific integration job.
def exit_banner(gridpack, cross_section, cross_section_error)
def do_build(gen_config, integration_jobs)
Do the build step.
def do_build_integrate_mergegrids(gen_config, integration_jobs)
Subsequent build, integrate and mergegrid steps.
def do_mergegrids(run_name, integration_jobs)
This function provides the mergegrids step.
def matchbox_run(gen_config, integration_jobs, cleanup_herwig_scratch)
Do the build, integrate, mergegrids and run step in one go without creating a gridpack.
def do_run_existing_runfile(gen_config)
Do the run step and re-use an already existing runfile.
int run(int argc, char *argv[])
def get_default_repository()
Copy default repository HerwigDefaults.rpo to current working directory.
def write_setupfile(run_name, commands, print_setupfile=True)
def do_step(step, command, logfile_name=None)
def matchbox_run_gridpack(gen_config, integration_jobs, gridpack_name, cleanup_herwig_scratch, integrate)
Either do the build, integrate and mergegrids steps and create a gridpack or extract it and generate ...
def do_uncompress_gridpack(gridpack_name)
logger
Get handle to Athena logging.
def get_infile_name(run_name="Herwig-Matchbox")
def get_share_path()
Get path to the share/Herwig folder.
def do_read_existing_infile(gen_config)
Do the read step and re-use an already existing infile.
std::string join(const std::vector< std::string > &v, const char c=',')
def do_read(gen_config)
Do the read step.
def do_compress_gridpack(run_name, gridpack_name)
def log(level='info', message='')
def get_software_versions()
def get_runfile_name(run_name="Herwig-Matchbox")
def do_run(gen_config, cleanup_herwig_scratch=True)
def get_setupfile_name(run_name="Herwig-Matchbox")
def write_infile(gen_config, print_infile=True)