ATLAS Offline Software
Loading...
Searching...
No Matches
gg4l_munue2all.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from ... import Logging
4from ...decorators import timed
5from ...utility import LHE
6import shutil
7
8
9logger = Logging.logging.getLogger("PowhegControl")
10
11
12@timed("gg4l_munue2all")
13def gg4l_munue2all(powheg_LHE_output):
14 """! Post-process existing events from muon pairs and electron neutrino
15 pairs to arbitrary charged lepton pairs and neutrino pairs
16
17 @param powheg_LHE_output Name of LHE file produced by PowhegBox.
18
19 @author Guglielmo Frattari <guglielmo.frattari@cern.ch>
20 """
21 logger.warning(
22 "Converting LHE events from 2mu2nue to 2l2nu final states."
23 )
24
25 # Get opening and closing strings
26 preamble = LHE.preamble(powheg_LHE_output)
27 postamble = LHE.postamble(powheg_LHE_output)
28
29 n_events = 0
30 powheg_LHE_2mu2nue = "{}.mod".format(powheg_LHE_output)
31 with open(powheg_LHE_2mu2nue, "w") as f_output:
32 f_output.write("{}\n".format(preamble))
33 for input_event in LHE.event_iterator(powheg_LHE_output):
34 is_event_changed, output_event = LHE.gg4l_munue2all(input_event)
35 f_output.write(output_event)
36 n_events += [0, 1][is_event_changed]
37 f_output.write(postamble)
38 logger.info(
39 "Changed 2mu2nue final state to 2l2nu in {} events!".format(n_events)
40 )
41
42 # Make a backup of the original events
43 shutil.move(
44 powheg_LHE_output,
45 "{}.mod_backup".format(powheg_LHE_output)
46 )
47 shutil.move(powheg_LHE_2mu2nue, powheg_LHE_output)