3 from AthenaCommon
import Logging
4 from .configurable
import Configurable
5 from ..utility
import check_svn_revision, FileParser
11 logger = Logging.logging.getLogger(
"PowhegControl")
15 """! Base class for PowhegBox processes.
17 All process types inherit from this class.
19 @author James Robinson <james.robinson@cern.ch>
20 @author Stefan Richter <stefan.richter@cern.ch>
25 Returns a list of strings to be treated as info messages in the log
26 They otherwise throw an error with HOPPET v. 1.2.0
29 return [
"-----------------------------------------------------------",
30 "Welcome to HOPPET v. 1.2.0",
31 "Higher Order Perturbative Parton Evolution Toolkit",
32 "Written by Gavin P. Salam (2001-2012)",
33 "with contributions from Juan Rojo",
34 "Frederic Dreyer and Alexander Karlberg",
35 "It is made available under the GNU public license,",
36 "with the additional request that if you use it or any",
37 "derivative of it in scientific work then you should cite:",
38 "G.P. Salam & J. Rojo, CPC 180(2009)120 (arXiv:0804.3755).",
39 "You are also encouraged to cite the original references,",
40 "for LO, NLO and NNLO splitting functions, the QCD",
41 "1, 2 and 3 loop beta functions and the coupling and",
42 "PDF and coupling mass threshold matching functions."]
46 Returns a list of strings to be treated as warning messages in the log
47 They otherwise throw an error
49 return [
"WARNING in InitMTMNNLO: using parametrisation (less accuracte) for A2PShg"]
53 Returns a list of strings to be treated as error messages in the log
54 They otherwise do not throw an error
56 return [
"[POWHEG-BOX+OpenLoops] Process not found!"]
58 def __init__(self, base_directory, version, executable_name, cores, powheg_executable="pwhg_main", is_reweightable=True, warning_output = [], info_output = [], error_output = [], **kwargs):
61 @param base_directory path to PowhegBox code.
62 @param version PowhegBox version.
63 @param executable_name folder containing appropriate PowhegBox executable.
64 @param powheg_executable name of the powheg executable.
65 @param warning_output list of patterns which if found in the output will be treated as warning in the log.
66 @param error_output list of patterns which if found in the output will be treated as error in the log.
67 @param info_output list of patterns which if found in the output will be treated as info in the log.
72 self.
executable = os.path.join(base_directory, version, executable_name, powheg_executable)
75 self.
executable = os.path.join(base_directory, version, executable_name,
"bin", powheg_executable)
82 os.environ[
"PYTHONPATH"] = os.path.join(base_directory, version, executable_name,
"python") +
":" + os.environ.get(
"PYTHONPATH",
"")
85 os.environ[
"LD_LIBRARY_PATH"] = os.path.join(base_directory, version, executable_name,
"amplitudes",
"obj-gnu") +
":" + os.environ.get(
"LD_LIBRARY_PATH",
"")
86 os.environ[
"LD_LIBRARY_PATH"] = os.path.join(base_directory, version, executable_name,
"QCDLoop-1.95",
"ff",
"obj-gnu") +
":" + os.environ.get(
"LD_LIBRARY_PATH",
"")
87 os.environ[
"LD_LIBRARY_PATH"] = os.path.join(base_directory, version, executable_name,
"Virtuals",
"obj-gnu") +
":" + os.environ.get(
"LD_LIBRARY_PATH",
"")
88 os.environ[
"LD_LIBRARY_PATH"] = os.path.join(base_directory, version, executable_name,
"obj-gfortran") +
":" + os.environ.get(
"LD_LIBRARY_PATH",
"")
89 os.environ[
"LD_LIBRARY_PATH"] = os.path.join(base_directory, version, executable_name,
"obj-gfortran",
"proclib") +
":" + os.environ.get(
"LD_LIBRARY_PATH",
"")
90 os.environ[
"LD_LIBRARY_PATH"] = os.path.join(base_directory, version, executable_name,
"obj-gnu") +
":" + os.environ.get(
"LD_LIBRARY_PATH",
"")
91 os.environ[
"LD_LIBRARY_PATH"] = os.path.join(base_directory, version, executable_name,
"obj-gnu",
"proclib") +
":" + os.environ.get(
"LD_LIBRARY_PATH",
"")
95 directories = [
'obj-gfortran',
'OpenLoops2',
'obj-gnu']
96 logger.info(
"OpenLoopsPath (before) = {0}".
format(os.getenv(
'OpenLoopsPath')))
97 for directory
in directories:
98 if os.path.isdir(os.path.join(base_directory, version, executable_name, directory,
'proclib')):
99 OLPath = os.path.join(base_directory, version, executable_name, directory)
100 os.environ[
'OpenLoopsPath'] = OLPath
101 logger.info(
"OpenLoopsPath (after) = {0}".
format(os.getenv(
'OpenLoopsPath')))
111 logger.info(
'MetaData: POWHEGVER = {0}'.
format(POWHEGVER))
112 os.environ[
"POWHEGVER"] = POWHEGVER
130 self.
add_keyword(
"ebeam1", kwargs.get(
"beam_energy",
None))
131 self.
add_keyword(
"ebeam2", kwargs.get(
"beam_energy",
None))
133 self.
add_keyword(
"numevts", kwargs.get(
"nEvents",
None))
157 """! Add an algorithm or external process to the sequence.
159 @param process Algorithm or external process to add.
162 if isinstance(alg_or_process, str):
166 self.
externals[alg_or_process.name] = alg_or_process
170 """! Wildcarded list of files created by this process that can be deleted."""
171 raise AttributeError(
"Names of unneeded files are not known for this process!")
175 """! Wildcarded list of integration files that might be created by this process."""
176 raise AttributeError(
"Integration file names are not known for this process!")
180 """! Wildcarded list of integration files that are needed for this process."""
181 raise AttributeError(
"Integration file names are not known for this process!")
185 """! Version of PowhegBox process."""
186 raise AttributeError(
"Powheg version is not known!")
190 """! Default PDFs for this process."""
191 raise AttributeError(
"Default PDFs are not known for this process!")
195 """! Default scale variations for this process."""
196 raise AttributeError(
"Default scales are not known for this process!")
199 """! Scale calculation parameters by n_cores."""
201 for keyword
in [
"ncall1",
"ncall1rm",
"ncall2",
"ncall2rm",
"nubound",
"numevts"]:
203 if int(parameter.value) > 0:
204 parameter.value =
int(math.ceil(
float(parameter.value) / n_cores))
206 logger.info(
"Scaling number of events per job from {} down to {}".
format(__nEvents_unscaled, __nEvents_scaled))
211 """! Set whether the specified POWHEG-BOX generation stage is complete."""
216 """! Validate any parameters which need it before preparing runcard."""
218 getattr(self, function_name)()
221 """! Validate integration keywords by forcing to integer values."""
223 for name
in (
"foldcsi",
"foldphi",
"foldy",
"itmx1",
"itmx2",
"ncall1",
"ncall2",
"nEvents"):
226 parameter.value =
int(parameter.value)
228 logger.fatal(
"Failed to validate {} with value {}".
format(name, parameter.value))
232 """! Check whether a decay mode is allowed an raise an exception if it is not."""
233 if allowed_decay_modes
is None:
234 allowed_decay_modes = self.allowed_decay_modes
235 if decay_mode
not in allowed_decay_modes:
236 logger.warning(
"Decay mode {} not recognised!".
format(decay_mode))
237 logger.info(
"Allowed decay modes are:")
238 for allowed_decay_mode
in allowed_decay_modes:
239 logger.info(
"... {}".
format(allowed_decay_mode))
240 raise ValueError(
"Decay mode {} not recognised!".
format(decay_mode))
246 missing_patterns = []
249 except AttributeError:
250 logger.fatal(
"No integration grid file name patterns defined for this process.")
252 for s
in search_strings:
257 missing_patterns.append(s)
258 if missing_patterns == []:
259 logger.info(
"Integration grid files found locally. Event generation shall continue, skipping the integration step.")
260 logger.info(
"Integration grid files found locally: {}".
format(found_files))
262 logger.info(
"Integration grid files needed were not found locally. Event generation shall continue, starting by the integration step.")
263 logger.info(
"Missing integration grid files with these patterns: {}".
format(missing_patterns))
264 logger.info(
"Integration grid files found locally (if any): {}".
format(found_files))
278 if abs(settingsList[2] - stage) <=1e-09:
284 FileParser(
"powheg.input").text_replace(key+
".*", key+
" {}".
format(value))