ATLAS Offline Software
Loading...
Searching...
No Matches
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
3from AthenaCommon import Logging
4from .external_base import ExternalBase
5import collections
6
7
8logger = 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
add_keyword(self, keyword, value=None, name=None, frozen=None, hidden=None, description=None, **kwargs)
Register configurable parameter that is exposed to the user.
expose(self)
Add all names to the interface of this object.
needs_scheduling(self, process)
Report whether the NNLO reweighting process should be scheduled.