ATLAS Offline Software
Loading...
Searching...
No Matches
preprocessors/reweighter.py
Go to the documentation of this file.
1# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3from ...decorators import timed
4from ...utility import FileParser
5import shutil
6
7
8@timed("reweighting setup")
9def reweighter(process, *args):
10 """! Prepare for reweighting by enabling the runcard option.
11
12 @author James Robinson <james.robinson@cern.ch>
13 """
14 # Alter/remove runcard options depending on which weighting scheme is being used
15 if process.use_XML_reweighting:
16 FileParser("powheg.input").text_remove("lhrwgt_descr")
17 FileParser("powheg.input").text_remove("lhrwgt_group_combine")
18 FileParser("powheg.input").text_remove("lhrwgt_group_name")
19 FileParser("powheg.input").text_remove("lhrwgt_id")
20 FileParser("powheg.input").text_remove("storeinfo_rwgt")
21 else:
22 FileParser("powheg.input").text_remove("rwl_add")
23 FileParser("powheg.input").text_remove("rwl_file")
24 FileParser("powheg.input").text_remove("rwl_format_rwgt")
25 FileParser("powheg.input").text_remove("rwl_group_events")
26 # Enable #rwgt information lines - these cause Pythia to crash if present in the final output
27 FileParser("powheg.input").text_replace("storeinfo_rwgt 0", "storeinfo_rwgt 1")
28
29 # Make a copy of the nominal input file
30 shutil.copy("powheg.input", "powheg_nominal.input")
31
Utility class to perform simple operations on files.