Commit 5b59e280 authored by Timothee Theveneaux-Pelzer's avatar Timothee Theveneaux-Pelzer 🖖
Browse files

Handling of log messages: AGENE-2016, AGENE-2024; Adding ttj MiNNLO: AGENE-2016

parent 95788ee5
......@@ -136,7 +136,10 @@ def multicore_untimed(process):
"""
if not os.path.isfile(process.executable):
raise OSError("Powheg executable {} not found!".format(process.executable))
threads = [SingleProcessThread(process.executable, seed_index=idx) for idx in range(1, process.cores + 1)]
threads = [SingleProcessThread(process.executable, seed_index=idx,
warning_output=(process.warning_output if hasattr(process,"warning_output") else None),
info_output=(process.info_output if hasattr(process,"info_output") else None),
error_output=(process.error_output if hasattr(process,"error_output") else None)) for idx in range(1, process.cores + 1)]
manager = ProcessManager(threads)
while manager.monitor():
pass
......@@ -25,7 +25,10 @@ def singlecore_untimed(process):
"""
if not os.path.isfile(process.executable):
raise OSError("Powheg executable {} not found!".format(process.executable))
threads = [SingleProcessThread(process.executable)]
threads = [SingleProcessThread(process.executable,
warning_output=(process.warning_output if hasattr(process,"warning_output") else None),
info_output=(process.info_output if hasattr(process,"info_output") else None),
error_output=(process.error_output if hasattr(process,"error_output") else None))]
manager = ProcessManager(threads)
while manager.monitor():
pass
\ No newline at end of file
pass
......@@ -254,7 +254,8 @@ def __run_executable(executable):
raise OSError("MadSpin executable {} not found!".format(executable))
logger.info("MadSpin executable: {}".format(executable))
with open("madspin_runcard.txt", "rb") as runcard_input:
processes = [SingleProcessThread([executable], stdin=runcard_input, ignore_output=["INFO:", "MadSpin>"])]
processes = [SingleProcessThread([executable], stdin=runcard_input, ignore_output=["INFO:", "MadSpin>"],
error_output=["Command \"launch\" interrupted with error:", "MadSpinError", "generating the production square matrix element"])]
manager = ProcessManager(processes)
while manager.monitor():
pass
......
......@@ -23,7 +23,11 @@ class Wj_MiNNLO(PowhegV2):
@param kwargs dictionary of arguments from Generate_tf.
"""
super(Wj_MiNNLO, self).__init__(base_directory, os.path.join("Wj", "WjMiNNLO"), powheg_executable="pwhg_main", **kwargs)
# this is very hacky
warnings = super(Wj_MiNNLO, self).hoppet_warning()
infos = super(Wj_MiNNLO, self).hoppet_info()
super(Wj_MiNNLO, self).__init__(base_directory, os.path.join("Wj", "WjMiNNLO"), powheg_executable="pwhg_main", warning_output=warnings, info_output=infos, **kwargs)
# Add algorithms to the sequence
......
......@@ -22,7 +22,12 @@ class Zj_MiNNLO(PowhegV2):
@param base_directory: path to PowhegBox code.
@param kwargs dictionary of arguments from Generate_tf.
"""
super(Zj_MiNNLO, self).__init__(base_directory, os.path.join("Zj", "ZjMiNNLO"), powheg_executable="pwhg_main", **kwargs)
# this is very hacky
warnings = super(Zj_MiNNLO, self).hoppet_warning()
infos = super(Zj_MiNNLO, self).hoppet_info()
super(Zj_MiNNLO, self).__init__(base_directory, os.path.join("Zj", "ZjMiNNLO"), powheg_executable="pwhg_main", warning_output=warnings, info_output=infos, **kwargs)
# Add algorithms to the sequence
......
......@@ -30,6 +30,7 @@ from tt_NLOdecays import tt_NLOdecays
from ttbb import ttbb
from ttH import ttH
from ttj import ttj
from ttj_MiNNLO import ttj_MiNNLO
from ttWm_EW import ttWm_EW
from ttWm_QCD import ttWm_QCD
from ttWp_EW import ttWp_EW
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from AthenaCommon import Logging
from ..powheg_V2 import PowhegV2
## Get handle to Athena logging
logger = Logging.logging.getLogger("PowhegControl")
class ttj_MiNNLO(PowhegV2):
"""! Default Powheg configuration for top pair production plus one jet with MiNNLO.
Create a configurable object with all applicable Powheg options.
@author Timothee Theveneaux-Pelzer <tpelzer@cern.ch>
"""
def __init__(self, base_directory, **kwargs):
"""! Constructor: all process options are set here.
@param base_directory: path to PowhegBox code.
@param kwargs dictionary of arguments from Generate_tf.
"""
# this is very hacky
errors = super(ttj_MiNNLO, self).openloops_error()
warnings = super(ttj_MiNNLO, self).hoppet_warning()
infos = super(ttj_MiNNLO, self).hoppet_info()
super(ttj_MiNNLO, self).__init__(base_directory, "ttJ_MiNNLOPS_v1.0_beta1", powheg_executable="pwhg_main-gnu", warning_output=warnings, info_output=infos, error_output=errors, **kwargs)
# Add parameter validation functions
self.validation_functions.append("validate_decays")
## List of allowed decay modes
self.allowed_decay_modes = ["t t~ > all", "t t~ > b j j b~ j j", "t t~ > b l+ vl b~ l- vl~", "t t~ > b emu+ vemu b~ emu- vemu~", "t t~ > semileptonic"]
# Add all keywords for this process, overriding defaults if required
self.add_keyword("alphaem")
self.add_keyword("bcut")
self.add_keyword("bornktmin", 5.0)
self.add_keyword("bornonly")
self.add_keyword("bornsuppfact", 100.0)
self.add_keyword("bornzerodamp")
self.add_keyword("bottommass")
self.add_keyword("bottomthr")
self.add_keyword("bottomthrpdf")
self.add_keyword("charmthr")
self.add_keyword("charmthrpdf")
self.add_keyword("CKM_Vcb")
self.add_keyword("CKM_Vcd")
self.add_keyword("CKM_Vcs")
self.add_keyword("CKM_Vtb")
self.add_keyword("CKM_Vtd")
self.add_keyword("CKM_Vts")
self.add_keyword("CKM_Vub")
self.add_keyword("CKM_Vud")
self.add_keyword("CKM_Vus")
self.add_keyword("clobberlhe")
self.add_keyword('collremnsamp"')
self.add_keyword("colltest")
self.add_keyword("compute_rwgt")
self.add_keyword("doublefsr")
self.add_keyword("elbranching")
self.add_keyword("facscfact", self.default_scales[0])
self.add_keyword("fastbtlbound")
self.add_keyword("ffltest")
self.add_keyword("flg_debug")
self.add_keyword("foldcsi", 2)
self.add_keyword("foldphi", 2)
self.add_keyword("foldy", 2)
self.add_keyword("fullrwgt")
self.add_keyword("fullrwgtmode")
self.add_keyword("ggproc")
self.add_keyword("gqbproc")
self.add_keyword("hdamp")
self.add_keyword("hfact")
self.add_keyword("icsimax", 3)
self.add_keyword("ih1")
self.add_keyword("ih2")
self.add_keyword("itmx1")
self.add_keyword("itmx2", 4)
self.add_keyword("iupperfsr")
self.add_keyword("iupperisr")
self.add_keyword("iymax", 3)
self.add_keyword("jacsing")
self.add_keyword("largecorrfact")
self.add_keyword("lhans1", self.default_PDFs)
self.add_keyword("lhans2", self.default_PDFs)
self.add_keyword("lhfm/bmass")
self.add_keyword("lhfm/cmass")
self.add_keyword("lhfm/emass")
self.add_keyword("lhfm/mumass")
self.add_keyword("lhfm/taumass")
self.add_keyword("manyseeds")
self.add_keyword("masswindow_high")
self.add_keyword("masswindow_low")
self.add_keyword("minlo", 1)
self.add_keyword("minnlo", 1)
self.add_keyword("ncall1", 51000)
self.add_keyword("ncall2", 91000)
self.add_keyword("nubound", 11000)
self.add_keyword("par_2gsupp")
self.add_keyword("par_diexp")
self.add_keyword("par_dijexp")
self.add_keyword("par_fsrtinycsi")
self.add_keyword("par_fsrtinyy")
self.add_keyword("par_isrtinycsi")
self.add_keyword("par_isrtinyy")
self.add_keyword("parallelstage")
self.add_keyword("pdfreweight")
self.add_keyword("psgen")
self.add_keyword("ptmin_jet", 20.0)
self.add_keyword("ptsqmin")
self.add_keyword("ptsupp")
self.add_keyword("qgproc")
self.add_keyword("qqbproc")
self.add_keyword("qqpproc")
self.add_keyword("qqproc")
self.add_keyword("R_jet")
self.add_keyword("radregion")
self.add_keyword("rand1")
self.add_keyword("rand2")
self.add_keyword("renscfact", self.default_scales[1])
self.add_keyword("runningscale")
self.add_keyword("rwl_add")
self.add_keyword("rwl_file")
self.add_keyword("rwl_format_rwgt")
self.add_keyword("rwl_group_events")
self.add_keyword("semileptonic", hidden=True)
self.add_keyword("smartsig")
self.add_keyword("softtest")
self.add_keyword("sthw2")
self.add_keyword("storeinfo_rwgt")
self.add_keyword("testplots")
self.add_keyword("testsuda")
self.add_keyword("topdecaymode", self.allowed_decay_modes[0], name="decay_mode")
self.add_keyword("topmass")
self.add_keyword("topwidth")
self.add_keyword("ubsigmadetails")
self.add_keyword("use-old-grid")
self.add_keyword("use-old-ubound")
self.add_keyword("use-OLP-interface")
self.add_keyword("withdamp")
self.add_keyword("withnegweights")
self.add_keyword("withsubtr")
self.add_keyword("Wmass")
self.add_keyword("Wwidth")
self.add_keyword("xupbound", 6)
self.add_keyword("zerowidth")
self.add_keyword("Zmass")
self.add_keyword("Zwidth")
def validate_decays(self):
"""! Validate semileptonic and topdecaymode keywords."""
self.expose() # convenience call to simplify syntax
if self.decay_mode not in self.allowed_decay_modes:
logger.warning("Decay mode {} not recognised!".format(self.decay_mode))
raise ValueError("Decay mode {} not recognised!".format(self.decay_mode))
# Calculate appropriate decay mode numbers
__decay_mode_lookup = {"t t~ > all": "22222", "t t~ > b j j b~ j j": "00022", "t t~ > b l+ vl b~ l- vl~": "22200", "t t~ > b emu+ vemu b~ emu- vemu~": "22000", "t t~ > semileptonic": "11111"}
self.parameters_by_keyword("topdecaymode")[0].value = __decay_mode_lookup[self.decay_mode]
if self.decay_mode == "semileptonic":
self.parameters_by_keyword("semileptonic")[0].value = 1
......@@ -18,8 +18,11 @@ class PowhegRES(PowhegBase):
@param base_directory path to PowhegBox code.
@param executable_name folder containing appropriate PowhegBox executable.
@param is_LO True if this is a leading-order process.
@param warning_output list of patterns which if found in the output will be treated as warning in the log.
@param error_output list of patterns which if found in the output will be treated as error in the log.
@param info_output list of patterns which if found in the output will be treated as info in the log.
"""
super(PowhegRES, self).__init__(base_directory, "POWHEG-BOX-RES", executable_name, **kwargs)
super(PowhegRES, self).__init__(base_directory, "POWHEG-BOX-RES", executable_name, warning_output = [], info_output = [], error_output = [], **kwargs)
@property
def default_PDFs(self):
......
......@@ -16,8 +16,11 @@ class PowhegV1(PowhegBase):
@param base_directory path to PowhegBox code.
@param executable_name folder containing appropriate PowhegBox executable.
@param warning_output list of patterns which if found in the output will be treated as warning in the log.
@param error_output list of patterns which if found in the output will be treated as error in the log.
@param info_output list of patterns which if found in the output will be treated as info in the log.
"""
super(PowhegV1, self).__init__(base_directory, "POWHEG-BOX", executable_name, is_reweightable=False, **kwargs)
super(PowhegV1, self).__init__(base_directory, "POWHEG-BOX", executable_name, is_reweightable=False, warning_output = [], info_output = [], error_output = [], **kwargs)
@property
def default_PDFs(self):
......
......@@ -11,14 +11,17 @@ class PowhegV2(PowhegBase):
@author James Robinson <james.robinson@cern.ch>
"""
def __init__(self, base_directory, executable_name, **kwargs):
def __init__(self, base_directory, executable_name, warning_output = [], info_output = [], error_output = [], **kwargs):
"""! Constructor.
@param base_directory path to PowhegBox code.
@param executable_name folder containing appropriate PowhegBox executable.
@param is_LO True if this is a leading-order process.
@param warning_output list of patterns which if found in the output will be treated as warning in the log.
@param error_output list of patterns which if found in the output will be treated as error in the log.
@param info_output list of patterns which if found in the output will be treated as info in the log.
"""
super(PowhegV2, self).__init__(base_directory, "POWHEG-BOX-V2", executable_name, **kwargs)
super(PowhegV2, self).__init__(base_directory, "POWHEG-BOX-V2", executable_name=executable_name, warning_output=warning_output, info_output=info_output, error_output=error_output, **kwargs)
@property
def default_PDFs(self):
......
......@@ -20,6 +20,41 @@ class PowhegBase(Configurable):
@author Stefan Richter <stefan.richter@cern.ch>
"""
def hoppet_info(self):
'''
Returns a list of strings to be treated as info messages in the log
They otherwise throw an error with HOPPET v. 1.2.0
Cf. AGENE-2016
'''
return ["-----------------------------------------------------------",
"Welcome to HOPPET v. 1.2.0",
"Higher Order Perturbative Parton Evolution Toolkit",
"Written by Gavin P. Salam (2001-2012)",
"with contributions from Juan Rojo",
"Frederic Dreyer and Alexander Karlberg",
"It is made available under the GNU public license,",
"with the additional request that if you use it or any",
"derivative of it in scientific work then you should cite:",
"G.P. Salam & J. Rojo, CPC 180(2009)120 (arXiv:0804.3755).",
"You are also encouraged to cite the original references,",
"for LO, NLO and NNLO splitting functions, the QCD",
"1, 2 and 3 loop beta functions and the coupling and",
"PDF and coupling mass threshold matching functions."]
def hoppet_warning(self):
'''
Returns a list of strings to be treated as warning messages in the log
They otherwise throw an error
'''
return ["WARNING in InitMTMNNLO: using parametrisation (less accuracte) for A2PShg"]
def openloops_error(self):
'''
Returns a list of strings to be treated as error messages in the log
They otherwise do not throw an error
'''
return ["[POWHEG-BOX+OpenLoops] Process not found!"]
def manually_set_openloops_paths(self):
'''
Manual fix for OpenLoops libraries path, avoiding issues when /afs not available
......@@ -66,12 +101,16 @@ class PowhegBase(Configurable):
else:
logger.info("Local directory \"virtual\" now points to {}".format(MadLoop_virtual))
def __init__(self, base_directory, version, executable_name, cores, powheg_executable="pwhg_main", is_reweightable=True, **kwargs):
def __init__(self, base_directory, version, executable_name, cores, powheg_executable="pwhg_main", is_reweightable=True, warning_output = [], info_output = [], error_output = [], **kwargs):
"""! Constructor.
@param base_directory path to PowhegBox code.
@param version PowhegBox version.
@param executable_name folder containing appropriate PowhegBox executable.
@param powheg_executable name of the powheg executable.
@param warning_output list of patterns which if found in the output will be treated as warning in the log.
@param error_output list of patterns which if found in the output will be treated as error in the log.
@param info_output list of patterns which if found in the output will be treated as info in the log.
"""
super(PowhegBase, self).__init__()
......@@ -121,6 +160,11 @@ class PowhegBase(Configurable):
## Switch to determine if the #rwgt and #pdf comments should be kept in lhe files despite using xml reweighting
self.remove_oldStyle_rwt_comments = None
## Special treatment for some log messages
self.warning_output = warning_output
self.info_output = info_output
self.error_output = error_output
def add_algorithm(self, alg_or_process):
"""! Add an algorithm or external process to the sequence.
......
......@@ -47,15 +47,18 @@ class SingleProcessThread(object):
__output_prefix = " | "
__ignore_output = []
def __init__(self, command_list, seed_index=None, stdin=None, ignore_output=None):
def __init__(self, command_list, seed_index=None, stdin=None, ignore_output=None, warning_output=[], info_output=[], error_output=[]):
"""! Constructor.
Setup underlying process together with non-blocking readers for stdout and stderr.
@param command_list Command that will be run (possibly with options).
@param seed_index Which seed from pwgseeds.dat to use.
@param stdin An open file handle providing input.
@param ignore_output List of strings to filter out from messages.
@param command_list Command that will be run (possibly with options).
@param seed_index Which seed from pwgseeds.dat to use.
@param stdin An open file handle providing input.
@param ignore_output List of strings to filter out from messages.
@param warning_output List of strings which would always trigger a warning only, even if produced in stderr.
@param info_output List of strings which would always trigger an info only, even if produced in stderr.
@param error_output List of strings which would always trigger an error, even if produced in stdout.
"""
if not isinstance(command_list, list):
command_list = [command_list]
......@@ -63,6 +66,11 @@ class SingleProcessThread(object):
# Set up messages to ignore
if ignore_output is not None:
self.__ignore_output = ignore_output
# Set up messages with special treatment
self.__warning_output = warning_output
self.__info_output = info_output
self.__error_output = error_output
ignore_output
# Usual case, where no open file handle is provided
if stdin is None:
self.__process = subprocess.Popen(command_list, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
......@@ -81,6 +89,8 @@ class SingleProcessThread(object):
self.__stdout = NonBlockingStreamReader(self.__process.stdout)
self.__stderr = NonBlockingStreamReader(self.__process.stderr)
def has_output(self):
"""! Write queued output and return process status."""
status = self.is_running()
......@@ -111,7 +121,13 @@ class SingleProcessThread(object):
for stream in ["stdout", "stderr"]:
while True:
output, queue_size = getattr(self, stream).readline(timeout=0.1)
if not (output is None or len(output) == 0):
if output is not None and any([(pattern in output) for pattern in self.__error_output]):
self.log(output, "error")
elif output is not None and any([(pattern in output) for pattern in self.__warning_output]):
self.log(output, "warning")
elif output is not None and any([(pattern in output) for pattern in self.__info_output]):
self.log(output, "info")
elif not (output is None or len(output) == 0):
self.log(output, self.log_level[stream])
if queue_size == 0:
break
......
import PowhegControl
transform_runArgs = runArgs if "runArgs" in dir() else None
transform_opts = opts if "opts" in dir() else None
PowhegConfig = PowhegControl.PowhegControl(process_name="ttj_MiNNLO", run_args=transform_runArgs, run_opts=transform_opts)
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
#--------------------------------------------------------------
# This is an example joboption to generate events with Powheg
# using ATLAS' interface. Users should optimise and carefully
# validate the settings before making an official sample request.
#--------------------------------------------------------------
#--------------------------------------------------------------
# EVGEN configuration
#--------------------------------------------------------------
evgenConfig.description = "POWHEG+Pythia8 tt+jet production with MiNNLO and A14 NNPDF2.3 tune."
evgenConfig.keywords = ["SM", "top", "1jet"]
evgenConfig.contact = ["tpelzer@cern.ch"]
# --------------------------------------------------------------
# Load ATLAS defaults for the Powheg ttj_MiNNLO process
# --------------------------------------------------------------
include("PowhegControl/PowhegControl_ttj_MiNNLO_Common.py")
# --------------------------------------------------------------
# Generate events
# --------------------------------------------------------------
PowhegConfig.generate()
#--------------------------------------------------------------
# Pythia8 showering with the A14 NNPDF2.3 tune, main31 routine
#--------------------------------------------------------------
include("Pythia8_i/Pythia8_A14_NNPDF23LO_EvtGen_Common.py")
include("Pythia8_i/Pythia8_Powheg_Main31.py")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment