 |
ATLAS Offline Software
|
|
def | get_share_path () |
|
def | run (gen_config) |
|
def | matchbox_run (gen_config, integration_jobs, cleanup_herwig_scratch) |
|
def | matchbox_run_gridpack (gen_config, integration_jobs, gridpack_name, cleanup_herwig_scratch, integrate) |
|
def | do_step (step, command, logfile_name=None) |
|
def | do_abort () |
|
def | do_read (gen_config) |
|
def | do_read_existing_infile (gen_config) |
|
def | do_build (gen_config, integration_jobs) |
|
def | do_integrate (run_name, integration_job) |
|
def | do_mergegrids (run_name, integration_jobs) |
|
def | do_build_integrate_mergegrids (gen_config, integration_jobs) |
|
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) |
|
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 () |
|
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 |
|
) |
| |
Definition at line 221 of file Herwig7Control.py.
224 do_build(gen_config, integration_jobs)
228 athMsgLog.info(hw7Utils.ansi_format_info(
'Starting integration with {} jobs'.
format(integration_jobs)))
230 integration_procs = []
231 for integration_job
in range(integration_jobs):
232 integrate_log = gen_config.run_name+
'.integrate'+
str(integration_job)+
'.log'
233 integrate_command = [herwig7_binary,
'integrate',runfile_name,
'--jobid='+
str(integration_job)]
234 integration_procs.append(hw7Utils.Process(integration_job, integrate_command, integrate_log))
236 integration_handler = hw7Utils.ProcessHandler(integration_procs, athMsgLog)
237 if not integration_handler.success():
238 raise RuntimeError(hw7Utils.ansi_format_error(
'Not all of the integration jobs finished successfully'))
240 athMsgLog.info(hw7Utils.ansi_format_ok(
'All integration jobs finished successfully'))
243 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 248 of file Herwig7Control.py.
250 if not (gridpack_name.endswith(
'.tar.gz')
or gridpack_name.endswith(
'.tgz')): gridpack_name +=
'.tar.gz'
254 athMsgLog.debug(
"Scratch area, this is Herwig version '{}'".
format(version))
255 if "7.1" in version
or "7.0" in version:
256 do_step(
'compress', [
'tar',
'czf', gridpack_name, infile_name, runfile_name,
'Herwig-scratch'])
258 do_step(
'compress', [
'tar',
'czf', gridpack_name, infile_name, runfile_name,
'Herwig-cache'])
◆ do_integrate()
def Herwig7Control.do_integrate |
( |
|
run_name, |
|
|
|
integration_job |
|
) |
| |
Definition at line 196 of file Herwig7Control.py.
200 integrate_log = run_name+
'.integrate'+
str(integration_job)+
'.log'
201 integrate_command = [herwig7_binary,
'integrate',runfile_name,
'--jobid='+
str(integration_job)]
203 do_step(
'integrate', integrate_command, integrate_log)
◆ do_mergegrids()
def Herwig7Control.do_mergegrids |
( |
|
run_name, |
|
|
|
integration_jobs |
|
) |
| |
Definition at line 207 of file Herwig7Control.py.
210 mergegrids_command = [herwig7_binary,
'mergegrids', runfile_name]
212 do_step(
'mergegrids', mergegrids_command)
215 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 | ) |
|
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 |
|
) |
| |
Definition at line 268 of file Herwig7Control.py.
268 def do_run(gen_config, cleanup_herwig_scratch=True):
274 JOChecker.check_file()
277 ConfigDecoder.DecodeRunCard(input_file = gen_config.genSeq.Herwig7.RunFile)
280 if gen_config.runArgs.randomSeed
is None:
281 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
False
283 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
True
284 gen_config.genSeq.Herwig7.RandomSeedFromGeneratetf = gen_config.runArgs.randomSeed
287 gen_config.genSeq.Herwig7.PDFNameME = gen_config.me_pdf_name
290 gen_config.genSeq.Herwig7.PDFNameMPI = gen_config.mpi_pdf_name
293 gen_config.genSeq.Herwig7.CleanupHerwigScratch = cleanup_herwig_scratch
297 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 | ) |
|
Definition at line 301 of file Herwig7Control.py.
304 gen_config.genSeq.Herwig7.RunFile = gen_config.runfile_name
307 if gen_config.runArgs.randomSeed
is None:
308 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
False
310 gen_config.genSeq.Herwig7.UseRandomSeedFromGeneratetf =
True
311 gen_config.genSeq.Herwig7.RandomSeedFromGeneratetf = gen_config.runArgs.randomSeed
315 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 261 of file Herwig7Control.py.
263 athMsgLog.info(
"unpacking gridpack '%s'", gridpack_name)
264 do_step(
'uncompress', [
'tar',
'xzf', gridpack_name])
◆ exit_banner()
def Herwig7Control.exit_banner |
( |
|
gridpack, |
|
|
|
cross_section, |
|
|
|
cross_section_error |
|
) |
| |
Definition at line 447 of file Herwig7Control.py.
447 def exit_banner(gridpack, cross_section, cross_section_error):
449 size = hw7Utils.humanize_bytes(hw7Utils.get_size(gridpack))
450 space_size = hw7Utils.get_repeated_pattern(
' ', 31-len(size))
452 xsec =
'{:f}'.
format(cross_section)
453 err =
'{:f}'.
format(cross_section_error)
454 rel_err =
'{:.2f}'.
format(cross_section_error / cross_section * 100.0)
455 space_xsec = hw7Utils.get_repeated_pattern(
' ', 37-len(xsec)-len(err)-len(rel_err))
458 space =
' '.
join([
'' for i
in range(70+4+1-len(gridpack))])
459 banner +=
"##########################################################################################\n"
460 banner +=
"## ------------------------------------------------------------------------------- ##\n"
461 banner +=
"## {} (size: {}){} ##\n".
format(hw7Utils.ansi_format_ok(
"HERWIG 7 successfully created the gridpack"), size, space_size)
463 banner +=
"## {}{} ##\n".
format(hw7Utils.ansi_format_info(gridpack), space)
465 banner +=
"## cross section from integration: {} +/- {} ({}%) nb {} ##\n".
format(xsec, err, rel_err, space_xsec)
467 if cross_section_error / cross_section > hw7Utils.integration_grids_precision_threshold:
468 threshold =
'{}%'.
format(hw7Utils.integration_grids_precision_threshold*100.0)
469 space_threshold = hw7Utils.get_repeated_pattern(
' ', 6-len(threshold))
471 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_warning(
"! WARNING: The integration grids only have a low precision (worse than {}){}!".
format(threshold, space_threshold)))
474 banner +=
"## ------------------------------------------------------------------------------- ##\n"
476 banner +=
"## Please ignore the error ##\n"
478 banner +=
"## No such file or directory: 'evgen.root' raised while stating file evgen.root ##\n"
480 banner +=
"##########################################################################################\n"
◆ get_default_repository()
def Herwig7Control.get_default_repository |
( |
| ) |
|
◆ 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 367 of file Herwig7Control.py.
369 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 |
( |
| ) |
|
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 352 of file Herwig7Control.py.
354 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 438 of file Herwig7Control.py.
438 def log(level='info', message=''):
440 if level
in [
'info',
'warn',
'error']:
441 logger = getattr(athMsgLog, level)
442 for line
in message.splitlines():
logger(line)
444 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 |
|
) |
| |
◆ matchbox_run_gridpack()
def Herwig7Control.matchbox_run_gridpack |
( |
|
gen_config, |
|
|
|
integration_jobs, |
|
|
|
gridpack_name, |
|
|
|
cleanup_herwig_scratch, |
|
|
|
integrate |
|
) |
| |
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 | ) |
|
◆ start_banner()
def Herwig7Control.start_banner |
( |
| ) |
|
Definition at line 331 of file Herwig7Control.py.
335 herwig_version_space =
' '.
join([
'' for i
in range(14-len(herwig_version_number))])
336 thepeg_version_space =
' '.
join([
'' for i
in range(14-len(thepeg_version_number))])
339 banner +=
"#####################################\n"
340 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_ok(
"---------------------------"))
341 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_ok(
"Starting HERWIG 7 in ATHENA"))
342 banner +=
"## {} ##\n".
format(hw7Utils.ansi_format_ok(
"---------------------------"))
344 banner +=
"## with software versions: ##\n"
345 banner +=
"## - Herwig7: {}{} ##\n".
format(herwig_version_number, herwig_version_space)
346 banner +=
"## - ThePEG: {}{} ##\n".
format(thepeg_version_number, thepeg_version_space)
348 banner +=
"#####################################\n"
◆ thepeg_version()
def Herwig7Control.thepeg_version |
( |
| ) |
|
◆ write_infile()
def Herwig7Control.write_infile |
( |
|
gen_config, |
|
|
|
print_infile = True |
|
) |
| |
Definition at line 372 of file Herwig7Control.py.
375 gen_config.default_commands.lock()
376 gen_config.commands.lock()
379 if print_infile: athMsgLog.info(
"")
380 athMsgLog.info(hw7Utils.ansi_format_info(
"Writing infile '{}'".
format(infile_name)))
382 gen_config.global_pre_commands().splitlines() \
383 + gen_config.local_pre_commands().splitlines() \
385 "## ================",
386 "## Default Commands",
387 "## ================"] \
388 +
str(gen_config.default_commands.commands).splitlines() \
390 "## ========================",
391 "## Commands from jobOptions",
392 "## ========================"] \
393 +
str(gen_config.commands.commands).splitlines() \
394 + gen_config.local_post_commands().splitlines()
396 with open(infile_name,
'w')
as infile:
397 for command
in commands:
398 infile.write(command+
'\n')
400 raise RuntimeError(
'Could not write Herwig/Matchbox infile')
404 for command
in commands:
405 athMsgLog.info(
' %s', command)
◆ write_setupfile()
def Herwig7Control.write_setupfile |
( |
|
run_name, |
|
|
|
commands, |
|
|
|
print_setupfile = True |
|
) |
| |
Definition at line 409 of file Herwig7Control.py.
413 if len(commands) > 0:
414 if print_setupfile: athMsgLog.info(
"")
415 athMsgLog.info(
"Writing setupfile '%s'", setupfile_name)
417 with open(setupfile_name,
'w')
as setupfile:
418 for command
in commands: setupfile.write(command+
'\n')
420 raise RuntimeError(
'Could not write Herwig/Matchbox setupfile')
424 for command
in commands: athMsgLog.info(
' %s', command)
428 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)
def exit_banner(gridpack, cross_section, cross_section_error)
def do_build(gen_config, integration_jobs)
def do_build_integrate_mergegrids(gen_config, integration_jobs)
def do_mergegrids(run_name, integration_jobs)
def matchbox_run(gen_config, integration_jobs, cleanup_herwig_scratch)
def do_run_existing_runfile(gen_config)
int run(int argc, char *argv[])
def get_default_repository()
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)
def do_uncompress_gridpack(gridpack_name)
logger
Get handle to Athena logging.
def get_infile_name(run_name="Herwig-Matchbox")
def do_read_existing_infile(gen_config)
std::string join(const std::vector< std::string > &v, const char c=',')
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)