3 from AthenaCommon
import Logging
4 from ..parameters
import Parameter, Registry
7 logger = Logging.logging.getLogger(
"PowhegControl")
11 """! Class for any process which can be configured.
13 @author James Robinson <james.robinson@cern.ch>
21 def add_keyword(self, keyword, value=None, name=None, frozen=None, hidden=None, description=None, **kwargs):
22 """! Register configurable parameter that is exposed to the user.
24 @param keyword Powheg keyword that gets written to the runcard.
25 @param value Value of the parameter.
26 @param name Configurable parameter name exposed to the user.
27 @param hidden True if this parameter should be hidden from the user.
28 @param frozen True if this parameter cannot be changed.
29 @param description Description for the run card.
30 @param parameter Name used in the run card if different.
33 defaults =
Registry().get_defaults(keyword)
34 if value == defaults[
"value"]
and value
is not None and (hidden
is not True):
35 if keyword
not in [
"ebeam1",
"ebeam2"]:
36 logger.debug(
"Unnecessarily setting parameter {} to {} which is its default value!".
format(keyword, value))
37 value = [value, defaults[
"value"]][value
is None]
38 name = [name, defaults[
"name"]][name
is None]
39 description = [description, defaults[
"description"]][description
is None]
40 hidden = [hidden, defaults[
"hidden"]][hidden
is None]
41 frozen = [frozen, defaults[
"frozen"]][frozen
is None]
42 if keyword
in [p.keyword
for p
in self.
parameters]:
43 raise AttributeError(
"Keyword '{}' has already been defined for this process".
format(keyword))
44 self.
parameters.
append(
Parameter(keyword, name=name, value=value, frozen=frozen, hidden=hidden, description=description, **kwargs))
47 """! Add all names to the interface of this object."""
49 setattr(self, parameter.name, parameter.value)
58 """! Retrieve all parameters that use a given keyword.
60 @param keyword Powheg keyword that gets written to the runcard.
62 return [p
for p
in self.
parameters if p.keyword == keyword]
65 """! Retrieve all parameters that use a given name.
67 @param name Configurable parameter name exposed to the user.
69 return [p
for p
in self.
parameters if p.name == name]