ATLAS Offline Software
external_nnlo_reweighter.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon import Logging
4 from .external_base import ExternalBase
5 import collections
6 
7 
8 logger = Logging.logging.getLogger("PowhegControl")
9 
10 
12  """! Class for running external NNLO reweighting process.
13 
14  @author James Robinson <james.robinson@cern.ch>
15  """
16 
17  def __init__(self, *executable_path):
18  """! Constructor.
19 
20  @param executable_path path to appropriate PowhegBox executable.
21  """
22  super(ExternalNNLOReweighter, self).__init__("NNLO reweighter", *executable_path)
23 
24  # Add parameters used by MadSpin
25  self.add_keyword("NNLO_reweighting_inputs")
26  self.add_keyword("NNLO_output_weights")
27 
28  def needs_scheduling(self, process):
29  """! Report whether the NNLO reweighting process should be scheduled.
30 
31  @param process PowhegBox process.
32  """
33  self.expose()
34  # Check first whether any reweighting inputs were provided. DYNNLO does not require outputs no test for these.
35  if len(self.NNLO_reweighting_inputs) == 0:
36  return False
37  # Check that NNLO reweighting arguments are dictionaries
38  if not isinstance(self.NNLO_reweighting_inputs, collections.OrderedDict):
39  if isinstance(self.NNLO_reweighting_inputs, dict):
40  self.decorated.logger.warning("NNLO_reweighting_inputs has been provided as an old-style unordered dictionary.")
41  else:
42  self.decorated.logger.fatal("NNLO_reweighting_inputs does not appear to be a valid label => file dictionary!")
43  raise ValueError("NNLO reweighting cannot be performed")
44  # Check that NNLO output weight arguments are dictionaries
45  if not isinstance(self.NNLO_output_weights, collections.OrderedDict):
46  if isinstance(self.NNLO_output_weights, dict):
47  self.decorated.logger.warning("NNLO_output_weights has been provided as an unordered dictionary! Weight numbering will be arbitrary")
48  else:
49  self.decorated.logger.fatal("NNLO_output_weights does not appear to be a valid ID string => calculation dictionary!")
50  raise ValueError("NNLO reweighting cannot be performed")
51  # Ensure that reweighting has been scheduled
52  process.add_algorithm("reweighting")
53  return True
python.processes.configurable.Configurable.expose
def expose(self)
Add all names to the interface of this object.
Definition: configurable.py:46
python.processes.external.external_nnlo_reweighter.ExternalNNLOReweighter.__init__
def __init__(self, *executable_path)
Constructor.
Definition: external_nnlo_reweighter.py:17
python.processes.configurable.Configurable.add_keyword
def add_keyword(self, keyword, value=None, name=None, frozen=None, hidden=None, description=None, **kwargs)
Register configurable parameter that is exposed to the user.
Definition: configurable.py:21
python.processes.external.external_base.ExternalBase
Base class for external processes.
Definition: external_base.py:11
python.processes.external.external_nnlo_reweighter.ExternalNNLOReweighter.needs_scheduling
def needs_scheduling(self, process)
Report whether the NNLO reweighting process should be scheduled.
Definition: external_nnlo_reweighter.py:28
python.processes.external.external_nnlo_reweighter.ExternalNNLOReweighter
Class for running external NNLO reweighting process.
Definition: external_nnlo_reweighter.py:11